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