fs.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. /* Replacement for permission bits missing in sys/stat.h */
  13. #ifndef S_ISLNK
  14. #define S_ISLNK(x) 0
  15. #endif
  16. #ifndef S_ISSOCK
  17. #define S_ISSOCK(x) 0
  18. #endif
  19. #ifndef S_ISFIFO
  20. #define S_ISFIFO(x) 0
  21. #endif
  22. #ifndef S_ISCHR
  23. #define S_ISCHR(x) 0
  24. #endif
  25. #ifndef S_ISBLK
  26. #define S_ISBLK(x) 0
  27. #endif
  28. /* Door is something that only exists on Solaris */
  29. #ifndef S_ISDOOR
  30. #define S_ISDOOR(x) 0
  31. #endif
  32. /* Special named files are widely used in QNX6 */
  33. #ifndef S_ISNAM
  34. #define S_ISNAM(x) 0
  35. #endif
  36. #ifndef PATH_MAX
  37. #ifdef _POSIX_VERSION
  38. #define PATH_MAX _POSIX_PATH_MAX
  39. #else
  40. #ifdef MAXPATHLEN
  41. #define PATH_MAX MAXPATHLEN
  42. #else
  43. #define PATH_MAX 1024
  44. #endif
  45. #endif
  46. #endif
  47. #ifndef MAXPATHLEN
  48. #define MC_MAXPATHLEN 4096
  49. #else
  50. #define MC_MAXPATHLEN MAXPATHLEN
  51. #endif
  52. /* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */
  53. #define NLENGTH(dirent) (strlen ((dirent)->d_name))
  54. #define DIRENT_LENGTH_COMPUTED 1
  55. /* DragonFlyBSD doesn't provide MAXNAMLEN macro */
  56. #ifndef MAXNAMLEN
  57. #define MAXNAMLEN NAME_MAX
  58. #endif
  59. #define MC_MAXFILENAMELEN MAXNAMLEN
  60. #define DIR_IS_DOT(x) ((x)[0] == '.' && (x)[1] == '\0')
  61. #define DIR_IS_DOTDOT(x) ((x)[0] == '.' && (x)[1] == '.' && (x)[2] == '\0')
  62. /*** enums ***************************************************************************************/
  63. /*** structures declarations (and typedefs of structures)*****************************************/
  64. /*** global variables defined in .c file *********************************************************/
  65. /*** declarations of public functions ************************************************************/
  66. /*** inline functions ****************************************************************************/
  67. static inline void
  68. compute_namelen (struct dirent *dent __attribute__ ((unused)))
  69. {
  70. #ifdef DIRENT_LENGTH_COMPUTED
  71. (void) dent;
  72. return;
  73. #else
  74. dent->d_namlen = strlen (dent);
  75. #endif
  76. }
  77. #endif