summaryrefslogtreecommitdiffstats
path: root/src/Serialiser.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-10-01 18:57:22 -0400
committerDavid Robillard <d@drobilla.net>2016-10-01 18:57:22 -0400
commit97bfcd3b24e7ae385cdec84363f9c868f580beb3 (patch)
tree6df00938609912051e1116123002eb74eec95624 /src/Serialiser.cpp
parentc1a28255f7e92e5e7a6bfe37510bcf079e334338 (diff)
downloadingen-97bfcd3b24e7ae385cdec84363f9c868f580beb3.tar.gz
ingen-97bfcd3b24e7ae385cdec84363f9c868f580beb3.tar.bz2
ingen-97bfcd3b24e7ae385cdec84363f9c868f580beb3.zip
Fix default doap:name of saved graphs
Diffstat (limited to 'src/Serialiser.cpp')
-rw-r--r--src/Serialiser.cpp13
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));