首页 > 其他 > 详细

NX二次开发-拆分路径为文件夹和文件名

时间:2020-12-14 18:41:39      阅读:40      评论:0      收藏:0      [点我收藏+]

NX二次开发-拆分路径为文件夹和文件名

 1 void SplitFileName(std::string fullName, std::string &dirName, std::string &fileName)
 2     {
 3         TrimString(fullName);
 4         dirName.clear();
 5         fileName.clear();
 6 
 7         if (fullName.empty())
 8             return;
 9 
10         std::size_t pos = fullName.rfind("\\");
11         if (pos != std::string::npos)
12         {
13             dirName = fullName.substr(0, pos);
14             fileName = fullName.substr(pos + 1);
15         }
16 
17         return;
18     }
 1 void TrimString(std::string &str)
 2 {
 3     string::size_type pos = str.find_last_not_of( );
 4     if (pos != string::npos)
 5     {
 6         str.erase(pos + 1);
 7         pos = str.find_first_not_of( );
 8         if (pos != string::npos) str.erase(0, pos);
 9     }
10     else
11     {
12         //a blank string
13         str.erase(str.begin(), str.end());
14     }
15 }

 

NX二次开发-拆分路径为文件夹和文件名

原文:https://www.cnblogs.com/xiang-L/p/14133037.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!