home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / cwin / c.exe / $INSTDIR / include / dirent.h < prev    next >
Encoding:
C/C++ Source or Header  |  2003-12-15  |  3.6 KB  |  148 lines

  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.  * $Revision: 1.4 $
  19.  * $Author: earnie $
  20.  * $Date: 2002/06/14 15:12:54 $
  21.  *
  22.  */
  23.  
  24. #ifndef    __STRICT_ANSI__
  25.  
  26. #ifndef _DIRENT_H_
  27. #define _DIRENT_H_
  28.  
  29. /* All the headers include this file. */
  30. #include <_mingw.h>
  31.  
  32. #include <io.h>
  33.  
  34. #ifndef RC_INVOKED
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. struct dirent
  41. {
  42.     long        d_ino;        /* Always zero. */
  43.     unsigned short    d_reclen;    /* Always zero. */
  44.     unsigned short    d_namlen;    /* Length of name in d_name. */
  45.     char*        d_name;        /* File name. */
  46.     /* NOTE: The name in the dirent structure points to the name in the
  47.      *       finddata_t structure in the DIR. */
  48. };
  49.  
  50. /*
  51.  * This is an internal data structure. Good programmers will not use it
  52.  * except as an argument to one of the functions below.
  53.  * dd_stat field is now int (was short in older versions).
  54.  */
  55. typedef struct
  56. {
  57.     /* disk transfer area for this dir */
  58.     struct _finddata_t    dd_dta;
  59.  
  60.     /* dirent struct to return from dir (NOTE: this makes this thread
  61.      * safe as long as only one thread uses a particular DIR struct at
  62.      * a time) */
  63.     struct dirent        dd_dir;
  64.  
  65.     /* _findnext handle */
  66.     long            dd_handle;
  67.  
  68.     /*
  69.          * Status of search:
  70.      *   0 = not started yet (next entry to read is first entry)
  71.      *  -1 = off the end
  72.      *   positive = 0 based index of next entry
  73.      */
  74.     int            dd_stat;
  75.  
  76.     /* given path for dir with search pattern (struct is extended) */
  77.     char            dd_name[1];
  78. } DIR;
  79.  
  80. DIR*        opendir (const char*);
  81. struct dirent*    readdir (DIR*);
  82. int        closedir (DIR*);
  83. void        rewinddir (DIR*);
  84. long        telldir (DIR*);
  85. void        seekdir (DIR*, long);
  86.  
  87.  
  88. /* wide char versions */
  89.  
  90. struct _wdirent
  91. {
  92.     long        d_ino;        /* Always zero. */
  93.     unsigned short    d_reclen;    /* Always zero. */
  94.     unsigned short    d_namlen;    /* Length of name in d_name. */
  95.     wchar_t*    d_name;        /* File name. */
  96.     /* NOTE: The name in the dirent structure points to the name in the     *       wfinddata_t structure in the _WDIR. */
  97. };
  98.  
  99. /*
  100.  * This is an internal data structure. Good programmers will not use it
  101.  * except as an argument to one of the functions below.
  102.  */
  103. typedef struct
  104. {
  105.     /* disk transfer area for this dir */
  106.     struct _wfinddata_t    dd_dta;
  107.  
  108.     /* dirent struct to return from dir (NOTE: this makes this thread
  109.      * safe as long as only one thread uses a particular DIR struct at
  110.      * a time) */
  111.     struct _wdirent        dd_dir;
  112.  
  113.     /* _findnext handle */
  114.     long            dd_handle;
  115.  
  116.     /*
  117.          * Status of search:
  118.      *   0 = not started yet (next entry to read is first entry)
  119.      *  -1 = off the end
  120.      *   positive = 0 based index of next entry
  121.      */
  122.     int            dd_stat;
  123.  
  124.     /* given path for dir with search pattern (struct is extended) */
  125.     wchar_t            dd_name[1];
  126. } _WDIR;
  127.  
  128.  
  129.  
  130. _WDIR*        _wopendir (const wchar_t*);
  131. struct _wdirent* _wreaddir (_WDIR*);
  132. int        _wclosedir (_WDIR*);
  133. void        _wrewinddir (_WDIR*);
  134. long        _wtelldir (_WDIR*);
  135. void        _wseekdir (_WDIR*, long);
  136.  
  137.  
  138. #ifdef    __cplusplus
  139. }
  140. #endif
  141.  
  142. #endif    /* Not RC_INVOKED */
  143.  
  144. #endif    /* Not _DIRENT_H_ */
  145.  
  146. #endif    /* Not __STRICT_ANSI__ */
  147.  
  148.