third_party/virtualbox/src/VBox/Main/src-server/MachineImpl.cpp
/**
 * Deletes the given file if it is no longer in use by either the current machine state
 * (if the machine is "saved") or any of the machine's snapshots.
 *
 * Note: This checks mSSData->strStateFilePath, which is shared by the Machine and SessionMachine
 * but is different for each SnapshotMachine. When calling this, the order of calling this
 * function on the one hand and changing that variable OR the snapshots tree on the other hand
 * is therefore critical. I know, it's all rather messy.
 *
 * @param strStateFile
 * @param pSnapshotToIgnore  Passed to Snapshot::sharesSavedStateFile(); this snapshot is ignored in
 * the test for whether the saved state file is in use.
 */
Deletes the given file if it is no longer in use by either the current machine state
(if the machine is "saved") or any of the machine's snapshots.

This checks mSSData->strStateFilePath, which is shared by the Machine and SessionMachine
but is different for each SnapshotMachine. When calling this, the order of calling this
function on the one hand and changing that variable OR the snapshots tree on the other hand
is therefore critical. I know, it's all rather messy.

@param strStateFile
@param pSnapshotToIgnore  Passed to Snapshot::sharesSavedStateFile(); this snapshot is ignored in
the test for whether the saved state file is in use.
Deletes the given file if it is no longer in use by either the current machine state ( if the machine is " saved " ) or any of the machine ' s snapshots . This checks mSSData - > strStateFilePath which is shared by the Machine and SessionMachine but is different for each SnapshotMachine . When calling this the order of calling this function on the one hand and changing that variable OR the snapshots tree on the other hand is therefore critical . I know it ' s all rather messy . @param strStateFile @param pSnapshotToIgnore Passed to Snapshot :: sharesSavedStateFile () ; this snapshot is ignored in the test for whether the saved state file is in use .
void SessionMachine::i_releaseSavedStateFile(const Utf8Str &strStateFile,
                                             Snapshot *pSnapshotToIgnore)
{
    if (    (strStateFile.isNotEmpty())
         && (strStateFile != mSSData->strStateFilePath)     
       )
        if (    !mData->mFirstSnapshot
             || !mData->mFirstSnapshot->i_sharesSavedStateFile(strStateFile, pSnapshotToIgnore)
           )
            RTFileDelete(strStateFile.c_str());
}
void SessionMachine :: i_releaseSavedStateFile ( const Utf8Str & strStateFile , Snapshot * pSnapshotToIgnore ) { if ( ( strStateFile . isNotEmpty ( ) ) && ( strStateFile != mSSData -> strStateFilePath ) ) if ( ! mData -> mFirstSnapshot || ! mData -> mFirstSnapshot -> i_sharesSavedStateFile ( strStateFile , pSnapshotToIgnore ) ) RTFileDelete ( strStateFile . c_str ( ) ) ; }
Deletes the given file if it is no longer in use by either the current machine state
 (if the machine is "saved") or any of the machine's snapshots.
Deletes the given file if it is no longer in use by either the current machine state ( if the machine is " saved " ) or any of the machine ' s snapshots .
// it is safe to delete this saved state file if it is not currently in use by the machine ... // session machine's saved state // ... and it must also not be shared with other snapshots // this checks the SnapshotMachine's state file paths