sys: filesystem isdir function
MODIFY
include/re_sys.h
include/re_sys.h
@@ -71,3 +71,4 @@ void rand_bytes(uint8_t *p, size_t size);
/* File-System */
int fs_mkdir(const char *path, uint16_t mode);
int fs_gethome(char *path, size_t sz);
+bool fs_isdir(const char *path);

MODIFY
src/sys/fs.c
src/sys/fs.c
*
* Copyright (C) 2010 Creytiv.com
*/
+#define _DEFAULT_SOURCE 1
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
@@ -105,3 +106,27 @@ int fs_gethome(char *path, size_t sz)
return ENOSYS;
#endif
}
+
+
+/**
+ * Check if given path is directory
+ *
+ * @param path Directory
+ *
+ * @return True if directory, False if not
+ */
+bool fs_isdir(const char *path)
+{
+ struct stat st;
+
+ if (!path)
+ return false;
+
+ if (stat(path, &st) < 0)
+ return false;
+
+ if ((st.st_mode & S_IFMT) != S_IFDIR)
+ return false;
+
+ return true;
+}

sys: filesystem isdir function