fs.h 2.4 KB

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