Skip to content

Truncate()

ts
Truncate(filePath: string, size: number): respBase;

Changes the size of the specified file in the target file-system.

WARNING

This method may or may not be supported depending on the file-system targeted by the VFS.

Parameters

ParameterTypeExplanation
filePathstringThe fully qualified root-based path to the file you wish to truncate
sizenumberDesired new file size in bytes (zero or positive integer)

Returns a respBase object.

Example

ts
var vfs = GetCurrentVFS();
if (vfs != null) {
    var resp = vfs.Truncate("/data/myfile.txt", 0);
    if (resp.Ok()) {
        Log("File truncated");
    } else {
        Log("Error: " + resp.ErrorMsg());
    }
} else {
    Log("VFS was null");
}