1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
|