Truncate a file: Difference between revisions

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


=={{header|Erlang}}==
=={{header|Erlang}}==