1 #ifndef _RAR_SCANTREE_ 2 #define _RAR_SCANTREE_ 3 4 enum SCAN_DIRS 5 { 6 SCAN_SKIPDIRS, // Skip directories, but recurse for files if recursion mode is enabled. 7 SCAN_GETDIRS, // Get subdirectories in recurse mode. 8 SCAN_GETDIRSTWICE, // Get the directory name both before and after the list of files it contains. 9 SCAN_GETCURDIRS // Get subdirectories in current directory even in RECURSE_NONE mode. 10 }; 11 12 enum SCAN_CODE { SCAN_SUCCESS,SCAN_DONE,SCAN_ERROR,SCAN_NEXT }; 13 14 #define MAXSCANDEPTH (NM/2) 15 16 class CommandData; 17 18 class ScanTree 19 { 20 private: 21 bool GetNextMask(); 22 SCAN_CODE FindProc(FindData *FD); 23 24 FindFile *FindStack[MAXSCANDEPTH]; 25 int Depth; 26 27 int SetAllMaskDepth; 28 29 StringList *FileMasks; 30 RECURSE_MODE Recurse; 31 bool GetLinks; 32 SCAN_DIRS GetDirs; 33 int Errors; 34 35 // set when processing paths like c:\ (root directory without wildcards) 36 bool ScanEntireDisk; 37 38 char CurMask[NM]; 39 wchar CurMaskW[NM]; 40 char OrigCurMask[NM]; 41 wchar OrigCurMaskW[NM]; 42 bool SearchAllInRoot; 43 size_t SpecPathLength; 44 size_t SpecPathLengthW; 45 46 char ErrArcName[NM]; 47 48 CommandData *Cmd; 49 public: 50 ScanTree(StringList *FileMasks,RECURSE_MODE Recurse,bool GetLinks,SCAN_DIRS GetDirs); 51 ~ScanTree(); 52 SCAN_CODE GetNext(FindData *FindData); GetSpecPathLength()53 size_t GetSpecPathLength() {return(SpecPathLength);}; GetSpecPathLengthW()54 size_t GetSpecPathLengthW() {return(SpecPathLengthW);}; GetErrors()55 int GetErrors() {return(Errors);}; SetErrArcName(const char * Name)56 void SetErrArcName(const char *Name) {strcpy(ErrArcName,Name);} SetCommandData(CommandData * Cmd)57 void SetCommandData(CommandData *Cmd) {ScanTree::Cmd=Cmd;} 58 }; 59 60 #endif 61