/
dirstuff.h
126 lines (108 loc) · 2.53 KB
/
dirstuff.h
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
* dirstuff.h
*
* Definitions to interface to unix-like DIRECTORY(3) procedures.
* Include this after "estruct.h"
*
* $Header: /usr/build/VCS/pgf-vile/RCS/dirstuff.h,v 1.22 1996/03/28 12:53:33 pgf Exp $
*
*/
#ifndef DIRSTUFF_H
#define DIRSTUFF_H
#if ! SYS_VMS
#define USE_LS_FOR_DIRS 0
#define OLD_STYLE_DIRS 0 /* e.g., pre-SysV.2 14-char names */
#if DIRNAMES_NOT_NULL_TERMINATED
/* rumor has it that some early readdir implementations didn't null-terminate
the d_name array, and on those you _have_ to use d_namlen to get
the length. most modern dirent structs are null-terminated, however. */
#define USE_D_NAMLEN 1
#endif
#if _POSIX_VERSION || HAVE_DIRENT_H || CC_TURBO || CC_WATCOM || CC_DJGPP || SYS_OS2
# if CC_WATCOM || CC_CSETPP
# include <direct.h>
# else
# include <dirent.h>
# endif
# define DIRENT struct dirent
#else /* apollo & other old bsd's */
# define DIRENT struct direct
# define USE_D_NAMLEN 1
# if HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# else
# if HAVE_SYS_DIR_H
# include <sys/dir.h>
# else
# if HAVE_NDIR_H
# include <ndir.h>
# else
# if SYS_WINNT
# if CC_MSVC
# include <direct.h>
# else
# include <dirent.h>
# endif
# undef USE_D_NAMLEN
# define USE_D_NAMELEN 0
struct direct {
char *d_name;
};
struct _dirdesc {
HANDLE hFindFile;
WIN32_FIND_DATA ffd;
int first;
struct direct de;
};
typedef struct _dirdesc DIR;
# else /* SYS_WINNT */
# undef USE_LS_FOR_DIRS
# define USE_LS_FOR_DIRS 1
# undef USE_D_NAMLEN
# define USE_D_NAMELEN 1
# endif /* SYS_WINNT */
# endif
# endif
# endif
#endif
#else /* SYS_VMS */
#include <rms.h>
#include <descrip.h>
#define USE_D_NAMLEN 1
typedef struct {
ULONG d_ino;
short d_reclen;
short d_namlen;
char d_name[NAM$C_MAXRSS]; /* result: SYS$SEARCH */
} DIRENT;
typedef struct {
DIRENT dd_ret;
struct FAB dd_fab;
struct NAM dd_nam;
char dd_esa[NAM$C_MAXRSS]; /* expanded: SYS$PARSE */
} DIR;
#endif /* SYS_VMS */
#if USE_LS_FOR_DIRS
#define DIR FILE
typedef struct {
char d_name[NFILEN];
} DIRENT;
#endif
#if SYS_WINNT && !CC_TURBO || SYS_VMS || USE_LS_FOR_DIRS
extern DIR * opendir ( char *path );
extern DIRENT *readdir ( DIR *dp );
extern int closedir ( DIR *dp );
#endif
#if OLD_STYLE_DIRS
this ifdef is untested
#define USE_D_NAMLEN 1
#define DIR FILE
#define DIRENT struct direct
#define opendir(n) fopen(n,"r")
extern DIRENT *readdir ( DIR *dp );
#define closedir(dp) fclose(dp)
#endif
#ifndef USE_D_NAMLEN
#define USE_D_NAMLEN 0
#endif
#endif /* DIRSTUFF_H */