Changeset 44545 in vbox
- Timestamp:
- Feb 5, 2013 2:19:49 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/com.cpp
r44528 r44545 55 55 #include <VBox/version.h> 56 56 57 const char *apcszUserHome[] = 57 58 #ifdef RT_OS_DARWIN 58 # define VBOX_USER_HOME_SUFFIX "Library/VirtualBox" 59 { "Library/VirtualBox" }; 60 #elif defined RT_OS_WINDOWS 61 { ".VirtualBox" }; 59 62 #else 60 # define VBOX_USER_HOME_SUFFIX ".VirtualBox" 63 { ".config/VirtualBox", ".VirtualBox" }; 61 64 #endif 62 65 … … 182 185 #endif // VBOX_WITH_XPCOM 183 186 187 static int composeHomePath(char *aDir, size_t aDirLen, 188 const char *pcszBase) 189 { 190 int vrc; 191 if (RTPathStartsWithRoot(pcszBase)) 192 vrc = RTStrCopy(aDir, aDirLen, pcszBase); 193 else 194 { 195 /* compose the config directory (full path) */ 196 /** @todo r=bird: RTPathUserHome doesn't necessarily return a 197 * full (abs) path like the comment above seems to indicate. */ 198 vrc = RTPathUserHome(aDir, aDirLen); 199 if (RT_SUCCESS(vrc)) 200 vrc = RTPathAppend(aDir, aDirLen, pcszBase); 201 } 202 return vrc; 203 } 204 184 205 int GetVBoxUserHomeDirectory(char *aDir, size_t aDirLen, bool fCreateDir) 185 206 { … … 194 215 if (RT_SUCCESS(vrc) || vrc == VERR_ENV_VAR_NOT_FOUND) 195 216 { 217 bool fFound = false; 196 218 if (RT_SUCCESS(vrc)) 197 219 { … … 201 223 else 202 224 { 203 /* compose the config directory (full path) */ 204 /** @todo r=bird: RTPathUserHome doesn't necessarily return a full (abs) path 205 * like the comment above seems to indicate. */ 206 vrc = RTPathUserHome(aDir, aDirLen); 207 if (RT_SUCCESS(vrc)) 208 vrc = RTPathAppend(aDir, aDirLen, VBOX_USER_HOME_SUFFIX); 225 #if !defined(RT_OS_WINDOWS) && !defined(RT_OS_DARWIN) 226 const char *pcszConfigHome = RTEnvGet("XDG_CONFIG_HOME"); 227 if (pcszConfigHome && pcszConfigHome[0]) 228 apcszUserHome[0] = pcszConfigHome; 229 #endif 230 for (unsigned i = 0; i < RT_ELEMENTS(apcszUserHome); ++i) 231 { 232 vrc = composeHomePath(aDir, aDirLen, apcszUserHome[i]); 233 if (RTDirExists(aDir)) 234 { 235 fFound = true; 236 break; 237 } 238 } 239 if (!fFound) 240 vrc = composeHomePath(aDir, aDirLen, apcszUserHome[0]); 209 241 } 210 242 211 243 /* ensure the home directory exists */ 212 244 if (RT_SUCCESS(vrc)) 213 if (! RTDirExists(aDir)&& fCreateDir)245 if (!fFound && fCreateDir) 214 246 vrc = RTDirCreateFullPath(aDir, 0700); 215 247 }
Note:
See TracChangeset
for help on using the changeset viewer.