Changeset 911 in vbox
- Timestamp:
- Feb 14, 2007 6:41:37 PM (18 years ago)
- svn:sync-xref-src-repo-rev:
- 18636
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HardDiskImpl.cpp
r362 r911 564 564 /** 565 565 * Checks basic accessibility of this hard disk only (w/o parents). 566 * Must be always called by every reimplementation in the first place. 567 * 568 * @param aAccessError on output, a null string indicates the hard disk is 566 * Must be always called by every HardDisk::getAccessible() reimplementation 567 * in the first place. 568 * 569 * When @a aCheckBusy is true, this method checks that mBusy = false and 570 * mReaders = 0 (and returns an appropriate error if not). This lets 571 * reimplementations successfully call setBusy() to lock the disk for the 572 * duration of the check if they need. Note that in this case, the 573 * reimplementation must enter the object lock before calling this method 574 * and not leave it before calling setBusy() to avoid race condition. 575 * 576 * @param aAccessError On output, a null string indicates the hard disk is 569 577 * accessible, otherwise contains a message describing 570 578 * the reason of inaccessibility. 571 */ 572 HRESULT HardDisk::getAccessible (Bstr &aAccessError) 573 { 574 AutoLock alock (this); 575 CHECK_READY(); 576 577 if (mBusy) 578 { 579 aAccessError = 580 Utf8StrFmt (tr ("Hard disk '%ls' is being used by another task"), 581 toString().raw()); 582 } 583 else 584 aAccessError.setNull(); 579 * @param aCheckBusy Whether to do the busy check or not. 580 */ 581 HRESULT HardDisk::getBaseAccessible (Bstr &aAccessError, 582 bool aCheckBusy /* = false */) 583 { 584 AutoLock alock (this); 585 CHECK_READY(); 586 587 aAccessError.setNull(); 588 589 if (aCheckBusy) 590 { 591 if (mBusy) 592 { 593 aAccessError = Utf8StrFmt ( 594 tr ("Hard disk '%ls' is being exclusively used by another task"), 595 toString().raw()); 596 } 597 else if (mReaders > 0) 598 { 599 aAccessError = Utf8StrFmt ( 600 tr ("Hard disk '%ls' is being used by another task (%d readers)"), 601 toString().raw(), mReaders); 602 } 603 } 585 604 586 605 return S_OK; … … 1565 1584 1566 1585 /* check the basic accessibility */ 1567 HRESULT rc = HardDisk::getAccessible (aAccessError);1586 HRESULT rc = getBaseAccessible (aAccessError, true /* aCheckBusy */); 1568 1587 if (FAILED (rc) || !aAccessError.isNull()) 1569 1588 return rc; … … 3007 3026 3008 3027 /* check the basic accessibility */ 3009 HRESULT rc = HardDisk::getAccessible (aAccessError);3028 HRESULT rc = getBaseAccessible (aAccessError); 3010 3029 if (FAILED (rc) || !aAccessError.isNull()) 3011 3030 return rc; -
trunk/src/VBox/Main/include/HardDiskImpl.h
r749 r911 129 129 ComObjPtr <HardDisk> root() const; 130 130 131 HRESULT getBaseAccessible (Bstr &aAccessError, bool aCheckBusy = false); 132 131 133 // virtual methods that need to be [re]implemented by every subclass 132 134 133 135 virtual HRESULT trySetRegistered (BOOL aRegistered); 134 virtual HRESULT getAccessible (Bstr &aAccessError) ;136 virtual HRESULT getAccessible (Bstr &aAccessError) = 0; 135 137 136 138 virtual HRESULT saveSettings (CFGNODE aHDNode, CFGNODE aStorageNode) = 0;
Note:
See TracChangeset
for help on using the changeset viewer.