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