XFcFile class Reference

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# XFcFile Class Reference

File handling operations. More...

List of all members.

## Public Member Functions

virtual XFCIMPORT INT32 | seek (INT32 aDisplacement, INT32 aMode)
| Seeks to a certain position in the file.
virtual XFCIMPORT INT32 | tell ()
| Returns the file position.
virtual XFCIMPORT const CHAR * | getFilename ()
| Returns pointer to the filename used to create this XFcFile object.
virtual XFCIMPORT INT32 | getChar ()
| Gets one byte from file. Returns EOF if end of file.
virtual XFCIMPORT INT32 | putChar (INT32 aChar)
| Puts one byte in the file.
virtual XFCIMPORT INT32 | read (void *aBuf, INT32 aSize, INT32 aCount)
| Read chunk(s) from file at once.
virtual XFCIMPORT INT32 | write (const void *aBuf, INT32 aSize, INT32 aCount)
| Writes chunk(s) to file at once.
virtual XFCIMPORT INT32 | close ()
| Closes file (also deletes the file object).
virtual XFCIMPORT INT | endOfFile ()
| Returns 1 if at end of file.
XFCIMPORT INT32 | writeFLOAT32 (FLOAT32 aValue)
| Writes FLOAT32.
XFCIMPORT INT32 | writeFLOAT64 (FLOAT64 aValue)
| Writes FLOAT64.
XFCIMPORT INT32 | writeINT32 (INT32 aValue)
| Writes INT32.
XFCIMPORT INT32 | writeINT16 (INT16 aValue)
| Writes INT16.
XFCIMPORT INT32 | writeINT8 (INT8 aValue)
| Writes INT8.
XFCIMPORT INT32 | writeUINT32 (UINT32 aValue)
| Writes UINT32.
XFCIMPORT INT32 | writeUINT16 (UINT16 aValue)
| Writes UINT16.
XFCIMPORT INT32 | writeUINT8 (UINT8 aValue)
| Writes UINT8.
XFCIMPORT FLOAT32 | readFLOAT32 ()
| Reads and returns FLOAT32.
XFCIMPORT FLOAT64 | readFLOAT64 ()
| Reads and returns FLOAT64.
XFCIMPORT INT32 | readINT32 ()
| Reads and returns INT32.
XFCIMPORT INT16 | readINT16 ()
| Reads and returns INT16.
XFCIMPORT INT8 | readINT8 ()
| Reads and returns INT8.
XFCIMPORT UINT32 | readUINT32 ()
| Reads and returns UINT32.
XFCIMPORT UINT16 | readUINT16 ()
| Reads and returns UINT16.
XFCIMPORT UINT8 | readUINT8 ()
| Reads and returns UINT8.
XFCIMPORT INT32 | readFLOAT32 (FLOAT32 &aValue)
| Reads FLOAT32 to reference.
XFCIMPORT INT32 | readFLOAT64 (FLOAT64 &aValue)
| Reads FLOAT64 to reference.
XFCIMPORT INT32 | readINT32 (INT32 &aValue)
| Reads INT32 to reference.
XFCIMPORT INT32 | readINT16 (INT16 &aValue)
| Reads INT16 to reference.
XFCIMPORT INT32 | readINT8 (INT8 &aValue)
| Reads INT8 to reference.
XFCIMPORT INT32 | readUINT32 (UINT32 &aValue)
| Reads UINT32 to reference.
XFCIMPORT INT32 | readUINT16 (UINT16 &aValue)
| Reads UINT16 to reference.
XFCIMPORT INT32 | readUINT8 (UINT8 &aValue)
| Reads UINT8 to reference.
XFCIMPORT void | writeCHARString (CHAR *aValue)
| Writes a null-terminated CHAR string.
XFCIMPORT CHAR * | readCHARString ()
| Reads a null-terminated CHAR string.
XFCIMPORT void | writeCHAR8String (CHAR8 *aValue)
| Writes a null-terminated CHAR8 string.
XFCIMPORT CHAR8 * | readCHAR8String ()
| Reads a null-terminated CHAR8 string.
XFCIMPORT void | writeCHAR16String (CHAR16 *aValue)
| Writes a null-terminated CHAR16 string.
XFCIMPORT CHAR16 * | readCHAR16String ()
| Reads a null-terminated CHAR16 string.

## Static Public Member Functions

