Xors3d Engine
File System

Functions

BBDECL void BBCALL xChangeDir (const char *path)
 Sets directory as current.
BBDECL void BBCALL xCloseDir (int handle)
 Closes previously opened directory.
BBDECL void BBCALL xCloseFile (xFile *file)
 Closes opened file.
BBDECL int BBCALL xCopyFile (const char *pathSrc, const char *pathDest)
 Copies file from source path to destination.
BBDECL int BBCALL xCreateDir (const char *path)
 Creates new directory.
BBDECL const char *BBCALL xCurrentDir ()
 Returns current directory path.
BBDECL int BBCALL xDeleteDir (const char *path)
 Deletes directory.
BBDECL int BBCALL xDeleteFile (const char *path)
 Deletes file.
BBDECL int BBCALL xEof (xFile *file)
 Checks to see if the End of File of an opened file or stream has been reached.
BBDECL int BBCALL xFileCreationTime (const char *path)
 Returns the time the file was created.
BBDECL const char *BBCALL xFileCreationTimeStr (const char *path)
 Returns the time the file was created.
BBDECL int BBCALL xFileModificationTime (const char *path)
 Returns the time the file was last modified.
BBDECL const char *BBCALL xFileModificationTimeStr (const char *path)
 Returns the time the file was last modified.
BBDECL int BBCALL xFilePos (xFile *file)
 Returns the current position within a file that is being processed following xReadFile(), xWriteFile() or xOpenFile()
BBDECL int BBCALL xFileSize (const char *path)
 Returns the size of the file.
BBDECL int BBCALL xFileType (const char *path)
 Checks the filename you pass and determines if it exists and whether or not it is a valid filename or if it is a directory.
BBDECL xPackFile *BBCALL xMountPackFile (const char *path, const char *mountpoint="", const char *password="")
 Mounts a zip file as a part of the file system and returns its handle.
BBDECL const char *BBCALL xNextFile (int handle)
 Returns the next file or folder from the currently open directory.
BBDECL xFile *BBCALL xOpenFile (const char *path)
 Opens the designated file and prepares it to be updated. The file must exists since this function will not create a new file.
BBDECL int BBCALL xReadByte (xFile *file)
 Reads byte value from file (1 byte)
BBDECL int BBCALL xReadDir (const char *path)
 Returns a directory handle. You will use the xNextFile() to iterate through each file entry (use xFileType() to see if it is a file or folder).
BBDECL xFile *BBCALL xReadFile (const char *path)
 Opens the designated filename and prepares it to be read from.
BBDECL float BBCALL xReadFloat (xFile *file)
 Reads float value from file (4 bytes)
BBDECL int BBCALL xReadInt (xFile *file)
 Reads integer value from file (4 bytes)
BBDECL const char *BBCALL xReadLine (xFile *file, int ls_flag=0)
 Reads a line from file. Line should be terminated with a line separator specified with ls_flag parameter.
BBDECL int BBCALL xReadShort (xFile *file)
 Reads short integer value from file (2 bytes)
BBDECL const char *BBCALL xReadString (xFile *file)
 Reads a string value from file.
BBDECL void BBCALL xSeekFile (xFile *file, int offset)
 Sets current position in file.
BBDECL void BBCALL xUnmountPackFile (xPackFile *packfile)
 Unmounts a pack file from the file system.
BBDECL void BBCALL xWriteByte (xFile *file, int value)
 Writes a byte value into file (1 byte)
BBDECL xFile *BBCALL xWriteFile (const char *path)
 Opens the designated filename and prepares it to be written to.
BBDECL void BBCALL xWriteFloat (xFile *file, float value)
 Writes a float value into file (4 bytes)
BBDECL void BBCALL xWriteInt (xFile *file, int value)
 Writes an integer value into file (4 bytes)
BBDECL void BBCALL xWriteLine (xFile *file, const char *value, int ls_flag=0)
 Writes a line to file. Line is terminated with a line separator specified with ls_flag parameter.
