sipxportlib  Version 3.3
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OsFileBase Class Referenceabstract

#include <OsFileBase.h>

Inheritance diagram for OsFileBase:
Inheritance graph
[legend]
Collaboration diagram for OsFileBase:
Collaboration graph
[legend]

Public Types

enum  Mode {
  READ_ONLY = 1, WRITE_ONLY = 2, READ_WRITE = 4, CREATE = 8,
  TRUNCATE = 16, APPEND = 32, FSLOCK = 64, FSLOCK_WAIT = 128
}
 
enum  FilePositionOrigin { START = 0, CURRENT = 1, END = 2 }
 enumcode: FSLOCK - Opens the file exclusively (advisory locking). enumcode: FSLOCK_WAIT - Waits to open the file locked rather than fail. More...
 

Public Member Functions

 OsFileBase (const OsPathBase &filename)
 enumcode: Start - Set position relative to start of file. enumcode: Current - Set position relative to current file position. enumcode: End - Set position relative to end of file. More...
 
virtual ~OsFileBase ()
 
virtual OsStatus open (const int mode=READ_WRITE)
 
virtual OsStatus fileunlock ()
 
virtual OsStatus filelock (const bool wait)
 
virtual OsStatus flush ()
 
virtual OsStatus write (const void *pBuf, unsigned long bufLen, unsigned long &rBytesWritten)
 
virtual OsStatus setLength (unsigned long newLength)
 
virtual OsStatus setPosition (long pos, FilePositionOrigin origin=START)
 
virtual OsStatus remove (UtlBoolean bForce=FALSE)
 
virtual OsStatus rename (const OsPathBase &rNewFilename)
 
virtual OsStatus copy (const OsPathBase &rNewFilename)
 
virtual OsStatus setReadOnly (UtlBoolean isReadOnly)
 
virtual OsStatus touch ()
 
virtual OsStatus getPosition (unsigned long &pos)
 
virtual void getFileName (OsPathBase &rOsPath) const
 
virtual OsStatus read (void *pBuf, unsigned long bufLen, unsigned long &rBytesRead)
 
virtual OsStatus readLine (UtlString &str)
 
virtual UtlBoolean close ()
 
OsStatus getLength (unsigned long &length)
 
FILE * getFileDescriptor ()
 
OsConfigDbgetFileLocks ()
 
UtlBoolean isReadonly () const
 
UtlBoolean exists ()
 
virtual OsStatus getFileInfo (OsFileInfoBase &rFileinfo) const =0
 
UtlBoolean isEOF ()
 

Static Public Member Functions

static long openAndRead (const char *filename, UtlString &fileContentsRead)
 Opens and reads the contents of the named file into the given UtlString. More...
 
static long openAndWrite (const char *filename, const UtlString &fileContentsToWrite)
 Opens and write the given UtlString to the named file. More...
 
static long openAndWrite (const char *filename, const char *fileContentsToWrite, unsigned int contentLength)
 Opens and write the given data to the named file. More...
 

Protected Member Functions

 OsFileBase (const OsFileBase &rOsFile)
 
OsFileBaseoperator= (const OsFileBase &rhs)
 

Protected Attributes

OsMutex fileMutex
 
FILE * mOsFileHandle
 
OsPathBase mFilename
 
int mMode
 

Member Enumeration Documentation

enum Mode
Enumerator
READ_ONLY 
WRITE_ONLY 
READ_WRITE 
CREATE 
TRUNCATE 
APPEND 
FSLOCK 
FSLOCK_WAIT 

enumcode: FSLOCK - Opens the file exclusively (advisory locking). enumcode: FSLOCK_WAIT - Waits to open the file locked rather than fail.

Enumerator
START 
CURRENT 
END 

Constructor & Destructor Documentation

OsFileBase ( const OsPathBase filename)

enumcode: Start - Set position relative to start of file. enumcode: Current - Set position relative to current file position. enumcode: End - Set position relative to end of file.

~OsFileBase ( )
virtual
OsFileBase ( const OsFileBase rOsFile)
protected

Member Function Documentation

long openAndRead ( const char *  filename,
UtlString fileContentsRead 
)
static

Opens and reads the contents of the named file into the given UtlString.

long openAndWrite ( const char *  filename,
const UtlString fileContentsToWrite 
)
static

Opens and write the given UtlString to the named file.

long openAndWrite ( const char *  filename,
const char *  fileContentsToWrite,
unsigned int  contentLength 
)
static

Opens and write the given data to the named file.

OsStatus open ( const int  mode = READ_WRITE)
virtual
OsStatus fileunlock ( )
virtual

Reimplemented in OsFileLinux, and OsFileWnt.

OsStatus filelock ( const bool  wait)
virtual

Reimplemented in OsFileWnt, and OsFileLinux.

OsStatus flush ( )
virtual
OsStatus write ( const void *  pBuf,
unsigned long  bufLen,
unsigned long &  rBytesWritten 
)
virtual
OsStatus setLength ( unsigned long  newLength)
virtual

Reimplemented in OsFileWnt, and OsFileLinux.

OsStatus setPosition ( long  pos,
FilePositionOrigin  origin = START 
)
virtual
OsStatus remove ( UtlBoolean  bForce = FALSE)
virtual
OsStatus rename ( const OsPathBase rNewFilename)
virtual
OsStatus copy ( const OsPathBase rNewFilename)
virtual
OsStatus setReadOnly ( UtlBoolean  isReadOnly)
virtual

Reimplemented in OsFileLinux.

OsStatus touch ( )
virtual

Reimplemented in OsFileLinux, and OsFileWnt.

OsStatus getPosition ( unsigned long &  pos)
virtual
void getFileName ( OsPathBase rOsPath) const
virtual
OsStatus read ( void *  pBuf,
unsigned long  bufLen,
unsigned long &  rBytesRead 
)
virtual
OsStatus readLine ( UtlString str)
virtual
UtlBoolean close ( )
virtual
OsStatus getLength ( unsigned long &  length)
FILE* getFileDescriptor ( )
inline
OsConfigDb* getFileLocks ( )
inline
UtlBoolean isReadonly ( ) const
UtlBoolean exists ( )
virtual OsStatus getFileInfo ( OsFileInfoBase rFileinfo) const
pure virtual

Implemented in OsFileLinux, and OsFileWnt.

UtlBoolean isEOF ( )
OsFileBase & operator= ( const OsFileBase rhs)
protected

Member Data Documentation

OsMutex fileMutex
protected
FILE* mOsFileHandle
protected
OsPathBase mFilename
protected
int mMode
protected