Line | |
---|
1 | #ifndef MARS_MDirIter
|
---|
2 | #define MARS_MDirIter
|
---|
3 |
|
---|
4 | #ifndef ROOT_TObjArray
|
---|
5 | #include <TObjArray.h>
|
---|
6 | #endif
|
---|
7 |
|
---|
8 | class MDirIter : public TObject
|
---|
9 | {
|
---|
10 | private:
|
---|
11 | TObjArray fList;
|
---|
12 | TString fFilter;
|
---|
13 |
|
---|
14 | TIter fNext; //!
|
---|
15 | void *fDirPtr; //!
|
---|
16 | TObject *fCurrentPath; //!
|
---|
17 |
|
---|
18 | void *Open();
|
---|
19 | void Close();
|
---|
20 | Bool_t Check(const TString n) const;
|
---|
21 | Int_t IsDir(const char *dir) const;
|
---|
22 | Bool_t MatchFilter(const TString &name, const TString &filter) const;
|
---|
23 | TString ConcatFileName(const char *dir, const char *name) const;
|
---|
24 | void PrintEntry(const TObject &o) const;
|
---|
25 |
|
---|
26 | public:
|
---|
27 | MDirIter() : fNext(&fList), fDirPtr(NULL)
|
---|
28 | {
|
---|
29 | fList.SetOwner();
|
---|
30 | }
|
---|
31 | MDirIter(const MDirIter &dir) : fNext(&fList), fDirPtr(NULL)
|
---|
32 | {
|
---|
33 | fList.SetOwner();
|
---|
34 |
|
---|
35 | TObject *o=NULL;
|
---|
36 | TIter Next(&dir.fList);
|
---|
37 | while ((o=Next()))
|
---|
38 | AddDirectory(o->GetName(), o->GetTitle());
|
---|
39 | }
|
---|
40 | MDirIter(const char *dir, const char *filter="") : fNext(&fList), fDirPtr(NULL)
|
---|
41 | {
|
---|
42 | fList.SetOwner();
|
---|
43 | AddDirectory(dir, filter);
|
---|
44 | }
|
---|
45 | ~MDirIter()
|
---|
46 | {
|
---|
47 | Close();
|
---|
48 | }
|
---|
49 |
|
---|
50 | Int_t AddDirectory(const char *dir, const char *filter="", Int_t recursive=0);
|
---|
51 | void Reset()
|
---|
52 | {
|
---|
53 | Close();
|
---|
54 | fNext.Reset();
|
---|
55 | }
|
---|
56 |
|
---|
57 | TString Next(Bool_t nocheck=kFALSE);
|
---|
58 | TString operator()(Bool_t nocheck=kFALSE) { return Next(nocheck); }
|
---|
59 |
|
---|
60 | void SetFilter(const char *f="") { fFilter = f; }
|
---|
61 |
|
---|
62 | void Print(const Option_t *o="") const;
|
---|
63 |
|
---|
64 | ClassDef(MDirIter, 1) // Iterator for files in several directories (with filters)
|
---|
65 | };
|
---|
66 |
|
---|
67 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.