From c3b76bacaddce404f3bc86ed29e8b18a6861238d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 4 Mar 2010 06:34:58 +0000 Subject: Always save to Ingen bundles (directories with names like foo.ingen.lv2 containg at least manifest.ttl and foo.ingen.ttl). Gracefully handle attempts to save over files, directories resembling ingen bundles, and non-ingen directories. Use Glib::file_test instead of attempting to open files with fstream. Construct a root patch URI from the bundle URI if Parser::parse_document is passed a bundle URI. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2515 a436a847-0d15-0410-975c-d299462d15a1 --- src/serialisation/Parser.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/serialisation/Parser.cpp') diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index 68ac46ce..11c0efb1 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include "raul/log.hpp" #include "redlandmm/Model.hpp" #include "redlandmm/Node.hpp" @@ -83,11 +85,20 @@ Parser::parse_document( { normalise_uri(document_uri); + const std::string filename(Glib::filename_from_uri(document_uri)); + const size_t ext = filename.find(".ingen.lv2"); + if (ext == filename.length() - 10 + || (ext == filename.length() - 11 && filename[filename.length() - 1] == '/')) { + std::string basename(Glib::path_get_basename(filename)); + basename = basename.substr(0, basename.find('.')); + document_uri += "/" + basename + ".ingen.ttl"; + } + Redland::Model model(*world->rdf_world, document_uri, document_uri); - LOG(info) << "Parsing document " << document_uri << endl; + LOG(info) << "Parsing " << document_uri << endl; if (data_path) - LOG(info) << "Document path: " << *data_path << endl; + LOG(info) << "Path: " << *data_path << endl; if (parent) LOG(info) << "Parent: " << *parent << endl; if (symbol) -- cgit v1.2.1