win32_dirent.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 <colin@bird.fu.is.saga-u.ac.jp>
  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. * Martin Otter, 2001/01/06:
  19. * Removed: #ifndef __STRICT_ANSI__
  20. * #include <_mingw.h>
  21. * since not needed in Modelica
  22. */
  23. #ifndef _DIRENT_H_
  24. #define _DIRENT_H_
  25. #if defined(_WIN32) && (defined(_MSC_VER) || defined(__GNUC__) && defined(DYMOSIM))
  26. #include <io.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. struct dirent
  31. {
  32. int d_ino; /* Always zero. */
  33. unsigned short d_reclen; /* Always zero. */
  34. unsigned short d_namlen; /* Length of name in d_name. */
  35. char* d_name; /* File name. */
  36. /* NOTE: The name in the dirent structure points to the name in the
  37. * finddata_t structure in the DIR. */
  38. };
  39. /*
  40. * This is an internal data structure. Good programmers will not use it
  41. * except as an argument to one of the functions below.
  42. */
  43. typedef struct
  44. {
  45. /* disk transfer area for this dir */
  46. struct _finddata_t dd_dta;
  47. /* dirent struct to return from dir (NOTE: this makes this thread
  48. * safe as long as only one thread uses a particular DIR struct at
  49. * a time) */
  50. struct dirent dd_dir;
  51. /* _findnext handle */
  52. int dd_handle;
  53. /*
  54. * Status of search:
  55. * 0 = not started yet (next entry to read is first entry)
  56. * -1 = off the end
  57. * positive = 0 based index of next entry
  58. */
  59. short dd_stat;
  60. /* given path for dir with search pattern (struct is extended) */
  61. char dd_name[1];
  62. } DIR;
  63. DIR* opendir (const char*);
  64. struct dirent* readdir (DIR*);
  65. int closedir (DIR*);
  66. void rewinddir (DIR*);
  67. int telldir (DIR*);
  68. void seekdir (DIR*, int);
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72. #endif /*defined(_WIN32) && (defined(_MSC_VER) || defined(__GNUC__) && defined(DYMOSIM))*/
  73. #endif /* Not _DIRENT_H_ */