summaryrefslogtreecommitdiffstats
path: root/src/world.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-30 02:24:18 +0000
committerDavid Robillard <d@drobilla.net>2011-04-30 02:24:18 +0000
commitd55f87b341e1855f2f6f544649f17f36aa22d7e4 (patch)
tree53f837b1b2738e5e1d0ac2b904c30fa97f1b257c /src/world.c
parent6c72abfc6d6649f07d85f70b25ce4393dc775a39 (diff)
downloadlilv-d55f87b341e1855f2f6f544649f17f36aa22d7e4.tar.gz
lilv-d55f87b341e1855f2f6f544649f17f36aa22d7e4.tar.bz2
lilv-d55f87b341e1855f2f6f544649f17f36aa22d7e4.zip
Use readdir_r instead of readdir for thread safety.
Don't open bundle directories to test if they exist. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3242 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/world.c')
-rw-r--r--src/world.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/world.c b/src/world.c
index edd9bd1..a18e0b8 100644
--- a/src/world.c
+++ b/src/world.c
@@ -492,8 +492,10 @@ lilv_world_load_bundle(LilvWorld* world, LilvNode* bundle_uri)
(const uint8_t*)"manifest.ttl",
(const uint8_t*)sord_node_get_string(bundle_node));
- sord_read_file(world->model, manifest_uri.buf, bundle_node,
- lilv_world_blank_node_prefix(world));
+ if (!sord_read_file(world->model, manifest_uri.buf, bundle_node,
+ lilv_world_blank_node_prefix(world))) {
+ return;
+ }
// ?plugin a lv2:Plugin
SordIter* plug_results = lilv_world_find_statements(
@@ -577,27 +579,21 @@ lilv_world_load_directory(LilvWorld* world, const char* dir_path)
#else
static const char* const file_scheme = "file://";
#endif
- const size_t file_scheme_len = strlen(file_scheme);
- struct dirent* pfile;
- while ((pfile = readdir(pdir))) {
- if (!strcmp(pfile->d_name, ".") || !strcmp(pfile->d_name, ".."))
+ struct dirent entry;
+ struct dirent* result;
+ while (!readdir_r(pdir, &entry, &result) && result) {
+ if (!strcmp(entry.d_name, ".") || !strcmp(entry.d_name, ".."))
continue;
char* uri = lilv_strjoin(file_scheme,
path, "/",
- pfile->d_name, "/",
+ entry.d_name, "/",
NULL);
- DIR* const bundle_dir = opendir(uri + file_scheme_len);
- if (bundle_dir) {
- closedir(bundle_dir);
- LilvNode* uri_val = lilv_new_uri(world, uri);
- lilv_world_load_bundle(world, uri_val);
- lilv_node_free(uri_val);
- } else {
- LILV_WARNF("failed to open bundle `%s'\n", uri);
- }
+ LilvNode* uri_val = lilv_new_uri(world, uri);
+ lilv_world_load_bundle(world, uri_val);
+ lilv_node_free(uri_val);
free(uri);
}