Truncate a file: Difference between revisions

m
→‎{{header|Sidef}}: modified the code to work with Sidef 2.30
m (→‎{{header|Perl 6}}: use native type)
m (→‎{{header|Sidef}}: modified the code to work with Sidef 2.30)
Line 969:
=={{header|Sidef}}==
<lang ruby>func truncate(filename, len) {
var file = File.new(filename);
len > file.size ->
&& die "The provided length is greater than the length of the file";
file.truncate(len);
};
 
# truncate "file.ext" to 1234 bytes
2,747

edits