home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / dos / compat / d_findf.txh < prev    next >
Encoding:
Text File  |  1995-10-09  |  1.5 KB  |  77 lines

  1. @node _dos_findfirst, dos
  2. @subheading Syntax
  3.  
  4. @example
  5. #include <dos.h>
  6.  
  7. unsigned int _dos_findfirst(char *name, unsigned int attr, struct find_t *result);
  8. @end example
  9.  
  10. @subheading Description
  11.  
  12. This function and the related @code{_dos_findnext} (@pxref{_dos_findnext})
  13. are used to scan directories for the list of files therein. The @var{name}
  14. is a wildcard that specifies the directory and files to search. @var{result}
  15. is a structure to hold the results and state of the search, and @var{attr}
  16. is a combination of the following:
  17.  
  18. @table @code
  19.  
  20. @item _A_NORMAL (0x00)
  21.  
  22. Normal file (no read/write restrictions)
  23.  
  24. @item _A_RDONLY (0x01)
  25.  
  26. Read only file
  27.  
  28. @item _A_HIDDEN (0x02)
  29.  
  30. Hidden file
  31.  
  32. @item _A_SYSTEM (0x04)
  33.  
  34. System file
  35.  
  36. @item _A_VOLID (0x08)
  37.  
  38. Volume ID file
  39.  
  40. @item _A_SUBDIR (0x10)
  41.  
  42. Subdirectory
  43.  
  44. @item _A_ARCH (0x20)
  45.  
  46. Archive file
  47.  
  48. @end table
  49.  
  50. @xref{_dos_findnext}.
  51.  
  52. @subheading Return Value
  53.  
  54. Zero if a match is found, DOS error code if not found (and sets @var{errno}).
  55.  
  56. @subheading Example
  57.  
  58. @example
  59. struct find_t f;
  60.  
  61. if ( !_dos_findfirst("*.DAT", &result, _A_ARCH | _A_RDONLY) )
  62. @{
  63.   do
  64.   @{
  65.     printf("%-14s %10u %02u:%02u:%02u %02u/%02u/%04u\n",
  66.            f.name,
  67.            f.size,
  68.            (f.wr_time >> 11) & 0x1f,
  69.            (f.wr_time >>  5) & 0x3f,
  70.            (f.wr_time & 0x1f) * 2,
  71.            (f.wr_date >>  5) & 0x0f,
  72.            (f.wr_date & 0x1f),
  73.            ((f.wr_date >> 9) & 0x7f) + 1980,
  74.   @} while( !_dos_findnext(&f) );
  75. @}
  76. @end example
  77.