Last change
on this file since 143 was
143,
checked in by rosiere, 14 years ago
|
1) change environment.sh
2) add lot of include
|
-
Property svn:keywords set to
Id
|
File size:
515 bytes
|
Rev | Line | |
---|
[131] | 1 | /* |
---|
| 2 | * $Id: Basename.cpp 143 2010-09-02 14:33:08Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "../include/Basename.h" |
---|
[143] | 9 | #include <libgen.h> |
---|
[131] | 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | |
---|
| 13 | std::string basename (std::string str, bool keep_extension) |
---|
| 14 | { |
---|
| 15 | std::string res = ::basename(str.c_str()); |
---|
| 16 | |
---|
| 17 | if (not keep_extension) |
---|
| 18 | { |
---|
| 19 | std::string::size_type index = res.rfind('.'); |
---|
| 20 | |
---|
| 21 | if(index != std::string::npos) |
---|
| 22 | { |
---|
| 23 | res = res.substr(0,index); |
---|
| 24 | } |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | return res; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | }; // end namespace morpheo |
---|
Note: See
TracBrowser
for help on using the repository browser.