RosettaCodeData/Task/Truncate-a-file/PureBasic/truncate-a-file.basic
2023-07-01 13:44:08 -04: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