From d9cb6885ab741ba69a966109cb05e26692143ce0 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 2 Oct 2020 16:27:59 +0200 Subject: Matrix: add video/regular file upload --- include/Path.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'include/Path.hpp') 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; -- cgit v1.2.3