Truncate a file: Difference between revisions
Content deleted Content added
Added Kotlin |
|||
Line 434: | Line 434: | ||
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}}== |
||
<lang elena> |
<lang elena>import system'io. |
||
import extensions. |
|||
extension |
file_info extension fileOp |
||
{ |
{ |
||
set |
set length:length |
||
[ |
[ |
||
stream stream := FileStream openForEdit |
stream stream := FileStream openForEdit:self. |
||
stream set |
stream set length:length. |
||
stream close. |
stream close. |
||
Line 452: | Line 452: | ||
[ |
[ |
||
if ('program'arguments length != 3) |
if ('program'arguments length != 3) |
||
[ console |
[ console printLine:"Please provide the path to the file and a new length". AbortException new; raise ]. |
||
file_info file := File new('program'arguments[1]). |
|||
var length := |
var length := 'program'arguments[2] toInt. |
||
ifnot ( |
ifnot (file isAvailable) |
||
[ console |
[ console printLine("File ",file," does not exist"). AbortException new; raise ]. |
||
file set length:length. |
|||
].</lang> |
].</lang> |
||