about summary refs log tree commit diff stats
path: root/src/global.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/global.cpp')
-rw-r--r--src/global.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/global.cpp b/src/global.cpp new file mode 100644 index 0000000..3ee4f58 --- /dev/null +++ b/src/global.cpp
@@ -0,0 +1,24 @@
1#include "global.h"
2
3#include <whereami.h>
4
5#include <filesystem>
6#include <string>
7#include <string_view>
8
9const std::filesystem::path& GetExecutableDirectory() {
10 static const std::filesystem::path* executable_directory = []() {
11 int length = wai_getExecutablePath(NULL, 0, NULL);
12 std::string buf(length, 0);
13 wai_getExecutablePath(buf.data(), length, NULL);
14
15 std::filesystem::path exec_path(buf);
16 return new std::filesystem::path(exec_path.parent_path());
17 }();
18
19 return *executable_directory;
20}
21
22std::string GetAbsolutePath(std::string_view path) {
23 return (GetExecutableDirectory() / path).string();
24}