(create_sequence): reduce variable scope, trivial refactoring.
[midnight-commander.git] / lib / fs.h
blobbb4c705dc8ddcc5fa0a9c0d8c75ddfad47f9e743
1 /** \file fs.h
2 * \brief Header: fs compatibility definitions
3 */
5 /* Include file to use opendir/closedir/readdir */
7 #ifndef MC_FS_H
8 #define MC_FS_H
10 #include <sys/types.h>
11 #include <unistd.h>
12 #include <sys/stat.h>
13 #include <dirent.h>
15 /*** typedefs(not structures) and defined constants **********************************************/
17 #ifdef S_ISREG
18 #define HAVE_S_ISREG 1
19 #else
20 #define HAVE_S_ISREG 0
21 #define S_ISREG(x) 0
22 #endif
24 #ifdef S_ISDIR
25 #define HAVE_S_ISDIR 1
26 #else
27 #define HAVE_S_ISDIR 0
28 #define S_ISDIR(x) 0
29 #endif
31 /* Replacement for permission bits missing in sys/stat.h */
32 #ifdef S_ISLNK
33 #define HAVE_S_ISLNK 1
34 #else
35 #define HAVE_S_ISLNK 0
36 #define S_ISLNK(x) 0
37 #endif
39 #ifdef S_ISSOCK
40 #define HAVE_S_ISSOCK 1
41 #else
42 #define HAVE_S_ISSOCK 0
43 #define S_ISSOCK(x) 0
44 #endif
46 #ifdef S_ISFIFO
47 #define HAVE_S_ISFIFO 1
48 #else
49 #define HAVE_S_ISFIFO 0
50 #define S_ISFIFO(x) 0
51 #endif
53 #ifdef S_ISCHR
54 #define HAVE_S_ISCHR 1
55 #else
56 #define HAVE_S_ISCHR 0
57 #define S_ISCHR(x) 0
58 #endif
60 #ifdef S_ISBLK
61 #define HAVE_S_ISBLK 1
62 #else
63 #define HAVE_S_ISBLK 0
64 #define S_ISBLK(x) 0
65 #endif
67 /* Door is something that only exists on Solaris */
68 #ifdef S_ISDOOR
69 #define HAVE_S_ISDOOR 1
70 #else
71 #define HAVE_S_ISDOOR 0
72 #define S_ISDOOR(x) 0
73 #endif
75 /* Special named files are widely used in QNX6 */
76 #ifdef S_ISNAM
77 #define HAVE_S_ISNAM 1
78 #else
79 #define HAVE_S_ISNAM 0
80 #define S_ISNAM(x) 0
81 #endif
83 #ifndef PATH_MAX
84 #ifdef _POSIX_VERSION
85 #define PATH_MAX _POSIX_PATH_MAX
86 #else
87 #ifdef MAXPATHLEN
88 #define PATH_MAX MAXPATHLEN
89 #else
90 #define PATH_MAX 1024
91 #endif
92 #endif
93 #endif
95 #ifndef MAXPATHLEN
96 #define MC_MAXPATHLEN 4096
97 #else
98 #define MC_MAXPATHLEN MAXPATHLEN
99 #endif
101 /* DragonFlyBSD doesn't provide MAXNAMLEN macro */
102 #ifndef MAXNAMLEN
103 #define MAXNAMLEN NAME_MAX
104 #endif
106 #define MC_MAXFILENAMELEN MAXNAMLEN
108 #define DIR_IS_DOT(x) ((x)[0] == '.' && (x)[1] == '\0')
109 #define DIR_IS_DOTDOT(x) ((x)[0] == '.' && (x)[1] == '.' && (x)[2] == '\0')
111 /*** enums ***************************************************************************************/
113 /*** structures declarations (and typedefs of structures)*****************************************/
115 /*** global variables defined in .c file *********************************************************/
117 /*** declarations of public functions ************************************************************/
119 /*** inline functions ****************************************************************************/
121 #endif