Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXGlobVisitor.h
1 /********************************************************************************
2 * *
3 * G l o b b i n g D i r e c t o r y V i s i t o r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2008,2026 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXGLOBVISITOR_H
22 #define FXGLOBVISITOR_H
23 
24 namespace FX {
25 
26 
31 class FXAPI FXGlobVisitor : public FXDirVisitor {
32 private:
33  FXString wildcard; // Match files against this wild card
34  FXuint options; // Matching options
35 private:
37  FXGlobVisitor& operator=(const FXGlobVisitor&);
38 public:
39 
41  FXGlobVisitor():options(0){}
42 
44  FXuint traverse(const FXString& path,const FXString& wild="*",FXuint opts=FXDir::MatchAll,FXint depth=1000);
45 
47  virtual FXuint enter(const FXString& path) override;
48 
50  virtual FXuint visit(const FXString& path) override;
51 
53  virtual FXuint leave(const FXString& path) override;
54 
56  virtual ~FXGlobVisitor();
57  };
58 
59 
66 class FXAPI FXGlobCountVisitor : public FXGlobVisitor {
67 private:
68  FXlong countFolders; // Count of folders seen
69  FXlong countFiles; // Count of files seen
70  FXlong countBytes; // Total number of bytes in files
71  FXlong maxDepth; // Maximum depth
72  FXlong depth; // Current depth during traversal
73 private:
75  FXGlobCountVisitor& operator=(const FXGlobCountVisitor&);
76 public:
77 
80 
82  FXuint traverse(const FXString& path,const FXString& wild="*",FXuint opts=FXDir::MatchAll,FXint limit=1000);
83 
85  FXlong getTotalFolders() const { return countFolders; }
86 
88  FXlong getTotalFiles() const { return countFiles; }
89 
91  FXlong getTotalBytes() const { return countBytes; }
92 
94  FXlong getMaximumDepth() const { return maxDepth; }
95 
97  virtual FXuint enter(const FXString& path) override;
98 
100  virtual FXuint visit(const FXString& path) override;
101 
103  virtual FXuint leave(const FXString& path) override;
104 
106  virtual ~FXGlobCountVisitor();
107  };
108 
109 }
110 
111 #endif
FXlong getTotalBytes() const
Return total number of bytes in matching files.
Definition: FXGlobVisitor.h:91
Directory visitor walks across all files and directories recursively, starting from the given path...
Definition: FXDirVisitor.h:57
FXlong getTotalFolders() const
Return total number of folders found.
Definition: FXGlobVisitor.h:85
Visit directory entries according to flags and matching with wild card pattern, as per FXGlobVisitor ...
Definition: FXGlobVisitor.h:66
Visit directory entries according to flags and matching with wild card pattern, with similar matching...
Definition: FXGlobVisitor.h:31
FXlong getTotalFiles() const
Return total number of files matched.
Definition: FXGlobVisitor.h:88
Definition: FX4Splitter.h:28
FXGlobVisitor()
Construct directory visitor.
Definition: FXGlobVisitor.h:41
FXlong getMaximumDepth() const
Return maximum depth of directory tree.
Definition: FXGlobVisitor.h:94
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2026 Jeroen van der Zijp