summaryrefslogtreecommitdiffstats
path: root/src/serialisation
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-03-04 06:34:58 +0000
committerDavid Robillard <d@drobilla.net>2010-03-04 06:34:58 +0000
commitc3b76bacaddce404f3bc86ed29e8b18a6861238d (patch)
tree57d3d9e05f9513593358f9ca9d6ba5e08df1e032 /src/serialisation
parent3157f13a4f8227d53d4c6c0669d2ea2e7ebe7d6b (diff)
downloadingen-c3b76bacaddce404f3bc86ed29e8b18a6861238d.tar.gz
ingen-c3b76bacaddce404f3bc86ed29e8b18a6861238d.tar.bz2
ingen-c3b76bacaddce404f3bc86ed29e8b18a6861238d.zip
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
Diffstat (limited to 'src/serialisation')
-rw-r--r--src/serialisation/Parser.cpp15
1 files changed, 13 insertions, 2 deletions
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 <locale.h>
#include <glibmm/ustring.h>
#include <glibmm/miscutils.h>
+#include <glibmm/fileutils.h>
+#include <glibmm/convert.h>
#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)