home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool.zip / OOL / source / xfilefi.cpp < prev    next >
C/C++ Source or Header  |  1997-04-03  |  2KB  |  72 lines

  1. #include "XFileFi.h"
  2.  
  3.  
  4. /*@ XFileFind :: XFileFind(const char *m, const LONG o)
  5. @group constructors/destructors
  6. @remarks Construct a XFileFind-instance (do not forget to call the destructor)
  7. @parameters <t '°' c=2>
  8.                 °char * fileMask              °mask for the files to find(e.g. "*.EXE" )
  9.             °LONG options                 °options to search, valid values are:
  10.                                                             <t '°' c=1>
  11.                                              °XFILE_NORMAL
  12.                                              °XFILE_READONLY
  13.                                              °XFILE_HIDDEN
  14.                                              °XFILE_SYSTEM
  15.                                              °XFILE_DIRECTORY
  16.                                              °XFILE_ARCHIVED
  17.                                              °XMUST_HAVE_READONLY
  18.                                              °XMUST_HAVE_HIDDEN
  19.                                              °XMUST_HAVE_SYSTEM
  20.                                              °XMUST_HAVE_DIRECTORY
  21.                                              °XMUST_HAVE_ARCHIVED
  22.                                                             </t>
  23.             </t>
  24. */
  25. XFileFind :: XFileFind(const char *m, const LONG o)
  26. {
  27.     init = TRUE;
  28.     mask = m;
  29.     options = o;
  30.     dir = HDIR_SYSTEM;
  31. }
  32.  
  33.  
  34. /*@ XFileFind::Find(XString * string)
  35. @group find files
  36. @remarks After you have created an instance you can start to find files. Find()
  37. copy the filename found to the given bufer and returns TRUE, it returns FALSE if no file is found.
  38. @parameters XString * buffer     buffer to hold the filename
  39. @returns BOOL
  40. */
  41. BOOL XFileFind::Find(XString * string)
  42. {
  43.     LONG res;
  44.     ULONG count = 1;
  45.  
  46.     if (init)
  47.     {
  48.         res = DosFindFirst((PSZ) (char *) mask, &dir, options, &buffer, sizeof(buffer), &count, 1);
  49.         init = FALSE;
  50.     }
  51.     else
  52.         res = DosFindNext(dir, &buffer, sizeof(buffer), &count);
  53.     if (res == 0)
  54.     {
  55.         memcpy(string->GetBuffer(buffer.cchName), buffer.achName, buffer.cchName);
  56.         string->ReleaseBuffer(buffer.cchName);
  57.         return TRUE;
  58.     }
  59.     else
  60.         return FALSE;
  61. }
  62.  
  63.  
  64. /*@ XFileFind :: ~XFileFind()
  65. @group constructors/destructors
  66. @remarks Destroys a XFileFind-instance. Never forget to call the destructor!
  67. */
  68. XFileFind :: ~XFileFind()
  69. {
  70.     DosFindClose(dir);
  71. }
  72.