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

FXDirVisitor.h
1 /********************************************************************************
2 * *
3 * D i r e c t o r y V i s i t o r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2008,2017 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 FXDIRVISITOR_H
22 #define FXDIRVISITOR_H
23 
24 namespace FX {
25 
26 
57 class FXAPI FXDirVisitor {
58 private:
59  struct Seen;
60 private:
61  Seen* current;
62 private:
63  FXDirVisitor(const FXDirVisitor&);
64  FXDirVisitor& operator=(const FXDirVisitor&);
65 public:
66 
68  FXDirVisitor():current(NULL){}
69 
71  FXuint traverse(const FXString& path,FXint limit=1000);
72 
74  FXbool visiting() const { return current!=NULL; }
75 
77  const FXStat& info() const;
78 
80  virtual FXuint enter(const FXString& path);
81 
83  virtual FXuint visit(const FXString& path);
84 
86  virtual FXuint leave(const FXString& path);
87 
89  virtual ~FXDirVisitor();
90  };
91 
92 
97 class FXAPI FXGlobVisitor : public FXDirVisitor {
98 private:
99  FXString wildcard; // Match files against this wild card
100  FXuint options; // Matching options
101 private:
103  FXGlobVisitor& operator=(const FXGlobVisitor&);
104 public:
105 
107  FXGlobVisitor():options(0){}
108 
110  FXuint traverse(const FXString& path,const FXString& wild="*",FXuint opts=FXDir::MatchAll,FXint depth=1000);
111 
113  virtual FXuint enter(const FXString& path);
114 
116  virtual FXuint visit(const FXString& path);
117 
119  virtual FXuint leave(const FXString& path);
120 
122  virtual ~FXGlobVisitor();
123  };
124 
125 
132 class FXAPI FXGlobCountVisitor : public FXGlobVisitor {
133 private:
134  FXlong countFolders; // Count of folders seen
135  FXlong countFiles; // Count of files seen
136  FXlong countBytes; // Total number of bytes in files
137  FXlong maxDepth; // Maximum depth
138  FXlong depth; // Current depth during traversal
139 private:
141  FXGlobCountVisitor& operator=(const FXGlobCountVisitor&);
142 public:
143 
146 
148  FXuint traverse(const FXString& path,const FXString& wild="*",FXuint opts=FXDir::MatchAll,FXint limit=1000);
149 
151  FXlong getTotalFolders() const { return countFolders; }
152 
154  FXlong getTotalFiles() const { return countFiles; }
155 
157  FXlong getTotalBytes() const { return countBytes; }
158 
160  FXlong getMaximumDepth() const { return maxDepth; }
161 
163  virtual FXuint enter(const FXString& path);
164 
166  virtual FXuint visit(const FXString& path);
167 
169  virtual FXuint leave(const FXString& path);
170 
172  virtual ~FXGlobCountVisitor();
173  };
174 
175 
176 }
177 
178 #endif

Copyright © 1997-2016 Jeroen van der Zijp