Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.4j

Application v 5.22b

  

 

Chapter SixFile Functions (continued)

TruncateFilePosition Function

Overview

The TruncateFilePosition function causes the end of file position within a Basic File Object to be set as 0 or a specified position.

Syntax/Parameters

Syntax

int = TruncateFilePosition ( handle hFileObject, [qword position ] );

Parameters

hFileObject

A handle to a Basic File Object.

position

An optional qword position to which the file will be truncated. If position is larger than the size of the file, the file will be extended.

Return Value

Returns an int as ERROR_NONE or a formatted error code on failure. Use the GetLastError function to retrieve error information.

Remarks

Each file stream has the following:

File size: the size of the data in a file (byte level).
Allocation size: the size of the space that is allocated for a file on a disk, which is always an even multiple of the cluster size.
Valid data length: the length of the data in a file that is actually written (byte level). This value is always less than or equal to the file size.

 

The TruncateFilePosition function can be used to truncate or extend a file by shifting the valid data length. This is different from either the SetFilePosition or the SetFilePositionAtEnd functions, which adjust the read/write position within a Basic File Object without altering the size of the file. If the file is extended, the contents of the file between the old end of the file and the new end of the file are not defined.

Related Functions

Platform Support

Go13, Go16, GoFiler Complete, GoFiler Corporate, GoFiler, GoFiler Lite, GoXBRL

Legato IDE, Legato Basic