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 |
} |
} |