diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-10-02 16:27:59 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-10-02 16:27:59 +0200 |
commit | d9cb6885ab741ba69a966109cb05e26692143ce0 (patch) | |
tree | e4e356c182011bc389bc895665dab1507ecdb767 /include/Path.hpp | |
parent | 9e68dfad4449d5c0180e252fada6de56b4f405d1 (diff) |
Matrix: add video/regular file upload
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; |