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
00047 #ifndef INETSTL_INCL_INETSTL_FILESYSTEM_HPP_FUNCTIONALS
00048 #define INETSTL_INCL_INETSTL_FILESYSTEM_HPP_FUNCTIONALS
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define INETSTL_VER_INETSTL_FILESYSTEM_HPP_FUNCTIONALS_MAJOR 4
00052 # define INETSTL_VER_INETSTL_FILESYSTEM_HPP_FUNCTIONALS_MINOR 0
00053 # define INETSTL_VER_INETSTL_FILESYSTEM_HPP_FUNCTIONALS_REVISION 3
00054 # define INETSTL_VER_INETSTL_FILESYSTEM_HPP_FUNCTIONALS_EDIT 33
00055 #endif
00056
00057
00058
00059
00060
00061 #ifndef INETSTL_INCL_INETSTL_H_INETSTL
00062 # include <inetstl/inetstl.h>
00063 #endif
00064 #ifndef INETSTL_OS_IS_WINDOWS
00065 # error This file is currently compatible only with the Win32/Win64 API
00066 #endif
00067 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
00068 # include <stlsoft/shims/access/string.hpp>
00069 #endif
00070 #ifndef INETSTL_INCL_INETSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS
00071 # include <inetstl/filesystem/filesystem_traits.hpp>
00072 #endif
00073 #ifndef _INETSTL_FUNCTIONALS_NO_STD
00074 # include <functional>
00075 #else
00076 # error Now need to write that std_binary_function stuff!!
00077 #endif
00078
00079
00080
00081
00082
00083 #ifndef _INETSTL_NO_NAMESPACE
00084 # if defined(_STLSOFT_NO_NAMESPACE) || \
00085 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00086
00087 namespace inetstl
00088 {
00089 # else
00090
00091
00092 namespace stlsoft
00093 {
00094
00095 namespace inetstl_project
00096 {
00097
00098 # endif
00099 #endif
00100
00101
00102
00103
00104
00113
00114 template< ss_typename_param_k C
00115 , ss_typename_param_k A1 = C const*
00116 , ss_typename_param_k A2 = C const*
00117 >
00118 struct path_compare
00119 : public inetstl_ns_qual_std(binary_function)<A1, A2, is_bool_t>
00120 {
00121 public:
00123 typedef C char_type;
00124 private:
00125 typedef inetstl_ns_qual_std(binary_function)<A1, A2, is_bool_t> parent_class_type;
00126 public:
00128 typedef ss_typename_type_k parent_class_type::first_argument_type first_argument_type;
00130 typedef ss_typename_type_k parent_class_type::second_argument_type second_argument_type;
00132 typedef ss_typename_type_k parent_class_type::result_type result_type;
00134 typedef filesystem_traits<C> traits_type;
00136 typedef path_compare<C, A1, A2> class_type;
00137
00138 public:
00142 #ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
00143 template<ss_typename_param_k T1, ss_typename_param_k T2>
00144 result_type operator ()(T1 const& s1, T2 const& s2) const
00145 #else
00146 result_type operator ()(first_argument_type s1, second_argument_type s2) const
00147 #endif
00148 {
00149 return compare_(stlsoft_ns_qual(c_str_ptr)(s1), stlsoft_ns_qual(c_str_ptr)(s2));
00150 }
00151
00152
00153 private:
00154 static result_type compare_(char_type const* s1, char_type const* s2)
00155 {
00156 char_type path1[_MAX_PATH + 1];
00157 char_type path2[_MAX_PATH + 1];
00158
00159 traits_type::str_n_copy(&path1[0], s1, STLSOFT_NUM_ELEMENTS(path1));
00160 traits_type::str_n_copy(&path2[0], s2, STLSOFT_NUM_ELEMENTS(path2));
00161
00162 traits_type::remove_dir_end(&path1[0]);
00163 traits_type::remove_dir_end(&path2[0]);
00164
00165 s1 = &path1[0];
00166 s2 = &path2[0];
00167
00168 return 0 == traits_type::str_compare(s1, s2);
00169 }
00170 };
00171
00179 template< ss_typename_param_k C
00180 , ss_typename_param_k A = C const*
00181 >
00182
00183 struct path_exists
00184 : public inetstl_ns_qual_std(unary_function)<A, is_bool_t>
00185 {
00186 public:
00188 typedef C char_type;
00190 typedef filesystem_traits<C> traits_type;
00192 typedef path_exists<C> class_type;
00193
00194 public:
00195 ss_explicit_k path_exists(HINTERNET hConnection)
00196 : m_hConnection(hConnection)
00197 {}
00198
00199 public:
00200 #ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
00201 template <ss_typename_param_k S>
00202 is_bool_t operator ()(S const& s) const
00203 #else
00204 is_bool_t operator ()(argument_type s) const
00205 #endif
00206 {
00207 return exists_(stlsoft_ns_qual(c_str_ptr)(s));
00208 }
00209
00210 private:
00211 is_bool_t exists_(char_type const* s) const
00212 {
00213 char_type sz0[1 + _MAX_PATH];
00214 is_dword_t dw;
00215
00216 if(!traits_type::get_full_path_name(m_hConnection, s, STLSOFT_NUM_ELEMENTS(sz0), sz0))
00217 {
00218 dw = 0xFFFFFFFF;
00219 }
00220 else
00221 {
00222 dw = ::GetFileAttributes(sz0);
00223 }
00224
00225 return 0xFFFFFFFF != dw;
00226 }
00227
00228 private:
00229 HINTERNET m_hConnection;
00230 };
00231
00233
00234
00235 #ifdef STLSOFT_UNITTEST
00236 # include "./unittest/functionals_unittest_.h"
00237 #endif
00238
00239
00240
00241 #ifndef _INETSTL_NO_NAMESPACE
00242 # if defined(_STLSOFT_NO_NAMESPACE) || \
00243 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00244 }
00245 # else
00246 }
00247 }
00248 # endif
00249 #endif
00250
00251
00252
00253 #endif
00254
00255