file#

Variables#

const long

Pos

const int

EOF

const int

Error

Constructors#

file

file(char32 path, char32 mode)

Functions#

bool

Open(char32[] filepath)

bool

Create(char32[] filepath)

bool

OpenMode(char32[] filepath, char32[] mode_string)

void

Close()

void

Free() deprecated

void

Own()

bool

isAllocated()

bool

isValid()

bool

Allocate()

bool

Flush()

int

ReadChars(char32[] buf, int count = -1, int pos = 0)

int

ReadInts(char32[] buf, int count = -1, int pos = 0)

int

WriteChars(char32[] buf, int count = -1, int pos = 0)

int

WriteInts(char32[] arr, int count = -1, int pos = 0)

int

ReadString(char32[] buf)

int

WriteString(char32[] str)

char32

GetChar()

char32

PutChar(char32 c)

char32

UngetChar(char32 c)

bool

Seek(long pos, bool from_current = false)

void

Rewind()

void

ClearError()

void

GetError(char32[] buf)

bool

Remove()

int

WriteBytes(char32[] arr, int count = -1, int pos = 0)

int

ReadBytes(char32[] buf, int count = -1, int pos = 0)

Variable descriptions#

const long Pos πŸ”— Source

This represents the current position in the file.


const int EOF πŸ”— Source

Returns true if a read call attempted to read past the end of the file.


const int Error πŸ”— Source

Returns 0 if the file has not enountered an error.


Constructor descriptions#

file file(char32 path, char32 mode) πŸ”— Source


Function descriptions#

bool Open(char32[] filepath) πŸ”— Source

If the file pointer is not allocated, this will allocate it. Also closes any file that is already open on the pointer.


bool Create(char32[] filepath) πŸ”— Source

If the file pointer is not allocated, this will allocate it. Also closes any file that is already open on the pointer.


bool OpenMode(char32[] filepath, char32[] mode_string) πŸ”— Source

If the file pointer is not allocated, this will allocate it. Also closes any file that is already open on the pointer.


void Close() πŸ”— Source

Closes any open file connected to the file pointer (which also includes β€˜Flush()’). Does *NOT* deallocate the pointer, it is still reserved to open new files on.


void Free() πŸ”— Source

Closes the currently open file as if calling Close(), then deallocates the file pointer so it may be re-used.

Warning

Deprecated! Free() no longer does anything as of ZC 3.0. Objects are now freed automatically.


void Own() πŸ”— Source

Grants β€˜Ownership’ of the file pointer to the script that calls this function. When the script with β€˜Ownership’ terminates (at the same time its’ local arrays are deallocated), this file pointer will automatically be β€˜Free()’d.


bool isAllocated() πŸ”— Source

Returns true if this pointer is allocated. This does not necessarily mean a file is open, just that the pointer has a reserved ID.


bool isValid() πŸ”— Source

Returns true if a file is open on the pointer.


bool Allocate() πŸ”— Source

Attempts to allocate the file pointer. If it was already allocated, this will re-allocate it without freeing it!


bool Flush() πŸ”— Source

Flushes the buffer of the file being written to.


int ReadChars(char32[] buf, int count = -1, int pos = 0) πŸ”— Source

Reads a section of characters from the file.


int ReadInts(char32[] buf, int count = -1, int pos = 0) πŸ”— Source

Reads a section of binary data from the file.


int WriteChars(char32[] buf, int count = -1, int pos = 0) πŸ”— Source

Writes characters from β€˜buf’ to file.


int WriteInts(char32[] arr, int count = -1, int pos = 0) πŸ”— Source

Writes 32b binary data from β€˜arr’ to file.


int ReadString(char32[] buf) πŸ”— Source

Reads a section of characters from the file.


int WriteString(char32[] str) πŸ”— Source

Writes the string stored in β€˜str’ to the file.


char32 GetChar() πŸ”— Source

Reads and returns the next character in the file.


char32 PutChar(char32 c) πŸ”— Source

Writes β€˜c’ to file.


char32 UngetChar(char32 c) πŸ”— Source

Un-reads β€˜c’ to the input stream.


bool Seek(long pos, bool from_current = false) πŸ”— Source

Moves the current position of the file.


void Rewind() πŸ”— Source

Rewinds to the beginning of the file.


void ClearError() πŸ”— Source

Clears the active EOF and Error indicators.


void GetError(char32[] buf) πŸ”— Source

Stores a string describing the current error into the buffer provided.


bool Remove() πŸ”— Source

Deletes the file. This will close it, as with Close(), and then delete it from the filesystem.


int WriteBytes(char32[] arr, int count = -1, int pos = 0) πŸ”— Source

Writes 8b binary data from β€˜arr’ to file.


int ReadBytes(char32[] buf, int count = -1, int pos = 0) πŸ”— Source

Reads a section of binary data from the file.