Changeset b67be8d in tol
- Timestamp:
- Sep 7, 2009, 7:47:05 AM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- d626b32
- Parents:
- d794d03
- Location:
- tol/btol/bdb
- Files:
-
- 1 added
- 1 edited
-
filehandle.cpp (modified) (13 diffs)
-
tol_filehandle.h (added)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/bdb/filehandle.cpp
rd794d03 rb67be8d 25 25 26 26 27 #include <tol/tol_filehandle.h> 27 28 #include <tol/tol_bout.h> 28 29 #include <tol/tol_btxtgra.h> … … 39 40 BTraceInit("file.cpp"); 40 41 41 ///////////////////////////////////////////////////////////////////////////// 42 struct BFileDesc 43 ///////////////////////////////////////////////////////////////////////////// 44 { 45 FILE* file_; 46 BText path_; 47 BFileDesc(FILE* file, BText path) 48 : file_(file), 49 path_(path) 50 { } 51 }; 52 53 BFileDesc noFileDesc_(NULL,""); 54 55 typedef hash_map_by_int <BFileDesc*>::dense_ BFileHashByHandle; 56 57 58 ///////////////////////////////////////////////////////////////////////////// 59 static BFileHashByHandle& FileHandle() 42 43 BFileDesc BFileDesc::noFileDesc_(NULL,""); 44 45 46 ///////////////////////////////////////////////////////////////////////////// 47 BFileDesc::BFileHashByHandle& BFileDesc::FileHandle() 60 48 ///////////////////////////////////////////////////////////////////////////// 61 49 { … … 73 61 74 62 ///////////////////////////////////////////////////////////////////////////// 75 static FILE*CheckFileHandle(int handle, bool verbose, const BText& msg,76 BFileHashByHandle::const_iterator& found)63 FILE* BFileDesc::CheckFileHandle(int handle, bool verbose, const BText& msg, 64 BFileHashByHandle::const_iterator& found) 77 65 ///////////////////////////////////////////////////////////////////////////// 78 66 { … … 96 84 97 85 ///////////////////////////////////////////////////////////////////////////// 98 static FILE*CheckFileHandle(int handle, bool verbose, const BText& msg)86 FILE* BFileDesc::CheckFileHandle(int handle, bool verbose, const BText& msg) 99 87 ///////////////////////////////////////////////////////////////////////////// 100 88 { … … 104 92 105 93 ///////////////////////////////////////////////////////////////////////////// 106 void SysChkErrNo(bool clean, bool verbose, const BText& msg)94 void BFileDesc::SysChkErrNo(bool clean, bool verbose, const BText& msg) 107 95 ///////////////////////////////////////////////////////////////////////////// 108 96 { … … 145 133 if(Arg(2)) { verbose = int(Real(Arg(2)))!=0; } 146 134 contens_ = errno; 147 SysChkErrNo(clean, verbose, "");135 BFileDesc::SysChkErrNo(clean, verbose, ""); 148 136 } 149 137 … … 215 203 { 216 204 handle = fileno(file); 217 FileHandle()[handle] = new BFileDesc(file, path);205 BFileDesc::FileHandle()[handle] = new BFileDesc(file, path); 218 206 } 219 207 else 220 208 { 221 SysChkErrNo(clean, verbose,209 BFileDesc::SysChkErrNo(clean, verbose, 222 210 I2("Fail in ","Fallo en ")+ 223 211 "FOpen(\""+path+"\",\""+access+"\")"); … … 245 233 contens_ = ""; 246 234 247 FILE* file = CheckFileHandle(handle,true,235 FILE* file = BFileDesc::CheckFileHandle(handle,true, 248 236 I2("Fail in ","Fallo en ")+"FGetText"); 249 237 if(file) … … 266 254 BText& txt = Text(Arg(2)); 267 255 contens_ = EOF; 268 FILE* file = CheckFileHandle(handle,true,256 FILE* file = BFileDesc::CheckFileHandle(handle,true, 269 257 I2("Fail in ","Fallo en ")+"FPutText"); 270 258 if(file) … … 288 276 int handle = (int)Real(Arg(1)); 289 277 contens_ = EOF; 290 FILE* file = CheckFileHandle(handle, true,278 FILE* file = BFileDesc::CheckFileHandle(handle, true, 291 279 I2("Fail in ","Fallo en ")+"FEof"); 292 280 if(file) … … 320 308 else 321 309 { 322 FILE* file = CheckFileHandle(handle, true,310 FILE* file = BFileDesc::CheckFileHandle(handle, true, 323 311 I2("Fail in ","Fallo en ")+"FFlush"); 324 312 if(file) … … 350 338 if(Arg(3)) { verbose = int(Real(Arg(3)))!=0; } 351 339 contens_ = EOF; 352 BFile HashByHandle::const_iterator found;340 BFileDesc::BFileHashByHandle::const_iterator found; 353 341 BText failMsg = I2("Fail in ","Fallo en ")+"FClose"; 354 FILE* file = CheckFileHandle(handle, true, failMsg, found);342 FILE* file = BFileDesc::CheckFileHandle(handle, true, failMsg, found); 355 343 if(file) 356 344 { … … 359 347 if(!fc) 360 348 { 361 FileHandle().erase(found->first);349 BFileDesc::FileHandle().erase(found->first); 362 350 } 363 351 else 364 352 { 365 SysChkErrNo(clean, verbose, failMsg);353 BFileDesc::SysChkErrNo(clean, verbose, failMsg); 366 354 } 367 355 }
Note: See TracChangeset
for help on using the changeset viewer.
