dirent.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* Directory entry structure `struct dirent'. 4.4BSD/Generic version.
  2. Copyright (C) 1996-2026 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef _DIRENT_H
  16. # error "Never use <bits/dirent.h> directly; include <dirent.h> instead."
  17. #endif
  18. struct dirent
  19. {
  20. #ifndef __USE_FILE_OFFSET64
  21. __ino_t d_ino; /* File serial number. */
  22. #else
  23. __ino64_t d_ino;
  24. #endif
  25. unsigned short int d_reclen; /* Length of the whole `struct dirent'. */
  26. unsigned char d_type; /* File type, possibly unknown. */
  27. unsigned char d_namlen; /* Length of the file name. */
  28. /* Only this member is in the POSIX standard. */
  29. char d_name[1]; /* File name (actually longer). */
  30. };
  31. #ifdef __USE_LARGEFILE64
  32. struct dirent64
  33. {
  34. __ino64_t d_ino;
  35. unsigned short int d_reclen;
  36. unsigned char d_type;
  37. unsigned char d_namlen;
  38. char d_name[1];
  39. };
  40. #endif
  41. #define d_fileno d_ino /* Backwards compatibility. */
  42. #define _DIRENT_HAVE_D_RECLEN 1
  43. #define _DIRENT_HAVE_D_NAMLEN 1
  44. #define _DIRENT_HAVE_D_TYPE 1
  45. #ifdef __INO_T_MATCHES_INO64_T
  46. /* Inform libc code that these two types are effectively identical. */
  47. # define _DIRENT_MATCHES_DIRENT64 1
  48. #else
  49. # define _DIRENT_MATCHES_DIRENT64 0
  50. #endif