Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CascadeFile Class Reference

an easy to use file class More...

#include <cascade/util/CascadeFile.h>

Inheritance diagram for CascadeFile:

CascadeFSObject CascadeObject List of all members.

Public Types

typedef bool() FileCopyCallback (u64 inTotal, u64 inComplete, void *pClientData)

Public Member Functions

 CascadeFile ()
 CascadeFile (const char *pName)
virtual ~CascadeFile ()
virtual bool Open (const char *pMode)
virtual bool Close ()
virtual bool Delete ()
virtual bool CopyInto (CascadeDirectory &inDestination, FSCopyError &outError, FileCopyCallback *inCallback=NULL, void *inClientData=NULL, bool inReplace=false)
virtual bool IsOpen () const
virtual bool SetName (const char *pName)
virtual bool Read (void *pBuff, u32 nBytes)
virtual bool Write (void *pBuff, u32 nBytes)
virtual u64 GetFileSize () const
virtual bool SeekToBeginning ()
virtual bool SeekForward (u32 nBytes)
virtual bool SeekBackward (u32 nBytes)
virtual bool SeekToEnd ()
virtual bool SeekToPosition (u64 nPosition)
virtual void * GetHandle () const
virtual bool IsDirectory (void) const

Detailed Description

an easy to use file class

Skip the description

CascadeFile provides easy to use object-based access to stdio filing operations.


class CascadeFile


Member Typedef Documentation

typedef bool() CascadeFile::FileCopyCallback(u64 inTotal, u64 inComplete, void *pClientData)
 

callback function for CopyInto method

Create a callback function of this signature to pass to the CopyInto method. Information is provided to calculate the progress of the copy operation.

Return true from your callback to allow the copy to proceed. Return false to cause the copy to stop. (The copy will return a false return value if canceled in this way.)

Parameters:
inTotal the total number of bytes of the file
inComplete the total number of bytes copied do far
pClientData client data provided to CopyInto
Returns:
true if copy is to proceed; false if stop requested


Constructor & Destructor Documentation

CascadeFile::CascadeFile  ) 
 

default constructor

This constructor constructs an unnamed file.

CascadeFile::CascadeFile const char *  pName  ) 
 

parameterized constructor

This constructor constructs a file with name pName.

Parameters:
pName the name of the file. Supply a full path (starting with a "/") to specify a location for the file other than the current working directory.

virtual CascadeFile::~CascadeFile  )  [virtual]
 

destructor

This is the CascadeFile destructor. If the file is open when the destructor is called, it will be closed by the destructor.

See also:
Close()


Member Function Documentation

virtual bool CascadeFile::Close  )  [virtual]
 

closes the file

Close() closes the file returning true if successful, false otherwise.

Returns:
whether or not the close succeeded
See also:
Open(), ~CascadeFile()

virtual bool CascadeFile::CopyInto CascadeDirectory inDestination,
FSCopyError outError,
FileCopyCallback inCallback = NULL,
void *  inClientData = NULL,
bool  inReplace = false
[virtual]
 

copy this file into the destination directory

Copies this file into the destination directory. If the copy is canceled via the callback, the destination file is deleted and the function returns false, with outError set to CascadeFSObject::eFSCopyCanceled

Parameters:
inDestination the directory into which the file is copied
outError on return, status information of type FSCopyError
inCallback callback of type FileCopyCallback. May be NULL.
inClientData client data returned to you in your callback. May be NULL.
inReplace whether or not to replace the file in the target directory if it exists
Returns:
true if successful, false if failure or canceled.

virtual bool CascadeFile::Delete  )  [virtual]
 

deletes the file

Delete() deletes the file referred to by this object.

Returns:
whether or not the delete succeeded

virtual u64 CascadeFile::GetFileSize  )  const [virtual]
 

gets the file size

