1/*
2 * Copyright 2002-2012 Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _DIRENT_H
6#define _DIRENT_H
7
8
9#include <sys/types.h>
10
11
12typedef struct dirent {
13	dev_t			d_dev;		/* device */
14	dev_t			d_pdev;		/* parent device (only for queries) */
15	ino_t			d_ino;		/* inode number */
16	ino_t			d_pino;		/* parent inode (only for queries) */
17	unsigned short	d_reclen;	/* length of this record, not the name */
18#if __GNUC__ == 2
19	char			d_name[0];	/* name of the entry (null byte terminated) */
20#else
21	char			d_name[];	/* name of the entry (null byte terminated) */
22#endif
23} dirent_t;
24
25typedef struct __DIR DIR;
26
27#ifndef MAXNAMLEN
28#	ifdef  NAME_MAX
29#		define MAXNAMLEN NAME_MAX
30#	else
31#		define MAXNAMLEN 256
32#	endif
33#endif
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39DIR*			fdopendir(int fd);
40DIR*			opendir(const char* dirName);
41struct dirent*	readdir(DIR* dir);
42int				readdir_r(DIR* dir, struct dirent* entry,
43					struct dirent** _result);
44int				closedir(DIR* dir);
45void			rewinddir(DIR* dir);
46void 			seekdir(DIR* dir, long int position);
47long int		telldir(DIR* dir);
48int				dirfd(DIR* dir);
49
50int				alphasort(const struct dirent** entry1,
51					const struct dirent** entry2);
52int				scandir(const char* dir, struct dirent*** _entryArray,
53					int (*selectFunc)(const struct dirent*),
54					int (*compareFunc)(const struct dirent** entry1,
55						const struct dirent** entry2));
56
57#ifdef __cplusplus
58}
59#endif
60
61#endif	/* _DIRENT_H */
62