Truncate a file: Difference between revisions

Content added Content deleted
m (added a ;Task: (bold) header.)
(Lingo added)
Line 618: Line 618:
end
end
</lang>
</lang>

=={{header|Lingo}}==
With native means (Fileio Xtra) file truncation can only be implemented indirectly, either using a temp file or loading truncated file contents into memory, deleting original and writing memory back to file.

But there are free plugins ("Xtras") like e.g. "BinFile Xtra" that support "in-file" truncation:
{{libheader|BinFile Xtra}}
<lang lingo>-- truncates file to 10 KB length
bx_file_truncate(_movie.path&"foo.dat", 10240)</lang>

=={{header|Lua}}==
=={{header|Lua}}==
Lua treats strings as being invariably one byte per character (hence the awkwardness of trying to use it with unicode), so it's safe to use string methods to truncate binary data.
Lua treats strings as being invariably one byte per character (hence the awkwardness of trying to use it with unicode), so it's safe to use string methods to truncate binary data.