- Timestamp:
- 01/11/2011 23:37:58 (7 months ago)
- File:
-
- 1 edited
-
box/trunk/lib/backupstore/BackupStoreInfo.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/lib/backupstore/BackupStoreInfo.cpp
r2975 r3039 454 454 } 455 455 456 #define APPLY_DELTA(field, delta) \ 457 if(mReadOnly) \ 458 { \ 459 THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) \ 460 } \ 461 \ 462 if((field + delta) < 0) \ 463 { \ 464 THROW_EXCEPTION_MESSAGE(BackupStoreException, \ 465 StoreInfoBlockDeltaMakesValueNegative, \ 466 "Failed to reduce " << #field << " from " << \ 467 field << " by " << delta); \ 468 } \ 469 \ 470 field += delta; \ 471 mIsModified = true; 472 456 473 // -------------------------------------------------------------------------- 457 474 // … … 464 481 void BackupStoreInfo::ChangeBlocksUsed(int64_t Delta) 465 482 { 466 if(mReadOnly) 467 { 468 THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) 469 } 470 if((mBlocksUsed + Delta) < 0) 471 { 472 THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) 473 } 474 475 mBlocksUsed += Delta; 476 477 mIsModified = true; 483 APPLY_DELTA(mBlocksUsed, Delta); 478 484 } 479 485 … … 489 495 void BackupStoreInfo::ChangeBlocksInCurrentFiles(int64_t Delta) 490 496 { 491 if(mReadOnly) 492 { 493 THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) 494 } 495 496 if((mBlocksInCurrentFiles + Delta) < 0) 497 { 498 THROW_EXCEPTION(BackupStoreException, 499 StoreInfoBlockDeltaMakesValueNegative) 500 } 501 502 mBlocksInCurrentFiles += Delta; 503 mIsModified = true; 497 APPLY_DELTA(mBlocksInCurrentFiles, Delta); 504 498 } 505 499 … … 514 508 void BackupStoreInfo::ChangeBlocksInOldFiles(int64_t Delta) 515 509 { 516 if(mReadOnly) 517 { 518 THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) 519 } 520 if((mBlocksInOldFiles + Delta) < 0) 521 { 522 THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) 523 } 524 525 mBlocksInOldFiles += Delta; 526 527 mIsModified = true; 510 APPLY_DELTA(mBlocksInOldFiles, Delta); 528 511 } 529 512 … … 538 521 void BackupStoreInfo::ChangeBlocksInDeletedFiles(int64_t Delta) 539 522 { 540 if(mReadOnly) 541 { 542 THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) 543 } 544 if((mBlocksInDeletedFiles + Delta) < 0) 545 { 546 THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) 547 } 548 549 mBlocksInDeletedFiles += Delta; 550 551 mIsModified = true; 523 APPLY_DELTA(mBlocksInDeletedFiles, Delta); 552 524 } 553 525 … … 562 534 void BackupStoreInfo::ChangeBlocksInDirectories(int64_t Delta) 563 535 { 564 if(mReadOnly) 565 { 566 THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) 567 } 568 if((mBlocksInDirectories + Delta) < 0) 569 { 570 THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) 571 } 572 573 mBlocksInDirectories += Delta; 574 575 mIsModified = true; 536 APPLY_DELTA(mBlocksInDirectories, Delta); 576 537 } 577 538 578 539 void BackupStoreInfo::AdjustNumFiles(int64_t increase) 579 540 { 580 if(mReadOnly) 581 { 582 THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) 583 } 584 585 if((mNumFiles + increase) < 0) 586 { 587 THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) 588 } 589 590 mNumFiles += increase; 591 mIsModified = true; 592 541 APPLY_DELTA(mNumFiles, increase); 593 542 } 594 543 595 544 void BackupStoreInfo::AdjustNumOldFiles(int64_t increase) 596 545 { 597 if(mReadOnly) 598 { 599 THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) 600 } 601 602 if((mNumOldFiles + increase) < 0) 603 { 604 THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) 605 } 606 607 mNumOldFiles += increase; 608 mIsModified = true; 546 APPLY_DELTA(mNumOldFiles, increase); 609 547 } 610 548 611 549 void BackupStoreInfo::AdjustNumDeletedFiles(int64_t increase) 612 550 { 613 if(mReadOnly) 614 { 615 THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) 616 } 617 618 if((mNumDeletedFiles + increase) < 0) 619 { 620 THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) 621 } 622 623 mNumDeletedFiles += increase; 624 mIsModified = true; 551 APPLY_DELTA(mNumDeletedFiles, increase); 625 552 } 626 553 627 554 void BackupStoreInfo::AdjustNumDirectories(int64_t increase) 628 555 { 629 if(mReadOnly) 630 { 631 THROW_EXCEPTION(BackupStoreException, StoreInfoIsReadOnly) 632 } 633 634 if((mNumDirectories + increase) < 0) 635 { 636 THROW_EXCEPTION(BackupStoreException, StoreInfoBlockDeltaMakesValueNegative) 637 } 638 639 mNumDirectories += increase; 640 mIsModified = true; 556 APPLY_DELTA(mNumDirectories, increase); 641 557 } 642 558
Note: See TracChangeset
for help on using the changeset viewer.
