summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-04-30 15:04:40 +0200
committerlouiz’ <louiz@louiz.org>2017-04-30 15:14:54 +0200
commit7b3e0e0cf3eddd3537455a3605b04a48ee663f47 (patch)
tree06658235b0082b1f173c6114d4aeac2388540297 /src/utils
parent1472adfa77f9c3a03967e723d8460f33544b545d (diff)
downloadbiboumi-7b3e0e0cf3eddd3537455a3605b04a48ee663f47.tar.gz
biboumi-7b3e0e0cf3eddd3537455a3605b04a48ee663f47.tar.bz2
biboumi-7b3e0e0cf3eddd3537455a3605b04a48ee663f47.tar.xz
biboumi-7b3e0e0cf3eddd3537455a3605b04a48ee663f47.zip
Make botan’s policy configurable from a file
fix #3244
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/dirname.cpp16
-rw-r--r--src/utils/dirname.hpp6
-rw-r--r--src/utils/xdg.hpp2
3 files changed, 22 insertions, 2 deletions
diff --git a/src/utils/dirname.cpp b/src/utils/dirname.cpp
new file mode 100644
index 0000000..71c9c38
--- /dev/null
+++ b/src/utils/dirname.cpp
@@ -0,0 +1,16 @@
+#include <utils/dirname.hpp>
+
+namespace utils
+{
+ std::string dirname(const std::string filename)
+ {
+ if (filename.empty())
+ return "./";
+ if (filename == ".." || filename == ".")
+ return filename;
+ auto pos = filename.rfind('/');
+ if (pos == std::string::npos)
+ return "./";
+ return filename.substr(0, pos + 1);
+ }
+}
diff --git a/src/utils/dirname.hpp b/src/utils/dirname.hpp
new file mode 100644
index 0000000..c1df81b
--- /dev/null
+++ b/src/utils/dirname.hpp
@@ -0,0 +1,6 @@
+#include <string>
+
+namespace utils
+{
+std::string dirname(const std::string filename);
+}
diff --git a/src/utils/xdg.hpp b/src/utils/xdg.hpp
index 56e11da..7be6922 100644
--- a/src/utils/xdg.hpp
+++ b/src/utils/xdg.hpp
@@ -10,5 +10,3 @@
*/
std::string xdg_config_path(const std::string& filename);
std::string xdg_data_path(const std::string& filename);
-
-