| 1 | /* |
| 2 | * DIRENT.H (formerly DIRLIB.H) |
| 3 | * This file has no copyright assigned and is placed in the Public Domain. |
| 4 | * This file is part of the mingw-runtime package. |
| 5 | * No warranty is given; refer to the file DISCLAIMER within the package. |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #ifndef _DIRENT_H_ |
| 10 | #define _DIRENT_H_ |
| 11 | |
| 12 | /* All the headers include this file. */ |
| 13 | #include <crtdefs.h> |
| 14 | |
| 15 | #include <io.h> |
| 16 | |
| 17 | #ifndef RC_INVOKED |
| 18 | |
| 19 | #pragma pack(push,_CRT_PACKING) |
| 20 | |
| 21 | #ifdef __cplusplus |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | struct dirent |
| 26 | { |
| 27 | 	long		d_ino;		/* Always zero. */ |
| 28 | 	unsigned short	d_reclen;	/* Always zero. */ |
| 29 | 	unsigned short	d_namlen;	/* Length of name in d_name. */ |
| 30 | 	char		d_name[260]; /* [FILENAME_MAX] */ /* File name. */ |
| 31 | }; |
| 32 | |
| 33 | /* |
| 34 | * This is an internal data structure. Good programmers will not use it |
| 35 | * except as an argument to one of the functions below. |
| 36 | * dd_stat field is now int (was short in older versions). |
| 37 | */ |
| 38 | typedef struct |
| 39 | { |
| 40 | 	/* disk transfer area for this dir */ |
| 41 | #ifdef _WIN64 |
| 42 | 	struct _finddata64i32_t	dd_dta; |
| 43 | #else |
| 44 | 	struct _finddata32_t	dd_dta; |
| 45 | #endif |
| 46 | |
| 47 | 	/* dirent struct to return from dir (NOTE: this makes this thread |
| 48 | 	 * safe as long as only one thread uses a particular DIR struct at |
| 49 | 	 * a time) */ |
| 50 | 	struct dirent		dd_dir; |
| 51 | |
| 52 | 	/* _findnext handle */ |
| 53 | 	intptr_t		dd_handle; |
| 54 | |
| 55 | 	/* |
| 56 | 	 * Status of search: |
| 57 | 	 * 0 = not started yet (next entry to read is first entry) |
| 58 | 	 * -1 = off the end |
| 59 | 	 * positive = 0 based index of next entry |
| 60 | 	 */ |
| 61 | 	int			dd_stat; |
| 62 | |
| 63 | 	/* given path for dir with search pattern (struct is extended) */ |
| 64 | 	char			dd_name[1]; |
| 65 | } DIR; |
| 66 | |
| 67 | DIR* __cdecl __MINGW_NOTHROW opendir (const char*); |
| 68 | struct dirent* __cdecl __MINGW_NOTHROW readdir (DIR*); |
| 69 | int __cdecl __MINGW_NOTHROW closedir (DIR*); |
| 70 | void __cdecl __MINGW_NOTHROW rewinddir (DIR*); |
| 71 | long __cdecl __MINGW_NOTHROW telldir (DIR*); |
| 72 | void __cdecl __MINGW_NOTHROW seekdir (DIR*, long); |
| 73 | |
| 74 | |
| 75 | /* wide char versions */ |
| 76 | |
| 77 | struct _wdirent |
| 78 | { |
| 79 | 	long		d_ino;		/* Always zero. */ |
| 80 | 	unsigned short	d_reclen;	/* Always zero. */ |
| 81 | 	unsigned short	d_namlen;	/* Length of name in d_name. */ |
| 82 | 	wchar_t		d_name[260]; /* [FILENAME_MAX] */ /* File name. */ |
| 83 | }; |
| 84 | |
| 85 | /* |
| 86 | * This is an internal data structure. Good programmers will not use it |
| 87 | * except as an argument to one of the functions below. |
| 88 | */ |
| 89 | typedef struct |
| 90 | { |
| 91 | 	/* disk transfer area for this dir */ |
| 92 | #ifdef _WIN64 |
| 93 | 	struct _wfinddata64i32_t	dd_dta; |
| 94 | #else |
| 95 | 	struct _wfinddata32_t	dd_dta; |
| 96 | #endif |
| 97 | |
| 98 | 	/* dirent struct to return from dir (NOTE: this makes this thread |
| 99 | 	 * safe as long as only one thread uses a particular DIR struct at |
| 100 | 	 * a time) */ |
| 101 | 	struct _wdirent		dd_dir; |
| 102 | |
| 103 | 	/* _findnext handle */ |
| 104 | 	intptr_t		dd_handle; |
| 105 | |
| 106 | 	/* |
| 107 | 	 * Status of search: |
| 108 | 	 * 0 = not started yet (next entry to read is first entry) |
| 109 | 	 * -1 = off the end |
| 110 | 	 * positive = 0 based index of next entry |
| 111 | 	 */ |
| 112 | 	int			dd_stat; |
| 113 | |
| 114 | 	/* given path for dir with search pattern (struct is extended) */ |
| 115 | 	wchar_t			dd_name[1]; |
| 116 | } _WDIR; |
| 117 | |
| 118 | _WDIR* __cdecl __MINGW_NOTHROW _wopendir (const wchar_t*); |
| 119 | struct _wdirent* __cdecl __MINGW_NOTHROW _wreaddir (_WDIR*); |
| 120 | int __cdecl __MINGW_NOTHROW _wclosedir (_WDIR*); |
| 121 | void __cdecl __MINGW_NOTHROW _wrewinddir (_WDIR*); |
| 122 | long __cdecl __MINGW_NOTHROW _wtelldir (_WDIR*); |
| 123 | void __cdecl __MINGW_NOTHROW _wseekdir (_WDIR*, long); |
| 124 | |
| 125 | |
| 126 | #ifdef	__cplusplus |
| 127 | } |
| 128 | #endif |
| 129 | |
| 130 | #pragma pack(pop) |
| 131 | |
| 132 | #endif	/* Not RC_INVOKED */ |
| 133 | |
| 134 | #endif	/* Not _DIRENT_H_ */ |
| 135 | |