3934
* Creates the path to the specified file according to the path information
3935
* present in the file name.
3934
* Checks if the path to the specified file exists, according to the path
3935
* information present in the file name. Optionally the path is created.
3937
3937
* Note that the given file name must contain the full path otherwise the
3938
3938
* extracted relative path will be created based on the current working
3939
3939
* directory which is normally unknown.
3941
* @param aFileName Full file name which path needs to be created.
3941
* @param aFileName Full file name which path is checked/created.
3942
* @param aCreate Flag if the path should be created if it doesn't exist.
3943
* @return Extended error information on failure to create the path.
3944
* @return Extended error information on failure to check/create the path.
3946
HRESULT VirtualBox::ensureFilePathExists(const Utf8Str &strFileName)
3947
HRESULT VirtualBox::ensureFilePathExists(const Utf8Str &strFileName, bool fCreate)
3948
3949
Utf8Str strDir(strFileName);
3949
3950
strDir.stripFilename();
3950
3951
if (!RTDirExists(strDir.c_str()))
3952
int vrc = RTDirCreateFullPath(strDir.c_str(), 0777);
3953
if (RT_FAILURE(vrc))
3954
return setErrorStatic(E_FAIL,
3955
Utf8StrFmt(tr("Could not create the directory '%s' (%Rrc)"),
3955
int vrc = RTDirCreateFullPath(strDir.c_str(), 0777);
3956
if (RT_FAILURE(vrc))
3957
return setErrorStatic(VBOX_E_IPRT_ERROR,
3958
Utf8StrFmt(tr("Could not create the directory '%s' (%Rrc)"),
3963
return setErrorStatic(VBOX_E_IPRT_ERROR,
3964
Utf8StrFmt(tr("Directory '%s' does not exist"),
4538
4546
// signal that we're ready
4539
4547
RTThreadUserSignal(thread);
4541
while (RT_SUCCESS(eventQ->processEventQueue(RT_INDEFINITE_WAIT)))
4550
* In case of spurious wakeups causing VERR_TIMEOUTs and/or other return codes
4551
* we must not stop processing events and delete the "eventQ" object. This must
4552
* be done ONLY when we stop this loop via interruptEventQueueProcessing().
4555
while (eventQ->processEventQueue(RT_INDEFINITE_WAIT) != VERR_INTERRUPTED)
4542
4556
/* nothing */ ;