diff options
Diffstat (limited to 'include/Path.hpp')
-rw-r--r-- | include/Path.hpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/include/Path.hpp b/include/Path.hpp index bdc31c1..95a5d23 100644 --- a/include/Path.hpp +++ b/include/Path.hpp @@ -26,12 +26,20 @@ namespace QuickMedia { return *this; } + const char* filename() const { + size_t index = data.rfind('/'); + if(index == std::string::npos) + return "/"; + return data.c_str() + index + 1; + } + // Returns empty string if no extension const char* ext() const { + size_t slash_index = data.rfind('/'); size_t index = data.rfind('.'); - if(index == std::string::npos) - return ""; - return data.c_str() + index; + if(index != std::string::npos && (slash_index == std::string::npos || index > slash_index)) + return data.c_str() + index; + return ""; } std::string data; |