XFCIMPORT XFcFile * | open (const CHAR *aFilename, const CHAR *aMode, UINT32 aFindStrategy=XFCFO_DEFAULT)
XFCIMPORT XFcFile * | open (const CHAR *aFilename, const INT8 *aBuffer, const UINT32 aBufferLength)
| Creates XFcFile object using a memory buffer as read-only file.
XFCIMPORT XFcFile * | openDiskFile (const CHAR *aFilename, const CHAR *aMode)
| Opens a file from disk (to force loading only from disk). DEPRECATED.
XFCIMPORT XFcFile * | openCFLFile (const CHAR *aFilename, const CHAR *aMode)
| Opens from resource file (to force loading only from resource files). DEPRECATED.
XFCIMPORT INT | remove (const CHAR *aFilename)
| Removes file from disk. This function will not touch files inside read-only storage.
XFCIMPORT INT | rename (const CHAR *aOldFilename, CHAR *aNewFilename)
| Renames file on disk. This function will not touch files inside read-only storage.
XFCIMPORT INT | mkdir (const CHAR *aDirectoryname)
| Creates a directory in the filesystem.
XFCIMPORT INT | rmdir (const CHAR *aDirectoryname)
| Removes a directory in the filesystem.
XFCIMPORT INT8 * | getFile (const CHAR *aFilename, UINT32 aFindStrategy=XFCFO_DEFAULT)
| Allocates sufficient amount of memory and reads the whole file in it.
XFCIMPORT INT32 | getFileSize (const CHAR *aFilename, UINT32 aFindStrategy=XFCFO_DEFAULT)
| Returns the file size.
XFCIMPORT INT | fileExists (const CHAR *aFilename)
| Tests if a file exists.

## Protected Member Functions

| XFcFile ()
| Protected constructor.
virtual | ~XFcFile ()
| Protected destructor.

## Static Protected Member Functions

XFCIMPORT XFcFile * | openStdFile (const CHAR *aFilename, const CHAR *aMode)
| Opens a stdio file.
CHAR * | makeDiskFilenameString (const CHAR *aFilename)
| Creates a platform specific representation of a file name.

## Protected Attributes

CHAR * | mFilename
| Copy of the filename.
void * | mFile
| File pointer, usually FILE *, or char * for ram-based files.
INT32 | mFilemode
| 0 for disk file, 1 for CFL-stored file.
INT32 | mFlag
| Flags for the file state.

## Detailed Description

File handling operations.

Used in same way compared to C standard library FILE * handling functions. You can use XFuFileDef.h from xfutil library to hack stdio.h FILE *-using sources to use this class instead. Include that file after the standard library headers.

Note:
  It is possible that some systems only have a read-only filesystem.

## Constructor & Destructor Documentation

XFcFile::XFcFile | ( |  | ) | `[protected]`

| Protected constructor.

virtual XFcFile::~XFcFile | ( |  | ) | `[protected, virtual]`

| Protected destructor.

## Member Function Documentation

virtual XFCIMPORT INT32 XFcFile::close | ( |  | ) | `[virtual]`

| Closes file (also deletes the file object).

virtual XFCIMPORT INT XFcFile::endOfFile | ( |  | ) | `[virtual]`

| Returns 1 if at end of file.

XFCIMPORT INT XFcFile::fileExists | ( | const CHAR * | aFilename | ) | `[static]`

Tests if a file exists.

Parameters:

  aFilename | file name to test.

Returns:
  0, if file does not exist.

  1, if file exists in read-only storage.

  2, if file exists on disk.

  3, if file exists on both.

virtual XFCIMPORT INT32 XFcFile::getChar | ( |  | ) | `[virtual]`

| Gets one byte from file. Returns EOF if end of file.

XFCIMPORT INT8* XFcFile::getFile | ( | const CHAR * | aFilename,
|  | UINT32 | aFindStrategy = XFCFO_DEFAULT
| ) | `[static]`

Allocates sufficient amount of memory and reads the whole file in it.

Parameters:

  aFilename | file name to load.
  aFindStrategy | defines whether to open disk file rather than cfl file if both exist, or to open only cfl file or only disk file. See XFCFILEOPENSTRATEGY enum in XFcFile.h.

Returns:
  pointer into newly allocated buffer containing the file data.

virtual XFCIMPORT const CHAR* XFcFile::getFilename | ( |  | ) | `[virtual]`

| Returns pointer to the filename used to create this XFcFile object.

XFCIMPORT INT32 XFcFile::getFileSize | ( | const CHAR * | aFilename,
|  | UINT32 | aFindStrategy = XFCFO_DEFAULT
| ) | `[static]`

Returns the file size.

Parameters:

  aFilename | file name to request size for.
  aFindStrategy | defines whether to open disk file rather than cfl file if both exist, or to open only cfl file or only disk file. See XFCFILEOPENSTRATEGY enum in XFcFile.h.

Returns:
  file size.

CHAR* XFcFile::makeDiskFilenameString | ( | const CHAR * | aFilename | ) | `[static, protected]`

Creates a platform specific representation of a file name.

Note:
  Client must delete[] the returned file name.

Parameters:

  aFilename | filename to create a platform specific representation for.

