summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/ingen/serialisation/Serialiser.hpp2
-rw-r--r--src/serialisation/Parser.cpp37
-rw-r--r--src/serialisation/Serialiser.cpp31
3 files changed, 29 insertions, 41 deletions
diff --git a/include/ingen/serialisation/Serialiser.hpp b/include/ingen/serialisation/Serialiser.hpp
index 4794aa60..4dbb78de 100644
--- a/include/ingen/serialisation/Serialiser.hpp
+++ b/include/ingen/serialisation/Serialiser.hpp
@@ -57,7 +57,7 @@ public:
const std::string& filename);
void write_bundle(SharedPtr<const Patch> patch,
- const std::string& uri);
+ const std::string& path);
std::string to_string(SharedPtr<const GraphObject> object,
const std::string& base_uri,
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index 5a3ec2a7..318158fa 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -59,27 +59,30 @@ namespace Serialisation {
static Glib::ustring
relative_uri(Glib::ustring base, const Glib::ustring uri, bool leading_slash)
{
- const char* out = NULL;
- if (uri == base) {
- out = "";
- } else {
- SerdURI base_uri;
- if (serd_uri_parse((const uint8_t*)base.c_str(), &base_uri)) {
- LOG(error) << boost::format("Invalid base URI `%1%'") % base << endl;
- return "";
+ Glib::ustring ret;
+ if (uri != base) {
+ SerdURI base_uri;
+ serd_uri_parse((const uint8_t*)base.c_str(), &base_uri);
+
+ SerdURI normal_base_uri;
+ SerdNode normal_base_uri_node = serd_node_new_uri_from_string(
+ (const uint8_t*)".", &base_uri, &normal_base_uri);
+
+ Glib::ustring normal_base_str((const char*)normal_base_uri_node.buf);
+
+ ret = uri;
+ if (uri.length() >= normal_base_str.length()
+ && uri.substr(0, normal_base_str.length()) == normal_base_str) {
+ ret = uri.substr(normal_base_str.length());
+ if (leading_slash && ret[0] != '/')
+ ret = Glib::ustring("/") + ret;
}
-
- SerdURI out_uri;
- SerdNode out_node = serd_node_new_uri_from_string(
- (const uint8_t*)uri.c_str(), &base_uri, &out_uri);
-
- out = (const char*)out_node.buf;
}
- if (leading_slash && out[0] != '/') {
- return Glib::ustring("/").append(out);
+ if (leading_slash && ret[0] != '/') {
+ ret = Glib::ustring("/").append(ret);
}
- return out;
+ return ret;
}
static std::string
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index 3d528af4..8d9b490a 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -39,7 +39,6 @@
#include "raul/Atom.hpp"
#include "raul/AtomRDF.hpp"
#include "raul/Path.hpp"
-#include "raul/TableImpl.hpp"
#include "raul/log.hpp"
#include "sord/sordmm.hpp"
@@ -139,15 +138,6 @@ Serialiser::to_file(SharedPtr<const GraphObject> object,
finish();
}
-static
-std::string
-uri_to_symbol(const std::string& uri)
-{
- const std::string filename = Glib::filename_from_uri(uri);
- return Path::nameify(Glib::path_get_basename(
- filename.substr(0, filename.find_last_of('.'))));
-}
-
void
Serialiser::Impl::write_manifest(const std::string& bundle_path,
SharedPtr<const Patch> patch,
@@ -201,23 +191,16 @@ normal_bundle_uri(const std::string& uri)
void
Serialiser::write_bundle(SharedPtr<const Patch> patch,
- const std::string& uri)
+ const std::string& path)
{
- me->write_bundle(patch, uri);
+ me->write_bundle(patch, path);
}
void
Serialiser::Impl::write_bundle(SharedPtr<const Patch> patch,
- const std::string& uri)
+ const std::string& a_path)
{
- Glib::ustring path = "";
- try {
- path = Glib::filename_from_uri(uri);
- } catch (...) {
- LOG(error) << "Illegal file URI `" << uri << "'" << endl;
- return;
- }
-
+ std::string path(a_path);
if (Glib::file_test(path, Glib::FILE_TEST_EXISTS)
&& !Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) {
path = Glib::path_get_dirname(path);
@@ -228,8 +211,10 @@ Serialiser::Impl::write_bundle(SharedPtr<const Patch> patch,
g_mkdir_with_parents(path.c_str(), 0744);
- const string symbol = uri_to_symbol(uri);
- const string root_file = path + symbol + ".ttl";
+ string symbol = Glib::path_get_basename(path);
+ symbol = symbol.substr(0, symbol.find("."));
+
+ const string root_file = Glib::build_filename(path, symbol + ".ttl");
start_to_filename(root_file);
const Path old_root_path = _root_path;