summaryrefslogtreecommitdiff
path: root/test.cc
diff options
context:
space:
mode:
authorNils Maier <maierman@web.de>2016-07-31 02:18:43 +0200
committerNils Maier <maierman@web.de>2016-08-29 16:52:20 +0200
commit366e2e8f795e82e2c8472bcf1cd0a892550789a9 (patch)
treee00f9d25494c412b04234cda11caf79bfc73fcbf /test.cc
parent08f4b5e4f41b343753d440f32ccc213c40f3726b (diff)
Use default where possible
Diffstat (limited to 'test.cc')
-rw-r--r--test.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/test.cc b/test.cc
new file mode 100644
index 00000000..d39babdd
--- /dev/null
+++ b/test.cc
@@ -0,0 +1,16 @@
+#include <iostream>
+#include <algorithm>
+
+int main() {
+ std::string filepath = "/ahue/hue/hue/kuk.jpg";
+ auto fn = filepath;
+ std::string ext;
+ auto idx = fn.find_last_of(".");
+ auto slash = fn.find_last_of("\\/");
+ if (idx != std::string::npos && (slash == std::string::npos || slash < idx)) {
+ ext = fn.substr(idx);
+ fn = fn.substr(0, idx);
+ }
+ std::cout << "fn:" << fn << " ext:" << ext;
+ return 0;
+}