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
#include "recls.h"
00046
00047
#include <stlsoft.h>
00048
#include <stlsoft_simple_string.h>
00049
00050
#include <inetstl.h>
00051
#include <inetstl_filesystem_traits.h>
00052
#include <inetstl_findfile_sequence.h>
00053
#ifdef USE_SEARCHSPEC_SEQ
00054
# include <inetstl_searchspec_sequence.h>
00055
#endif
00056
00057
00058
#if defined(RECLS_COMPILER_IS_MSVC) && \
00059
_MSC_VER >= 1310
00060
# include <vector>
00061
#else
00062
# include <list>
00063
#endif
00064
00065
00066
00067
00068
00069
#if !defined(RECLS_NO_NAMESPACE)
00070
namespace recls
00071 {
00072
#endif
00073
00074
#ifdef USE_SEARCHSPEC_SEQ
00075
inetstl_ns_using(searchspec_sequence)
00076 #endif
00077 inetstl_ns_using(basic_findfile_sequence)
00078
00079
00080
00081
00082
00083 class ReclsFtpSearchDirectoryNode
00084
00085 {
00086
public:
00087
typedef recls_char_t char_type;
00088
typedef ReclsFtpSearchDirectoryNode class_type;
00089
typedef inetstl_ns_qual(filesystem_traits)<recls_char_t> traits_type;
00090
private:
00091
typedef stlsoft_ns_qual(basic_simple_string)<recls_char_t> string_type;
00092
typedef basic_findfile_sequence<char_type, traits_type> file_find_sequence_type;
00093
#if defined(RECLS_COMPILER_IS_MSVC) && \
00094
_MSC_VER >= 1310
00095
typedef stlsoft_ns_qual_std(vector)<string_type> directory_sequence_type;
00096
#else
00097
typedef stlsoft_ns_qual_std(list)<string_type> directory_sequence_type;
00098
#endif
00099
#ifdef USE_SEARCHSPEC_SEQ
00100
typedef searchspec_sequence<file_find_sequence_type> entry_sequence_type;
00101
#else
00102
typedef file_find_sequence_type entry_sequence_type;
00103
#endif
00104
00105
00106
#if defined(RECLS_COMPILER_IS_GCC)
00107
protected:
00108
#else
00109
private:
00110
#endif
00111 ReclsFtpSearchDirectoryNode(HINTERNET connection, recls_uint32_t
flags, char_type
const *rootDir, char_type
const *
pattern);
00112
public:
00113
virtual ~ReclsFtpSearchDirectoryNode();
00114
00115
static ReclsFtpSearchDirectoryNode *FindAndCreate(HINTERNET connection, recls_uint32_t
flags, char_type
const *rootDir, char_type
const *
pattern);
00116
static ReclsFtpSearchDirectoryNode *FindAndCreate(HINTERNET connection, recls_uint32_t
flags, char_type
const *rootDir, char_type
const *subDir, char_type
const *
pattern);
00117
00118
00119
public:
00120 recls_rc_t GetNext();
00121 recls_rc_t GetDetails(recls_info_t *
pinfo);
00122 recls_rc_t GetNextDetails(recls_info_t *
pinfo);
00123
00124
00125
private:
00126 recls_rc_t Initialise();
00127
00128 recls_bool_t is_valid_()
const;
00129
00130
#if defined(RECLS_COMPILER_IS_BORLAND)
00131
static directory_sequence_type::const_iterator _select_iter(
int b, directory_sequence_type::const_iterator trueVal, directory_sequence_type::const_iterator falseVal)
00132 {
00133
00134
if(b)
00135 {
00136
return trueVal;
00137 }
00138
else
00139 {
00140
return falseVal;
00141 }
00142 }
00143
#endif
00144
static int _ssFlags_from_reclsFlags(recls_uint32_t
flags)
00145 {
00146
#if 0
00147
recls_assert(0 == (
flags & RECLS_F_LINKS));
00148 recls_assert(0 == (
flags & RECLS_F_DEVICES));
00149
#endif
00150
00151
int ssFlags = 0;
00152
00153
if(0 != (
flags & RECLS_F_FILES))
00154 {
00155
#ifdef USE_SEARCHSPEC_SEQ
00156
00157
typedef entry_sequence_type::find_sequence_type sequence_t;
00158
00159 ssFlags |= sequence_t::files;
00160
00161
00162
#else
00163 ssFlags |= entry_sequence_type::files;
00164
#endif
00165 }
00166
if(0 != (
flags & RECLS_F_DIRECTORIES))
00167 {
00168
#ifdef USE_SEARCHSPEC_SEQ
00169
00170
typedef entry_sequence_type::find_sequence_type sequence_t;
00171
00172 ssFlags |= sequence_t::directories;
00173
00174
00175
#else
00176 ssFlags |= entry_sequence_type::directories;
00177
#endif
00178 }
00179
00180
return ssFlags;
00181 }
00182
00183
00184
private:
00185 HINTERNET m_connection;
00186 recls_info_t m_current;
00187 ReclsFtpSearchDirectoryNode *m_dnode;
00188 recls_uint32_t
const m_flags;
00189 entry_sequence_type m_entries;
00190 entry_sequence_type::const_iterator m_entriesBegin;
00191 directory_sequence_type m_directories;
00192 directory_sequence_type::const_iterator m_directoriesBegin;
00193 string_type
m_rootDir;
00194 string_type m_pattern;
00195
00196
00197
private:
00198 ReclsFtpSearchDirectoryNode(class_type
const &);
00199 class_type &operator =(class_type
const &);
00200 };
00201
00202
00203
00204
00205
00206
#if !defined(RECLS_NO_NAMESPACE)
00207
}
00208
#endif
00209
00210