Changeset 2543 for box/trunk/lib/raidfile/RaidFileWrite.cpp
- Timestamp:
- 05/07/2009 22:43:57 (3 years ago)
- File:
-
- 1 edited
-
box/trunk/lib/raidfile/RaidFileWrite.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/raidfile/RaidFileWrite.cpp
r2529 r2543 43 43 // Function 44 44 // Name: RaidFileWrite::RaidFileWrite(int, const std::string &) 45 // Purpose: Construtor, just stores requried details45 // Purpose: Simple constructor, just stores required details 46 46 // Created: 2003/07/10 47 47 // … … 50 50 : mSetNumber(SetNumber), 51 51 mFilename(Filename), 52 mOSFileHandle(-1) // not valid file handle 53 { 52 mOSFileHandle(-1), // not valid file handle 53 mRefCount(-1) // unknown refcount 54 { 55 } 56 57 // -------------------------------------------------------------------------- 58 // 59 // Function 60 // Name: RaidFileWrite::RaidFileWrite(int, 61 // const std::string &, int refcount) 62 // Purpose: Constructor with check for overwriting file 63 // with multiple references 64 // Created: 2009/07/05 65 // 66 // -------------------------------------------------------------------------- 67 RaidFileWrite::RaidFileWrite(int SetNumber, const std::string &Filename, 68 int refcount) 69 : mSetNumber(SetNumber), 70 mFilename(Filename), 71 mOSFileHandle(-1), // not valid file handle 72 mRefCount(refcount) 73 { 74 // Can't check for zero refcount here, because it's legal 75 // to create a RaidFileWrite to delete an object with zero refcount. 76 // Check in Commit() and Delete() instead. 77 if (refcount > 1) 78 { 79 BOX_ERROR("Attempted to modify object " << mFilename << 80 ", which has " << refcount << " references"); 81 THROW_EXCEPTION(RaidFileException, 82 RequestedModifyMultiplyReferencedFile); 83 } 54 84 } 55 85 … … 251 281 THROW_EXCEPTION(RaidFileException, NotOpen) 252 282 } 253 283 284 if (mRefCount == 0) 285 { 286 BOX_ERROR("Attempted to modify object " << mFilename << 287 ", which has no references"); 288 THROW_EXCEPTION(RaidFileException, 289 RequestedModifyUnreferencedFile); 290 } 291 254 292 // Rename it into place -- BEFORE it's closed so lock remains 255 293 … … 639 677 void RaidFileWrite::Delete() 640 678 { 679 if (mRefCount != 0 && mRefCount != -1) 680 { 681 BOX_ERROR("Attempted to delete object " << mFilename << 682 " which has " << mRefCount << " references"); 683 THROW_EXCEPTION(RaidFileException, 684 RequestedDeleteReferencedFile); 685 } 686 641 687 // Get disc set 642 688 RaidFileController &rcontroller(RaidFileController::GetController());
Note: See TracChangeset
for help on using the changeset viewer.
