(input_execute_cmd): refactoring.
[midnight-commander.git] / lib / fs.h
blob24cc94350fd382bbfe1880ff65f35b6d55790d61
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 /* Replacement for permission bits missing in sys/stat.h */
18 #ifndef S_ISLNK
19 #define S_ISLNK(x) 0
20 #endif
22 #ifndef S_ISSOCK
23 #define S_ISSOCK(x) 0
24 #endif
26 #ifndef S_ISFIFO
27 #define S_ISFIFO(x) 0
28 #endif
30 #ifndef S_ISCHR
31 #define S_ISCHR(x) 0
32 #endif
34 #ifndef S_ISBLK
35 #define S_ISBLK(x) 0
36 #endif
38 /* Door is something that only exists on Solaris */
39 #ifndef S_ISDOOR
40 #define S_ISDOOR(x) 0
41 #endif
43 /* Special named files are widely used in QNX6 */
44 #ifndef S_ISNAM
45 #define S_ISNAM(x) 0
46 #endif
48 #ifndef PATH_MAX
49 #ifdef _POSIX_VERSION
50 #define PATH_MAX _POSIX_PATH_MAX
51 #else
52 #ifdef MAXPATHLEN
53 #define PATH_MAX MAXPATHLEN
54 #else
55 #define PATH_MAX 1024
56 #endif
57 #endif
58 #endif
60 #ifndef MAXPATHLEN
61 #define MC_MAXPATHLEN 4096
62 #else
63 #define MC_MAXPATHLEN MAXPATHLEN
64 #endif
66 /* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */
67 #define NLENGTH(dirent) (strlen ((dirent)->d_name))
68 #define DIRENT_LENGTH_COMPUTED 1
70 /* DragonFlyBSD doesn't provide MAXNAMLEN macro */
71 #ifndef MAXNAMLEN
72 #define MAXNAMLEN NAME_MAX
73 #endif
75 #define MC_MAXFILENAMELEN MAXNAMLEN
77 #define DIR_IS_DOT(x) ((x)[0] == '.' && (x)[1] == '\0')
78 #define DIR_IS_DOTDOT(x) ((x)[0] == '.' && (x)[1] == '.' && (x)[2] == '\0')
80 /*** enums ***************************************************************************************/
82 /*** structures declarations (and typedefs of structures)*****************************************/
84 /*** global variables defined in .c file *********************************************************/
86 /*** declarations of public functions ************************************************************/
88 /*** inline functions ****************************************************************************/
90 static inline void
91 compute_namelen (struct dirent *dent __attribute__ ((unused)))
93 #ifdef DIRENT_LENGTH_COMPUTED
94 (void) dent;
95 return;
96 #else
97 dent->d_namlen = strlen (dent);
98 #endif
101 #endif