Truncate a file: Difference between revisions
Content deleted Content added
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 |
ELENA 4.x: |
||
<lang elena>import system'io |
<lang elena>import system'io; |
||
import extensions |
import extensions; |
||
extension |
extension fileOp : File |
||
{ |
{ |
||
set |
set Length(int len) |
||
{ |
|||
auto stream := FileStream |
auto stream := FileStream.openForEdit(self); |
||
stream |
stream.Length := len; |
||
stream |
stream.close() |
||
} |
|||
} |
} |
||
public program |
public program() |
||
{ |
|||
[ |
|||
if (program_arguments |
if (program_arguments.Length != 3) |
||
{ console.printLine:"Please provide the path to the file and a new length"; AbortException.raise() }; |
|||
auto file := File |
auto file := File.assign(program_arguments[1]); |
||
var length := program_arguments[2] |
var length := program_arguments[2].toInt(); |
||
ifnot |
ifnot(file.Available) |
||
{ console.printLine("File ",file," does not exist"); AbortException.raise() }; |
|||
file |
file.Length := length |
||
}</lang> |
|||
=={{header|Erlang}}== |
=={{header|Erlang}}== |