/* * 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: */ /* ------------------------------------------------------------------------- * 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 #include #include #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