zoukankan      html  css  js  c++  java
  • NX二次开发-拆分路径为文件夹和文件名

    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 }
  • 相关阅读:
    第二十天笔记
    第十九天笔记
    第十七天笔记
    第十五天笔记
    第十六天笔记
    第十二天笔记
    数字三角形
    最大子段和与最大子矩阵和
    分组背包
    二维背包
  • 原文地址:https://www.cnblogs.com/xiang-L/p/14133037.html
Copyright © 2011-2022 走看看