new_file

CFile Class


The CFile class provides file reading and writing operations. Normally, this class is used for binary-mode file operations. You also can use this class for text-mode file operations but lua includes the lua io package for working with text files (see the lua reference books or the documentation at https://lua.org).

Usage

Construction

Object = new_file()

Object = CFile:new()

Destruction

Object:delete()

Properties

This class contains 3 enumeration properties for use with the Seek method:

eBegin

The file offset is moved relative to the beginning of the file.

eCurrent

The file offset is moved relative to the current position.

eEnd

The file offset is moved relative to the end of the file.

Global Functions using CFile

This function may be used to directly open a file and return a new CFile object without first creating the object.

FileOpen

Opens a file in the specified mode and returns a new instance of a CFile class. This can be used in place of using the new constructor followed by the Open method.

Creation - Non-class Functions

This function is normally used to create a new CFile object as an alternative to the class-based new method.

new_file

Creates a new instance of a CFile object.

Construction and Destruction - Class Methods

new

Creates a new instance of a CFile object.

delete

Deletes the instance of the CFile object.

Operations

Close

Closes the file.

FilePos

Returns the current file position.

Flush

Commits data in the operating system buffer to the file.

GetPath

Returns the name of the file.

Open

Opens the file.

Printf

Writes formatted text to the file.

Read

Reads a value or table of values of specified pixel type from a binary file.

ReadBswap

Reads a value or table of values of specified pixel type from a binary file. The values are automatically byte-swapped.

Seek

Resets the file position to a given location.

Write

Writes a value or table to a binary file using the specified pixel type.

WriteBswap

Writes a value or table to a binary file using the specified pixel type. The values are automatically byte-swapped before being written to the file.

Related Topics

Printf

CFindFiles class

 


Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.