File: dirent.h

package info (click to toggle)
rust-git-cinnabar 0.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,372 kB
  • sloc: ansic: 300,181; makefile: 2,754; sh: 118
file content (34 lines) | stat: -rw-r--r-- 834 bytes parent folder | download
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
#ifndef DIRENT_H
#define DIRENT_H

#define DT_UNKNOWN 0
#define DT_DIR     1
#define DT_REG     2
#define DT_LNK     3

struct dirent {
	unsigned char d_type; /* file type to prevent lstat after readdir */
	char d_name[FLEX_ARRAY]; /* file name */
};

/*
 * Base DIR structure, contains pointers to readdir/closedir implementations so
 * that opendir may choose a concrete implementation on a call-by-call basis.
 */
typedef struct DIR {
	struct dirent *(*preaddir)(struct DIR *dir);
	int (*pclosedir)(struct DIR *dir);
} DIR;

/* default dirent implementation */
extern DIR *dirent_opendir(const char *dirname);

#define opendir git_opendir

/* current dirent implementation */
extern DIR *(*opendir)(const char *dirname);

#define readdir(dir) (dir->preaddir(dir))
#define closedir(dir) (dir->pclosedir(dir))

#endif /* DIRENT_H */