From 17888cbea7107d22034d761ee6f5abceedf6e6d3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 5 Aug 2020 23:35:42 +0200 Subject: Make lilv_dir_for_each() ignore dot entries --- src/filesystem.c | 8 ++++++-- 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); -- cgit v1.2.1