|
@@ -0,0 +1,42 @@
|
|
|
+#include "executable.hpp"
|
|
|
+
|
|
|
+#ifdef __linux__
|
|
|
+
|
|
|
+#define _EXEC_PATH_IMPL_ 1
|
|
|
+
|
|
|
+#include <unistd.h>
|
|
|
+#include <string>
|
|
|
+#include <climits>
|
|
|
+
|
|
|
+boost::filesystem::path get_executable_path()
|
|
|
+{
|
|
|
+ static char buf[PATH_MAX];
|
|
|
+ readlink("/proc/self/exe", buf, PATH_MAX);
|
|
|
+ return buf;
|
|
|
+}
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
+#ifdef __WINNT__
|
|
|
+
|
|
|
+#define _EXEC_PATH_IMPL_ 1
|
|
|
+
|
|
|
+#include <windows.h>
|
|
|
+
|
|
|
+boost::filesystem::path get_executable_path()
|
|
|
+{
|
|
|
+ static char buf[MAX_PATH];
|
|
|
+ GetModuleFileNameA(NULL, buf, MAX_PATH);
|
|
|
+ return buf;
|
|
|
+}
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
+#ifndef _EXEC_PATH_IMPL_
|
|
|
+#error "don't know how to get executable path"
|
|
|
+#endif
|
|
|
+
|
|
|
+boost::filesystem::path get_executable_directory()
|
|
|
+{
|
|
|
+ return get_executable_path().parent_path();
|
|
|
+}
|