utilunix.c(mc_tmpdir): Check return value of getpwuid() for NULL.
[midnight-commander.git] / src / fs.h
blob0adc8ccd56de04f68ca34850d29497a3c7c0de96
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_ISLNK
15 # define S_ISLNK(x) 0
16 #endif
18 #ifndef S_ISSOCK
19 # define S_ISSOCK(x) 0
20 #endif
22 #ifndef S_ISFIFO
23 # define S_ISFIFO(x) 0
24 #endif
26 #ifndef S_ISCHR
27 # define S_ISCHR(x) 0
28 #endif
30 #ifndef S_ISBLK
31 # define S_ISBLK(x) 0
32 #endif
34 /* Door is something that only exists on Solaris */
35 #ifndef S_ISDOOR
36 # define S_ISDOOR(x) 0
37 #endif
41 #ifndef MAXPATHLEN
42 # define MC_MAXPATHLEN 4096
43 #else
44 # define MC_MAXPATHLEN MAXPATHLEN
45 #endif
47 /* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */
48 #ifdef HAVE_DIRENT_H
49 # include <dirent.h>
50 # define NLENGTH(dirent) (strlen ((dirent)->d_name))
51 # define DIRENT_LENGTH_COMPUTED 1
52 #elif defined(_MSC_VER)
53 /* dirent provided by glib */
54 # define NLENGTH(dirent) (strlen ((dirent)->d_name))
55 # define DIRENT_LENGTH_COMPUTED 1
56 #else
57 # define dirent direct
58 # define NLENGTH(dirent) ((dirent)->d_namlen)
60 # ifdef HAVE_SYS_NDIR_H
61 # include <sys/ndir.h>
62 # endif /* HAVE_SYS_NDIR_H */
64 # ifdef HAVE_SYS_DIR_H
65 # include <sys/dir.h>
66 # endif /* HAVE_SYS_DIR_H */
68 # ifdef HAVE_NDIR_H
69 # include <ndir.h>
70 # endif /* HAVE_NDIR_H */
71 #endif /* not (HAVE_DIRENT_H or _POSIX_VERSION) */
73 static inline void
74 compute_namelen (struct dirent *dent __attribute__ ((unused)))
76 #ifdef DIRENT_LENGTH_COMPUTED
77 return;
78 #else
79 dent->d_namlen = strlen (dent);
80 #endif
83 #endif /* !__FS_H */