Changeset 33238 in vbox for trunk/src/VBox/Main/VirtualBoxImpl.cpp
- Timestamp:
- Oct 19, 2010 3:41:23 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r33232 r33238 1149 1149 ///////////////////////////////////////////////////////////////////////////// 1150 1150 1151 STDMETHODIMP VirtualBox::ComposeMachineFilename(IN_BSTR aName, 1152 IN_BSTR aBaseFolder, 1153 BSTR *aFilename) 1154 { 1155 LogFlowThisFuncEnter(); 1156 LogFlowThisFunc(("aName=\"%ls\",aBaseFolder=\"%ls\"\n", aName, aBaseFolder)); 1157 1158 CheckComArgStrNotEmptyOrNull(aName); 1159 CheckComArgOutPointerValid(aFilename); 1160 1161 AutoCaller autoCaller(this); 1162 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1163 1164 /* Compose the settings file name using the following scheme: 1165 * 1166 * <base_folder>/<machine_name>/<machine_name>.xml 1167 * 1168 * If a non-null and non-empty base folder is specified, the default 1169 * machine folder will be used as a base folder. 1170 */ 1171 Utf8Str strBase = aBaseFolder; 1172 if (strBase.isEmpty()) 1173 /* we use the non-full folder value below to keep the path relative */ 1174 getDefaultMachineFolder(strBase); 1175 1176 Bstr bstrSettingsFile = BstrFmt("%s%c%ls%c%ls.vbox", 1177 strBase.c_str(), 1178 RTPATH_DELIMITER, 1179 aName, 1180 RTPATH_DELIMITER, 1181 aName); 1182 1183 bstrSettingsFile.detachTo(aFilename); 1184 1185 return S_OK; 1186 } 1187 1151 1188 /** @note Locks mSystemProperties object for reading. */ 1152 1189 STDMETHODIMP VirtualBox::CreateMachine(IN_BSTR aName, … … 1167 1204 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1168 1205 1169 /* Compose the settings file name using the following scheme: 1170 * 1171 * <base_folder>/<machine_name>/<machine_name>.xml 1172 * 1173 * If a non-null and non-empty base folder is specified, the default 1174 * machine folder will be used as a base folder. 1175 */ 1176 Utf8Str strSettingsFile = aBaseFolder; 1177 if (strSettingsFile.isEmpty()) 1178 /* we use the non-full folder value below to keep the path relative */ 1179 getDefaultMachineFolder(strSettingsFile); 1180 1181 strSettingsFile = Utf8StrFmt("%s%c%ls%c%ls.vbox", 1182 strSettingsFile.c_str(), 1183 RTPATH_DELIMITER, 1184 aName, 1185 RTPATH_DELIMITER, 1186 aName); 1187 1188 HRESULT rc = E_FAIL; 1206 Bstr bstrSettingsFilename; 1207 HRESULT rc = ComposeMachineFilename(aName, aBaseFolder, bstrSettingsFilename.asOutParam()); 1208 if (FAILED(rc)) return rc; 1189 1209 1190 1210 /* create a new object */ … … 1204 1224 /* initialize the machine object */ 1205 1225 rc = machine->init(this, 1206 strSettingsFile,1226 Utf8Str(bstrSettingsFilename), 1207 1227 Utf8Str(aName), 1208 1228 id, … … 2846 2866 AutoReadLock propsLock(m->pSystemProperties COMMA_LOCKVAL_SRC_POS); 2847 2867 str = m->pSystemProperties->m->strDefaultMachineFolder; 2848 }2849 2850 /**2851 * Returns the default hard disk folder from the system properties2852 * with proper locking.2853 * @return2854 */2855 void VirtualBox::getDefaultHardDiskFolder(Utf8Str &str) const2856 {2857 AutoReadLock propsLock(m->pSystemProperties COMMA_LOCKVAL_SRC_POS);2858 str = m->pSystemProperties->m->strDefaultHardDiskFolder;2859 2868 } 2860 2869
Note:
See TracChangeset
for help on using the changeset viewer.