[心得] 得到文件目录

std::string getFileDir(const char* pFilePath)
{
assert(pFilePath);
std::string strDir = pFilePath
std::string::size_type begin = 0;
std::string::size_type end = 0;
end = strDir.find_last_of("/");
if(end != std::string::npos)
{
        // end+1 : 包括最后一个“/”
strDir = strDir.substr(begin,end+1);
}
else
{
strDir = "";
}

return strDir;
}

posted on 2012-03-31 15:56  甲骨魚  阅读(173)  评论(0编辑  收藏  举报

导航