FileIO Class Reference

FileIO implements file-based IO. More...

#include <FileIO.h>

Inheritance diagram for FileIO:
IO Object

List of all members.

Public Member Functions

void init (const char *path, const char *mode)
 Initialize with the file path and access mode.
void init (const char *tempdir)
 Create a temporary file for readeing and writing.
void unlink (void)
 Delete the resource when the IO object is deleted.

Static Public Member Functions

static void deleteFile (const char *path)
 Delete a file.
static bool fileExists (const char *path)
 Test if the file exists.

Protected Attributes

Mutex m_openLock
int m_openCount
bool m_unlinkFile

Detailed Description

The FileIO class implements a file-based IO object. It uses the pread() and pwrite() on POSIX systems and ReadFile() and WriteFile() with overlaps on Windows systems.

See also:
See examples/src/support.cpp compareFiles() for an example of reading a file.

Definition at line 30 of file FileIO.h.


Member Function Documentation

static void FileIO::deleteFile ( const char *  path  )  [static]

This is utility function for deleting a file.

Parameters:
path path to the file
static bool FileIO::fileExists ( const char *  path  )  [static]

This is utility function for seeing if the file exists.

Parameters:
path path to the file
void FileIO::init ( const char *  tempdir  ) 

This method creates temporary file for reading and writing. When the FileIO object is deallocted the temporary file is deleted. If tempdir is NULL the default temporary directory is used.

Parameters:
tempdir the location of the temporary directory (UTF-8 encode)
void FileIO::init ( const char *  path,
const char *  mode 
)

This method initializes the FileIO object with a filename path and access mode.

Modes:

  • "r": Open a file for reading.
  • "r+": Open a file for reading and writing.
  • "w": Truncate or create a file for writing.
  • "w+": Truncate or create a file for reading and writing.
Parameters:
path the filename path (UTF-8 encoded)
mode the file access mode
void FileIO::unlink ( void   )  [virtual]

This method marks the resource for deletion when the object goes away.

Implements IO.


Member Data Documentation

int FileIO::m_openCount [protected]

Definition at line 127 of file FileIO.h.

Definition at line 125 of file FileIO.h.

bool FileIO::m_unlinkFile [protected]

Definition at line 128 of file FileIO.h.


The documentation for this class was generated from the following file:

LizardTech