Whats the point of the truncate() function for writing to files? 01-07-2014, 12:34 AM
#1
What's the point of the truncate() function?
For example in this PoC:
I can't find anything on the truncate funct. itself. Is it really necessary to use, or is it mandatory to have it? I know I could just delete that line of code, and attempt running it anyway, but I want someones input.
For example in this PoC:
PHP Code:
from sys import argv
script, filename = argv
print "Okay, we are going to write to the file %r" % filename
print "You can print what you like, hit enter to continue, or press Ctrl C to exit(^C)"
raw_input("?")
print "Opening the selected file now..."
HPP = open(filename, 'w')
print "Truncating the file"
HPP.truncate() [color=#FF1493]#The fuck is truncate() for?[/color]
print "Okay, print what you want into the .txt file"
line1 = raw_input("Line 1: ")
line2 = raw_input("Line 2: ")
line3 = raw_input("Line 3: ")
line4 = raw_input("Line 4: ")
line5 = raw_input("Line 5: ")
line6 = raw_input("Line 6: ")
print "Okay, whatever you input above^ will be written to the filename"
HPP.write(line1)
HPP.write("\n")
HPP.write(line2)
HPP.write("\n")
HPP.write(line3)
HPP.write("\n")
HPP.write(line4)
HPP.write("\n")
HPP.write(line5)
HPP.write("\n")
HPP.write(line6)
HPP.write("\n")
print "Thank you, and goodbye"
I can't find anything on the truncate funct. itself. Is it really necessary to use, or is it mandatory to have it? I know I could just delete that line of code, and attempt running it anyway, but I want someones input.
Unleash the lead from my pistol into my head bumpin' crystal
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)

