From 9c6f78b046962c13584f1c35ba253749f1cb9585 Mon Sep 17 00:00:00 2001 From: "mykola.salomatin" Date: Tue, 19 Jan 2021 17:01:46 +0200 Subject: =?UTF-8?q?[MTX-3785]=20mPower=20R.5.4:=20GP-971=20-=20Device=20sh?= =?UTF-8?q?all=20implement=20file=20type=20restrictions=20for=20all=20?= =?UTF-8?q?=E2=80=9Cupload=E2=80=9D=20sections=20on=20the=20UI=20LoRaWAN?= =?UTF-8?q?=20components:=20LoraLicense=20(.lic),=20LoraFotaFile=20(.bin),?= =?UTF-8?q?=20LoraMulticast=20(.bin=20for=20Binary,=20.txt=20for=20Hexadec?= =?UTF-8?q?imal=20and=20Base64),=20LoraGroup=20(.json)=20validated=20by=20?= =?UTF-8?q?file=20extension.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/mts/MTS_Text.h | 2 ++ src/MTS_Text.cpp | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/mts/MTS_Text.h b/include/mts/MTS_Text.h index 2380add..4ded3fc 100644 --- a/include/mts/MTS_Text.h +++ b/include/mts/MTS_Text.h @@ -137,6 +137,8 @@ namespace MTS { } return true; } + + static std::string getFileExtension(const std::string& filename); }; } diff --git a/src/MTS_Text.cpp b/src/MTS_Text.cpp index d823bfe..8dcb85f 100644 --- a/src/MTS_Text.cpp +++ b/src/MTS_Text.cpp @@ -699,3 +699,10 @@ bool Text::parseHex(uint64_t& value, const std::string& str) { return ((uint8_t) ss.rdstate() == RDSTATE_SUCCESS_MASK); } +std::string Text::getFileExtension(const std::string& filename) { + size_t pos = filename.rfind('.', filename.length()); + if (pos != std::string::npos) { + return (filename.substr(pos + 1, filename.length() - pos)); + } + return (""); +} -- cgit v1.2.3 From da261ffdee9e0a49d1e3ec9e06fa3b6828596dd5 Mon Sep 17 00:00:00 2001 From: "mykola.salomatin" Date: Thu, 4 Feb 2021 18:42:16 +0200 Subject: =?UTF-8?q?[MTX-3785]=20mPower=20R.5.4:=20GP-971=20-=20Device=20sh?= =?UTF-8?q?all=20implement=20file=20type=20restrictions=20for=20all=20?= =?UTF-8?q?=E2=80=9Cupload=E2=80=9D=20sections=20on=20the=20UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MTS_Text.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MTS_Text.cpp b/src/MTS_Text.cpp index 8dcb85f..8672acb 100644 --- a/src/MTS_Text.cpp +++ b/src/MTS_Text.cpp @@ -702,7 +702,7 @@ bool Text::parseHex(uint64_t& value, const std::string& str) { std::string Text::getFileExtension(const std::string& filename) { size_t pos = filename.rfind('.', filename.length()); if (pos != std::string::npos) { - return (filename.substr(pos + 1, filename.length() - pos)); + return (filename.substr(pos + 1)); } return (""); } -- cgit v1.2.3