sword::FileMgr Class Reference

This class ist used make file access operations easier. More...

#include <filemgr.h>

Inheritance diagram for sword::FileMgr:

Inheritance graph
[legend]
Collaboration diagram for sword::FileMgr:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FileMgr (int maxFiles=35)
 Constructor.
 ~FileMgr ()
 Destructor.
FileDescopen (const char *path, int mode, bool tryDowngrade)
 Open a file and return a FileDesc for it.
FileDescopen (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 FileMgrgetSystemFileMgr ()
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 FileMgrsystemFileMgr

Private Member Functions

int sysOpen (FileDesc *file)

Private Attributes

FileDescfiles

Friends

class FileDesc
class __staticsystemFileMgr

Detailed Description

This class ist used make file access operations easier.

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.


Constructor & Destructor Documentation

sword::FileMgr::FileMgr ( int  maxFiles = 35  ) 

Constructor.

Parameters:
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.


Member Function Documentation

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.

Parameters:
path Filename.
mode File access mode.
tryDowngrade 
Returns:
FileDesc object for the requested file.

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.

Parameters:
path Filename.
mode File access mode.
perms Permissions.
tryDowngrade 
Returns:
FileDesc object for the requested file.

void sword::FileMgr::close ( FileDesc file  ) 

Close a given file and delete its FileDesc object.

Will only close the file if it was created by this FileMgr object.

Parameters:
file The file to close.

static signed char sword::FileMgr::existsFile ( const char *  ipath,
const char *  ifileName = 0 
) [static]

Checks for the existence of a file.

Parameters:
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.

Parameters:
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.

Parameters:
file The file to operate on.


Member Data Documentation

int sword::FileMgr::maxFiles

Maximum number of open files set in the constructor.

determines the max number of real system files that filemgr will open. Adjust for tuning.

Definition at line 108 of file filemgr.h.


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