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 
00048 #ifndef UNIXSTL_INCL_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_FUNCTIONALS
00049 #define UNIXSTL_INCL_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_FUNCTIONALS
00050 
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_FUNCTIONALS_MAJOR    4
00053 # define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_FUNCTIONALS_MINOR    1
00054 # define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_FUNCTIONALS_REVISION 2
00055 # define UNIXSTL_VER_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_FUNCTIONALS_EDIT     48
00056 #endif 
00057 
00058 
00059 
00060 
00061 
00062 #ifndef UNIXSTL_INCL_UNIXSTL_H_UNIXSTL
00063 # include <unixstl/unixstl.h>
00064 #endif 
00065 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
00066 # include <stlsoft/shims/access/string.hpp>
00067 #endif 
00068 #ifndef UNIXSTL_INCL_UNIXSTL_SHIMS_ACCESS_HPP_STRING
00069 # include <unixstl/shims/access/string.hpp>
00070 #endif 
00071 #ifndef UNIXSTL_INCL_UNIXSTL_FILESYSTEM_HPP_FILESYSTEM_TRAITS
00072 # include <unixstl/filesystem/filesystem_traits.hpp>
00073 #endif 
00074 #ifndef UNIXSTL_INCL_UNIXSTL_FILESYSTEM_HPP_FILE_PATH_BUFFER
00075 # include <unixstl/filesystem/file_path_buffer.hpp>
00076 #endif 
00077 #ifndef _UNIXSTL_FUNCTIONALS_NO_STD
00078 # include <functional>
00079 #else 
00080 # error Now need to write that std_binary_function stuff!!
00081 #endif 
00082 
00083 
00084 
00085 
00086 
00087 #ifndef _UNIXSTL_NO_NAMESPACE
00088 # if defined(_STLSOFT_NO_NAMESPACE) || \
00089      defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00090 
00091 namespace unixstl
00092 {
00093 # else
00094 
00095 
00096 namespace stlsoft
00097 {
00098 
00099 namespace unixstl_project
00100 {
00101 
00102 # endif 
00103 #endif 
00104 
00105 
00106 
00107 
00108 
00113 template <ss_typename_param_k C>
00114 
00115 struct path_compare
00116     : public unixstl_ns_qual_std(binary_function)<C const*, C const*, us_bool_t>
00117 {
00118 public:
00120     typedef C                                                                       char_type;
00121 private:
00122     typedef unixstl_ns_qual_std(binary_function)<C const*, C const*, us_bool_t>   parent_class_type;
00123 public:
00125     typedef ss_typename_type_k parent_class_type::first_argument_type               first_argument_type;
00127     typedef ss_typename_type_k parent_class_type::second_argument_type              second_argument_type;
00129     typedef ss_typename_type_k parent_class_type::result_type                       result_type;
00131     typedef filesystem_traits<C>                                                    traits_type;
00133     typedef path_compare<C>                                                         class_type;
00134 
00135 public:
00139 #ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
00140     template <ss_typename_param_k T1, ss_typename_param_k T2>
00141     result_type operator ()(T1 const& s1, T2 const& s2)
00142 #else 
00143     result_type operator ()(first_argument_type s1, second_argument_type s2)
00144 #endif 
00145     {
00146         return compare_(stlsoft_ns_qual(c_str_ptr)(s1), stlsoft_ns_qual(c_str_ptr)(s2));
00147     }
00148 
00149 
00150 private:
00151     result_type compare_(char_type const* s1, char_type const* s2)
00152     {
00153         basic_file_path_buffer<char_type>   path1;
00154         basic_file_path_buffer<char_type>   path2;
00155 
00156         if( !traits_type::get_full_path_name(s1, path1.size(), &path1[0]) ||
00157             !traits_type::get_full_path_name(s2, path2.size(), &path2[0]))
00158         {
00159             return false;
00160         }
00161         else
00162         {
00163             traits_type::remove_dir_end(&path1[0]);
00164             traits_type::remove_dir_end(&path2[0]);
00165 
00166             s1 = path1.c_str();
00167             s2 = path2.c_str();
00168 
00169             return 0 == traits_type::str_compare(s1, s2);
00170         }
00171     }
00172 };
00173 
00184 template<   ss_typename_param_k C
00185         ,   ss_typename_param_k A = C const*
00186         >
00187 
00188 struct path_exists
00189     : public unixstl_ns_qual_std(unary_function)<A, us_bool_t>
00190 {
00191 private:
00192     typedef unixstl_ns_qual_std(unary_function)<A, us_bool_t>   parent_class_type;
00193     typedef filesystem_traits<C>                                traits_type;
00194 public:
00196     typedef C                                                   char_type;
00198     typedef A                                                   argument_type;
00200     typedef path_exists<C, A>                                   class_type;
00201 
00202 public:
00203 #ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
00204     template <ss_typename_param_k S>
00205     us_bool_t operator ()(S const& s) const
00206 #else 
00207     us_bool_t operator ()(argument_type s) const
00208 #endif 
00209     {
00210         return traits_type::file_exists(stlsoft_ns_qual(c_str_ptr)(s));
00211     }
00212 };
00213 
00215 
00216 
00217 #ifdef STLSOFT_UNITTEST
00218 # include "./unittest/functionals_unittest_.h"
00219 #endif 
00220 
00221 
00222 
00223 #ifndef _UNIXSTL_NO_NAMESPACE
00224 # if defined(_STLSOFT_NO_NAMESPACE) || \
00225      defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00226 } 
00227 # else
00228 } 
00229 } 
00230 # endif 
00231 #endif 
00232 
00233 
00234 
00235 #endif 
00236 
00237