/[svn]/linuxsampler/trunk/src/common/File.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/common/File.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1726 by persson, Sat Apr 26 09:27:24 2008 UTC revision 1781 by iliev, Mon Sep 29 18:21:21 2008 UTC
# Line 169  namespace LinuxSampler { Line 169  namespace LinuxSampler {
169          return 0;          return 0;
170      };      };
171  #endif  #endif
172            std::string File::basename(std::string path) {
173                    size_t begin = 0;
174                    size_t end = path.length();
175                    
176                    for(size_t i=0; i<path.length(); ++i){
177                            if(path[i] == File::DirSeparator) begin = i+1;
178                    }
179                    return path.substr(begin, end).c_str();
180            }
181            
182            std::string File::basename(std::string path, std::string sep) {
183                    std::string tmp = File::basename(path);
184                    if(sep.empty())
185                            sep = ".";
186                    size_t begin = 0;
187                    size_t end = tmp.length();
188                    size_t lastdot = tmp.find_last_of(sep)-1;
189                    if(lastdot > 0)
190                            end = lastdot;
191                    return tmp.substr(begin, end).c_str();
192            }
193  }  }

Legend:
Removed from v.1726  
changed lines
  Added in v.1781

  ViewVC Help
Powered by ViewVC