00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00065 # define RECLS_VER_H_RECLSPP_FILESEARCH_MAJOR 1
00066 # define RECLS_VER_H_RECLSPP_FILESEARCH_MINOR 0
00067 # define RECLS_VER_H_RECLSPP_FILESEARCH_REVISION 9
00068 # define RECLS_VER_H_RECLSPP_FILESEARCH_EDIT 9
00069 #endif
00070
00075
00076
00077
00078
00079 #include "reclspp.h"
00080 #include "reclspp_fileentry.h"
00081 #include <recls_assert.h>
00082
00083
00084
00085
00086
00087 #if !defined(RECLS_NO_NAMESPACE)
00088 namespace recls
00089 {
00090
00091 namespace cpp
00092 {
00093 #endif
00094
00095
00096
00097
00098
00102 class FileSearch
00103 {
00104 public:
00105
00108 public:
00114 FileSearch(char const *rootDir, char const *pattern, recls_uint32_t flags);
00116 ~FileSearch();
00117
00119
00122 public:
00124 recls_rc_t GetNext();
00125
00127
00130 public:
00132 recls_bool_t HasMoreElements() const;
00136 FileEntry GetCurrentEntry() const;
00137
00139 recls_rc_t GetLastError() const;
00140
00142 recls_uint32_t GetNumOutstandingDetails() const;
00143
00145
00146
00147 private:
00148
00149
00150 private:
00151 hrecls_t m_hSrch;
00152 mutable recls_rc_t m_lastError;
00153
00154
00155 private:
00156 FileSearch(FileSearch const &rhs);
00157 FileSearch &operator =(FileSearch const &rhs);
00158 };
00159
00160
00161
00162
00163
00164 inline FileSearch::FileSearch(char const *rootDir, char const *pattern, recls_uint32_t flags)
00165 :
00166 m_lastError((m_hSrch = NULL, Recls_Search(rootDir, pattern, flags, &const_cast<hrecls_t&>(m_hSrch))))
00167 {}
00168
00169 inline FileSearch::~FileSearch()
00170 {
00171 if(NULL != m_hSrch)
00172 {
00173 Recls_SearchClose(m_hSrch);
00174 }
00175 }
00176
00177 inline recls_rc_t FileSearch::GetNext()
00178 {
00179 recls_assert(NULL != m_hSrch);
00180
00181 recls_rc_t rc = Recls_GetNext(m_hSrch);
00182
00183 if(RECLS_FAILED(rc))
00184 {
00185 Recls_SearchClose(m_hSrch);
00186 m_hSrch = NULL;
00187 }
00188
00189 m_lastError = rc;
00190
00191 return rc;
00192 }
00193
00194 inline recls_bool_t FileSearch::HasMoreElements() const
00195 {
00196 return RECLS_SUCCEEDED(m_lastError);
00197 }
00198
00199 inline FileEntry FileSearch::GetCurrentEntry() const
00200 {
00201 recls_info_t info;
00202 recls_rc_t rc = Recls_GetDetails(m_hSrch, &info);
00203
00204 return RECLS_SUCCEEDED(m_lastError = rc) ? FileEntry(info) : FileEntry();
00205 }
00206
00207 inline recls_rc_t FileSearch::GetLastError() const
00208 {
00209 return m_lastError;
00210 }
00211
00212 inline recls_uint32_t FileSearch::GetNumOutstandingDetails() const
00213 {
00214 recls_uint32_t cDetails;
00215 recls_rc_t rc = Recls_OutstandingDetails(m_hSrch, &cDetails);
00216
00217 if(RECLS_FAILED(m_lastError = rc))
00218 {
00219 cDetails = 0;
00220 }
00221
00222 return cDetails;
00223 }
00224
00225
00226
00227
00228
00229 #if !defined(RECLS_NO_NAMESPACE)
00230 }
00231 }
00232 #endif
00233
00234
00235
00236
00237
00238