summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-03-08 17:33:50 +0000
committerDavid Robillard <d@drobilla.net>2012-03-08 17:33:50 +0000
commita442a47f3a6265de156ad278760f50438cbdde64 (patch)
tree5f0787cd590c9ef978b4b6e879de11d46a5153e3
parentc89a62e1c8b399a8ecb753e5e14efc33e64bc971 (diff)
downloadlilv-a442a47f3a6265de156ad278760f50438cbdde64.tar.gz
lilv-a442a47f3a6265de156ad278760f50438cbdde64.tar.bz2
lilv-a442a47f3a6265de156ad278760f50438cbdde64.zip
serd_node_new_uri_from_path => serd_node_new_file_uri.
Tidy. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@4031 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/sratom/sratom.c4
-rw-r--r--src/state.c33
-rw-r--r--test/lilv_test.c4
3 files changed, 16 insertions, 25 deletions
diff --git a/src/sratom/sratom.c b/src/sratom/sratom.c
index 2117705..1e74067 100644
--- a/src/sratom/sratom.c
+++ b/src/sratom/sratom.c
@@ -206,7 +206,7 @@ sratom_write(Sratom* sratom,
const uint8_t* str = USTR(body);
if (path_is_absolute((const char*)str)) {
new_node = true;
- object = serd_node_new_uri_from_path(str, NULL, NULL);
+ object = serd_node_new_file_uri(str, NULL, NULL);
} else {
SerdEnv* env = serd_writer_get_env(writer);
SerdURI base_uri = SERD_URI_NULL;
@@ -218,7 +218,7 @@ sratom_write(Sratom* sratom,
datatype = serd_node_from_string(SERD_URI, USTR(LV2_ATOM__Path));
} else {
new_node = true;
- SerdNode rel = serd_node_new_uri_from_path(str, NULL, NULL);
+ SerdNode rel = serd_node_new_file_uri(str, NULL, NULL);
object = serd_node_new_uri_from_node(&rel, &base_uri, NULL);
serd_node_free(&rel);
}
diff --git a/src/state.c b/src/state.c
index 266f7d3..1149b32 100644
--- a/src/state.c
+++ b/src/state.c
@@ -624,7 +624,7 @@ lilv_state_new_from_file(LilvWorld* world,
}
uint8_t* abs_path = (uint8_t*)lilv_path_absolute(path);
- SerdNode node = serd_node_new_uri_from_path(abs_path, NULL, NULL);
+ SerdNode node = serd_node_new_file_uri(abs_path, NULL, NULL);
SerdEnv* env = serd_env_new(&node);
SordModel* model = sord_new(world->world, SORD_SPO, false);
SerdReader* reader = sord_new_reader(model, env, SERD_TURTLE, NULL);
@@ -743,13 +743,12 @@ add_state_to_manifest(const LilvNode* plugin_uri,
return 4;
}
- SerdNode file = serd_node_new_uri_from_path(USTR(state_path), 0, 0);
- SerdNode manifest = serd_node_new_uri_from_path(USTR(manifest_path), 0, 0);
-
lilv_flock(fd, true);
- SerdEnv* env = NULL;
- SerdWriter* writer = ttl_file_writer(fd, &manifest, &env);
+ SerdNode file = serd_node_new_file_uri(USTR(state_path), 0, 0);
+ SerdNode manifest = serd_node_new_file_uri(USTR(manifest_path), 0, 0);
+ SerdEnv* env = NULL;
+ SerdWriter* writer = ttl_file_writer(fd, &manifest, &env);
if (!state_uri) {
state_uri = (const char*)file.buf;
@@ -965,36 +964,28 @@ lilv_state_save(LilvWorld* world,
((LilvState*)state)->dir = lilv_strdup(abs_dir);
}
- char* const manifest = lilv_path_join(abs_dir, "manifest.ttl");
-
// Create symlinks to files if necessary
lilv_state_make_links(state, abs_dir);
// Write state to Turtle file
- SerdNode file = serd_node_new_uri_from_path(USTR(path), NULL, NULL);
+ SerdNode file = serd_node_new_file_uri(USTR(path), NULL, NULL);
SerdEnv* env = NULL;
SerdWriter* writer = ttl_file_writer(fd, &file, &env);
- SerdNode node = SERD_NODE_NULL;
- if (!uri) {
- node = serd_node_new_uri_from_path(USTR(path), NULL, NULL);
- uri = (const char*)node.buf;
- }
-
- int ret = lilv_state_write(world, map, unmap, state, writer, uri, dir);
+ SerdNode node = uri ? serd_node_from_string(SERD_URI, USTR(uri)) : file;
+ int ret = lilv_state_write(
+ world, map, unmap, state, writer, (const char*)node.buf, dir);
serd_node_free(&file);
serd_writer_free(writer);
serd_env_free(env);
fclose(fd);
- if (manifest) {
- add_state_to_manifest(state->plugin_uri, manifest, uri, path);
- }
+ char* const manifest = lilv_path_join(abs_dir, "manifest.ttl");
+ add_state_to_manifest(state->plugin_uri, manifest, uri, path);
- serd_node_free(&node);
- free(abs_dir);
free(manifest);
+ free(abs_dir);
free(path);
return ret;
}
diff --git a/test/lilv_test.c b/test/lilv_test.c
index 6d5ba9d..5e2c54a 100644
--- a/test/lilv_test.c
+++ b/test/lilv_test.c
@@ -1156,7 +1156,7 @@ int
test_state(void)
{
uint8_t* abs_bundle = (uint8_t*)lilv_path_absolute(LILV_TEST_BUNDLE);
- SerdNode bundle = serd_node_new_uri_from_path(abs_bundle, 0, 0);
+ SerdNode bundle = serd_node_new_file_uri(abs_bundle, 0, 0);
LilvWorld* world = lilv_world_new();
LilvNode* bundle_uri = lilv_new_uri(world, (const char*)bundle.buf);
LilvNode* plugin_uri = lilv_new_uri(world,
@@ -1272,7 +1272,7 @@ test_state(void)
// Load default bundle into world and load state from it
uint8_t* state6_path = (uint8_t*)lilv_path_absolute("state6.lv2/");
- SerdNode state6_uri = serd_node_new_uri_from_path(state6_path, 0, 0);
+ SerdNode state6_uri = serd_node_new_file_uri(state6_path, 0, 0);
LilvNode* test_state_bundle = lilv_new_uri(world, (const char*)state6_uri.buf);
LilvNode* test_state_node = lilv_new_uri(world, state_uri);
lilv_world_load_bundle(world, test_state_bundle);