Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter SixFile Functions (continued)

6.3 Low-Level File Functions

6.3.1 Overview

This section covers basic file and folder operations including testing, creating, opening, reading and writing along with various related functions.

The lowest level file object is the Basic File Object which allows a file to be accessed as a large block of data for reading and writing. This is generally considered a random-access file with the ability to set any position and read and write the file. Line level routines such as ReadLine and WriteLine are also provided, however, this is not the fastest method of accessing textual data.

Above this is the Mapped Text Object which is a high-level object allowing for access, read and write of a file by text lines. Very large files can be managed with a maximum of over 1 billion lines of text and a maximum width of 1,048,575 characters.

In addition, Legato provides a wide variety of folder and file management tools.

6.3.2 Understanding File Handles

Each of the object types relating to files within Legato have object or file handles. The primitive file handles for the operating system are embedded in the object and are generally not accessible to the script.

After a handle has been created, either by opening a file or perhaps, enumerating files, the handle should eventually be closed with the CloseHandle function and the work has been completed. Some functions, such as StringToFile will not return a handle to the file since the entire operation is performed at once and there is no residual object or handle.

If a handle for one type of object is used with a function that does not support that object type, and error will be returned (normally an invalid handle error). For example, if a basic file was opened with OpenFile and then accessed with the ReplaceLine function, an error would be returned by the ReplaceLine since it expects a Mapped Text Object handle. On the other handle, there are functions such as ReadLine that actually will take multiple types of handles. The documentation for those functions detail the types of handles and behavior expected.

6.3.3 Short File and Path Names

There are a number of functions to support 8.3 filenames. Short names can be used for legacy support and also when interfacing with programs that do not support Unicode filenames. Short path names are limited to 260 characters by Windows while full Unicode names can be up to 32kb in length (not internally Novaworks applications support path names of 512 characters).

Not all platforms support short filenames. If the platform does not support short names, or the supplied name is 8.2 compliant, the same name is returned as supplied. Use the “fsutil 8dot3name” in the command line to enable short file and path names.

6.3.4 File Functions

Testing and Names: 

CanAccessFile — Tests for ability to access or create file using an optionally specified mode.

DoesFileExist — Tests for the existence of a file at a specified location.

DoesPathExist — Tests for the existence of a specified path.

GetCorrectedFilename — Gets a corrected long filename (i.e., converts an 8.3 style name to a Windows long name).

GetFileOpenStatus — Tests the ability to open a file using a specified mode.

GetLongFilename — Returns a corrected long filename (no path) for specified string (filename and path).

GetLongPathName — Returns a corrected long path name for a specified string (filename and path).

GetShortFilename — Returns an 8.3 short filename (no path) for specified string (filename and path).

GetShortPathName — Returns an 8.3 short path name for specified string (filename and path).

IsFile — Tests a string for being a valid path and filename.

IsFolder — Tests a string for being a valid path to a folder.

Reporting File Access

GetFileLockMetaData — Returns an array of application-based file lock meta data, if available.

QueryOverwrite — Presents a query to the user to overwrite the file if the file exists.

QueryReadOnlyOverwrite — Presents a query to overwrite the file if the file exists and is read-only.

ReportFileError — Reports a file error to the user using filename and formatted error code.

ReportFileOpenStatus — Reports the open file status to a user if a cookie is available.

Basic File Access:

CloseFile — Closes file (handle). Same as CloseHandle.

CloseHandle — Closes an object handle and releases any associated resources.

CreateFile — Creates a basic file with optional access mode and characteristics.

DeleteFile — Deletes the specified file (with open handle or closed with a string specification).

GetFilePosition — Gets the current position of a flat file for reading or writing.

GetTempFile — Creates a unique temporary file in the user’s temporary area with the optional extension.

ReadBlock — Reads a block of data directly to a variable from the current position of a Basic File Object.

ReadLine — Reads the next line of data from a Basic File or Pool Object, or, reads a specified line from a Mapped Text or Edit Object.

RecycleFile — Sends a file, folder or folder tree to the recycle bin or deletes it, if required.

RenameFile — Renames a specified file. The file can also be moved if it is on the same path limb.

SetFilePosition — Sets the file’s next read or write position for a Basic File Object.

