summaryrefslogtreecommitdiff
path: root/src/file.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/file.h')
-rw-r--r--src/file.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/file.h b/src/file.h
new file mode 100644
index 0000000..1b46dd2
--- /dev/null
+++ b/src/file.h
@@ -0,0 +1,85 @@
+/*
+ * AUTHOR
+ * N. Nielsen
+ *
+ * LICENSE
+ * This software is in the public domain.
+ *
+ * The software is provided "as is", without warranty of any kind,
+ * express or implied, including but not limited to the warranties
+ * of merchantability, fitness for a particular purpose, and
+ * noninfringement. In no event shall the author(s) be liable for any
+ * claim, damages, or other liability, whether in an action of
+ * contract, tort, or otherwise, arising from, out of, or in connection
+ * with the software or the use or other dealings in the software.
+ *
+ * SUPPORT
+ * Send bug reports to: <nielsen@memberwebs.com>
+ */
+
+/* -------------------------------------------------------------------------
+ * Directory iterating routines and other handy stuff
+ */
+
+#ifndef __FILE_H__
+#define __FILE_H__
+
+#ifndef MAX_PATH
+#if defined(MAXNAMLEN)
+#define MAX_PATH MAXNAMLEN
+#elif defined(_MAX_FNAME)
+#define MAX_PATH _MAX_FNAME
+#else
+#define MAX_PATH 256
+#endif
+#endif
+
+#if HAVE_UNISTD_H && HAVE_DIRENT_H
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+
+#else
+
+
+struct dirent {
+ long d_fileno; /* file number of entry */
+ short d_reclen; /* length of this record */
+ unsigned char d_type; /* file type, see below */
+ unsigned char d_namlen; /* length of string in d_name */
+#ifdef _POSIX_SOURCE
+ char d_name[255 + 1]; /* name must be no longer than this */
+#else
+#define MAXNAMLEN 255
+ char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
+#endif
+};
+
+#define DT_UNKNOWN 0
+#define DT_FIFO 1
+#define DT_CHR 2
+#define DT_DIR 4
+#define DT_BLK 6
+#define DT_REG 8
+#define DT_LNK 10
+#define DT_SOCK 12
+#define DT_WHT 14
+
+typedef int DIR;
+
+#endif
+
+DIR* dir_first(const char* folder, const char* wildcard, struct dirent* entry);
+int dir_next(DIR* handle, const char* wildcard, struct dirent* entry);
+void dir_close(DIR* handle);
+
+#define INVALID_DIR ((DIR*)-1)
+
+const char* getFilename(const char* szPath);
+const char* getExtension(const char* szPath);
+int isDots(const char* szPath);
+int isDirectory(const char* szPath);
+
+#endif \ No newline at end of file