Returns:
  newly allocated string with the platform specific mangled filename.

XFCIMPORT INT XFcFile::mkdir | ( | const CHAR * | aDirectoryname | ) | `[static]`

Creates a directory in the filesystem.

If the parameter isn't prefixed with "//", the directory will be created under the application's root directory.

Some platforms may be able to create whole directory hierarchies with one call, and some platforms may not support directories at all.

You can create a directory on a different drive, etc, using the "//" prefix. See open() for description.

See also:
  open()

  rmdir()

XFCIMPORT XFcFile* XFcFile::open | ( | const CHAR * | aFilename,
|  | const INT8 * | aBuffer,
|  | const UINT32 | aBufferLength
| ) | `[static]`

Creates XFcFile object using a memory buffer as read-only file.

Note:
  Closing the file calls delete[] on the memory buffer.

XFCIMPORT XFcFile* XFcFile::open | ( | const CHAR * | aFilename,
|  | const CHAR * | aMode,
|  | UINT32 | aFindStrategy = XFCFO_DEFAULT
| ) | `[static]`

XFCIMPORT XFcFile* XFcFile::openCFLFile | ( | const CHAR * | aFilename,
|  | const CHAR * | aMode
| ) | `[static]`

Opens from resource file (to force loading only from resource files). DEPRECATED.

See also:
  open This method is deprecated; use open with open strategy XFCFO_CFLONLY instead.

XFCIMPORT XFcFile* XFcFile::openDiskFile | ( | const CHAR * | aFilename,
|  | const CHAR * | aMode
| ) | `[static]`

Opens a file from disk (to force loading only from disk). DEPRECATED.

See also:
  open This method is deprecated; use open with open strategy XFCFO_DISKONLY instead.

XFCIMPORT XFcFile* XFcFile::openStdFile | ( | const CHAR * | aFilename,
|  | const CHAR * | aMode
| ) | `[static, protected]`

| Opens a stdio file.

virtual XFCIMPORT INT32 XFcFile::putChar | ( | INT32 | aChar | ) | `[virtual]`

| Puts one byte in the file.

virtual XFCIMPORT INT32 XFcFile::read | ( | void * | aBuf,
|  | INT32 | aSize,
|  | INT32 | aCount
| ) | `[virtual]`

Read chunk(s) from file at once.

Parameters:

  aBuf | destination for the read data.
  aSize | size of one chunk of data.
  aCount | number of chunks to read.

Returns:
  number of chunks successfully read from the file.

Note:
  aBuf must point to at least aSize*aCount bytes of allocated memory.

XFCIMPORT CHAR16* XFcFile::readCHAR16String | ( |  | ) |

Reads a null-terminated CHAR16 string.

Returns:
  read string.

Note:
  also reads the NULL.

XFCIMPORT CHAR8* XFcFile::readCHAR8String | ( |  | ) |

Reads a null-terminated CHAR8 string.

Returns:
  read string.

Note:
  also reads the NULL.

XFCIMPORT CHAR* XFcFile::readCHARString | ( |  | ) |

Reads a null-terminated CHAR string.

Note:
  performs CHAR8<->CHAR16 conversion.

Returns:
  read string.

Note:
  also reads the NULL.

XFCIMPORT INT32 XFcFile::readFLOAT32 | ( | FLOAT32 & | aValue | ) |

| Reads FLOAT32 to reference.

XFCIMPORT FLOAT32 XFcFile::readFLOAT32 | ( |  | ) |

| Reads and returns FLOAT32.

XFCIMPORT INT32 XFcFile::readFLOAT64 | ( | FLOAT64 & | aValue | ) |

| Reads FLOAT64 to reference.

XFCIMPORT FLOAT64 XFcFile::readFLOAT64 | ( |  | ) |

| Reads and returns FLOAT64.

XFCIMPORT INT32 XFcFile::readINT16 | ( | INT16 & | aValue | ) |

| Reads INT16 to reference.

XFCIMPORT INT16 XFcFile::readINT16 | ( |  | ) |

| Reads and returns INT16.

XFCIMPORT INT32 XFcFile::readINT32 | ( | INT32 & | aValue | ) |

| Reads INT32 to reference.

XFCIMPORT INT32 XFcFile::readINT32 | ( |  | ) |

| Reads and returns INT32.

XFCIMPORT INT32 XFcFile::readINT8 | ( | INT8 & | aValue | ) |

| Reads INT8 to reference.

XFCIMPORT INT8 XFcFile::readINT8 | ( |  | ) |

| Reads and returns INT8.

XFCIMPORT INT32 XFcFile::readUINT16 | ( | UINT16 & | aValue | ) |

| Reads UINT16 to reference.

XFCIMPORT UINT16 XFcFile::readUINT16 | ( |  | ) |

