Changeset 33458 in vbox for trunk/src/VBox/Main/MachineImpl.cpp
- Timestamp:
- Oct 26, 2010 11:18:04 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r33451 r33458 253 253 * @param strName name for the machine 254 254 * @param aId UUID for the new machine. 255 * @param aOsType Optional OS Type of this machine. 255 * @param aOsType OS Type of this machine or NULL. 256 * @param fForceOverwrite Whether to overwrite an existing machine settings file. 256 257 * 257 258 * @return Success indicator. if not S_OK, the machine object is invalid … … 260 261 const Utf8Str &strConfigFile, 261 262 const Utf8Str &strName, 263 GuestOSType *aOsType, 262 264 const Guid &aId, 263 GuestOSType *aOsType /* = NULL */)265 bool fForceOverwrite) 264 266 { 265 267 LogFlowThisFuncEnter(); … … 273 275 if (FAILED(rc)) return rc; 274 276 275 rc = tryCreateMachineConfigFile( );277 rc = tryCreateMachineConfigFile(fForceOverwrite); 276 278 if (FAILED(rc)) return rc; 277 279 … … 473 475 if (FAILED(rc)) return rc; 474 476 475 rc = tryCreateMachineConfigFile( );477 rc = tryCreateMachineConfigFile(false /* fForceOverwrite */); 476 478 if (FAILED(rc)) return rc; 477 479 … … 569 571 * @return 570 572 */ 571 HRESULT Machine::tryCreateMachineConfigFile( )573 HRESULT Machine::tryCreateMachineConfigFile(bool fForceOverwrite) 572 574 { 573 575 HRESULT rc = S_OK; … … 582 584 if (RT_SUCCESS(vrc)) 583 585 RTFileClose(f); 584 rc = setError(VBOX_E_FILE_ERROR, 585 tr("Machine settings file '%s' already exists"), 586 mData->m_strConfigFileFull.c_str()); 586 if (!fForceOverwrite) 587 rc = setError(VBOX_E_FILE_ERROR, 588 tr("Machine settings file '%s' already exists"), 589 mData->m_strConfigFileFull.c_str()); 590 else 591 { 592 /* try to delete the config file, as otherwise the creation 593 * of a new settings file will fail. */ 594 int vrc2 = RTFileDelete(mData->m_strConfigFileFull.c_str()); 595 if (RT_FAILURE(vrc2)) 596 rc = setError(VBOX_E_FILE_ERROR, 597 tr("Could not delete the existing settings file '%s' (%Rrc)"), 598 mData->m_strConfigFileFull.c_str(), vrc2); 599 } 587 600 } 588 601 else if ( vrc != VERR_FILE_NOT_FOUND
Note:
See TracChangeset
for help on using the changeset viewer.