diff options
Diffstat (limited to 'src/filesystem.c')
-rw-r--r-- | src/filesystem.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/filesystem.c b/src/filesystem.c index 6b17ccb..39ba2a2 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -68,6 +68,25 @@ 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) { |