00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WT_COFFEE_BASE_H
00023 #define WT_COFFEE_BASE_H
00024
00025 #include <wefts_cleanup.h>
00026 #include <string>
00027
00043 namespace Wefts {
00044
00050 #if defined(_MSC_VER) || defined(__BORLANDC__)
00051 typedef unsigned __int64 file_size_t;
00052 #else
00053 typedef long long file_size_t;
00054 #endif
00055
00057 typedef enum {
00058
00059 LM_SHARED,
00060
00061 LM_SHARED_RO,
00062
00063 LM_EXCLUSIVE,
00064 } LockMode;
00065
00066
00068 typedef enum {
00070 OM_RO,
00072 OM_WO,
00074 OM_RW,
00079 OM_TRUNC_WO,
00084 OM_TRUNC_RW,
00086 OM_APPEND_WO,
00088 OM_APPEND_RW
00089 } OpenMode;
00090
00109 typedef enum {
00111 CM_ARCHIVE,
00113 CM_SYSTEM,
00120 CM_EXECUTABLE,
00122 CM_PRIVATE,
00124 CM_PRIVATE_EX
00125 } CreateMode;
00126
00127
00142 typedef enum {
00144 CFF_DONE,
00147 CFF_WAITING,
00157 CFF_TIMEDOUT,
00158
00164 CFF_SOFTERROR,
00165
00169 CFF_HARDERROR,
00170
00187 CFF_PROGERROR
00188 }CffStatus;
00189
00191 typedef enum {
00192 SW_FROM_BEGIN=0,
00193 SW_FROM_CUR=1,
00194 SW_FROM_CURENT=1,
00195 SW_FROM_END=2
00196 } SeekWhence;
00197
00219 class OSFileFuncBase {
00220 protected:
00231 OSFileFuncBase() {
00232 m_timeout = -1.0;
00233 m_osError = 0;
00234 m_status = CFF_DONE;
00235 }
00236
00237 double m_timeout;
00238 CffStatus m_status;
00239 int m_osError;
00240
00241 public:
00274 virtual inline CffStatus open(
00275 std::string filespec,
00276 OpenMode openMode = OM_RO,
00277 LockMode lockMode = LM_SHARED
00278 ) = 0;
00279
00309 virtual inline CffStatus create(
00310 std::string filespec,
00311 CreateMode cMode = CM_ARCHIVE,
00312 LockMode lockMode = LM_EXCLUSIVE
00313 ) = 0;
00314
00327 inline virtual void getDescriptor( void *data ) const = 0;
00328
00341 inline virtual void setDescriptor( void *data ) = 0;
00342
00343
00345 inline CffStatus status() const { return m_status; }
00346
00349 inline void status(const CffStatus st ) { m_status = st ; }
00350
00359 inline int osError() const { return m_osError; }
00360
00364 inline void osError( const int osError ) { m_osError = osError; }
00365
00366
00368 inline double timeout() const { return m_timeout; }
00369
00377 inline void timeout( const double to ) { m_timeout = to; }
00378
00379
00380
00381
00382 inline void clearTimeout() { timeout( -1.0 ); }
00383
00384
00385
00386
00387
00388 inline void dontBlock() { timeout( 0.0 ); }
00389
00403 virtual file_size_t read( void *buffer, const file_size_t len ) = 0;
00404
00418 virtual file_size_t write( void *buffer, const file_size_t len ) = 0;
00419
00427 virtual file_size_t seek(
00428 const file_size_t position,
00429 const SeekWhence swFrom= SW_FROM_BEGIN
00430 ) = 0;
00431
00432 virtual CffStatus close()=0;
00433
00434 inline virtual void setStdIn() = 0;
00435 inline virtual void setStdOut() = 0;
00436 inline virtual void setStdErr() = 0;
00437
00438 };
00439
00441 }
00442
00443 #endif
00444
00445