summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-05 23:35:07 +0200
committerDavid Robillard <d@drobilla.net>2020-08-06 17:34:42 +0200
commitd40f2ca3498592c2ffcb6de82642dfcb5a6f301d (patch)
treef616f872ab4c05cd22ecc2c18623c57293b27035 /src
parent0cdd992e06a090f1965045fade378579ea5ac05d (diff)
downloadlilv-d40f2ca3498592c2ffcb6de82642dfcb5a6f301d.tar.gz
lilv-d40f2ca3498592c2ffcb6de82642dfcb5a6f301d.tar.bz2
lilv-d40f2ca3498592c2ffcb6de82642dfcb5a6f301d.zip
Add lilv_is_directory()
Diffstat (limited to 'src')
-rw-r--r--src/filesystem.c8
-rw-r--r--src/filesystem.h4
2 files changed, 12 insertions, 0 deletions
diff --git a/src/filesystem.c b/src/filesystem.c
index 4ba0bd9..dc72d93 100644
--- a/src/filesystem.c
+++ b/src/filesystem.c
@@ -32,6 +32,7 @@
# include <io.h>
# define F_OK 0
# define mkdir(path, flags) _mkdir(path)
+# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#else
# include <dirent.h>
# include <unistd.h>
@@ -240,6 +241,13 @@ lilv_path_exists(const char* path)
#endif
}
+bool
+lilv_is_directory(const char* path)
+{
+ struct stat st;
+ return !stat(path, &st) && S_ISDIR(st.st_mode);
+}
+
int
lilv_copy_file(const char* src, const char* dst)
{
diff --git a/src/filesystem.h b/src/filesystem.h
index b43e394..09b8b5f 100644
--- a/src/filesystem.h
+++ b/src/filesystem.h
@@ -77,6 +77,10 @@ lilv_path_canonical(const char* path);
bool
lilv_path_exists(const char* path);
+/// Return true iff `path` points to an existing directory
+bool
+lilv_is_directory(const char* path);
+
/**
Copy the file at path `src` to path `dst`.