dirent.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * DIRENT.H (formerly DIRLIB.H)
  3. *
  4. * by M. J. Weinstein Released to public domain 1-Jan-89
  5. *
  6. * Because I have heard that this feature (opendir, readdir, closedir)
  7. * it so useful for programmers coming from UNIX or attempting to port
  8. * UNIX code, and because it is reasonably light weight, I have included
  9. * it in the Mingw32 package. I have also added an implementation of
  10. * rewinddir, seekdir and telldir.
  11. * - Colin Peters <[email protected]>
  12. *
  13. * This code is distributed in the hope that is will be useful but
  14. * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  15. * DISCLAIMED. This includeds but is not limited to warranties of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. *
  18. * $Revision: 1.2 $
  19. * $Author: bellard $
  20. * $Date: 2005/04/17 13:14:29 $
  21. *
  22. */
  23. #ifndef __STRICT_ANSI__
  24. #ifndef _DIRENT_H_
  25. #define _DIRENT_H_
  26. /* All the headers include this file. */
  27. #include <_mingw.h>
  28. #include <io.h>
  29. #ifndef RC_INVOKED
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. struct dirent
  34. {
  35. long d_ino; /* Always zero. */
  36. unsigned short d_reclen; /* Always zero. */
  37. unsigned short d_namlen; /* Length of name in d_name. */
  38. char* d_name; /* File name. */
  39. /* NOTE: The name in the dirent structure points to the name in the
  40. * finddata_t structure in the DIR. */
  41. };
  42. /*
  43. * This is an internal data structure. Good programmers will not use it
  44. * except as an argument to one of the functions below.
  45. */
  46. typedef struct
  47. {
  48. /* disk transfer area for this dir */
  49. struct _finddata_t dd_dta;
  50. /* dirent struct to return from dir (NOTE: this makes this thread
  51. * safe as long as only one thread uses a particular DIR struct at
  52. * a time) */
  53. struct dirent dd_dir;
  54. /* _findnext handle */
  55. long dd_handle;
  56. /*
  57. * Status of search:
  58. * 0 = not started yet (next entry to read is first entry)
  59. * -1 = off the end
  60. * positive = 0 based index of next entry
  61. */
  62. short dd_stat;
  63. /* given path for dir with search pattern (struct is extended) */
  64. char dd_name[1];
  65. } DIR;
  66. DIR* opendir (const char*);
  67. struct dirent* readdir (DIR*);
  68. int closedir (DIR*);
  69. void rewinddir (DIR*);
  70. long telldir (DIR*);
  71. void seekdir (DIR*, long);
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif /* Not RC_INVOKED */
  76. #endif /* Not _DIRENT_H_ */
  77. #endif /* Not __STRICT_ANSI__ */