PMemoryFile Class Reference

#include <memfile.h>

Inheritance diagram for PMemoryFile:

PFile PChannel PObject List of all members.

Public Member Functions

Construction
 PMemoryFile ()
 PMemoryFile (const PBYTEArray &data)
Overrides from class PObject
Comparison Compare (const PObject &obj) const
Overrides from class PChannel
virtual PBoolean Read (void *buf, PINDEX len)
virtual PBoolean Write (const void *buf, PINDEX len)
Overrides from class PFile
off_t GetLength () const
PBoolean SetLength (off_t len)
PBoolean SetPosition (off_t pos, FilePositionOrigin origin=Start)
off_t GetPosition () const
Overrides from class PFile
const PBYTEArrayGetData () const

Protected Attributes

PBYTEArray data
off_t position

Detailed Description

This class is used to allow a block of memory to substitute for a disk file.


Constructor & Destructor Documentation

PMemoryFile::PMemoryFile (  ) 

Create a new, empty, memory file.

PMemoryFile::PMemoryFile ( const PBYTEArray data  ) 

Create a new memory file initialising to the specified content.

Parameters:
data  New content filr memory file.


Member Function Documentation

Comparison PMemoryFile::Compare ( const PObject obj  )  const [virtual]

Determine the relative rank of the two objects. This is essentially the string comparison of the PFilePath# names of the files.

Returns:
relative rank of the file paths.
Parameters:
obj  Other file to compare against.

Reimplemented from PFile.

const PBYTEArray& PMemoryFile::GetData (  )  const [inline]

Get the memory data the file has operated with.

off_t PMemoryFile::GetLength (  )  const [virtual]

Get the current size of the file. The size of the file corresponds to the size of the data array.

Returns:
length of file in bytes.

Reimplemented from PFile.

off_t PMemoryFile::GetPosition (  )  const [virtual]

Get the current active position in the file for the next read or write operation.

Returns:
current file position relative to start of file.

Reimplemented from PFile.

virtual PBoolean PMemoryFile::Read ( void *  buf,
PINDEX  len 
) [virtual]

Low level read from the memory file channel. The read timeout is ignored. The GetLastReadCount() function returns the actual number of bytes read.

The GetErrorCode() function should be consulted after Read() returns PFalse to determine what caused the failure.

Returns:
PTrue indicates that at least one character was read from the channel. PFalse means no bytes were read due to timeout or some other I/O error.
Parameters:
buf  Pointer to a block of memory to receive the read bytes.
len  Maximum number of bytes to read into the buffer.

Reimplemented from PFile.

PBoolean PMemoryFile::SetLength ( off_t  len  )  [virtual]

Set the size of the file, padding with 0 bytes if it would require expanding the file, or truncating it if being made shorter.

Returns:
PTrue if the file size was changed to the length specified.
Parameters:
len  New length of file.

Reimplemented from PFile.

PBoolean PMemoryFile::SetPosition ( off_t  pos,
FilePositionOrigin  origin = Start 
)

Set the current active position in the file for the next read or write operation. The pos# variable is a signed number which is added to the specified origin. For origin == PFile::Start# only positive values for pos# are meaningful. For origin == PFile::End# only negative values for pos# are meaningful.

Returns:
PTrue if the new file position was set.
Parameters:
pos  New position to set.
origin  Origin for position change.

virtual PBoolean PMemoryFile::Write ( const void *  buf,
PINDEX  len 
) [virtual]

Low level write to the memory file channel. The write timeout is ignored. The GetLastWriteCount() function returns the actual number of bytes written.

The GetErrorCode() function should be consulted after Write() returns PFalse to determine what caused the failure.

Returns:
PTrue if at least len bytes were written to the channel.
Parameters:
buf  Pointer to a block of memory to write.
len  Number of bytes to write.

Reimplemented from PFile.


Member Data Documentation

PBYTEArray PMemoryFile::data [protected]

off_t PMemoryFile::position [protected]


The documentation for this class was generated from the following file:
Generated on Thu May 27 01:36:49 2010 for PTLib by  doxygen 1.4.7