X-Git-Url: https://git.jsancho.org/?p=dungeon-master.git;a=blobdiff_plain;f=src%2Fpaths.cpp;fp=src%2Fpaths.cpp;h=ae05f3b661d400ac988201c429b4ee1c2889c885;hp=0000000000000000000000000000000000000000;hb=c4a0774d367b5e8ff7a2aeebf1bbe4386621b51f;hpb=1f856dd6077fa25c8236146cf15d95e759b96b5e diff --git a/src/paths.cpp b/src/paths.cpp new file mode 100644 index 0000000..ae05f3b --- /dev/null +++ b/src/paths.cpp @@ -0,0 +1,28 @@ +#include +#include "paths.h" + +std::string get_exec_path() +{ + char pBuf[256]; + size_t len = sizeof(pBuf); + char szTmp[32]; + + sprintf(szTmp, "/proc/%d/exe", getpid()); + int bytes = readlink(szTmp, pBuf, len); + if (bytes > len - 1) + bytes = len - 1; + if (bytes >= 0) + pBuf[bytes] = '\0'; + + std::string exec_path = pBuf; + return exec_path.substr(0, exec_path.rfind(DIR_DELIM) + 1); +} + + +std::set get_dm_paths() { + std::set paths; + + paths.insert(get_exec_path()); + + return paths; +}