summaryrefslogtreecommitdiffstats
path: root/src/libs/module
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-05-04 03:59:38 +0000
committerDavid Robillard <d@drobilla.net>2007-05-04 03:59:38 +0000
commita96166710faf2447ed10194d1829db5564b0dff9 (patch)
tree4eb792fcceee17f188566fc6e6bee11e5a8c4336 /src/libs/module
parentcf14d321e8f084f742b03e09c086d5ef30297492 (diff)
downloadingen-a96166710faf2447ed10194d1829db5564b0dff9.tar.gz
ingen-a96166710faf2447ed10194d1829db5564b0dff9.tar.bz2
ingen-a96166710faf2447ed10194d1829db5564b0dff9.zip
Made engine, serialisation, client library, and GUI all dynamically loaded modules.
Combined all executables into a single "ingen" program which can do everything. git-svn-id: http://svn.drobilla.net/lad/ingen@493 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/module')
-rw-r--r--src/libs/module/Module.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/libs/module/Module.cpp b/src/libs/module/Module.cpp
index d92ee97a..073e612d 100644
--- a/src/libs/module/Module.cpp
+++ b/src/libs/module/Module.cpp
@@ -20,6 +20,7 @@
#include <iostream>
#include <glibmm/module.h>
#include <glibmm/miscutils.h>
+#include <glibmm/fileutils.h>
#include <raul/SharedPtr.h>
#ifndef INGEN_MODULE_DIR
@@ -43,7 +44,7 @@ namespace Shared {
SharedPtr<Glib::Module>
load_module(const string& name)
{
- SharedPtr<Glib::Module> module;
+ Glib::Module* module = NULL;
// Search INGEN_MODULE_PATH first
bool module_path_found;
@@ -52,24 +53,30 @@ load_module(const string& name)
string dir;
istringstream iss(module_path);
while (getline(iss, dir, ':')) {
- module = SharedPtr<Glib::Module>(new Glib::Module(
- Glib::Module::build_path(dir, name),
- Glib::MODULE_BIND_LAZY));
+
+ string filename = Glib::Module::build_path(dir, name);
+ if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) {
+ module = new Glib::Module(filename, Glib::MODULE_BIND_LAZY);
- if (module && *module.get())
- return module;
+ if (*module) {
+ return SharedPtr<Glib::Module>(module);
+ } else {
+ delete module;
+ cerr << Glib::Module::get_last_error() << endl;
+ }
+ }
}
}
// Try default directory if not found
- module = SharedPtr<Glib::Module>(new Glib::Module(
+ module = new Glib::Module(
Glib::Module::build_path(INGEN_MODULE_DIR, name),
- Glib::MODULE_BIND_LAZY));
+ Glib::MODULE_BIND_LAZY);
- if (*module.get()) {
- return module;
+ if (*module) {
+ return SharedPtr<Glib::Module>(module);
} else {
- cerr << "Unable to load module \"" << name << "\" (you may want to set INGEN_MODULE_PATH)." << endl;
+ cerr << "Unable to load module \"" << name << "\" (try setting INGEN_MODULE_PATH)." << endl;
return SharedPtr<Glib::Module>();
}
}