GetFileSize() returns the size of the file in bytes. If the file is not open, GetFileSize() returns 0. GetFileSize() returns a 64 bit quantity. Whether or not 64 bit file sizes are supported is dependent on the underlying file system.

Returns:
the file size of the file or 0 if the file is not open

virtual void* CascadeFile::GetHandle  )  const [virtual]
 

gets the internal FILE * of the file

GetHandle() returns the operating system file handle for the open file or NULL if the file is not open. This value may safely be cast to a FILE * and the function fileno() may be used on the handle returned to turn it into a file descriptor.

Returns:
the FILE * of the file or NULL if the file is not open

virtual bool CascadeFile::IsDirectory void   )  const [inline, virtual]
 

determines whether or not the file is a directory

IsDirectory() determines if the file refers to a directory.

Returns:
always false

Implements CascadeFSObject.

virtual bool CascadeFile::IsOpen  )  const [virtual]
 

determines whether or not the file is open

IsOpen() returns true if the file is already open.

Returns:
whether or not the file is open

virtual bool CascadeFile::Open const char *  pMode  )  [virtual]
 

opens the file

Open() opens the file with mode pMode. The modes are the same as the modes for fopen. If the file is already open, Open() returns false.

Parameters:
pMode the open mode of the file (as in fopen)
Returns:
whether or not the open succeeded
See also:
SetName()

virtual bool CascadeFile::Read void *  pBuff,
u32  nBytes
[virtual]
 

reads data from the file

Read() reads nBytes from the file into *pBuff returning true if successful, false otherwise.

Parameters:
pBuff the buffer to read data into
nBytes the size in bytes for the read
Returns:
whether or not the read succeeded

virtual bool CascadeFile::SeekBackward u32  nBytes  )  [virtual]
 

seeks backward in the file

SeekBackward() seeks an open file backward nBytes from the current position returning true if successful, false otherwise.

Parameters:
nBytes the number of bytes to seek backward
Returns:
whether or not the seek succeeded

virtual bool CascadeFile::SeekForward u32  nBytes  )  [virtual]
 

seeks forward in the file

SeekForward() seeks an open file forward nBytes from the current position returning true if successful, false otherwise.

Parameters:
nBytes the number of bytes to seek forward
Returns:
whether or not the seek succeeded

virtual bool CascadeFile::SeekToBeginning  )  [virtual]
 

seeks to the beginning of the file

SeekToBeginning() seeks an open file to the beginning returning true if successful, false otherwise.

Returns:
whether or not the seek succeeded

virtual bool CascadeFile::SeekToEnd  )  [virtual]
 

seeks to the end of the file

SeekToEnd() seeks an open file to the end returning true if successful, false otherwise.

Returns:
whether or not the seek succeeded

virtual bool CascadeFile::SeekToPosition u64  nPosition  )  [virtual]
 

seeks to a position in the file

SeekToPosition() seeks an open file to the absolute byte position identified by nPosition returning true if successful, false otherwise. Whether or not 64 bit file positions are supported is dependent on the underlying file system.

Parameters:
nPosition the absolute byte position in the file to seek to
Returns:
whether or not the seek succeeded

virtual bool CascadeFile::SetName const char *  pName  )  [virtual]
 

sets the file name

SetName() sets the name of the file object to pName. If the file is already open SetName() returns false. The file name must be set with SetName() (or with a name setting constructor) before a file open will succeed.

Parameters:
pName the name to set
Returns:
whether or not the name setting succeeded

Reimplemented from CascadeFSObject.

virtual bool CascadeFile::Write void *  pBuff,
u32  nBytes
[virtual]
 

writes data to the file

Write() writes nBytes from *pBuff to the file returning true if successful, false otherwise.

Parameters:
pBuff the data to write to the file
nBytes the size in bytes of the data to write
Returns:
whether or not the write succeeded


The documentation for this class was generated from the following file:
Generated on Sun Jul 24 14:27:19 2005 for Cascade Library by  doxygen 1.4.1