00001 #ifndef _T_FILE_HH
00002 #define _T_FILE_HH
00003
00004 #include "TString.hh"
00005 #if defined (_WIN32) || defined (__CYGWIN__)
00006 #include <windows.h>
00007 #endif
00008
00009 #define TFILE_BUF_LEN 4096
00010
00011
00017 class TFile
00018 {
00019 public:
00020
00024 enum Seek
00025 {
00027 SET,
00028
00030 CUR,
00031
00033 END
00034 };
00035
00039 TFile ();
00040
00049 TFile (const TString& path, const TString& mode);
00050
00054 ~TFile ();
00055
00059 void Close ();
00060
00068 bool GetMap (void*& start, long& length);
00069
00075 bool IsValid ();
00076
00082 long Length ();
00083
00092 void * Map ();
00093
00104 void * Map (long offset, long length);
00105
00109 void UnMap ();
00110
00118 bool Open (const TString& path, const TString& mode);
00119
00125 inline TString Path () { return myPath; }
00126
00134 long Read (void *buf, long count);
00135
00143 long Seek (long offset, enum Seek whence = SET);
00144
00149 void Sync ();
00150
00158 bool Write (const TFile& file);
00159
00166 bool Write (const TString& str);
00167
00175 long Write (const void *buf, long count);
00176
00177
00178 private:
00179
00181 TString myPath;
00182
00184 void *myMemory;
00185
00187 long myMemoryLen;
00188
00189 #if defined (_WIN32) || defined (__CYGWIN__)
00190
00191 HANDLE myFildes;
00192
00194 HANDLE myMapdes;
00195
00197 DWORD myProt;
00198
00199 #else
00200
00201 int myFildes;
00202
00204 int myProt;
00205 #endif
00206 };
00207
00208 #endif // _T_FILE_HH