Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Wefts::OSFileFuncUnix Class Reference
[Oscoffee]

#include <wefts_coffee_unix.h>

Inheritance diagram for Wefts::OSFileFuncUnix:

Inheritance graph
[legend]
Collaboration diagram for Wefts::OSFileFuncUnix:

Collaboration graph
[legend]
List of all members.

Public Methods

 OSFileFuncUnix (void *descriptor=0)
virtual CffStatus open (std::string filespec, OpenMode openMode=OM_RO, LockMode lockMode=LM_SHARED)
 Unix layer COFFEE function to open a file It opens a single file using the specified mode.

virtual CffStatus create (std::string filespec, CreateMode cMode=CM_ARCHIVE, LockMode lockMode=LM_EXCLUSIVE)
 Creates the file.

virtual void getDescriptor (void *data) const
 To get the descriptor, pass a pointer to an integer where the descriptor will be placed.

virtual void setDescriptor (void *data)
 To set the descriptor, pass a pointer to the integer.

virtual file_size_t read (void *buffer, const file_size_t len)
 Read data from the underlying file.

virtual file_size_t write (void *buffer, const file_size_t len)
 Write data to the underlying file Application should not rely on osError() if the function retunrs a vaild number.

virtual file_size_t seek (const file_size_t position, const SeekWhence swFrom=SW_FROM_BEGIN)
 Change the position in the file.

virtual CffStatus close ()
virtual void setStdIn ()
virtual void setStdOut ()
virtual void setStdErr ()

Protected Methods

bool waitForWrite ()
bool waitForRead ()

Protected Attributes

int m_fd

Constructor & Destructor Documentation

Wefts::OSFileFuncUnix::OSFileFuncUnix void *    descriptor = 0 [inline]
 


Member Function Documentation

CffStatus Wefts::OSFileFuncUnix::close   [virtual]
 

Implements Wefts::OSFileFuncBase.

CffStatus Wefts::OSFileFuncUnix::create std::string    filespec,
CreateMode    cMode = CM_ARCHIVE,
LockMode    lockMode = LM_EXCLUSIVE
[virtual]
 

Creates the file.

The create-lock parameter is provided because some systems may not allow to lock the file after the create step (the lock politic must be chosen at open time). The timeout is provided because the file may be located on a network disk, or a COFFEE implementation may use a network protocol as underlying layer. It is theoretically possible to provide a COFFEE for FTP.

Anyhow, a reasonable timeout may also protect against program deadlocks due to local filesystem failure on systems that do not provide a prompt error diagniostic.

File is always created with read-write access from the creator, and it can be locked against concurrent access from other processes.

By default, the timeout is not set; to set a given timeout, use the setTimeout() method.

Note:
Please note that you can use OS system dependant routine to open the file descriptor, and then setup the
Parameters:
filespec  the file name
OpenMode  the file open mode
LockScheme  wether the file may be accessed by other processes willing to open it or not.
Returns:
a Cff Status indicating success or failure (see CffStatus)

Implements Wefts::OSFileFuncBase.

virtual void Wefts::OSFileFuncUnix::getDescriptor void *    data const [inline, virtual]
 

To get the descriptor, pass a pointer to an integer where the descriptor will be placed.

Implements Wefts::OSFileFuncBase.

CffStatus Wefts::OSFileFuncUnix::open std::string    filespec,
OpenMode    openMode = OM_RO,
LockMode    lockMode = LM_SHARED
[virtual]
 

Unix layer COFFEE function to open a file It opens a single file using the specified mode.

Implements Wefts::OSFileFuncBase.

file_size_t Wefts::OSFileFuncUnix::read void *    buffer,
const file_size_t    len
[virtual]
 

Read data from the underlying file.

Application should not rely on osError() if the function retunrs a vaild number.

file_size_t is the longest integer type provided by the platform.

Parameters:
buffer  memory area where to load the data
len  amount of byte to be read on the memory data
Returns:
the amount of byte read from the file, 0 on end of file and -1 on error. On error status() and osError() will return proper values.

Implements Wefts::OSFileFuncBase.

file_size_t Wefts::OSFileFuncUnix::seek const file_size_t    position,
const SeekWhence    swFrom = SW_FROM_BEGIN
[virtual]
 

Change the position in the file.

Must return current position after change, so that seek( 0, SW_FROM_END ) return the current file length (that is one past last byte).

Returns:
current position after seek or -1 on error

Implements Wefts::OSFileFuncBase.

virtual void Wefts::OSFileFuncUnix::setDescriptor void *    data [inline, virtual]
 

To set the descriptor, pass a pointer to the integer.

Implements Wefts::OSFileFuncBase.

virtual void Wefts::OSFileFuncUnix::setStdErr   [inline, virtual]
 

Implements Wefts::OSFileFuncBase.

virtual void Wefts::OSFileFuncUnix::setStdIn   [inline, virtual]
 

Implements Wefts::OSFileFuncBase.

virtual void Wefts::OSFileFuncUnix::setStdOut   [inline, virtual]
 

Implements Wefts::OSFileFuncBase.

bool Wefts::OSFileFuncUnix::waitForRead   [inline, protected]
 

bool Wefts::OSFileFuncUnix::waitForWrite   [inline, protected]
 

file_size_t Wefts::OSFileFuncUnix::write void *    buffer,
const file_size_t    len
[virtual]
 

Write data to the underlying file Application should not rely on osError() if the function retunrs a vaild number.

file_size_t is the longest integer type provided by the platform.

Parameters:
buffer  memory area where from which to write
len  amount of byte to be written from the memory data
Returns:
the amount of bytes written to the file, 0 if the timeout has elapsed and -1 on error. On error status() and osError() will return proper values.

Implements Wefts::OSFileFuncBase.


Member Data Documentation

int Wefts::OSFileFuncUnix::m_fd [protected]
 


The documentation for this class was generated from the following files:
Generated on Mon Dec 22 04:12:38 2003 for Wefts by doxygen1.2.18