scantree.hpp 1.6 KB

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