Anonymous user
Truncate a file: Difference between revisions
m
→{{header|PureBasic}}: Update
(Adding PureBasic) |
m (→{{header|PureBasic}}: Update) |
||
Line 5:
=={{header|PureBasic}}==
PureBasic has the internal function [http://www.purebasic.com/documentation/file/truncatefile.html TruncateFile] that cuts the file at the current file position and discards all data that follows.
▲<lang PureBasic>Procedure SetFileSize(File$, length.i)
Protected fh, pos, i
If FileSize(File$) < length
Debug "File to small, is a directory or does not exist."
Else
fh = OpenFile(#PB_Any, File$)
▲ If Not fh: ProcedureReturn #False: EndIf
FileSeek(fh, length)
TruncateFile(fh)
|