Changeset 38818 in vbox for trunk/src/VBox/Main
- Timestamp:
- Sep 21, 2011 5:10:25 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 74113
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r38786 r38818 9783 9783 </desc> 9784 9784 </const> 9785 <const name="NoCreateDir" value="0x40000000"> 9786 <desc> 9787 Special flag which suppresses automatic creation of the subdirectory. 9788 Only used when passing the medium variant as an input parameter. 9789 </desc> 9790 </const> 9785 9791 </enum> 9786 9792 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r37985 r38818 282 282 HRESULT saveRegistries(const GuidList &llRegistriesThatNeedSaving); 283 283 284 static HRESULT ensureFilePathExists(const Utf8Str &strFileName );284 static HRESULT ensureFilePathExists(const Utf8Str &strFileName, bool fCreate); 285 285 286 286 static HRESULT handleUnexpectedExceptions (RT_SRC_POS_DECL); -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r38775 r38818 6448 6448 if (capabilities & MediumFormatCapabilities_File) 6449 6449 { 6450 rc = VirtualBox::ensureFilePathExists(location );6450 rc = VirtualBox::ensureFilePathExists(location, !(task.mVariant & MediumVariant_NoCreateDir) /* fCreate */); 6451 6451 if (FAILED(rc)) 6452 6452 throw rc; … … 6459 6459 location.c_str(), 6460 6460 task.mSize, 6461 task.mVariant ,6461 task.mVariant & ~MediumVariant_NoCreateDir, 6462 6462 NULL, 6463 6463 &geo, … … 6615 6615 if (capabilities & MediumFormatCapabilities_File) 6616 6616 { 6617 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation );6617 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation, !(task.mVariant & MediumVariant_NoCreateDir) /* fCreate */); 6618 6618 if (FAILED(rc)) 6619 6619 throw rc; … … 6623 6623 targetFormat.c_str(), 6624 6624 targetLocation.c_str(), 6625 task.mVariant| VD_IMAGE_FLAGS_DIFF,6625 (task.mVariant & ~MediumVariant_NoCreateDir) | VD_IMAGE_FLAGS_DIFF, 6626 6626 NULL, 6627 6627 targetId.raw(), … … 7118 7118 if (capabilities & MediumFormatCapabilities_File) 7119 7119 { 7120 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation );7120 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation, !(task.mVariant & MediumVariant_NoCreateDir) /* fCreate */); 7121 7121 if (FAILED(rc)) 7122 7122 throw rc; … … 7181 7181 false /* fMoveByRename */, 7182 7182 0 /* cbSize */, 7183 task.mVariant ,7183 task.mVariant & ~MediumVariant_NoCreateDir, 7184 7184 targetId.raw(), 7185 7185 VD_OPEN_FLAGS_NORMAL, … … 7199 7199 task.midxSrcImageSame, 7200 7200 task.midxDstImageSame, 7201 task.mVariant ,7201 task.mVariant & ~MediumVariant_NoCreateDir, 7202 7202 targetId.raw(), 7203 7203 VD_OPEN_FLAGS_NORMAL, … … 7789 7789 if (capabilities & MediumFormatCapabilities_File) 7790 7790 { 7791 rc = VirtualBox::ensureFilePathExists(targetLocation );7791 rc = VirtualBox::ensureFilePathExists(targetLocation, !(task.mVariant & MediumVariant_NoCreateDir) /* fCreate */); 7792 7792 if (FAILED(rc)) 7793 7793 throw rc; … … 7807 7807 false /* fMoveByRename */, 7808 7808 0 /* cbSize */, 7809 task.mVariant ,7809 task.mVariant & ~MediumVariant_NoCreateDir, 7810 7810 NULL /* pDstUuid */, 7811 7811 VD_OPEN_FLAGS_NORMAL | VD_OPEN_FLAGS_SEQUENTIAL, … … 7914 7914 if (capabilities & MediumFormatCapabilities_File) 7915 7915 { 7916 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation );7916 HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation, !(task.mVariant & MediumVariant_NoCreateDir) /* fCreate */); 7917 7917 if (FAILED(rc)) 7918 7918 throw rc; … … 7975 7975 false /* fMoveByRename */, 7976 7976 0 /* cbSize */, 7977 task.mVariant ,7977 task.mVariant & ~MediumVariant_NoCreateDir, 7978 7978 targetId.raw(), 7979 7979 VD_OPEN_FLAGS_NORMAL, -
trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
r38718 r38818 7 7 8 8 /* 9 * Copyright (C) 2006-201 0Oracle Corporation9 * Copyright (C) 2006-2011 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 1431 1431 { 1432 1432 // ensure the directory for the saved state file exists 1433 HRESULT rc = VirtualBox::ensureFilePathExists(strStateFilePath );1433 HRESULT rc = VirtualBox::ensureFilePathExists(strStateFilePath, true /* fCreate */); 1434 1434 if (FAILED(rc)) return rc; 1435 1435 } -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r38754 r38818 3932 3932 3933 3933 /** 3934 * C reates the path to the specified file according to the path information3935 * 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. 3936 3936 * 3937 3937 * Note that the given file name must contain the full path otherwise the … … 3939 3939 * directory which is normally unknown. 3940 3940 * 3941 * @param aFileName Full file name which path needs to be created. 3942 * 3943 * @return Extended error information on failure to create the path. 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 * 3944 * @return Extended error information on failure to check/create the path. 3944 3945 */ 3945 3946 /* static */ 3946 HRESULT VirtualBox::ensureFilePathExists(const Utf8Str &strFileName )3947 HRESULT VirtualBox::ensureFilePathExists(const Utf8Str &strFileName, bool fCreate) 3947 3948 { 3948 3949 Utf8Str strDir(strFileName); … … 3950 3951 if (!RTDirExists(strDir.c_str())) 3951 3952 { 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)"), 3956 strDir.c_str(), 3957 vrc)); 3953 if (fCreate) 3954 { 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)"), 3959 strDir.c_str(), 3960 vrc)); 3961 } 3962 else 3963 return setErrorStatic(VBOX_E_IPRT_ERROR, 3964 Utf8StrFmt(tr("Directory '%s' does not exist"), 3965 strDir.c_str())); 3958 3966 } 3959 3967
Note:
See TracChangeset
for help on using the changeset viewer.