| 1 |
// |
| 2 |
// 03/10/2006 James Haley |
| 3 |
// |
| 4 |
// For this module only: |
| 5 |
// This code is public domain. No change sufficient enough to constitute a |
| 6 |
// significant or original work has been made, and thus it remains as such. |
| 7 |
// |
| 8 |
// |
| 9 |
// DESCRIPTION: |
| 10 |
// |
| 11 |
// Implementation of POSIX opendir for Visual C++. |
| 12 |
// Derived from the MinGW C Library Extensions Source (released to the |
| 13 |
// public domain). |
| 14 |
// |
| 15 |
|
| 16 |
#ifndef I_OPNDIR_H__ |
| 17 |
#define I_OPNDIR_H__ |
| 18 |
|
| 19 |
#include <io.h> |
| 20 |
|
| 21 |
#ifndef FILENAME_MAX |
| 22 |
#define FILENAME_MAX 260 |
| 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[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 |
struct _finddata_t dd_dta; |
| 42 |
|
| 43 |
/* dirent struct to return from dir (NOTE: this makes this thread |
| 44 |
* safe as long as only one thread uses a particular DIR struct at |
| 45 |
* a time) */ |
| 46 |
struct dirent dd_dir; |
| 47 |
|
| 48 |
/* _findnext handle */ |
| 49 |
intptr_t dd_handle; |
| 50 |
|
| 51 |
/* |
| 52 |
* Status of search: |
| 53 |
* 0 = not started yet (next entry to read is first entry) |
| 54 |
* -1 = off the end |
| 55 |
* positive = 0 based index of next entry |
| 56 |
*/ |
| 57 |
int dd_stat; |
| 58 |
|
| 59 |
/* given path for dir with search pattern (struct is extended) */ |
| 60 |
char dd_name[1]; |
| 61 |
} DIR; |
| 62 |
|
| 63 |
DIR *opendir(const char *); |
| 64 |
struct dirent *readdir(DIR *); |
| 65 |
int closedir(DIR *); |
| 66 |
void rewinddir(DIR *); |
| 67 |
long telldir(DIR *); |
| 68 |
void seekdir(DIR *, long); |
| 69 |
|
| 70 |
#endif |
| 71 |
|
| 72 |
// EOF |
| 73 |
|