// 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; }