fs.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. /*** 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. (void) dent;
  70. return;
  71. #else
  72. dent->d_namlen = strlen (dent);
  73. #endif
  74. }
  75. #endif