If len is smaller than the current file size, the file is shortened and
the trailing data is discarded. If len is larger, the file is extended
with zero bytes (\x00).
The file must already exist; this operation never creates a new file.
Truncating a directory path returns a TypeMismatchError.
Parameters
filePath: string
The absolute path of the file to truncate.
len: number
The target size in bytes. Must be a non-negative integer.
Returns AsyncVoidIOResult
A promise that resolves to an AsyncVoidIOResult indicating success or failure.
Truncates (resizes) a file to the specified size.
If
lenis smaller than the current file size, the file is shortened and the trailing data is discarded. Iflenis larger, the file is extended with zero bytes (\x00).The file must already exist; this operation never creates a new file. Truncating a directory path returns a
TypeMismatchError.