diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/filesystem.c | 42 | ||||
-rw-r--r-- | src/filesystem.h | 16 | ||||
-rw-r--r-- | src/util.c | 3 | ||||
-rw-r--r-- | src/world.c | 4 |
4 files changed, 4 insertions, 61 deletions
diff --git a/src/filesystem.c b/src/filesystem.c index 584eaad..734e258 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -9,13 +9,6 @@ #include "zix/filesystem.h" #include "zix/path.h" -#ifdef _WIN32 -# include <io.h> -# include <windows.h> -#else -# include <dirent.h> -#endif - #include <stdbool.h> #include <stdio.h> #include <stdlib.h> @@ -147,41 +140,6 @@ lilv_path_filename(const char* path) return ret; } -void -lilv_dir_for_each(const char* path, - void* data, - void (*f)(const char* path, const char* name, void* data)) -{ -#ifdef _WIN32 - - char* pat = zix_path_join(NULL, path, "*"); - WIN32_FIND_DATA fd; - HANDLE fh = FindFirstFile(pat, &fd); - if (fh != INVALID_HANDLE_VALUE) { - do { - if (strcmp(fd.cFileName, ".") && strcmp(fd.cFileName, "..")) { - f(path, fd.cFileName, data); - } - } while (FindNextFile(fh, &fd)); - } - FindClose(fh); - free(pat); - -#else - - DIR* dir = opendir(path); - if (dir) { - for (struct dirent* entry = NULL; (entry = readdir(dir));) { - if (strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..")) { - f(path, entry->d_name, data); - } - } - closedir(dir); - } - -#endif -} - char* lilv_create_temporary_directory(const char* pattern) { diff --git a/src/filesystem.h b/src/filesystem.h index d2f14b6..5dfd3d7 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -34,22 +34,6 @@ char* lilv_path_filename(const char* path); /** - Visit every file in the directory at `path`. - - @param path A path to a directory. - - @param data Opaque user data that is passed to `f`. - - @param f A function called on every entry in the directory. The `path` - parameter is always the directory path passed to this function, the `name` - parameter is the name of the directory entry (not its full path). -*/ -void -lilv_dir_for_each(const char* path, - void* data, - void (*f)(const char* path, const char* name, void* data)); - -/** Create a unique temporary directory. This is like lilv_create_temporary_directory_in(), except it creates the @@ -7,6 +7,7 @@ #include "lilv/lilv.h" #include "serd/serd.h" #include "zix/allocator.h" +#include "zix/filesystem.h" #include "zix/path.h" #include <sys/stat.h> @@ -271,7 +272,7 @@ lilv_get_latest_copy(const char* path, const char* copy_path) LILV_ERRORF("stat(%s) (%s)\n", path, strerror(errno)); } - lilv_dir_for_each(copy_dir, &latest, update_latest); + zix_dir_for_each(copy_dir, &latest, update_latest); free(latest.pattern); free(copy_dir); diff --git a/src/world.c b/src/world.c index af0ab06..23116e9 100644 --- a/src/world.c +++ b/src/world.c @@ -1,13 +1,13 @@ // Copyright 2007-2019 David Robillard <d@drobilla.net> // SPDX-License-Identifier: ISC -#include "filesystem.h" #include "lilv_config.h" // IWYU pragma: keep #include "lilv_internal.h" #include "lilv/lilv.h" #include "serd/serd.h" #include "sord/sord.h" +#include "zix/filesystem.h" #include "zix/tree.h" #include "lv2/core/lv2.h" @@ -957,7 +957,7 @@ lilv_world_load_directory(LilvWorld* world, const char* dir_path) { char* path = lilv_expand(dir_path); if (path) { - lilv_dir_for_each(path, world, load_dir_entry); + zix_dir_for_each(path, world, load_dir_entry); free(path); } } |