The Sword Project: sword::FileMgr Class Reference |
#include <filemgr.h>
Inheritance diagram for sword::FileMgr:
Public Member Functions | |
FileMgr (int maxFiles=35) | |
Constructor. | |
~FileMgr () | |
Destructor. | |
FileDesc * | open (const char *path, int mode, bool tryDowngrade) |
Open a file and return a FileDesc for it. | |
FileDesc * | open (const char *path, int mode, int perms=IREAD|IWRITE, bool tryDowngrade=false) |
Open a file and return a FileDesc for it. | |
void | close (FileDesc *file) |
Close a given file and delete its FileDesc object. | |
virtual void | flush () |
Cacher methods overridden. | |
virtual long | resourceConsumption () |
signed char | trunc (FileDesc *file) |
Truncate a file at its current position leaving byte at current possition intact deleting everything afterward. | |
Static Public Member Functions | |
static FileMgr * | getSystemFileMgr () |
static void | setSystemFileMgr (FileMgr *newFileMgr) |
static signed char | existsFile (const char *ipath, const char *ifileName=0) |
Checks for the existence of a file. | |
static signed char | existsDir (const char *ipath, const char *idirName=0) |
Checks for the existence of a directory. | |
static char | isDirectory (const char *path) |
static int | createParent (const char *pName) |
static int | createPathAndFile (const char *fName) |
static int | copyFile (const char *srcFile, const char *destFile) |
static int | copyDir (const char *srcDir, const char *destDir) |
static int | removeDir (const char *targetDir) |
static int | removeFile (const char *fName) |
static char | getLine (FileDesc *fDesc, SWBuf &line) |
Public Attributes | |
int | maxFiles |
Maximum number of open files set in the constructor. | |
Static Public Attributes | |
static int | CREAT |
static int | APPEND |
static int | TRUNC |
static int | RDONLY |
static int | RDWR |
static int | WRONLY |
static int | IREAD |
static int | IWRITE |
Static Protected Attributes | |
static FileMgr * | systemFileMgr |
Private Member Functions | |
int | sysOpen (FileDesc *file) |
Private Attributes | |
FileDesc * | files |
Friends | |
class | FileDesc |
class | __staticsystemFileMgr |
It keeps a list of all open files internally and closes them when the destructor is called.
Definition at line 85 of file filemgr.h.
sword::FileMgr::FileMgr | ( | int | maxFiles = 35 |
) |
Constructor.
maxFiles | The number of files that this FileMgr may open in parallel, if necessary. |
sword::FileMgr::~FileMgr | ( | ) |
Destructor.
Clean things up. Will close all files opened by this FileMgr object.
FileDesc* sword::FileMgr::open | ( | const char * | path, | |
int | mode, | |||
bool | tryDowngrade | |||
) |
Open a file and return a FileDesc for it.
The file itself will only be opened when FileDesc::getFd() is called.
path | Filename. | |
mode | File access mode. | |
tryDowngrade |
FileDesc* sword::FileMgr::open | ( | const char * | path, | |
int | mode, | |||
int | perms = IREAD|IWRITE , |
|||
bool | tryDowngrade = false | |||
) |
Open a file and return a FileDesc for it.
The file itself will only be opened when FileDesc::getFd() is called.
path | Filename. | |
mode | File access mode. | |
perms | Permissions. | |
tryDowngrade |
void sword::FileMgr::close | ( | FileDesc * | file | ) |
static signed char sword::FileMgr::existsFile | ( | const char * | ipath, | |
const char * | ifileName = 0 | |||
) | [static] |
Checks for the existence of a file.
ipath | Path to file. | |
ifileName | Name of file to check for. |
static signed char sword::FileMgr::existsDir | ( | const char * | ipath, | |
const char * | idirName = 0 | |||
) | [static] |
Checks for the existence of a directory.
ipath | Path to directory. | |
idirName | Name of directory to check for. |
signed char sword::FileMgr::trunc | ( | FileDesc * | file | ) |
Truncate a file at its current position leaving byte at current possition intact deleting everything afterward.
file | The file to operate on. |
The SWORD Project; P. O. Box 2528; Tempe, AZ 85280-2528 USA |