summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-01-30 20:36:42 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-02-04 19:29:49 +0000
commitbde4a9f40bb4af39270a124d5ef9571a83305d0a (patch)
tree536719df20d8f18d4c40e893c2f93b4fa45fb2d5 /lib
parentAdd some tests over collection (diff)
downloadilt-bde4a9f40bb4af39270a124d5ef9571a83305d0a.tar.bz2
ilt-bde4a9f40bb4af39270a124d5ef9571a83305d0a.tar.xz
ilt-bde4a9f40bb4af39270a124d5ef9571a83305d0a.zip
Restructure to allow a resource path and testing
Diffstat (limited to 'lib')
-rw-r--r--lib/resource.cpp16
-rw-r--r--lib/resource.h23
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/resource.cpp b/lib/resource.cpp
new file mode 100644
index 0000000..b9aa4fa
--- /dev/null
+++ b/lib/resource.cpp
@@ -0,0 +1,16 @@
+#include "resource.h"
+#include <utility>
+
+std::filesystem::path base {std::filesystem::current_path() / "res"};
+
+void
+Resource::setBasePath(std::filesystem::path newbase)
+{
+ base = std::move(newbase);
+}
+
+std::filesystem::path
+Resource::mapPath(const std::filesystem::path & rel)
+{
+ return std::filesystem::canonical(base / rel);
+}
diff --git a/lib/resource.h b/lib/resource.h
new file mode 100644
index 0000000..958c49d
--- /dev/null
+++ b/lib/resource.h
@@ -0,0 +1,23 @@
+#ifndef RESOURCE_H
+#define RESOURCE_H
+
+#include <filesystem>
+
+class Resource {
+public:
+ static void setBasePath(std::filesystem::path);
+ static std::filesystem::path mapPath(const std::filesystem::path &);
+};
+
+#if defined(RESDIR) && defined(BOOST_TEST_MODULE)
+class SetResourcePath {
+public:
+ SetResourcePath()
+ {
+ Resource::setBasePath(RESDIR);
+ }
+};
+BOOST_GLOBAL_FIXTURE(SetResourcePath);
+#endif
+
+#endif