bin_PROGRAMS = $(top_builddir)/DungeonMaster
-__top_builddir__DungeonMaster_SOURCES = main.cpp mods.cpp
+__top_builddir__DungeonMaster_SOURCES = main.cpp mods.cpp paths.cpp
__top_builddir__DungeonMaster_CPPFLAGS = @GUILE_CFLAGS@
__top_builddir__DungeonMaster_LDFLAGS = @GUILE_LIBS@
+#include <iostream>
#include <libguile.h>
#include "mods.h"
+#include "paths.h"
SCM register_generator(SCM name, SCM proc)
{
void load_mods()
{
+ std::set<std::string> paths = get_dm_paths();
+ for (const std::string &path : paths) {
+ std::cout << path << std::endl;
+ }
+
scm_init_guile();
scm_init_dungeon_master_module();
scm_primitive_load(scm_from_locale_string("mods/default/main.scm"));
--- /dev/null
+#include <unistd.h>
+#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<std::string> get_dm_paths() {
+ std::set<std::string> paths;
+
+ paths.insert(get_exec_path());
+
+ return paths;
+}
--- /dev/null
+#include <set>
+#include <iostream>
+
+#define DIR_DELIM "/"
+
+std::string get_exec_path();
+std::set<std::string> get_dm_paths();