]> git.sesse.net Git - vlc/blob - src/extras/dirent.h
* ./Makefile.am: added a "update-vlc.dsp" rule to create the MSVC project
[vlc] / src / extras / dirent.h
1 /*
2  * DIRENT.H (formerly DIRLIB.H)
3  *
4  * by M. J. Weinstein   Released to public domain 1-Jan-89
5  *
6  * Because I have heard that this feature (opendir, readdir, closedir)
7  * it so useful for programmers coming from UNIX or attempting to port
8  * UNIX code, and because it is reasonably light weight, I have included
9  * it in the Mingw32 package. I have also added an implementation of
10  * rewinddir, seekdir and telldir.
11  *   - Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
12  *
13  *  This code is distributed in the hope that is will be useful but
14  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
15  *  DISCLAIMED. This includeds but is not limited to warranties of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17  *
18  * $Revision: 1.1 $
19  * $Author: sam $
20  * $Date: 2002/11/09 16:34:52 $
21  *
22  */
23
24 #ifndef __STRICT_ANSI__
25
26 #ifndef _DIRENT_H_
27 #define _DIRENT_H_
28
29 #include <io.h>
30
31 #ifndef RC_INVOKED
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 struct dirent
38 {
39         long            d_ino;          /* Always zero. */
40         unsigned short  d_reclen;       /* Always zero. */
41         unsigned short  d_namlen;       /* Length of name in d_name. */
42         char*           d_name;         /* File name. */
43         /* NOTE: The name in the dirent structure points to the name in the
44          *       finddata_t structure in the DIR. */
45 };
46
47 /*
48  * This is an internal data structure. Good programmers will not use it
49  * except as an argument to one of the functions below.
50  */
51 typedef struct
52 {
53         /* disk transfer area for this dir */
54         struct _finddata_t      dd_dta;
55
56         /* dirent struct to return from dir (NOTE: this makes this thread
57          * safe as long as only one thread uses a particular DIR struct at
58          * a time) */
59         struct dirent           dd_dir;
60
61         /* _findnext handle */
62         long                    dd_handle;
63
64         /*
65          * Status of search:
66          *   0 = not started yet (next entry to read is first entry)
67          *  -1 = off the end
68          *   positive = 0 based index of next entry
69          */
70         short                   dd_stat;
71
72         /* given path for dir with search pattern (struct is extended) */
73         char                    dd_name[1];
74 } DIR;
75
76
77
78 DIR*            opendir (const char*);
79 struct dirent*  readdir (DIR*);
80 int             closedir (DIR*);
81 void            rewinddir (DIR*);
82 long            telldir (DIR*);
83 void            seekdir (DIR*, long);
84
85
86 /* wide char versions */
87
88 struct _wdirent
89 {
90         long            d_ino;          /* Always zero. */
91         unsigned short  d_reclen;       /* Always zero. */
92         unsigned short  d_namlen;       /* Length of name in d_name. */
93         wchar_t*        d_name;         /* File name. */
94         /* NOTE: The name in the dirent structure points to the name in the
95          *       wfinddata_t structure in the _WDIR. */
96 };
97
98 /*
99  * This is an internal data structure. Good programmers will not use it
100  * except as an argument to one of the functions below.
101  */
102 typedef struct
103 {
104         /* disk transfer area for this dir */
105         struct _wfinddata_t     dd_dta;
106
107         /* dirent struct to return from dir (NOTE: this makes this thread
108          * safe as long as only one thread uses a particular DIR struct at
109          * a time) */
110         struct _wdirent         dd_dir;
111
112         /* _findnext handle */
113         long                    dd_handle;
114
115         /*
116          * Status of search:
117          *   0 = not started yet (next entry to read is first entry)
118          *  -1 = off the end
119          *   positive = 0 based index of next entry
120          */
121         short                   dd_stat;
122
123         /* given path for dir with search pattern (struct is extended) */
124         wchar_t                 dd_name[1];
125 } _WDIR;
126
127
128
129 _WDIR*          _wopendir (const wchar_t*);
130 struct _wdirent* _wreaddir (_WDIR*);
131 int             _wclosedir (_WDIR*);
132 void            _wrewinddir (_WDIR*);
133 long            _wtelldir (_WDIR*);
134 void            _wseekdir (_WDIR*, long);
135
136
137 #ifdef  __cplusplus
138 }
139 #endif
140
141 #endif  /* Not RC_INVOKED */
142
143 #endif  /* Not _DIRENT_H_ */
144
145 #endif  /* Not __STRICT_ANSI__ */
146