Revision d5b7a27f custompackages/graph-parser/src/utility.cpp

View differences:

custompackages/graph-parser/src/utility.cpp
182 182

  
183 183
// GENERAL HELPERS
184 184
namespace helper {
185
    string get_file_name(const string& s) {
186
       char sep = '/';
187

  
188
    #ifdef _WIN32
189
       sep = '\\';
190
    #endif
191

  
192
       size_t i = s.rfind(sep, s.length());
193
       if (i != string::npos) {
194
          return(s.substr(i+1, s.length() - i));
195
       }
196

  
197
       return("");
185
    void get_file_name_and_extension(string path, string& name, string& ext) {
186
        size_t sep = path.find_last_of("\\/");
187
        if (sep != std::string::npos)
188
            path = path.substr(sep + 1, path.size() - sep - 1);
189

  
190
        size_t dot = path.find_last_of(".");
191
        if (dot != std::string::npos)
192
        {
193
            name = path.substr(0, dot);
194
            ext  = path.substr(dot, path.size() - dot);
195
        }
196
        else
197
        {
198
            name = path;
199
            ext  = "";
200
        }
198 201
    }
199 202
}

Also available in: Unified diff