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
00065
00066
00067
00068
00069
00076
00077
00078
00079
00080 #ifndef RECLS_INCL_H_RECLSTL
00081 # include "reclstl.h"
00082 #endif
00083 #ifndef RECLS_INCL_H_RECLS_ASSERT
00084 # include <recls_assert.h>
00085 #endif
00086 #ifndef _STLSOFT_INCL_H_STLSOFT_ITERATOR
00087 # include <stlsoft_iterator.h>
00088 #endif
00089 #ifndef _STLSOFT_INCL_H_STLSOFT_PROXY_SEQUENCE
00090 # include <stlsoft_proxy_sequence.h>
00091 #endif
00092
00093
00094
00095
00096
00097 #if !defined(RECLS_NO_NAMESPACE)
00098 namespace recls
00099 {
00100
00101 namespace stl
00102 {
00103 #endif
00104
00105
00106
00107
00108
00112 template <typename C>
00113 struct reclstl_traits
00114 {
00115 public:
00120 typedef void char_type;
00125 typedef void *entry_type;
00126
00127 public:
00128 #if defined(RECLS_API_FTP)
00129
00130 static hrecls_t SearchFtp(char_type const *host, char_type const *username, char_type const *password, char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags);
00131 #endif
00132
00134 static hrecls_t Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags);
00135
00137 static recls_rc_t GetDetails(hrecls_t hSrch, entry_type *pinfo);
00139 static recls_rc_t GetNextDetails(hrecls_t hSrch, entry_type *pinfo);
00140
00142 static void CloseDetails(entry_type fileInfo);
00144 static entry_type CopyDetails(entry_type fileInfo);
00145
00147 static char_type *str_copy(char_type *, char_type const *);
00148 };
00149
00150 #ifndef RECLS_DOCUMENTATION_SKIP_SECTION
00151
00152 # ifdef RECLS_CHAR_TYPE_IS_CHAR
00153
00154 template <>
00155 struct reclstl_traits<recls_char_a_t>
00156 {
00157 public:
00158 typedef reclstl_traits<recls_char_a_t> traits_type;
00159 typedef recls_char_a_t char_type;
00160 typedef recls_info_t entry_type;
00161 typedef recls_strptrs_t strptrs_type;
00162 typedef recls_strptrsptrs_t strptrsptrs_type;
00163
00165 typedef stlsoft::proxy_sequence< const strptrs_type
00166 , string_t
00167 , traits_type
00168 > directory_parts_type;
00169
00173 static string_t make_value(strptrs_type const &ptrs)
00174 {
00175 return string_t(ptrs.begin, ptrs.end);
00176 }
00177
00178 public:
00179 #if defined(RECLS_API_FTP)
00180 static hrecls_t SearchFtp(char_type const *host, char_type const *username, char_type const *password, char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00181 {
00182 hrecls_t hSrch;
00183 recls_rc_t rc = Recls_SearchFtp(host, username, password, searchRoot, pattern, flags, &hSrch);
00184
00185 return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00186 }
00187 #endif
00188
00189 static hrecls_t Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00190 {
00191 hrecls_t hSrch;
00192 recls_rc_t rc = Recls_Search(searchRoot, pattern, flags, &hSrch);
00193
00194 return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00195 }
00196
00197 static recls_rc_t GetDetails(hrecls_t hSrch, entry_type *pinfo)
00198 {
00199 return Recls_GetDetails(hSrch, pinfo);
00200 }
00201
00202 static recls_rc_t GetNextDetails(hrecls_t hSrch, entry_type *pinfo)
00203 {
00204 return Recls_GetNextDetails(hSrch, pinfo);
00205 }
00206
00207 static void CloseDetails(entry_type fileInfo)
00208 {
00209 Recls_CloseDetails(fileInfo);
00210 }
00211 static entry_type CopyDetails(entry_type fileInfo)
00212 {
00213 entry_type infoCopy;
00214
00215 return RECLS_SUCCEEDED(Recls_CopyDetails(fileInfo, &infoCopy)) ? infoCopy : static_cast<entry_type>(NULL);
00216 }
00217
00218 static char_type *str_copy(char_type *dest, char_type const *src)
00219 {
00220 return strcpy(dest, src);
00221 }
00222 };
00223
00224 # elif defined(RECLS_CHAR_TYPE_IS_WCHAR)
00225
00226 template <>
00227 struct reclstl_traits<recls_char_w_t>
00228 {
00229 public:
00230 typedef reclstl_traits<recls_char_w_t> traits_type;
00231 typedef recls_char_w_t char_type;
00232 typedef recls_info_t entry_type;
00233 typedef recls_strptrs_t strptrs_type;
00234 typedef recls_strptrsptrs_t strptrsptrs_type;
00235
00237 typedef stlsoft::proxy_sequence< const strptrs_type
00238 , string_t
00239 , traits_type
00240 > directory_parts_type;
00241
00245 static string_t make_value(strptrs_type const &ptrs)
00246 {
00247 return string_t(ptrs.begin, ptrs.end);
00248 }
00249
00250 public:
00251 #if defined(RECLS_API_FTP)
00252 static hrecls_t SearchFtp(char_type const *host, char_type const *username, char_type const *password, char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00253 {
00254 hrecls_t hSrch;
00255 recls_rc_t rc = Recls_SearchFtp(host, username, password, searchRoot, pattern, flags, &hSrch);
00256
00257 return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00258 }
00259 #endif
00260
00261 static hrecls_t Search(char_type const *searchRoot, char_type const *pattern, recls_uint32_t flags)
00262 {
00263 hrecls_t hSrch;
00264 recls_rc_t rc = Recls_Search(searchRoot, pattern, flags, &hSrch);
00265
00266 return RECLS_SUCCEEDED(rc) ? hSrch : static_cast<hrecls_t>(NULL);
00267 }
00268
00269 static recls_rc_t GetDetails(hrecls_t hSrch, entry_type *pinfo)
00270 {
00271 return Recls_GetDetails(hSrch, pinfo);
00272 }
00273
00274 static recls_rc_t GetNextDetails(hrecls_t hSrch, entry_type *pinfo)
00275 {
00276 return Recls_GetNextDetails(hSrch, pinfo);
00277 }
00278
00279 static void CloseDetails(entry_type fileInfo)
00280 {
00281 Recls_CloseDetails(fileInfo);
00282 }
00283 static entry_type CopyDetails(entry_type fileInfo)
00284 {
00285 entry_type infoCopy;
00286
00287 return RECLS_SUCCEEDED(Recls_CopyDetails(fileInfo, &infoCopy)) ? infoCopy : static_cast<entry_type>(NULL);
00288 }
00289
00290 static char_type *str_copy(char_type *dest, char_type const *src)
00291 {
00292 return wcscpy(dest, src);
00293 }
00294 };
00295
00296 # else
00297
00298 # error Neither RECLS_CHAR_TYPE_IS_WCHAR nor RECLS_CHAR_TYPE_IS_CHAR are defined
00299
00300 # endif
00301
00302
00303 #endif
00304
00305
00306
00307
00308
00309 }
00310 #endif
00311
00312
00313
00314
00315
00316