summaryrefslogtreecommitdiff
path: root/win32/readdir.h
blob: 5c594fd7ea5e1cfadffb8d5be7241f3f26701a56 (plain)
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
#ifndef READDIR_H
#define READDIR_H


#ifdef __cplusplus
extern "C" {
#endif

/*
 * Structures and types used to implement opendir/readdir/closedir
 * on Windows.
 */

#include <config.w32.h>

#include "ioutil.h"

#define php_readdir_r readdir_r

/* struct dirent - same as Unix */
struct dirent {
	long d_ino;					/* inode (always 1 in WIN32) */
	off_t d_off;					/* offset to this dirent */
	unsigned short d_reclen;			/* length of d_name */
	unsigned short pad0;
#if defined(_WIN64)
	uint32_t pad1;
#endif
	char d_name[1];	/* null terminated filename in the current encoding, glyph number <= 255 wchar_t's + \0 byte */
};

/* typedef DIR - not the same as Unix */
struct DIR_W32 {
	HANDLE handle;			/* _findfirst/_findnext handle */
	uint16_t offset;		/* offset into directory */
	uint8_t finished;		/* 1 if there are not more files */
	WIN32_FIND_DATAW fileinfo;	/* from _findfirst/_findnext */
	wchar_t *dirw;			/* the dir we are reading */
	struct dirent dent;		/* the dirent to return */
};
typedef struct DIR_W32 DIR;

/* Function prototypes */
DIR *opendir(const char *);
struct dirent *readdir(DIR *);
int readdir_r(DIR *, struct dirent *, struct dirent **);
int closedir(DIR *);
int rewinddir(DIR *);

#ifdef __cplusplus
}
#endif

#endif /* READDIR_H */

/*
 * Local variables:
 * tab-width: 4
 * c-basic-offset: 4
 * End:
 * vim600: sw=4 ts=4 fdm=marker
 * vim<600: sw=4 ts=4
 */