diff options
author | David Robillard <d@drobilla.net> | 2020-08-05 23:35:42 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-08-06 17:34:42 +0200 |
commit | 17888cbea7107d22034d761ee6f5abceedf6e6d3 (patch) | |
tree | 1b1309b220eb6ddc375b626eb76cbcf09b207df3 | |
parent | 36af38408e9e5ba2c49738ad08ff2b959bcf7e27 (diff) | |
download | lilv-17888cbea7107d22034d761ee6f5abceedf6e6d3.tar.gz lilv-17888cbea7107d22034d761ee6f5abceedf6e6d3.tar.bz2 lilv-17888cbea7107d22034d761ee6f5abceedf6e6d3.zip |
Make lilv_dir_for_each() ignore dot entries
-rw-r--r-- | src/filesystem.c | 8 | ||||
-rw-r--r-- | src/world.c | 10 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/filesystem.c b/src/filesystem.c index 27476ec..957629b 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -324,7 +324,9 @@ lilv_dir_for_each(const char* path, HANDLE fh = FindFirstFile(pat, &fd); if (fh != INVALID_HANDLE_VALUE) { do { - f(path, fd.cFileName, data); + if (strcmp(fd.cFileName, ".") && strcmp(fd.cFileName, "..")) { + f(path, fd.cFileName, data); + } } while (FindNextFile(fh, &fd)); } free(pat); @@ -332,7 +334,9 @@ lilv_dir_for_each(const char* path, DIR* dir = opendir(path); if (dir) { for (struct dirent* entry = NULL; (entry = readdir(dir));) { - f(path, entry->d_name, data); + if (strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..")) { + f(path, entry->d_name, data); + } } closedir(dir); } diff --git a/src/world.c b/src/world.c index 17896ee..7095a6e 100644 --- a/src/world.c +++ b/src/world.c @@ -956,13 +956,9 @@ static void load_dir_entry(const char* dir, const char* name, void* data) { LilvWorld* world = (LilvWorld*)data; - if (!strcmp(name, ".") || !strcmp(name, "..")) { - return; - } - - char* path = lilv_strjoin(dir, "/", name, "/", NULL); - SerdNode suri = serd_node_new_file_uri((const uint8_t*)path, 0, 0, true); - LilvNode* node = lilv_new_uri(world, (const char*)suri.buf); + char* path = lilv_strjoin(dir, "/", name, "/", NULL); + SerdNode suri = serd_node_new_file_uri((const uint8_t*)path, 0, 0, true); + LilvNode* node = lilv_new_uri(world, (const char*)suri.buf); lilv_world_load_bundle(world, node); lilv_node_free(node); |