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

Wefts::OSFileFuncWin Class Reference
[OS Cooperative File Function Extended Enviroment]

Implements COFFEE file specific extensions for MS-Windows. More...

#include <wefts_coffee_win.h>

Inheritance diagram for Wefts::OSFileFuncWin:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 OSFileFuncWin (void *descriptor=0)
 ~OSFileFuncWin ()
virtual CffStatus open (std::string filespec, OpenMode openMode=OM_RO, LockMode lockMode=LM_SHARED)
virtual CffStatus create (std::string filespec, CreateMode cMode=CM_ARCHIVE, LockMode lockMode=LM_EXCLUSIVE)
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)
virtual file_size_t write (void *buffer, const file_size_t len)
virtual file_size_t seek (const file_size_t position, const SeekWhence swFrom=SW_FROM_BEGIN)
virtual CffStatus close ()
virtual void setStdIn ()
 Use STDIN as the handle of this FileFunc object.

virtual void setStdOut ()
 Use STDOUT as the handle of this FileFunc object.

virtual void setStdErr ()
 Use STDERR as the handle of this FileFunc object.


Protected Member Functions

file_size_t internal_rw (void *buffer, const file_size_t len, bool rw, bool bFile)

Protected Attributes

HANDLE m_handle
HANDLE m_evtComplete
LARGE_INTEGER m_liSize
LARGE_INTEGER m_liPos
bool m_bOvlFiles

Detailed Description

Implements COFFEE file specific extensions for MS-Windows.

This class is able to understand if the underlying system is capable to do asynchronous file or network operations via OVERLAPPED files; this is possible only with Windows 2000 or later, and only if the target file is not a memory-based character file (that is, a CONSOLE).

If the asynchronous file operations are available, they are used to cleanly cleanup the thread in case of cancelation. If they are not available, two actions may be taken: if cancelation is not allowed in the underlying windows specific OSTAIL, the a blocking read is performed. If cancelation is allowed, then a new thread is started, and the calling thread puts itself in wait for the I/O thread to terminate. The new thread is created with minimal resources available, and it hasn't any data to be cleaned.

In case of cancelation requests arriving while waiting for I/O thread to terminate, the target thread is canceled with TerminateThread(). This is sayed to be an unsafe method (From MSDN), but chances are for the system not allocating resources to be cleaned; this means that this cancelation scheme should be safe, but since internal documentation of ReadFile or WriteFile functions is not available, we cannot be certain.

Anyhow, whenever possible (i.e. whenever it is demonstrable that the I/O call may return data or error in a reasonable time), turn off cancelation BEFORE calling entering read or write methods.

Instead of instantiating OSFileFuncWin, use the typedef OSFileFunc, that is turned into the correct class depending on the host system.

See also:
How to use OS Cooperative File Function Extended Environment layer


Constructor & Destructor Documentation

Wefts::OSFileFuncWin::OSFileFuncWin void *  descriptor = 0  ) 
 

Wefts::OSFileFuncWin::~OSFileFuncWin  )  [inline]
 


Member Function Documentation

CffStatus Wefts::OSFileFuncWin::close  )  [virtual]
 

Implements Wefts::OSFileFuncBase.

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

Implements Wefts::OSFileFuncBase.

virtual void Wefts::OSFileFuncWin::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.

file_size_t Wefts::OSFileFuncWin::internal_rw void *  buffer,
const file_size_t  len,
bool  rw,
bool  bFile
[protected]
 

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

Implements Wefts::OSFileFuncBase.

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

Implements Wefts::OSFileFuncBase.

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

Implements Wefts::OSFileFuncBase.

virtual void Wefts::OSFileFuncWin::setDescriptor void *  data  )  [inline, virtual]
 

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

Implements Wefts::OSFileFuncBase.

virtual void Wefts::OSFileFuncWin::setStdErr  )  [inline, virtual]
 

Use STDERR as the handle of this FileFunc object.

Implements Wefts::OSFileFuncBase.

virtual void Wefts::OSFileFuncWin::setStdIn  )  [inline, virtual]
 

Use STDIN as the handle of this FileFunc object.

Implements Wefts::OSFileFuncBase.

virtual void Wefts::OSFileFuncWin::setStdOut  )  [inline, virtual]
 

Use STDOUT as the handle of this FileFunc object.

Implements Wefts::OSFileFuncBase.

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

Implements Wefts::OSFileFuncBase.


Member Data Documentation

bool Wefts::OSFileFuncWin::m_bOvlFiles [protected]
 

HANDLE Wefts::OSFileFuncWin::m_evtComplete [protected]
 

HANDLE Wefts::OSFileFuncWin::m_handle [protected]
 

LARGE_INTEGER Wefts::OSFileFuncWin::m_liPos [protected]
 

LARGE_INTEGER Wefts::OSFileFuncWin::m_liSize [protected]
 


The documentation for this class was generated from the following files:
Generated on Sat Mar 13 21:05:44 2004 for Wefts by doxygen 1.3.5