Jump to content

Truncate a file: Difference between revisions

m
added a ;Task: (bold) header.
m (→‎{{header|Sidef}}: modified the code to work with Sidef 2.30)
m (added a ;Task: (bold) header.)
Line 1:
{{task}} [[Category:File System Operations]]
[[Category:File System Operations]]
 
;Task:
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).
 
 
Truncation can be achieved using system or library calls intended for such a task, if such methods exist, or by creating a temporary file of a reduced size and renaming it, after first deleting the original file, if no other method is available.   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.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.