std::string GetFileExt(std::string &strFile, int isLower=0)
{
if(isLower == 1)
{
std::string strTemp = strFile;
std::transform(strTemp.begin(), strTemp.end(), strTemp.begin(), ::tolower);
std::string::size_type pos = strTemp.rfind('.');
std::string strExt = strTemp.substr(pos == std::string::npos ? strTemp.length() : pos+1);
return strExt;
}
else
{
std::string::size_type pos = strFile.rfind('.');
std::string strExt = strFile.substr(pos == std::string::npos ? strFile.length() : pos+1);
return strExt;
}
}
比如:输入yolov6s.onnx则执行函数返回onnx,注意返回没有点,如果只想获取文件路径+文件名无后缀,则
std::string Yolov6Manager::GetFileNameWithPath(std::string &strFile)
{
std::string::size_type pos = strFile.rfind('.');
std::string str = strFile.substr(0,pos);
return str;
}