uce/site/doc/pages/file_truncate.txt
2026-06-16 23:02:45 +00:00

21 lines
474 B
Plaintext

:sig
bool file_truncate(String path, u64 size)
:params
path : file to resize
size : new length in bytes
return value : true on success
:content
Truncates (or extends) a file to exactly `size` bytes. Shrinking discards trailing bytes; growing pads with zero bytes.
:example
file_put_contents("/tmp/doc-truncate.txt", "hello world");
file_truncate("/tmp/doc-truncate.txt", 5);
print(file_get_contents("/tmp/doc-truncate.txt"), "\n");
:see
>sys
file_put_contents
file_stat