C/C++ User's Journal STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ... ATLSTL - where the Standard Template Library meets the Active Template Library COMSTL - where the Standard Template Library meets the Component Object Model
Synesis Software InetSTL - where the Standard Template Library meets the Internet UNIXSTL - Template Software for the UNIX Operating System WinSTL - where the Standard Template Library meets the Win32 API

Main Page | Modules | Namespace List | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Dev/src/ReclsFtpSearchDirectoryNode_win32.h

Go to the documentation of this file.
00001 /* ///////////////////////////////////////////////////////////////////////////// 00002 * File: ReclsFtpSearchDirectoryNode_win32.h 00003 * 00004 * Purpose: ReclsFtpSearchDirectoryNode class, for Win32. 00005 * 00006 * Created: 31st May 2004 00007 * Updated: 10th January 2005 00008 * 00009 * Home: http://recls.org/ 00010 * 00011 * Copyright 2004-2005, Matthew Wilson and Synesis Software 00012 * All rights reserved. 00013 * 00014 * Redistribution and use in source and binary forms, with or without 00015 * modification, are permitted provided that the following conditions are met: 00016 * 00017 * - Redistributions of source code must retain the above copyright notice, this 00018 * list of conditions and the following disclaimer. 00019 * - Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of 00023 * any contributors may be used to endorse or promote products derived from 00024 * this software without specific prior written permission. 00025 * 00026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00036 * POSSIBILITY OF SUCH DAMAGE. 00037 * 00038 * ////////////////////////////////////////////////////////////////////////// */ 00039 00040 00041 /* ///////////////////////////////////////////////////////////////////////////// 00042 * Includes 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 /* USE_SEARCHSPEC_SEQ */ 00056 00057 // The Dinkumware list implementation causes Visual C++ 7.1 to give C4702 warning, so we don't use it 00058 #if defined(RECLS_COMPILER_IS_MSVC) && \ 00059 _MSC_VER >= 1310 00060 # include <vector> 00061 #else /* ? compiler */ 00062 # include <list> 00063 #endif /* compiler */ 00064 00065 /* ///////////////////////////////////////////////////////////////////////////// 00066 * Namespace 00067 */ 00068 00069 #if !defined(RECLS_NO_NAMESPACE) 00070 namespace recls 00071 { 00072 #endif /* !RECLS_NO_NAMESPACE */ 00073 00074 #ifdef USE_SEARCHSPEC_SEQ 00075 inetstl_ns_using(searchspec_sequence) 00076 #endif /* USE_SEARCHSPEC_SEQ */ 00077 inetstl_ns_using(basic_findfile_sequence) 00078 00079 /* ///////////////////////////////////////////////////////////////////////////// 00080 * Classes 00081 */ 00082 00083 class ReclsFtpSearchDirectoryNode 00084 // : public ReclsDNode 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 /* ? compiler */ 00097 typedef stlsoft_ns_qual_std(list)<string_type> directory_sequence_type; 00098 #endif /* compiler */ 00099 #ifdef USE_SEARCHSPEC_SEQ 00100 typedef searchspec_sequence<file_find_sequence_type> entry_sequence_type; 00101 #else /* ? USE_SEARCHSPEC_SEQ */ 00102 typedef file_find_sequence_type entry_sequence_type; 00103 #endif /* USE_SEARCHSPEC_SEQ */ 00104 00105 // Construction 00106 #if defined(RECLS_COMPILER_IS_GCC) 00107 protected: 00108 #else /* ? compiler */ 00109 private: 00110 #endif /* compiler */ 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 // ReclsDNode methods 00119 public: 00120 /* virtual */ recls_rc_t GetNext(); 00121 /* virtual */ recls_rc_t GetDetails(recls_info_t *pinfo); 00122 /* virtual */ recls_rc_t GetNextDetails(recls_info_t *pinfo); 00123 00124 // Implementation 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 // I can't explain it, but Borland does not like the tertiary operator and the copy-ctors of the iterators 00134 if(b) 00135 { 00136 return trueVal; 00137 } 00138 else 00139 { 00140 return falseVal; 00141 } 00142 } 00143 #endif /* !RECLS_COMPILER_IS_BORLAND */ 00144 static int _ssFlags_from_reclsFlags(recls_uint32_t flags) 00145 { 00146 #if 0 00147 recls_assert(0 == (flags & RECLS_F_LINKS)); // Doesn't work with links 00148 recls_assert(0 == (flags & RECLS_F_DEVICES)); // Doesn't work with devices 00149 #endif /* 0 */ 00150 00151 int ssFlags = 0; 00152 00153 if(0 != (flags & RECLS_F_FILES)) 00154 { 00155 #ifdef USE_SEARCHSPEC_SEQ 00156 // Because Digital Mars 8.40- has a problem, we must access the typedef separately from the enum value 00157 typedef entry_sequence_type::find_sequence_type sequence_t; 00158 00159 ssFlags |= sequence_t::files; 00160 00161 // ssFlags |= entry_sequence_type::find_sequence_type::files; 00162 #else /* ? USE_SEARCHSPEC_SEQ */ 00163 ssFlags |= entry_sequence_type::files; 00164 #endif /* USE_SEARCHSPEC_SEQ */ 00165 } 00166 if(0 != (flags & RECLS_F_DIRECTORIES)) 00167 { 00168 #ifdef USE_SEARCHSPEC_SEQ 00169 // Because Digital Mars 8.40- has a problem, we must access the typedef separately from the enum value 00170 typedef entry_sequence_type::find_sequence_type sequence_t; 00171 00172 ssFlags |= sequence_t::directories; 00173 00174 // ssFlags |= entry_sequence_type::find_sequence_type::directories; 00175 #else /* ? USE_SEARCHSPEC_SEQ */ 00176 ssFlags |= entry_sequence_type::directories; 00177 #endif /* USE_SEARCHSPEC_SEQ */ 00178 } 00179 00180 return ssFlags; 00181 } 00182 00183 // Members 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 // Not to be implemented 00197 private: 00198 ReclsFtpSearchDirectoryNode(class_type const &); 00199 class_type &operator =(class_type const &); 00200 }; 00201 00202 /* ///////////////////////////////////////////////////////////////////////////// 00203 * Namespace 00204 */ 00205 00206 #if !defined(RECLS_NO_NAMESPACE) 00207 } /* namespace recls */ 00208 #endif /* !RECLS_NO_NAMESPACE */ 00209 00210 /* ////////////////////////////////////////////////////////////////////////// */

recls Library documentation © Synesis Software Pty Ltd, 2001-2005