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
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #ifndef WINSTL_INCL_H_WINSTL
00061 # include "winstl.h"
00062 #endif
00063 #ifndef WINSTL_INCL_H_WINSTL_FILESYSTEM_TRAITS
00064 # include "winstl_filesystem_traits.h"
00065 #endif
00066 #ifndef WINSTL_INCL_H_WINSTL_STRING_ACCESS
00067 # include "winstl_string_access.h"
00068 #endif
00069 #ifndef STLSOFT_INCL_H_STLSOFT_CONSTRAINTS
00070 # include "stlsoft_constraints.h"
00071 #endif
00072
00073
00074
00075
00076
00077 #ifndef _WINSTL_NO_NAMESPACE
00078 # if defined(_STLSOFT_NO_NAMESPACE) || \
00079 defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00080
00081 namespace winstl
00082 {
00083 # else
00084
00085
00086 namespace stlsoft
00087 {
00088
00089 namespace winstl_project
00090 {
00091
00092 # endif
00093 #endif
00094
00095
00096
00099
00103
00108
00109
00110
00111
00112
00113
00114
00115
00120 template< ss_typename_param_k C
00121 #ifdef __STLSOFT_CF_TEMPLATE_CLASS_DEFAULT_CLASS_ARGUMENT_SUPPORT
00122 , ss_typename_param_k T = filesystem_traits<C>
00123 #else
00124 , ss_typename_param_k T
00125 #endif
00126 >
00127 class basic_system_directory
00128 {
00129 public:
00131 typedef C char_type;
00133 typedef T traits_type;
00135 typedef basic_system_directory<C, T> class_type;
00137 typedef ws_size_t size_type;
00138
00139
00140 public:
00142 static size_type get_path(ws_char_a_t *buffer, size_type cchBuffer);
00144 static size_type get_path(ws_char_w_t *buffer, size_type cchBuffer);
00145
00146
00147 public:
00149 char_type const *get_path() const;
00151 char_type const *c_str() const;
00153 size_type length() const;
00154
00155
00156 public:
00158 operator char_type const *() const
00159 {
00160 return get_path();
00161 }
00162
00163
00164 private:
00165 struct Information
00166 {
00167 char_type m_dir[_MAX_PATH];
00168 size_type m_len;
00169
00170 Information()
00171 : m_len(get_path(m_dir, winstl_num_elements(m_dir)))
00172 {}
00173 };
00174
00175 #if !defined(__STLSOFT_COMPILER_IS_DMC)
00176 static Information const &get_information_()
00177 {
00178 static Information s_info;
00179
00180 return s_info;
00181 }
00182 #else
00183
00184
00185
00186 Information m_information;
00187 Information const &get_information_() const
00188 {
00189 return m_information;
00190 }
00191 #endif
00192 };
00193
00194
00195
00196
00197
00199 typedef basic_system_directory<ws_char_a_t, filesystem_traits<ws_char_a_t> > system_directory_a;
00201 typedef basic_system_directory<ws_char_w_t, filesystem_traits<ws_char_w_t> > system_directory_w;
00203 typedef basic_system_directory<TCHAR, filesystem_traits<TCHAR> > system_directory;
00204
00205
00206
00207
00208
00209 #ifndef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00210
00211 template< ss_typename_param_k C
00212 , ss_typename_param_k T
00213 >
00214 inline ss_typename_type_k basic_system_directory<C, T>::size_type basic_system_directory<C, T>::get_path(ws_char_a_t *buffer, ss_typename_type_k basic_system_directory<C, T>::size_type cchBuffer)
00215 {
00216 return static_cast<size_type>(::GetSystemDirectoryA(buffer, cchBuffer));
00217 }
00218
00219 template< ss_typename_param_k C
00220 , ss_typename_param_k T
00221 >
00222 inline ss_typename_type_k basic_system_directory<C, T>::size_type basic_system_directory<C, T>::get_path(ws_char_w_t *buffer, ss_typename_type_k basic_system_directory<C, T>::size_type cchBuffer)
00223 {
00224 return static_cast<size_type>(::GetSystemDirectoryW(buffer, cchBuffer));
00225 }
00226
00227 template< ss_typename_param_k C
00228 , ss_typename_param_k T
00229 >
00230 inline ss_typename_type_k basic_system_directory<C, T>::char_type const *basic_system_directory<C, T>::get_path() const
00231 {
00232 #if defined(__STLSOFT_COMPILER_IS_DMC)
00233 return get_information_().m_dir;
00234 #else
00235 static char_type const *s_sz = get_information_().m_dir;
00236
00237 return s_sz;
00238 #endif
00239 }
00240
00241 template< ss_typename_param_k C
00242 , ss_typename_param_k T
00243 >
00244 inline ss_typename_type_k basic_system_directory<C, T>::char_type const *basic_system_directory<C, T>::c_str() const
00245 {
00246 return get_path();
00247 }
00248
00249 template< ss_typename_param_k C
00250 , ss_typename_param_k T
00251 >
00252 inline ss_typename_type_k basic_system_directory<C, T>::size_type basic_system_directory<C, T>::length() const
00253 {
00254 return get_information_().m_len;
00255 }
00256
00257 #endif
00258
00260
00261
00262 #ifdef STLSOFT_UNITTEST
00263
00264 namespace unittest
00265 {
00266 ss_bool_t test_winstl_system_directory(unittest_reporter *r)
00267 {
00268 using stlsoft::unittest::unittest_initialiser;
00269
00270 ss_bool_t bSuccess = true;
00271
00272 unittest_initialiser init(r, "WinSTL", "system_directory", __FILE__);
00273
00274 #if 0
00275 if(<<TODO>>)
00276 {
00277 r->report("<<TODO>> failed ", __LINE__);
00278 bSuccess = false;
00279 }
00280 #endif
00281
00282 return bSuccess;
00283 }
00284
00285 unittest_registrar unittest_winstl_system_directory(test_winstl_system_directory);
00286
00287 }
00288
00289 #endif
00290
00291
00292
00294
00295
00296
00297
00298
00300
00303
00307
00312
00314 template< ss_typename_param_k C
00315 , ss_typename_param_k T
00316 >
00317 inline C const *c_str_ptr_null(basic_system_directory<C, T> const &sd)
00318 {
00319 return sd;
00320 }
00321
00323 template< ss_typename_param_k C
00324 , ss_typename_param_k T
00325 >
00326 inline C const *c_str_ptr(basic_system_directory<C, T> const &sd)
00327 {
00328 return sd;
00329 }
00330
00332 template< ss_typename_param_k C
00333 , ss_typename_param_k T
00334 >
00335 inline ws_size_t c_str_len(basic_system_directory<C, T> const &sd)
00336 {
00337 return sd.length();
00338 }
00339
00341 template< ss_typename_param_k C
00342 , ss_typename_param_k T
00343 >
00344 inline ws_size_t c_str_size(basic_system_directory<C, T> const &sd)
00345 {
00346 return sd.length() * sizeof(C);
00347 }
00348
00349
00350
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363 #endif
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 #ifndef _WINSTL_NO_NAMESPACE
00374 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00375 !defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00376 namespace stlsoft
00377 {
00378 # else
00379
00380 # endif
00381
00382 using ::winstl::c_str_ptr_null;
00383
00384 using ::winstl::c_str_ptr;
00385
00386 using ::winstl::c_str_len;
00387
00388 using ::winstl::c_str_size;
00389
00390 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00391 !defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00392 }
00393 # else
00394
00395 # endif
00396 #endif
00397
00398
00399
00400
00401
00402