| Reads and returns UINT16.

XFCIMPORT INT32 XFcFile::readUINT32 | ( | UINT32 & | aValue | ) |

| Reads UINT32 to reference.

XFCIMPORT UINT32 XFcFile::readUINT32 | ( |  | ) |

| Reads and returns UINT32.

XFCIMPORT INT32 XFcFile::readUINT8 | ( | UINT8 & | aValue | ) |

| Reads UINT8 to reference.

XFCIMPORT UINT8 XFcFile::readUINT8 | ( |  | ) |

| Reads and returns UINT8.

XFCIMPORT INT XFcFile::remove | ( | const CHAR * | aFilename | ) | `[static]`

Removes file from disk. This function will not touch files inside read-only storage.

Note:
  Removing a .cfl file while it is mounted will cause unpredictable behavior.

XFCIMPORT INT XFcFile::rename | ( | const CHAR * | aOldFilename,
|  | CHAR * | aNewFilename
| ) | `[static]`

Renames file on disk. This function will not touch files inside read-only storage.

Note:
  Renaming a .cfl file while it is mounted will cause unpredictable behavior.

XFCIMPORT INT XFcFile::rmdir | ( | const CHAR * | aDirectoryname | ) | `[static]`

Removes a directory in the filesystem.

The directory removal will most likely fail if the directory is not empty.

See also:
  open()

  mkdir()

virtual XFCIMPORT INT32 XFcFile::seek | ( | INT32 | aDisplacement,
|  | INT32 | aMode
| ) | `[virtual]`

Seeks to a certain position in the file.

Parameters:

  aDisplacement | defines how much to seek from the position specified by aMode.

  aMode

  - SEEK_SET to seek from start of the file,
  - SEEK_END to seek from end of the file or
  - SEEK_CURR to seek from the current file position.

Returns:
  0 if successful.

virtual XFCIMPORT INT32 XFcFile::tell | ( |  | ) | `[virtual]`

| Returns the file position.

virtual XFCIMPORT INT32 XFcFile::write | ( | const void * | aBuf,
|  | INT32 | aSize,
|  | INT32 | aCount
| ) | `[virtual]`

Writes chunk(s) to file at once.

Parameters:

  aBuf | pointer to the data to be written.
  aSize | size of one chunk of data.
  aCount | number of chunks to write.

Returns:
  number of chunks successfully written to the file.

Note:
  aBuf must point to at least aSize*aCount bytes of data.

XFCIMPORT void XFcFile::writeCHAR16String | ( | CHAR16 * | aValue | ) |

Writes a null-terminated CHAR16 string.

Parameters:

  aValue | string to write.

Note:
  also stores the NULL.

XFCIMPORT void XFcFile::writeCHAR8String | ( | CHAR8 * | aValue | ) |

Writes a null-terminated CHAR8 string.

Parameters:

  aValue | string to write.

Note:
  also stores the NULL.

XFCIMPORT void XFcFile::writeCHARString | ( | CHAR * | aValue | ) |

Writes a null-terminated CHAR string.

Note:
  performs CHAR8<->CHAR16 conversion.

Parameters:

  aValue | string to write.

Note:
  also stores the NULL.

XFCIMPORT INT32 XFcFile::writeFLOAT32 | ( | FLOAT32 | aValue | ) |

| Writes FLOAT32.

XFCIMPORT INT32 XFcFile::writeFLOAT64 | ( | FLOAT64 | aValue | ) |

| Writes FLOAT64.

XFCIMPORT INT32 XFcFile::writeINT16 | ( | INT16 | aValue | ) |

| Writes INT16.

XFCIMPORT INT32 XFcFile::writeINT32 | ( | INT32 | aValue | ) |

| Writes INT32.

XFCIMPORT INT32 XFcFile::writeINT8 | ( | INT8 | aValue | ) |

| Writes INT8.

XFCIMPORT INT32 XFcFile::writeUINT16 | ( | UINT16 | aValue | ) |

| Writes UINT16.

XFCIMPORT INT32 XFcFile::writeUINT32 | ( | UINT32 | aValue | ) |

| Writes UINT32.

XFCIMPORT INT32 XFcFile::writeUINT8 | ( | UINT8 | aValue | ) |

| Writes UINT8.

## Member Data Documentation

void* XFcFile::mFile`[protected]`

| File pointer, usually FILE *, or char * for ram-based files.

INT32 XFcFile::mFilemode`[protected]`

| 0 for disk file, 1 for CFL-stored file.

CHAR* XFcFile::mFilename`[protected]`

| Copy of the filename.

INT32 XFcFile::mFlag`[protected]`

| Flags for the file state.

|  | X-Forge Documentation Confidential Copyright © 2002-2003 Fathammer |  | Documentation generated with doxygen by Dimitri van Heesch