#include <wefts_coffee_win.h>
Inheritance diagram for Wefts::OSFileFuncWin:
Public Methods | |
OSFileFuncWin (void *descriptor=0) | |
~OSFileFuncWin () | |
virtual CffStatus | open (std::string filespec, OpenMode openMode=OM_RO, LockMode lockMode=LM_SHARED) |
Creates a file. | |
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 () |
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 Methods | |
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 |
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.
|
|
|
|
|
Implements Wefts::OSFileFuncBase. |
|
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.
Implements Wefts::OSFileFuncBase. |
|
To get the descriptor, pass a pointer to an integer where the descriptor will be placed.
Implements Wefts::OSFileFuncBase. |
|
|
|
Creates a file. The file may be opened with a locking sckeme, if the underlying provides it, and may be triggered with a given timeout. The open-lock parameter is provided because some systems may not allow to lock the file after the open 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 can be opened for reading, for writing, can be open truncated or in append mode (see OpenMode). Text-to-binary translation is not provided: data is read as is on all systems. By default, the timeout is not set; to set a given timeout, use the setTimeout() method.
Implements Wefts::OSFileFuncBase. |
|
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.
Implements Wefts::OSFileFuncBase. |
|
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).
Implements Wefts::OSFileFuncBase. |
|
To set the descriptor, pass a pointer to the integer.
Implements Wefts::OSFileFuncBase. |
|
Use STDERR as the handle of this FileFunc object.
Implements Wefts::OSFileFuncBase. |
|
Use STDIN as the handle of this FileFunc object.
Implements Wefts::OSFileFuncBase. |
|
Use STDOUT as the handle of this FileFunc object.
Implements Wefts::OSFileFuncBase. |
|
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.
Implements Wefts::OSFileFuncBase. |
|
|
|
|
|
|
|
|
|
|