RosettaCodeData/Task/Truncate-a-file/PureBasic/truncate-a-file.purebasic
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

13 lines
330 B
Text

Procedure SetFileSize(File$, length.q)
Protected fh, pos, i
If FileSize(File$) < length
Debug "File to small, is a directory or does not exist."
ProcedureReturn #False
Else
fh = OpenFile(#PB_Any, File$)
FileSeek(fh, length)
TruncateFile(fh)
CloseFile(fh)
EndIf
ProcedureReturn #True
EndProcedure