// static bool OTPaths::AppendFile(String& out_strPath, const String& strBasePath, const String& strFileName) { if (!strBasePath.Exists()) { otErr << __FUNCTION__ << ": Null: " << "strBasePath" << " passed in!\n"; OT_FAIL; } if (!strFileName.Exists()) { otErr << __FUNCTION__ << ": Null: " << "strFileName" << " passed in!\n"; OT_FAIL; } String l_strBasePath_fix(""), l_strFileName_fix(""); if (!FixPath(strBasePath, l_strBasePath_fix, true)) return false; if (!FixPath(strFileName, l_strFileName_fix, false)) return false; std::string l_strBasePath(l_strBasePath_fix.Get()), l_strFileName(l_strFileName_fix.Get()); l_strBasePath.append(l_strFileName); const String l_strPath(l_strBasePath); out_strPath = l_strPath; return true; }
const bool OTPaths::AppendFile(OTString & out_strPath, const OTString & strBasePath, const OTString & strFileName) { if (!strBasePath.Exists()) { OTLog::sError("%s: Null: %s passed in!\n", __FUNCTION__, "strBasePath"); OT_ASSERT(false); } if (!strFileName.Exists()) { OTLog::sError("%s: Null: %s passed in!\n", __FUNCTION__, "strFileName"); OT_ASSERT(false); } OTString l_strBasePath_fix(""), l_strFileName_fix(""); if(!FixPath(strBasePath,l_strBasePath_fix,true)) return false; if(!FixPath(strFileName,l_strFileName_fix,false)) return false; std::string l_strBasePath(l_strBasePath_fix.Get()), l_strFileName(l_strFileName_fix.Get()); l_strBasePath.append(l_strFileName); const OTString l_strPath(l_strBasePath); out_strPath = l_strPath; return true; }
// this function dosn't change the "strRelativePath" so. It will only fix the strBasePath. const bool OTPaths::RelativeToCanonical(OTString & out_strCanonicalPath, const OTString & strBasePath, const OTString & strRelativePath) { if (!strBasePath.Exists()) { OTLog::sError("%s: Null: %s passed in!\n", __FUNCTION__, "strBasePath" ); OT_ASSERT(false); } if (!strRelativePath.Exists()) { OTLog::sError("%s: Null: %s passed in!\n", __FUNCTION__, "strRelativePath" ); OT_ASSERT(false); } OTString l_strBasePath_fix(""); if(!FixPath(strBasePath,l_strBasePath_fix,true)) return false; if(strRelativePath.Compare(".")) { out_strCanonicalPath = strBasePath; return true; } // if ".", return base path. std::string l_strBasePath(l_strBasePath_fix.Get()), l_strRelativePath(strRelativePath.Get()); l_strBasePath.append(l_strRelativePath); OTString l_strPath(l_strBasePath), l_strCanonicalPath(""); if(!ToReal(l_strPath,l_strCanonicalPath)) return false; out_strCanonicalPath = l_strCanonicalPath; return true; }
// this function dosn't change the "strRelativePath" so. It will only fix the // strBasePath. // static bool OTPaths::RelativeToCanonical(String& out_strCanonicalPath, const String& strBasePath, const String& strRelativePath) { if (!strBasePath.Exists()) { otErr << __FUNCTION__ << ": Null: " << "strBasePath" << " passed in!\n"; OT_FAIL; } if (!strRelativePath.Exists()) { otErr << __FUNCTION__ << ": Null: " << "strRelativePath" << " passed in!\n"; OT_FAIL; } String l_strBasePath_fix(""); if (!FixPath(strBasePath, l_strBasePath_fix, true)) return false; if (strRelativePath.Compare(".")) { out_strCanonicalPath = strBasePath; return true; } // if ".", return base path. std::string l_strBasePath(l_strBasePath_fix.Get()), l_strRelativePath(strRelativePath.Get()); l_strBasePath.append(l_strRelativePath); String l_strPath(l_strBasePath), l_strCanonicalPath(""); if (!ToReal(l_strPath, l_strCanonicalPath)) return false; out_strCanonicalPath = l_strCanonicalPath; return true; }