diff options
-rw-r--r-- | src/filesystem.c | 22 | ||||
-rw-r--r-- | src/filesystem.h | 4 | ||||
-rw-r--r-- | test/test_filesystem.c | 11 |
3 files changed, 2 insertions, 35 deletions
diff --git a/src/filesystem.c b/src/filesystem.c index 6958600..ec13df3 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -5,6 +5,7 @@ #include "lilv_config.h" #include "lilv_internal.h" +#include "zix/filesystem.h" #include "zix/path.h" #ifdef _WIN32 @@ -49,25 +50,6 @@ is_windows_path(const char* path) } #endif -char* -lilv_temp_directory_path(void) -{ -#ifdef _WIN32 - DWORD len = GetTempPath(0, NULL); - char* buf = (char*)calloc(len, 1); - if (GetTempPath(len, buf) == 0) { - free(buf); - return NULL; - } - - return buf; -#else - const char* const tmpdir = getenv("TMPDIR"); - - return tmpdir ? lilv_strdup(tmpdir) : lilv_strdup("/tmp"); -#endif -} - bool lilv_path_is_absolute(const char* path) { @@ -367,7 +349,7 @@ lilv_create_temporary_directory_in(const char* pattern, const char* parent) char* lilv_create_temporary_directory(const char* pattern) { - char* const tmpdir = lilv_temp_directory_path(); + char* const tmpdir = zix_temp_directory_path(NULL); char* const result = lilv_create_temporary_directory_in(pattern, tmpdir); free(tmpdir); diff --git a/src/filesystem.h b/src/filesystem.h index 9337a97..a1b8fd7 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -4,10 +4,6 @@ #include <stdbool.h> #include <stdio.h> -/// Return the path to a directory suitable for making temporary files -char* -lilv_temp_directory_path(void); - /// Return true iff `path` is an absolute path bool lilv_path_is_absolute(const char* path); diff --git a/test/test_filesystem.c b/test/test_filesystem.c index 1ac4639..25f73ec 100644 --- a/test/test_filesystem.c +++ b/test/test_filesystem.c @@ -26,16 +26,6 @@ equals(char* string, const char* expected) } static void -test_temp_directory_path(void) -{ - char* tmpdir = lilv_temp_directory_path(); - - assert(lilv_is_directory(tmpdir)); - - free(tmpdir); -} - -static void test_path_is_absolute(void) { assert(lilv_path_is_absolute("/a/b")); @@ -328,7 +318,6 @@ test_create_directories(void) int main(void) { - test_temp_directory_path(); test_path_is_absolute(); test_path_is_child(); test_path_current(); |