sipxportlib  Version 3.3
OsFileIteratorBase.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005-2017 SIPez LLC. All rights reserved.
3 //
4 // Copyright (C) 2004-2006 SIPfoundry Inc.
5 // Licensed by SIPfoundry under the LGPL license.
6 //
7 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
8 // Licensed to SIPfoundry under a Contributor Agreement.
9 //
10 // $$
12 
13 
14 #ifndef _OsFileIteratorBase_h_
15 #define _OsFileIteratorBase_h_
16 
17 // SYSTEM INCLUDES
18 
19 // APPLICATION INCLUDES
20 #include <os/OsDefs.h>
21 #include <os/OsStatus.h>
22 #include <os/OsPathBase.h>
23 #include <utl/UtlRegex.h>
24 
25 // DEFINES
26 // MACROS
27 // EXTERNAL FUNCTIONS
28 // EXTERNAL VARIABLES
29 // CONSTANTS
30 // STRUCTS
31 // TYPEDEFS
32 // FORWARD DECLARATIONS
33 class OsFileInfoBase;
34 class OsFileBase;
35 
36 //:Abstraction class to iterate through files and/or directories
38 {
39 /* //////////////////////////// PUBLIC //////////////////////////////////// */
40 public:
42  {
46  };
47 
48 #ifdef _WIN32
49  enum { INVALID_HANDLE = -1 };
50 #else
51  enum { INVALID_HANDLE = 0 };
52 #endif
53 
54 
55 
56  //: type specified for FindFirst
60 
61 /* ============================ CREATORS ================================== */
62 
64 
65  OsFileIteratorBase(const OsPathBase& rPathName);
66 
67  virtual ~OsFileIteratorBase();
68  //:Destructor
69 
70 
71 /* ============================ MANIPULATORS ============================== */
72 
73 
74 /* ============================ ACCESSORS ================================= */
75 
76  virtual OsStatus findFirst(OsPathBase& rEntry, const char* filterExp = ".*",
77  OsFileType fileType = ANY_FILE);
78  //: Searches a directory specified by rEntry for all entries matching
79  //: the (unanchored) regexp filterExp and also of type fileType.
80  //: Returns the full path name of the found entries.
81  //: filterExp is unanchored; it need only match a substring of the
82  //: file name. To force it to match the entire file name, use "^...$".
83  //: On Unix-like systems the "." and ".." entries may be returned.
84 
85  virtual OsStatus findNext(OsPathBase& rEntry);
86  //: Finds the next entry matching the search criteria.
87  //: Use FindFirst before calling this function.
88 
89 
90 /* ============================ INQUIRY =================================== */
91  int getFileCount() {return mFileCount;}
92  //: Returns total files enumerated thus far.
93 
94 /* //////////////////////////// PROTECTED ///////////////////////////////// */
95 protected:
97  //: What the user passed in as path to search
99  //: What is searched against the filesystem
101  //: The regular expression that the user searched for
102 
104 
105  // release memory that allocated for mFilterExp
106  //
107  // Morerover, OsFileIteratorBase's Subclass needs override this
108  // function for releasing mSearchHandle.
109  virtual void Release();
110 
111 /* //////////////////////////// PRIVATE /////////////////////////////////// */
112 private:
113 
114  virtual OsStatus getNextEntryName(UtlString &rName, OsFileType &rFileType);
115  //: Platform dependant call for getting entry
116  virtual OsStatus getFirstEntryName(UtlString &rName, OsFileType &rFileType);
117  //: Platform dependant call for getting entry
118 
119  OsFileType mMatchAttrib;
120  //: Attributes for file matching
121 
122  long mFileCount;
123  //: How many file did this class find
124 
125 };
126 
127 /* ============================ INLINE METHODS ============================ */
128 
129 #endif // _OsFileIteratorBase_h_
130 
131 
Definition: OsFileIteratorBase.h:51
RegEx * mFilterExp
Definition: OsFileIteratorBase.h:100
OsFileIteratorBase()
enumcode: ANY_FILE - Directories and Files enumcode: DIRECTORY - Search for directories only enumcode...
Definition: OsFileIteratorBase.cpp:37
intptr_t mSearchHandle
Definition: OsFileIteratorBase.h:103
Definition: OsFileIteratorBase.h:45
OsStatus
Definition: OsStatus.h:27
OsFileType
Definition: OsFileIteratorBase.h:41
virtual OsStatus findNext(OsPathBase &rEntry)
Definition: OsFileIteratorBase.cpp:138
Definition: UtlRegex.h:57
virtual OsStatus findFirst(OsPathBase &rEntry, const char *filterExp=".*", OsFileType fileType=ANY_FILE)
Definition: OsFileIteratorBase.cpp:64
Definition: OsFileIteratorBase.h:37
Definition: OsFileInfoBase.h:34
Definition: UtlString.h:48
virtual void Release()
Definition: OsFileIteratorBase.cpp:44
OsPathBase mUserSpecifiedPath
Definition: OsFileIteratorBase.h:96
Definition: OsFileIteratorBase.h:44
Definition: OsFileIteratorBase.h:43
Definition: OsFileBase.h:42
OsPathBase mFullSearchSpec
Definition: OsFileIteratorBase.h:98
virtual ~OsFileIteratorBase()
Definition: OsFileIteratorBase.cpp:54
int getFileCount()
Definition: OsFileIteratorBase.h:91
Definition: OsPathBase.h:34
_W64 signed int intptr_t
Definition: stdint.h:118