truncate-file ( path n -- ) (original) (raw)
Vocabulary
io.directories
Inputs
path | a pathname string |
---|---|
n | an integer |
Outputs
None
Word description
Set the length of the file to n bytes. If the file was previously longer, the extra data is lost. If the file was previously shorter, the behavior is platform-dependent on whether the file is extended with zeros (Unix) or the contents of the extended portion are undefined (Windows).
Errors
Throws an error if the file does not exist or the truncate operation fails.
Definition
HOOK: truncate-file io-backend ( path n -- )
Methods
USING: io.backend io.directories kernel system unix unix.ffi ;
M: unix truncate-file
[ normalize-path ] dip [ truncate ] unix-system-call drop ;