diff options
author | David Robillard <d@drobilla.net> | 2016-10-01 18:57:22 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-10-02 12:24:57 -0400 |
commit | a2cb63943b9e720be55e175da7c970c8dc3833d9 (patch) | |
tree | 5429ce634eb5ffe5b83dbf83578f62db577c4a61 | |
parent | 424bd44c4b6f64a15f9dc18df47b77c39b62a855 (diff) | |
download | ingen-a2cb63943b9e720be55e175da7c970c8dc3833d9.tar.gz ingen-a2cb63943b9e720be55e175da7c970c8dc3833d9.tar.bz2 ingen-a2cb63943b9e720be55e175da7c970c8dc3833d9.zip |
Fix default doap:name of saved graphs
-rw-r--r-- | src/Serialiser.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp index ed1a5504..b0d760dc 100644 --- a/src/Serialiser.cpp +++ b/src/Serialiser.cpp @@ -104,6 +104,7 @@ struct Serialiser::Impl { Raul::Path _root_path; Mode _mode; std::string _base_uri; + std::string _basename; World& _world; Sord::Model* _model; Sratom* _sratom; @@ -227,6 +228,7 @@ Serialiser::Impl::write_bundle(SPtr<const Node> graph, void Serialiser::Impl::start_to_file(const Raul::Path& root, const string& filename) { + // Set Base URI assert(filename.find(":") == string::npos || filename.substr(0, 5) == "file:"); if (filename.find(":") == string::npos) { _base_uri = "file://" + filename; @@ -234,6 +236,12 @@ Serialiser::Impl::start_to_file(const Raul::Path& root, const string& filename) _base_uri = filename; } + // Find graph basename to use as symbol / fallback name + _basename = Glib::path_get_basename(filename); + if (_basename == "main.ttl") { + _basename = Glib::path_get_basename(Glib::path_get_dirname(filename)); + } + _model = new Sord::Model(*_world.rdf_world(), _base_uri); _mode = Mode::TO_FILE; _root_path = root; @@ -335,10 +343,9 @@ Serialiser::Impl::serialise_graph(SPtr<const Node> graph, Sord::URI(world, LV2_UI__ui), Sord::URI(world, "http://drobilla.net/ns/ingen#GraphUIGtk2")); - // If the graph has no doap:name (required by LV2), use the symbol + // If the graph has no doap:name (required by LV2), use the basename if (graph->properties().find(uris.doap_name) == graph->properties().end()) { - std::string sym = Glib::path_get_basename(graph_id.to_string()); - sym = sym.substr(0, sym.find('.')); + const std::string sym = _basename.substr(0, _basename.find('.')); _model->add_statement(graph_id, Sord::URI(world, uris.doap_name), Sord::Literal(world, sym)); |