Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,4 +1,9 @@
|
|||
def truncate_file(fname, size):
|
||||
"Open a file for writing, and truncate it to size bytes."
|
||||
with open(fname, "ab") as f:
|
||||
f.truncate(size)
|
||||
def truncate_file(name, length):
|
||||
if not os.path.isfile(name):
|
||||
return False
|
||||
if length >= os.path.getsize(name):
|
||||
return False
|
||||
with open(name, 'ab') as f:
|
||||
f.truncate(length)
|
||||
f.close()
|
||||
return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue