summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-12-18 17:04:04 +0100
committerDavid Robillard <d@drobilla.net>2020-12-18 17:39:02 +0100
commitfe55575fc73190568c6899e1b69f37037942daff (patch)
tree479f9add4fa66f87090cbd4c405b767a705d5a62
parentf38626d31547445c1acb73d5838b1655cf8a2639 (diff)
downloadlilv-fe55575fc73190568c6899e1b69f37037942daff.tar.gz
lilv-fe55575fc73190568c6899e1b69f37037942daff.tar.bz2
lilv-fe55575fc73190568c6899e1b69f37037942daff.zip
Windows: Fix updating state manifests
This didn't work because the mode was wrong (serd uses binary because it is always UTF-8), and... other reasons I don't understand. Regarless this is more consistent without files are read elsewhere.
-rw-r--r--src/state.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/state.c b/src/state.c
index 1174b74..57a5783 100644
--- a/src/state.c
+++ b/src/state.c
@@ -910,11 +910,13 @@ add_state_to_manifest(LilvWorld* lworld,
SerdEnv* env = serd_env_new(&manifest);
SordModel* model = sord_new(world, SORD_SPO, false);
- FILE* rfd = fopen(manifest_path, "r");
- if (rfd) {
+ if (lilv_path_exists(manifest_path)) {
// Read manifest into model
SerdReader* reader = sord_new_reader(model, env, SERD_TURTLE, NULL);
- serd_reader_read_file_handle(reader, rfd, manifest.buf);
+ SerdStatus st = serd_reader_read_file(reader, manifest.buf);
+ if (st) {
+ LILV_WARNF("Failed to read manifest (%s)\n", serd_strerror(st));
+ }
serd_reader_free(reader);
}
@@ -954,21 +956,16 @@ add_state_to_manifest(LilvWorld* lworld,
serd_node_from_string(SERD_URI,
USTR(lilv_node_as_string(plugin_uri))));
- // Close manifest since we're done reading
- if (rfd) {
- fclose(rfd);
- }
-
/* Re-open manifest for locked writing. We need to do this because it may
need to be truncated, and the file can only be open once on Windows. */
- FILE* wfd = fopen(manifest_path, "w");
- int st = 0;
+ FILE* wfd = fopen(manifest_path, "wb");
+ int r = 0;
if (!wfd) {
LILV_ERRORF("Failed to open %s for writing (%s)\n",
manifest_path,
strerror(errno));
- st = 1;
+ r = 1;
}
SerdWriter* writer = ttl_file_writer(wfd, &manifest, &env);
@@ -983,7 +980,7 @@ add_state_to_manifest(LilvWorld* lworld,
serd_node_free(&manifest);
serd_env_free(env);
- return st;
+ return r;
}
static bool