Merge from emacs-24; up to 2014-05-15T16:55:18Z!jan.h.d@swipnet.se
[bpt/emacs.git] / nt / inc / dirent.h
CommitLineData
d427b66a 1/*
95ef7787 2 <dirent.h> -- definitions for POSIX-compatible directory access
d427b66a 3
14216c95
GM
4 * The code here is forced by the interface, and is not subject to
5 * copyright, constituting the only possible expression of the
6 * algorithm in this format.
7 */
d427b66a
JB
8
9#define DIRBLKSIZ 512 /* size of directory block */
6cc1fc1d
RS
10#ifdef WINDOWSNT
11#define MAXNAMLEN 255
12#else /* not WINDOWSNT */
d427b66a 13#define MAXNAMLEN 15 /* maximum filename length */
6cc1fc1d 14#endif /* not WINDOWSNT */
d427b66a
JB
15 /* NOTE: MAXNAMLEN must be one less than a multiple of 4 */
16
95ef7787 17struct dirent /* data from readdir() */
d427b66a
JB
18 {
19 long d_ino; /* inode number of entry */
20 unsigned short d_reclen; /* length of this record */
21 unsigned short d_namlen; /* length of string in d_name */
2f4586ad
EZ
22#if __MINGW_MAJOR_VERSION >= 4
23 /* MinGW.org runtime 4.x introduces a modified layout of
24 'struct dirent', which makes it binary incompatible with
25 previous versions. To add insult to injury, the MinGW
26 startup code calls 'readdir', which is implemented in
27 w32.c. So we need to define the same layout of this struct
28 as the MinGW runtime does, or else command-line globbing
29 will be broken. (Versions of MinGW runtime after 4.0 are
30 supposed not to call 'readdir' from startup code, but we
31 had better be safe than sorry.) */
32 unsigned d_type; /* File attributes */
33 /* The next 3 fields are declared 'time_t' in the MinGW 4.0
34 headers, but 'time_t' is by default a 64-bit type in 4.x,
35 and presumably the libmingwex library was compiled using
36 that default definition. So we must use 64-bit types here,
37 even though our time_t is a 32-bit type. What a mess! */
38 __int64 d_time_create;
39 __int64 d_time_access; /* always midnight local time */
40 __int64 d_time_write;
41 _fsize_t d_size;
42#endif
0b9de7cd 43 char d_name[MAXNAMLEN * 4 + 1]; /* name of file */
d427b66a
JB
44 };
45
46typedef struct
47 {
48 int dd_fd; /* file descriptor */
49 int dd_loc; /* offset in block */
50 int dd_size; /* amount of valid data */
51 char dd_buf[DIRBLKSIZ]; /* directory block */
52 } DIR; /* stream data from opendir() */
53
cf01a359 54extern DIR *opendir (const char *);
95ef7787 55extern struct dirent *readdir (DIR *);
361358ea
JB
56extern void seekdir (DIR *, long);
57extern void closedir (DIR *);
d427b66a
JB
58
59#define rewinddir( dirp ) seekdir( dirp, 0L )