| 195 | } |
| 196 | |
| 197 | void ApplicationDirectories::configurePaths(std::map<std::string,std::string>& mConfig) |
| 198 | { |
| 199 | bool keepDeprecatedPaths = mConfig.contains("KeepDeprecatedPaths"); |
| 200 | |
| 201 | // std paths |
| 202 | _home = Base::FileInfo::stringToPath(mConfig.at("AppHomePath")); |
| 203 | mConfig["BinPath"] = mConfig.at("AppHomePath") + "bin" + PATHSEP; |
| 204 | mConfig["DocPath"] = mConfig.at("AppHomePath") + "doc" + PATHSEP; |
| 205 | |
| 206 | // this is to support a portable version of FreeCAD |
| 207 | auto [customHome, customData, customTemp] = getCustomPaths(); |
| 208 | _usingCustomDirectories = !customHome.empty() || !customData.empty(); |
| 209 | |
| 210 | // get the system standard paths |
| 211 | auto [configHome, dataHome, cacheHome, tempPath] = getStandardPaths(); |
| 212 | |
| 213 | if (mConfig.contains("SafeMode")) { |
| 214 | if (startSafeMode(mConfig)) { |
| 215 | // If we're in safe mode, don't try to set any directories here, they've been overridden |
| 216 | // by temp directories in the SafeMode setup. |
| 217 | return; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | // User home path |
| 222 | // |
| 223 | fs::path homePath = findUserHomePath(customHome); |
| 224 | mConfig["UserHomePath"] = Base::FileInfo::pathToString(homePath); |
| 225 | _userHome = homePath; |
| 226 | |
| 227 | // the old path name to save config and data files |
| 228 | std::vector<std::string> subdirs; |
| 229 | if (keepDeprecatedPaths) { |
| 230 | configHome = homePath; |
| 231 | dataHome = homePath; |
| 232 | cacheHome = homePath; |
| 233 | getOldDataLocation(mConfig, subdirs); |
| 234 | } |
| 235 | else { |
| 236 | getSubDirectories(mConfig, subdirs); |
| 237 | } |
| 238 | |
| 239 | |
| 240 | // User data path |
| 241 | // |
| 242 | auto dataSubdirs = subdirs; |
| 243 | appendVersionIfPossible(dataHome, dataSubdirs, MissingDirectoryBehavior::doNotAppend); |
| 244 | fs::path data = findPath(dataHome, customData, dataSubdirs, true); |
| 245 | _userAppData = data; |
| 246 | mConfig["UserAppData"] = Base::FileInfo::pathToString(data) + PATHSEP; |
| 247 | |
| 248 | |
| 249 | // User config path |
| 250 | // |
| 251 | auto configSubdirs = subdirs; |
| 252 | appendVersionIfPossible(configHome, configSubdirs, MissingDirectoryBehavior::doNotAppend); |
| 253 | fs::path config = findPath(configHome, customHome, configSubdirs, true); |
| 254 | _userConfig = config; |
nothing calls this directly
no test coverage detected