355 const bool bPreLoaded(config.IsLoaded());
359 if (!config.Load()) {
368 if (!strDefaultPrefixPath.Exists()) {
369 otErr << __FUNCTION__ <<
": Error: OT_PREFIX_PATH is not set!";
375 if (OTPaths::Win_GetInstallFolderFromRegistry(strTemp)) {
376 strDefaultPrefixPath = strTemp;
380 if (!
ToReal(strDefaultPrefixPath, strDefaultPrefixPath)) {
383 if (!
FixPath(strDefaultPrefixPath, strDefaultPrefixPath,
true)) {
388 OTString strLocalPrefixPath =
"";
389 bool bPrefixPathOverride =
false;
393 OTString strConfigPath =
"";
396 OTString strPrefixPathOverride(
"prefix_path_override");
398 if (!config.CheckSet_str(
"paths",
"prefix_path",
399 strDefaultPrefixPath, strConfigPath,
403 if (!config.CheckSet_bool(
404 "paths", strPrefixPathOverride,
false, bPrefixPathOverride,
405 bIsNew,
"; This will force the prefix not to change")) {
412 if (!strConfigPath.Exists() || (3 > strConfigPath.GetLength())) {
413 otErr << __FUNCTION__ <<
": Error: Bad "
415 <<
" in config, will reset!";
417 strConfigPath = strDefaultPrefixPath;
418 bPrefixPathOverride =
false;
421 bool bNewOrUpdate =
false;
422 if (!config.Set_str(
"paths",
"prefix_path",
423 strDefaultPrefixPath, bNewOrUpdate)) {
426 if (!config.Set_bool(
"paths", strPrefixPathOverride,
false,
432 strLocalPrefixPath = strConfigPath;
436 if (!bPrefixPathOverride) {
437 bool bUpdate =
false;
440 if (!strLocalPrefixPath.Compare(strDefaultPrefixPath)) {
441 strLocalPrefixPath = strDefaultPrefixPath;
446 if (strPrefixFolder.Exists() &&
447 (3 < strPrefixFolder.GetLength())) {
450 OTString strTmp = strPrefixFolder;
452 if (!
ToReal(strTmp, strTmp)) {
456 if (!
FixPath(strTmp, strTmp,
true)) {
460 if (!strLocalPrefixPath.Compare(strTmp)) {
461 strLocalPrefixPath = strTmp;
468 bool bNewOrUpdate =
false;
469 if (!config.Set_str(
"paths",
"prefix_path",
470 strLocalPrefixPath, bNewOrUpdate)) {
478 if (!strLocalPrefixPath.Exists()) {
482 if (!
ToReal(strLocalPrefixPath, strLocalPrefixPath)) {
485 if (!
FixPath(strLocalPrefixPath, strLocalPrefixPath,
true)) {
488 s_strPrefixFolder = strLocalPrefixPath;
493 if (!config.Save()) {
static EXPORT bool ToReal(const OTString &strExactPath, OTString &out_strCanonicalPath)
static EXPORT bool FixPath(const OTString &strPath, OTString &out_strFixedPath, const bool &bIsFolder)
OTLOG_IMPORT OTLogStream otErr