Truncate a file: Difference between revisions

Content added Content deleted
Line 894: Line 894:
truncate($file, $to) == 0 or die "Truncation was unsuccessful";
truncate($file, $to) == 0 or die "Truncation was unsuccessful";
}</lang>
}</lang>

=={{header|Phix}}==
In honour of this very task, there is now (0.8.0+) a set_file_size() builtin, for the grubby/cross-platform details see builtins/pfile.e (an autoinclude)<br>
It will pad or truncate as needed.
<lang Phix>?get_file_size("test.txt")
?set_file_size("test.txt",100)
?get_file_size("test.txt")
?set_file_size("test.txt",1024)
?get_file_size("test.txt")</lang>
{{out}} (annotated, repeatable, assumes test.txt already exists)
<pre>
--1024
--1 (true)
--100
--1 (true)
--1024
</pre>


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==