Truncate a file: Difference between revisions
Content added Content deleted
Catskill549 (talk | contribs) |
|||
Line 411: | Line 411: | ||
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>#import system. |
<lang elena>#import system'io. |
||
#import system'io. |
|||
#import extensions. |
#import extensions. |
||
extension(file_path) fileOp |
|||
{ |
{ |
||
set &length:length |
|||
[ |
[ |
||
stream stream := FileStream openForEdit &path:self. |
|||
stream set &length:length. |
stream set &length:length. |
||
stream close. |
stream close. |
||
] |
] |
||
} |
} |
||
program = |
|||
[ |
[ |
||
('program'arguments length != 3) |
if ('program'arguments length != 3) |
||
[ console << "Please provide the path to the file and a new length". |
[ console << "Please provide the path to the file and a new length". AbortException new raise. ]. |
||
var fileName := 'program'arguments@1. |
|||
var length := ('program'arguments@2) toInt. |
|||
(fileName file_path is &available) |
ifnot (fileName file_path is &available) |
||
[ console writeLine:"File ":fileName:" does not exist". AbortException new raise. ]. |
|||
fileName file_path set &length:length. |
fileName file_path set &length:length. |
||
].</lang> |
].</lang> |