summaryrefslogtreecommitdiffstats
path: root/src/serialisation
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-01-14 19:17:26 +0000
committerDavid Robillard <d@drobilla.net>2012-01-14 19:17:26 +0000
commitae3f0b93049194bdefefd6226d5080cf28f5d67a (patch)
treeb4a6fe9e2c7cd17c4e8ebcff1c61e4b96ae032b2 /src/serialisation
parent35754a69e1653dd2586670031622fb2b01a220d1 (diff)
downloadingen-ae3f0b93049194bdefefd6226d5080cf28f5d67a.tar.gz
ingen-ae3f0b93049194bdefefd6226d5080cf28f5d67a.tar.bz2
ingen-ae3f0b93049194bdefefd6226d5080cf28f5d67a.zip
Fix loading patches by relative path (fix #798).
Gracefully handle and report Glib path to URI conversion errors. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3943 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/serialisation')
-rw-r--r--src/serialisation/Parser.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index 8a9293fb..2ef387e8 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -581,10 +581,21 @@ Parser::parse_file(Ingen::Shared::World* world,
path = Glib::build_filename(path, get_basename(path) + ".ttl");
}
- const std::string uri = Glib::filename_to_uri(path, "");
- const uint8_t* uri_c_str = (const uint8_t*)uri.c_str();
- SerdNode base_node = serd_node_from_string(SERD_URI, uri_c_str);
- SerdEnv* env = serd_env_new(&base_node);
+ if (!Glib::path_is_absolute(path)) {
+ path = Glib::build_filename(Glib::get_current_dir(), path);
+ }
+
+ std::string uri;
+ try {
+ uri = Glib::filename_to_uri(path, "");
+ } catch (const Glib::ConvertError& e) {
+ LOG(error) << "Path to URI conversion error: " << e.what() << endl;
+ return false;
+ }
+
+ const uint8_t* uri_c_str = (const uint8_t*)uri.c_str();
+ SerdNode base_node = serd_node_from_string(SERD_URI, uri_c_str);
+ SerdEnv* env = serd_env_new(&base_node);
// Load patch file into model
Sord::Model model(*world->rdf_world(), uri);