BBDECL void BBCALL xWriteShort (xFile *file, int value)
 Writes a short integer value into file (2 bytes)
BBDECL void BBCALL xWriteString (xFile *file, const char *value)
 Writes a string into file.

Function Documentation

BBDECL xPackFile* BBCALL xMountPackFile ( const char *  path,
const char *  mountpoint = "",
const char *  password = "" 
)

Mounts a zip file as a part of the file system and returns its handle.

Use a zip file as a pack of your resources. Use of packs allows to compress the resources and to encrypt them with a password. Once mounted pack file becomes visible for the engine as a part of the file system. The second parameter is a mount point which is the location in the file system structure where a mounted pack file appears.

When you load some media, the engine searches that media in the mounted pack files first. For instance, the pack was mounted by using following

xMountPackFile("textures.zip", "textures\", "super_password");

Since now a pack file "textures.zip" is seen as a "textures\" directory.

If you load some texture by using

xLoadTexture("textures\something.dds");

the engine will try to load a texture "something.dds" from the pack mounted before since its mount point is "textures\". If there isn't such texture in the pack, the engine will try to load it from the disk using the path "textures\something.dds".

Such system allows you to develop and release your applications with ease. During development use loading from the disk. Before release pack your media and mount the packs using proper mount points.

Note:
: You can only read from packs (i.e. xReadFile(), xFileType() and xFileSize(), etc) You can't create, delete or change files in the packs.
Parameters:
pathA path to the pack file.
mountpointMount point of the pack file.
passwordA password of the pack file.
BBDECL void BBCALL xUnmountPackFile ( xPackFile *  packfile)

Unmounts a pack file from the file system.

Parameters:
packfilePackfile handle.
BBDECL xFile* BBCALL xOpenFile ( const char *  path)

Opens the designated file and prepares it to be updated. The file must exists since this function will not create a new file.

Parameters:
pathFilename to opens
BBDECL xFile* BBCALL xReadFile ( const char *  path)

Opens the designated filename and prepares it to be read from.

Parameters:
pathFilename to opens
BBDECL xFile* BBCALL xWriteFile ( const char *  path)

Opens the designated filename and prepares it to be written to.

Parameters:
pathFilename to opens
BBDECL void BBCALL xCloseFile ( xFile *  file)

Closes opened file.

Parameters:
fileFile handle
BBDECL int BBCALL xFilePos ( xFile *  file)

Returns the current position within a file that is being processed following xReadFile(), xWriteFile() or xOpenFile()

Parameters:
fileFile handle
BBDECL void BBCALL xSeekFile ( xFile *  file,
int  offset 
)

Sets current position in file.

Parameters:
fileFile handle
offsetOffset in bytes from the start of file
BBDECL int BBCALL xFileType ( const char *  path)

Checks the filename you pass and determines if it exists and whether or not it is a valid filename or if it is a directory.

The values to be returned: 0 - The file doesn't exist 1 - The file exists 2 - The file is not a file - but a directory

Parameters:
pathFilename to check
BBDECL int BBCALL xFileSize ( const char *  path)

Returns the size of the file.

Parameters:
pathFilename to check
BBDECL int BBCALL xFileCreationTime ( const char *  path)

Returns the time the file was created.

The time to be returned is the number of seconds since the beginning of January 1, 1970.

Note:
This function will return the modification time for the files from the packs.
Parameters:
pathFilename to check
BBDECL const char* BBCALL xFileCreationTimeStr ( const char *  path)

Returns the time the file was created.

The time to be returned is a string in format "MM/DD/YYYY hh:mm:ss".

Note:
This function will return the modification time for the files from the packs.
Parameters:
pathFilename to check
BBDECL int BBCALL xFileModificationTime ( const char *  path)

Returns the time the file was last modified.

The time to be returned is the number of seconds since the beginning of January 1, 1970.

Parameters:
pathFilename to check
BBDECL const char* BBCALL xFileModificationTimeStr ( const char *  path)

Returns the time the file was last modified.

The time to be returned is a string in format "MM/DD/YYYY hh:mm:ss".

Parameters:
pathFilename to check
BBDECL int BBCALL xReadDir ( const char *  path)

Returns a directory handle. You will use the xNextFile() to iterate through each file entry (use xFileType() to see if it is a file or folder).

Parameters:
pathDirectory path
BBDECL void BBCALL xCloseDir ( int  handle)

Closes previously opened directory.

Parameters:
handleDirectory handle
BBDECL const char* BBCALL xNextFile ( int  handle)

Returns the next file or folder from the currently open directory.

Parameters:
handleDirectory handle
BBDECL const char* BBCALL xCurrentDir ( )

Returns current directory path.

BBDECL void BBCALL xChangeDir ( const char *  path)

Sets directory as current.

Parameters:
pathDirectory path
BBDECL int BBCALL xCreateDir ( const char *  path)

Creates new directory.

Parameters:
pathDirectory path
BBDECL int BBCALL xDeleteDir ( const char *  path)

Deletes directory.

Parameters:
pathDirectory path
BBDECL int BBCALL xCopyFile ( const char *  pathSrc,
const char *  pathDest 
)

Copies file from source path to destination.

Parameters:
pathSrcSource file
pathDestDestination file
BBDECL int BBCALL xDeleteFile ( const char *  path)

Deletes file.

Parameters:
pathFilename to delete
BBDECL int BBCALL xEof ( xFile *  file)

Checks to see if the End of File of an opened file or stream has been reached.

Parameters:
fileFile handle
BBDECL int BBCALL xReadByte ( xFile *  file)

Reads byte value from file (1 byte)

Parameters:
fileFile handle
BBDECL int BBCALL xReadShort ( xFile *  file)

Reads short integer value from file (2 bytes)

Parameters:
fileFile handle
BBDECL int BBCALL xReadInt ( xFile *  file)

Reads integer value from file (4 bytes)

Parameters:
fileFile handle
BBDECL float BBCALL xReadFloat ( xFile *  file)

Reads float value from file (4 bytes)

Parameters:
fileFile handle
BBDECL const char* BBCALL xReadString ( xFile *  file)

Reads a string value from file.

Each string is stored in the file as a 4 byte integer followed by the characters that form the string. The integer contains the number of characters in the string, i.e. its length. Note, that Carriage Return, Line Feed and Null characters are not use to indicate the end of the string.

Parameters:
fileFile handle
BBDECL const char* BBCALL xReadLine ( xFile *  file,
int  ls_flag = 0 
)

Reads a line from file. Line should be terminated with a line separator specified with ls_flag parameter.

Parameters:
fileFile handle.
ls_flagLine separator. Default value is 0 (LS_NUL). See 'Line separtor types' for more information.
BBDECL void BBCALL xWriteByte ( xFile *  file,
int  value 
)

Writes a byte value into file (1 byte)

Parameters:
fileFile handle
valueValue to write
BBDECL void BBCALL xWriteShort ( xFile *  file,
int  value 
)

Writes a short integer value into file (2 bytes)

Parameters:
fileFile handle
valueValue to write
BBDECL void BBCALL xWriteInt ( xFile *  file,
int  value 
)

Writes an integer value into file (4 bytes)

Parameters:
fileFile handle
valueValue to write
BBDECL void BBCALL xWriteFloat ( xFile *  file,
float  value 
)

Writes a float value into file (4 bytes)

Parameters:
fileFile handle
valueValue to write
BBDECL void BBCALL xWriteString ( xFile *  file,
const char *  value 
)

Writes a string into file.

Each string is stored in the file as a 4 byte integer followed by the characters that form the string

Parameters:
fileFile handle
valueValue to write
BBDECL void BBCALL xWriteLine ( xFile *  file,
const char *  value,
int  ls_flag = 0 
)

Writes a line to file. Line is terminated with a line separator specified with ls_flag parameter.

Parameters:
fileFile handle
valueValue to write
ls_flagLine separator. Default value is 0 (LS_NUL). See 'Line separtor types' for more information.