home *** CD-ROM | disk | FTP | other *** search
- #include "XFileFi.h"
-
-
- /*@ XFileFind :: XFileFind(const char *m, const LONG o)
- @group constructors/destructors
- @remarks Construct a XFileFind-instance (do not forget to call the destructor)
- @parameters <t '°' c=2>
- °char * fileMask °mask for the files to find(e.g. "*.EXE" )
- °LONG options °options to search, valid values are:
- <t '°' c=1>
- °XFILE_NORMAL
- °XFILE_READONLY
- °XFILE_HIDDEN
- °XFILE_SYSTEM
- °XFILE_DIRECTORY
- °XFILE_ARCHIVED
- °XMUST_HAVE_READONLY
- °XMUST_HAVE_HIDDEN
- °XMUST_HAVE_SYSTEM
- °XMUST_HAVE_DIRECTORY
- °XMUST_HAVE_ARCHIVED
- </t>
- </t>
- */
- XFileFind :: XFileFind(const char *m, const LONG o)
- {
- init = TRUE;
- mask = m;
- options = o;
- dir = HDIR_SYSTEM;
- }
-
-
- /*@ XFileFind::Find(XString * string)
- @group find files
- @remarks After you have created an instance you can start to find files. Find()
- copy the filename found to the given bufer and returns TRUE, it returns FALSE if no file is found.
- @parameters XString * buffer buffer to hold the filename
- @returns BOOL
- */
- BOOL XFileFind::Find(XString * string)
- {
- LONG res;
- ULONG count = 1;
-
- if (init)
- {
- res = DosFindFirst((PSZ) (char *) mask, &dir, options, &buffer, sizeof(buffer), &count, 1);
- init = FALSE;
- }
- else
- res = DosFindNext(dir, &buffer, sizeof(buffer), &count);
- if (res == 0)
- {
- memcpy(string->GetBuffer(buffer.cchName), buffer.achName, buffer.cchName);
- string->ReleaseBuffer(buffer.cchName);
- return TRUE;
- }
- else
- return FALSE;
- }
-
-
- /*@ XFileFind :: ~XFileFind()
- @group constructors/destructors
- @remarks Destroys a XFileFind-instance. Never forget to call the destructor!
- */
- XFileFind :: ~XFileFind()
- {
- DosFindClose(dir);
- }
-