路径转换

int kbd_public::CCommonConfigParse::makeConfigFileFullPath(const std::string &strFilePath,
const std::string &strFileName,
std::string &strFullPath)
{
namespace fs = boost::filesystem;
fs::path objPath = strFilePath;
objPath /= strFileName;
if (objPath.is_absolute())
{
strFullPath = objPath.string();
return kbdSuccess;
}

/* @brief 如果传入的是相对路径,转换为绝对路径 */
string strCurDir = CFileUtil::getCurModuleDir();
if (strCurDir.empty())
{
LOGERROR("获取程序所在路径失败");
return kbdFailed;
}
fs::path objFullPath = strCurDir;
objFullPath /= objPath;
strFullPath = objFullPath.string();

return kbdSuccess;
}

posted on 2019-01-25 10:46  码农er  阅读(227)  评论(0)    收藏  举报