Truncate a file: Difference between revisions

m
(Adds Clojure solution)
Line 442:
Cannot open file "<File name with full path>. The system cannot find the file specified.
=={{header|Elena}}==
ELENA 3.4:
<lang elena>import system'io.
import extensions.
file_info extension<File> fileOp
{
set length:lengthlen
[
streamauto stream := FileStream openForEdit:self.
stream set length :length= len.
stream close.
Line 457 ⟶ 458:
}
programpublic =program
[
if ('program'argumentsprogram_arguments length != 3)
[ console printLine:"Please provide the path to the file and a new length". AbortException new; raise ].
file_infoauto file := File new('program'argumentsprogram_arguments[1]).
var length := 'program'argumentsprogram_arguments[2] toInt.
ifnot (file isAvailable)
[ console printLine("File ",file," does not exist"). AbortException new; raise ].
file set length := length.
].</lang>
 
=={{header|Erlang}}==
Anonymous user