/*========================================================================= * * GENFIND.H - Dave Humphrey (uesp@m0use.net) - August 1999 * *=======================================================================*/ #ifndef __GENFIND_H #define __GENFIND_H /* Required Includes */ #include "genutil.h" #if defined(__MSDOS__) #include "dir.h" #endif /*========================================================================= * * Begin Defines * *=======================================================================*/ /* Used to indicate an invalid find handle */ #define NULL_FIND_HANDLE (-1l) /* Platform specific defines */ #if defined(_WIN32) /* Define the base file block type */ typedef struct _finddata_t fileblock_t; /* Redefine attribute values */ #define FA_ARCH _A_ARCH #define FA_DIREC _A_SUBDIR #define FA_RDONLY _A_RDONLY #define FA_HIDDEN _A_HIDDEN #define FA_SYSTEM _A_SYSTEM #define FA_NORMAL _A_NORMAL #elif defined(__MSDOS__) /* Define the base file block type */ typedef struct ffblk fileblock_t; #endif /*========================================================================= * End of Defines *=======================================================================*/ /*========================================================================= * * Class CFileBlock Definition * * A class to handle the different variations of the fileblock structure * under the various operating systems. * *=======================================================================*/ class CFileBlock { /* Begin protected class members */ protected: fileblock_t BlockData; /* Begin public class methods */ public: /* Class Constructor */ CFileBlock (void) { Destroy(); } /* Class Destructor */ virtual void Destroy (void); /* Return various members of the file block data */ fileblock_t& GetBlock (void) { return (BlockData); } fileblock_t* GetBlockPtr (void) { return (&BlockData); } /* Define the get methods depending on the platform */ #if defined (_WIN32) char* GetName (void) { return (&BlockData.name[0]); } int GetAttribute (void) const { return (BlockData.attrib); } time_t GetCreationTime (void) const { return (BlockData.time_create); } time_t GetAccessTime (void) const { return (BlockData.time_access); } time_t GetWriteTime (void) const { return (BlockData.time_write); } ulong GetSize (void) const { return (BlockData.size); } #elif defined(__MSDOS__) char* GetName (void) const { return (&BlockData.ff_name[0]); } int GetAttribute (void) const { return (BlockData.ff_attrib); } time_t GetCreationTime (void) const { return (-1l); } time_t GetAccessTime (void) const { return (-1l); } time_t GetWriteTime (void) const; ulong GetSize (void) const { return (BlockData.ff_fsize); } #endif }; /*========================================================================= * End of Class CFileBlock Definition *=======================================================================*/ /*========================================================================= * * Begin Class CFindFile Definition * * Main class used for searching files under many operating systems. * *=======================================================================*/ class CFindFile { /* Begin protected class members */ protected: long FindHandle; /* Handle for the current find */ CFileBlock FileBlock; /* Block for holding file info */ /* Begin public class methods */ public: /* Class Constructor */ CFindFile (void); /* Class Destructors */ ~CFindFile (void) { Destroy(); } void Destroy (void); /* Closes the file find */ boolean Close (void); /* Find the first occurence of a given file spec */ boolean FindFirst (const char* pFileSpec, const int Attributes = FA_NORMAL); /* Find the next occurence of the previous file spec */ boolean FindNext (void); /* Used to get information on a found file */ char* GetName (void) { return (FileBlock.GetName()); } int GetAttribute (void) { return (FileBlock.GetAttribute()); } time_t GetCreationTime(void) { return (FileBlock.GetCreationTime()); } time_t GetAccessTime (void) { return (FileBlock.GetAccessTime()); } time_t GetWriteTime (void) { return (FileBlock.GetWriteTime()); } ulong GetSize (void) { return (FileBlock.GetSize()); } }; /*========================================================================= * End of Class CFindFile Definition *=======================================================================*/ #endif /*========================================================================= * End of File GENFIND.H *=======================================================================*/