+#include <dirent.h>
#include <iostream>
#include <libguile.h>
#include "mods.h"
void load_mods()
{
+ scm_init_guile();
+ scm_init_dungeon_master_module();
+
std::set<std::string> paths = get_dm_paths();
+ DIR* mods_dir;
+ struct dirent* mod;
+ std::string
+ mods_path,
+ mod_main;
+
for (const std::string &path : paths) {
- std::cout << path << std::endl;
+ mods_path = path + DIR_DELIM + "mods";
+ mods_dir = opendir(mods_path.c_str());
+ if (mods_dir != NULL) {
+ while (mod = readdir(mods_dir)) {
+ if (strcmp(mod->d_name, ".") != 0 && strcmp(mod->d_name, "..") != 0) {
+ mod_main = mods_path + DIR_DELIM + mod->d_name + DIR_DELIM + "main.scm";
+ scm_primitive_load(scm_from_locale_string(mod_main.c_str()));
+ }
+ }
+ }
+ closedir(mods_dir);
}
-
- scm_init_guile();
- scm_init_dungeon_master_module();
- scm_primitive_load(scm_from_locale_string("mods/default/main.scm"));
}