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
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #ifndef WINSTL_INCL_H_WINSTL
00060 # include "winstl.h"
00061 #endif
00062 #ifndef WINSTL_INCL_H_WINSTL_SYSTEM_VERSION
00063 # include "winstl_filesystem_traits.h"
00064 #endif
00065 #ifndef WINSTL_INCL_H_WINSTL_FILE_PATH_BUFFER
00066 # include "winstl_file_path_buffer.h"
00067 #endif
00068 #ifndef STLSOFT_INCL_H_STLSOFT_STRING_ACCESS
00069 # include "stlsoft_string_access.h"
00070 #endif
00071 #ifndef WINSTL_INCL_H_WINSTL_STRING_ACCESS
00072 # include "winstl_string_access.h"
00073 #endif
00074
00075
00076
00077
00078
00079 #ifndef _WINSTL_NO_NAMESPACE
00080 # if defined(_STLSOFT_NO_NAMESPACE) || \
00081 defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00082
00083 namespace winstl
00084 {
00085 # else
00086
00087
00088 namespace stlsoft
00089 {
00090
00091 namespace winstl_project
00092 {
00093
00094 # endif
00095 #endif
00096
00097 #if !defined(__STLSOFT_COMPILER_IS_MWERKS)
00098 stlsoft_ns_using(c_str_ptr)
00099 #endif
00100
00101
00102
00105
00109
00114
00115
00116
00117
00118
00119
00120
00121
00126 template< ss_typename_param_k C
00127 #ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
00128 , ss_typename_param_k T = filesystem_traits<C>
00129 #else
00130 , ss_typename_param_k T
00131 #endif
00132 >
00133 class basic_absolute_path
00134 {
00135 public:
00137 typedef C char_type;
00139 typedef T traits_type;
00141 typedef basic_absolute_path<C, T> class_type;
00143 typedef ws_size_t size_type;
00144
00145
00146 public:
00148 ss_explicit_k basic_absolute_path(char_type const *path)
00149 : m_len(traits_type::get_full_path_name(path, winstl_num_elements(m_path), &m_path[0]))
00150 {}
00151 #ifdef __STLSOFT_CF_MEMBER_TEMPLATE_CTOR_SUPPORT
00152
00153 template<ss_typename_param_k S>
00154 ss_explicit_k basic_absolute_path(S const &path)
00155 : m_len(traits_type::get_full_path_name(c_str_ptr(path), winstl_num_elements(m_path), &m_path[0]))
00156 {}
00157 #endif
00158
00159
00160 public:
00162 operator char_type const *() const
00163 {
00164 return stlsoft_ns_qual(c_str_ptr)(m_path);
00165 }
00166
00167
00168 public:
00170 size_type length() const
00171 {
00172 return m_len;
00173 }
00174
00175
00176 private:
00177 basic_file_path_buffer<char_type> m_path;
00178 size_type const m_len;
00179
00180
00181 private:
00182 basic_absolute_path(const class_type &);
00183 basic_absolute_path &operator =(const class_type &);
00184 };
00185
00186
00187
00188
00189
00191 typedef basic_absolute_path<ws_char_a_t, filesystem_traits<ws_char_a_t> > absolute_path_a;
00193 typedef basic_absolute_path<ws_char_w_t, filesystem_traits<ws_char_w_t> > absolute_path_w;
00195 typedef basic_absolute_path<TCHAR, filesystem_traits<TCHAR> > absolute_path;
00196
00197
00198
00199
00200
00201 #if !defined(__STLSOFT_COMPILER_IS_MSVC) || \
00202 _MSC_VER >= 1100
00203
00206 template<ss_typename_param_k C>
00207 inline basic_absolute_path<C> make_absolute_path(C const *path)
00208 {
00209 return basic_absolute_path<C>(path);
00210 }
00211
00212 #endif
00213
00215
00216
00217 #ifdef STLSOFT_UNITTEST
00218
00219 namespace unittest
00220 {
00221 ss_bool_t test_winstl_absolute_path(unittest_reporter *r)
00222 {
00223 using stlsoft::unittest::unittest_initialiser;
00224
00225 ss_bool_t bSuccess = true;
00226
00227 unittest_initialiser init(r, "UNIXSTL", "absolute_path", __FILE__);
00228
00229 TCHAR cwd[1 + _MAX_PATH];
00230
00231 ::GetCurrentDirectory(stlsoft_num_elements(cwd), cwd);
00232
00233 if(0 != lstrcmp(cwd, absolute_path(".")))
00234 {
00235 r->report("absolute path for \".\" failed ", __LINE__);
00236 bSuccess = false;
00237 }
00238
00239 return bSuccess;
00240 }
00241
00242 unittest_registrar unittest_winstl_absolute_path(test_winstl_absolute_path);
00243
00244 }
00245
00246 #endif
00247
00248
00249
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262 #endif
00263
00264
00265
00266
00267
00268