fs.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #ifndef MAXNAMLEN
  56. #define MC_MAXFILENAMELEN 256
  57. #else
  58. #define MC_MAXFILENAMELEN MAXNAMLEN
  59. #endif
  60. /*** enums ***************************************************************************************/
  61. /*** structures declarations (and typedefs of structures)*****************************************/
  62. /*** global variables defined in .c file *********************************************************/
  63. /*** declarations of public functions ************************************************************/
  64. /*** inline functions ****************************************************************************/
  65. static inline void
  66. compute_namelen (struct dirent *dent __attribute__ ((unused)))
  67. {
  68. #ifdef DIRENT_LENGTH_COMPUTED
  69. return;
  70. #else
  71. dent->d_namlen = strlen (dent);
  72. #endif
  73. }
  74. #endif