From ae3f0b93049194bdefefd6226d5080cf28f5d67a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 14 Jan 2012 19:17:26 +0000 Subject: 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 --- src/serialisation/Parser.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/serialisation') 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); -- cgit v1.2.1