kzs_file.hpp File Reference

Standard file I/O functions. More...

Macros

#define KZS_FILE_ERROR
 Result value indicating that an error occurred in the function. More...
 
#define KZS_FILE_WRITEONLY
 File is opened in writeable text mode. More...
 
#define KZS_FILE_WRITEONLY_BINARY
 File is opened in writeable binary mode. More...
 
#define KZS_FILE_READONLY
 File is opened in read only text mode. More...
 
#define KZS_FILE_READONLY_BINARY
 File is opened in read only binary mode. More...
 

Typedefs

typedef void kzsFile
 File type. More...
 

Enumerations

enum  KzsFileOrigin { KZS_FILE_ORIGIN_SEEK_SET, KZS_FILE_ORIGIN_SEEK_CUR, KZS_FILE_ORIGIN_SEEK_END }
 Origin for kzsFseek. More...
 

Functions

kzsFilekzsFopen (kzString fileName, kzString mode)
 Opens a file. More...
 
kzInt kzsFclose (kzsFile *file)
 Closes a file. More...
 
kzBool kzsFeof (kzsFile *file)
 Checks if the end of a file has been reached. More...
 
kzInt kzsFerror (kzsFile *file)
 Checks if there is an error in a file. More...
 
kzInt kzsFseek (kzsFile *file, kzInt offset, enum KzsFileOrigin origin)
 Seeks to given position in a file. More...
 
kzInt kzsFtell (kzsFile *file)
 Gets the current position in a file. More...
 
kzInt kzsFflush (kzsFile *file)
 Flushes the stream. More...
 
kzInt kzsFgetc (kzsFile *file)
 Gets a byte from a file. More...
 
kzInt kzsFputc (kzInt character, kzsFile *file)
 Writes a byte to a file. More...
 
kzUint kzsFread (void *buffer, kzUint elementSize, kzUint elementCount, kzsFile *file)
 Reads elements from a file. More...
 
kzUint kzsFwrite (const void *buffer, kzUint elementSize, kzUint elementCount, kzsFile *file)
 Writes elements to a file. More...
 
kzInt kzsFileno (const kzsFile *file)
 Gets file descriptor. More...
 
kzInt kzsFileGetSize (kzsFile *file)
 Get the size of a file. More...
 
kzInt kzsFileReadSkip (kzsFile *file, kzUint byteCount)
 Skips bytes in a file. More...
 

Detailed Description

Standard file I/O functions.

Copyright 2008-2017 by Rightware. All rights reserved.

Macro Definition Documentation

#define KZS_FILE_ERROR

Result value indicating that an error occurred in the function.

#define KZS_FILE_WRITEONLY

File is opened in writeable text mode.

#define KZS_FILE_WRITEONLY_BINARY

File is opened in writeable binary mode.

#define KZS_FILE_READONLY

File is opened in read only text mode.

#define KZS_FILE_READONLY_BINARY

File is opened in read only binary mode.

Typedef Documentation

typedef void kzsFile

File type.

Enumeration Type Documentation

Origin for kzsFseek.

Enumerator
KZS_FILE_ORIGIN_SEEK_SET 

Seek from the start of the file.

KZS_FILE_ORIGIN_SEEK_CUR 

Seek from the current location.

KZS_FILE_ORIGIN_SEEK_END 

Seek from the end of the file.

Function Documentation

kzsFile* kzsFopen ( kzString  fileName,
kzString  mode 
)

Opens a file.

kzInt kzsFclose ( kzsFile file)

Closes a file.

kzBool kzsFeof ( kzsFile file)

Checks if the end of a file has been reached.

kzInt kzsFerror ( kzsFile file)

Checks if there is an error in a file.

kzInt kzsFseek ( kzsFile file,
kzInt  offset,
enum KzsFileOrigin  origin 
)

Seeks to given position in a file.

kzInt kzsFtell ( kzsFile file)

Gets the current position in a file.

kzInt kzsFflush ( kzsFile file)

Flushes the stream.

Writes any unwritten data to file.

kzInt kzsFgetc ( kzsFile file)

Gets a byte from a file.

kzInt kzsFputc ( kzInt  character,
kzsFile file 
)

Writes a byte to a file.

kzUint kzsFread ( void *  buffer,
kzUint  elementSize,
kzUint  elementCount,
kzsFile file 
)

Reads elements from a file.

Returns the number of elements read.

kzUint kzsFwrite ( const void *  buffer,
kzUint  elementSize,
kzUint  elementCount,
kzsFile file 
)

Writes elements to a file.

Returns the number of elements written.

kzInt kzsFileno ( const kzsFile file)

Gets file descriptor.

kzInt kzsFileGetSize ( kzsFile file)

Get the size of a file.

Returns -1 if an error occurred.

kzInt kzsFileReadSkip ( kzsFile file,
kzUint  byteCount 
)

Skips bytes in a file.

Returns the number of bytes skipped. Returns KZS_FILE_ERROR if an error occurred. This function is intended for skipping in a file only when reading it. To skip in a writable file, use kzsFseek with KZS_FILE_ORIGIN_SEEK_CUR as origin.