Truncate a file: Difference between revisions

m
minor rewording
m (category and omissions)
m (minor rewording)
Line 1:
{{draft task}}
 
The task is to demonstrate how to truncate a file to a specific length. This should be implemented as a routine that takes two parameters: the filename and the required file length (in bytes). The truncation can be achived using a system or library callcalls intended for such a task, if such methods exist, or by creating a temporary file of a reduced size and renaming it, if no other method is possible. The file may contain non human readable binary data in an unspecified format, so the routine should be "binary safe", leaving the contents of the untruncated part of the file unchanged. If the specified filename does not exist, or the provided length is not less than the current file length, then the routine should raise an appropriate error condition and exit.
 
{{omit from|GUISS}}