SetFilePositionAtEnd — Sets the file position to the end of file for a Basic File Object.

TruncateFilePosition — Truncates a Basic File Object’s end position.

WriteBlock — Writes a block to a Basic File Object at the current or specified position.

Folders and Files:

CreateFolder — Creates a folder at specified path position.

CreateFolders — Creates a tree limb of folders at path position.

DeleteFolder — Deletes the last folder in the path tree.

EnumerateFiles — Enumerates files with relative paths to an array.

EnumerateFolderDetails — Enumerates files and folders with relative paths to a table with basic details.

EnumerateFolders — Enumerates folders with relative paths to an array.

EnumeratePlaces — Enumerates accessible computer places such as drives, network shares, etc.

EnumerateShares — Enumerates the published shares for a host name.

GetFileAttributeString — Gets file attributes in string form using a filename or handle for a file or an enumeration object.

GetFileAttributeBits — Gets file attributes as a bitwise set of flags from a specified handle or filename.

GetFileCreateTime — Gets file creation time as a file time qword.

GetFileCreateTimeString — Gets file creation time as a string with optional date/time modes.

GetFileModifiedTime — Gets the file modified time as a file time qword.

GetFileModifiedTimeString — Gets file modified time as a string with optional date/time modes.

GetFileSize — Gets the size of a file from a file handle, file enumeration handle, folder, or FTP object.

GetFirstFile — Gets the first file in a series of matching of files.

GetNextFile — Gets the next file from a list started with the GetFirstFile function.

GetVolumeFreeSpace — Gets the free space for a specified volume.

GetVolumeLabel — Gets the volume (drive) label.

GetVolumeSerialNumber — Gets a drive’s serial number.

GetVolumeSize — Gets a volume or drive size.

GetVolumeType — Gets the type for the specified drive.

GetUNCLabel — Gets a network map/share label (and UNC).

GetUNCLabelOnly — Gets a network map/share label.

GetWorkingDirectory — Returns the Windows current working directory for the process.

PathToUNC — Converts a specified path to a UNC path.

Mapped Text Object:

CreateMappedTextFile — Creates a file and then opens it as a Mapped Text Object.

CreateMappedTextString — Creates a Mapped Text Object based on a string.

DeleteLine — Deletes one or more lines from Mapped Text Object.

GetAbsoluteFilePosition — Translates X and Y position to the absolute file position within a Mapped Text Object.

GetLineCount — Gets the number of lines in a Mapped Text or Edit Object.

GetLineSize — Gets the size of a line in a Mapped Text or Edit Object as native or optional realized bytes.

GetMappedTextEncoding — Returns the encoding for a Mapped Text Object.

GetMappedTextEncodingString — Returns the encoding for a Mapped Text Object as a string.

GetMappedTextFilename — Returns the name of the file associated with a Mapped Text Object.

GetMappedTextFileType — Returns the file type code associated with a Mapped Text Object.

InsertLine — Inserts a line of text into a Mapped Text Object.

IsBlankLine — Tests a line within a Mapped Text Object for being blank (white space does not count as text).

MappedTextExport — Exports a Mapped Text Object to the specified file.

MappedTextSave — Saves a Mapped Text Object (remaps to new saved file).

MappedTextToString — Captures the content of a Mapped Text or Edit Object to a string.

MoveToNonBlankLine — Looks forward until a non-blank line is encountered within a Mapped Text Object.

OpenFile — Opens the specified file as a Basic File Object.

OpenMappedTextFile — Opens the specified file as a Mapped Text Object.

ReadLine — Reads the next line of data from a Basic File or Pool Object, or, reads a specified line from a Mapped Text or Edit Object.

ReadSegment — Reads a segment of data from a Mapped Text or Edit Object.

ReplaceLine — Replaces the text for the specified line in a Mapped Text Object.

WriteLine — Writes a formatted line of text to a Basic File Object. Follows FormatString parameters.

WriteSegment — Writes a segment of string data to a Mapped Text or Edit Object at an optional specified position.

Variables and Files:

BufferToFile — Writes a buffer (variable) to a file.

FileToBuffer — Reads the content of a file into a buffer variable.

FileToString — Loads content of a file into a string.

StringToFile — Writes a string to a specified file.

VariableToFile — Writes the contents of the specified variable to a specified filename.