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
00143 typedef enum {
00145 CFF_DONE,
00148 CFF_WAITING,
00158 CFF_TIMEDOUT,
00159
00165 CFF_SOFTERROR,
00166
00170 CFF_HARDERROR,
00171
00188 CFF_PROGERROR
00189 }CffStatus;
00190
00192 typedef enum {
00194 SW_FROM_BEGIN=0,
00196 SW_FROM_CUR=1,
00198 SW_FROM_CURENT=1,
00200 SW_FROM_END=2
00201 } SeekWhence;
00202
00225 class OSFileFuncBase {
00226 protected:
00237 OSFileFuncBase() {
00238 m_timeout = -1.0;
00239 m_osError = 0;
00240 m_status = CFF_DONE;
00241 }
00242
00243 double m_timeout;
00244 CffStatus m_status;
00245 int m_osError;
00246
00247 public:
00280 virtual inline CffStatus open(
00281 std::string filespec,
00282 OpenMode openMode = OM_RO,
00283 LockMode lockMode = LM_SHARED
00284 ) = 0;
00285
00315 virtual inline CffStatus create(
00316 std::string filespec,
00317 CreateMode cMode = CM_ARCHIVE,
00318 LockMode lockMode = LM_EXCLUSIVE
00319 ) = 0;
00320
00333 inline virtual void getDescriptor( void *data ) const = 0;
00334
00347 inline virtual void setDescriptor( void *data ) = 0;
00348
00349
00351 inline CffStatus status() const { return m_status; }
00352
00357 inline void status(const CffStatus st ) { m_status = st ; }
00358
00367 inline int osError() const { return m_osError; }
00368
00372 inline void osError( const int osError ) { m_osError = osError; }
00373
00374
00376 inline double timeout() const { return m_timeout; }
00377
00388 inline void timeout( const double to ) { m_timeout = to; }
00389
00390
00391
00392
00393 inline void clearTimeout() { timeout( -1.0 ); }
00394
00395
00396
00397
00398
00399 inline void dontBlock() { timeout( 0.0 ); }
00400
00414 virtual file_size_t read( void *buffer, const file_size_t len ) = 0;
00415
00430 virtual file_size_t write( void *buffer, const file_size_t len ) = 0;
00431
00439 virtual file_size_t seek(
00440 const file_size_t position,
00441 const SeekWhence swFrom= SW_FROM_BEGIN
00442 ) = 0;
00443
00445 virtual CffStatus close()=0;
00446
00451 inline virtual void setStdIn() = 0;
00452
00457 inline virtual void setStdOut() = 0;
00458
00463 inline virtual void setStdErr() = 0;
00464
00465 };
00466
00468 }
00469
00470 #endif
00471
00472