Truncate a file: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: use native type) |
m (→{{header|Sidef}}: modified the code to work with Sidef 2.30) |
||
Line 969: | Line 969: | ||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
<lang ruby>func truncate(filename, len) { |
<lang ruby>func truncate(filename, len) { |
||
var file = File |
var file = File(filename); |
||
len > file.size |
len > file.size -> |
||
&& die "The provided length is greater than the length of the file"; |
&& die "The provided length is greater than the length of the file"; |
||
file.truncate(len); |
file.truncate(len); |
||
} |
} |
||
# truncate "file.ext" to 1234 bytes |
# truncate "file.ext" to 1234 bytes |