*** empty log message ***
[midnight-commander.git] / src / fs.h
blob1a5bae28fa5c474d89e4fac8a7a54fcd041bf6c6
1 /* Include file to use opendir/closedir/readdir */
3 #ifndef __FS_H
4 #define __FS_H
6 #include <sys/types.h>
7 #ifdef HAVE_UNISTD_H
8 # include <unistd.h>
9 #endif
10 #include <sys/stat.h>
13 /* Replacement for permission bits missing in sys/stat.h */
14 #ifndef S_IFLNK
15 # define S_IFLNK 0
16 #endif
18 #ifndef S_ISLNK
19 # define S_ISLNK(x) (((x) & S_IFLNK) == S_IFLNK)
20 #endif
22 #ifndef S_IFSOCK
23 # define S_IFSOCK 0
24 #endif
26 #ifndef S_ISSOCK
27 # define S_ISSOCK(x) (((x) & S_IFSOCK) == S_IFSOCK)
28 #endif
30 #ifndef S_IFFIFO
31 # define S_IFFIFO 0
32 #endif
34 #ifndef S_ISFIFO
35 # define S_ISFIFO(x) (((x) & S_IFFIFO) == S_IFFIFO)
36 #endif
38 #ifndef S_IFCHR
39 # define S_IFCHR 0
40 #endif
42 #ifndef S_ISCHR
43 # define S_ISCHR(x) (((x) & S_IFCHR) == S_IFCHR)
44 #endif
46 #ifndef S_IFBLK
47 # define S_IFBLK 0
48 #endif
50 #ifndef S_ISBLK
51 # define S_ISBLK(x) (((x) & S_IFBLK) == S_IFBLK)
52 #endif
55 #ifndef MAXPATHLEN
56 # define MC_MAXPATHLEN 4096
57 #else
58 # define MC_MAXPATHLEN MAXPATHLEN
59 #endif
61 /* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */
62 #ifdef HAVE_DIRENT_H
63 # include <dirent.h>
64 # define NLENGTH(dirent) (strlen ((dirent)->d_name))
65 # define DIRENT_LENGTH_COMPUTED 1
66 #elif defined(_MSC_VER)
67 /* dirent provided by glib */
68 # define NLENGTH(dirent) (strlen ((dirent)->d_name))
69 # define DIRENT_LENGTH_COMPUTED 1
70 #else
71 # define dirent direct
72 # define NLENGTH(dirent) ((dirent)->d_namlen)
74 # ifdef HAVE_SYS_NDIR_H
75 # include <sys/ndir.h>
76 # endif /* HAVE_SYS_NDIR_H */
78 # ifdef HAVE_SYS_DIR_H
79 # include <sys/dir.h>
80 # endif /* HAVE_SYS_DIR_H */
82 # ifdef HAVE_NDIR_H
83 # include <ndir.h>
84 # endif /* HAVE_NDIR_H */
85 #endif /* not (HAVE_DIRENT_H or _POSIX_VERSION) */
87 static inline void compute_namelen(struct dirent* dent) {
88 #ifdef DIRENT_LENGTH_COMPUTED
89 return;
90 #else
91 dent->d_namlen = strlen (dent);
92 #endif
95 #endif /* !__FS_H */