os/ossrv/ossrv_pub/boost_apis/boost/filesystem/operations.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/filesystem/operations.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1099 @@
     1.4 +//  boost/filesystem/operations.hpp  -----------------------------------------//
     1.5 +
     1.6 +//  Copyright 2002-2005 Beman Dawes
     1.7 +//  Copyright 2002 Jan Langer
     1.8 +//  Copyright 2001 Dietmar Kuehl                                        
     1.9 +//  
    1.10 +//  Use, modification, and distribution is subject to the Boost Software
    1.11 +//  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
    1.12 +//  at http://www.boost.org/LICENSE_1_0.txt)                             
    1.13 +
    1.14 +//  See library home page at http://www.boost.org/libs/filesystem
    1.15 +
    1.16 +//----------------------------------------------------------------------------// 
    1.17 +
    1.18 +#ifndef BOOST_FILESYSTEM_OPERATIONS_HPP
    1.19 +#define BOOST_FILESYSTEM_OPERATIONS_HPP
    1.20 +
    1.21 +#include <boost/filesystem/path.hpp>  // includes <boost/filesystem/config.hpp>
    1.22 +
    1.23 +#include <boost/shared_ptr.hpp>
    1.24 +#include <boost/utility/enable_if.hpp>
    1.25 +#include <boost/type_traits/is_same.hpp>
    1.26 +#include <boost/iterator.hpp>
    1.27 +#include <boost/cstdint.hpp>
    1.28 +#include <boost/assert.hpp>
    1.29 +
    1.30 +#include <string>
    1.31 +#include <utility> // for pair
    1.32 +#include <ctime>
    1.33 +
    1.34 +#ifdef BOOST_WINDOWS_API
    1.35 +#  include <fstream>
    1.36 +#  if !defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0500
    1.37 +#    define BOOST_FS_HARD_LINK // Default for Windows 2K or later 
    1.38 +#  endif
    1.39 +#endif
    1.40 +
    1.41 +#include <boost/config/abi_prefix.hpp> // must be the last #include
    1.42 +
    1.43 +# ifdef BOOST_NO_STDC_NAMESPACE
    1.44 +    namespace std { using ::time_t; }
    1.45 +# endif
    1.46 +
    1.47 +# ifndef BOOST_FILESYSTEM_NARROW_ONLY
    1.48 +#   define BOOST_FS_FUNC(BOOST_FS_TYPE) \
    1.49 +      template<class Path> typename boost::enable_if<is_basic_path<Path>, \
    1.50 +      BOOST_FS_TYPE>::type
    1.51 +#   define BOOST_INLINE_FS_FUNC(BOOST_FS_TYPE) \
    1.52 +      template<class Path> inline typename boost::enable_if<is_basic_path<Path>, \
    1.53 +      BOOST_FS_TYPE>::type
    1.54 +#   define BOOST_FS_TYPENAME typename
    1.55 +# else
    1.56 +#   define BOOST_FS_FUNC(BOOST_FS_TYPE) inline BOOST_FS_TYPE
    1.57 +#   define BOOST_INLINE_FS_FUNC(BOOST_FS_TYPE) inline BOOST_FS_TYPE
    1.58 +    typedef boost::filesystem::path Path;
    1.59 +#   define BOOST_FS_TYPENAME
    1.60 +# endif
    1.61 +
    1.62 +//----------------------------------------------------------------------------//
    1.63 +
    1.64 +namespace boost
    1.65 +{
    1.66 +  namespace filesystem
    1.67 +  {
    1.68 +    template<class Path> class basic_directory_iterator;
    1.69 +
    1.70 +    // BOOST_FILESYSTEM_NARROW_ONLY needs this:
    1.71 +    typedef basic_directory_iterator<path> directory_iterator;
    1.72 +
    1.73 +    template<class Path> class basic_directory_entry;
    1.74 +
    1.75 +    enum file_type
    1.76 +    { 
    1.77 +      status_unknown,
    1.78 +      file_not_found,
    1.79 +      regular_file,
    1.80 +      directory_file,
    1.81 +      // the following will never be reported by some operating or file systems
    1.82 +      symlink_file,
    1.83 +      block_file,
    1.84 +      character_file,
    1.85 +      fifo_file,
    1.86 +      socket_file,
    1.87 +      type_unknown // file does exist, but isn't one of the above types
    1.88 +    };
    1.89 +
    1.90 +    class file_status
    1.91 +    {
    1.92 +    public:
    1.93 +      explicit file_status( file_type v = status_unknown ) : m_value(v) {}
    1.94 +
    1.95 +      void type( file_type v )  { m_value = v; }
    1.96 +      file_type type() const    { return m_value; }
    1.97 +
    1.98 +    private:
    1.99 +      // the internal representation is unspecified so that additional state
   1.100 +      // information such as permissions can be added in the future; this
   1.101 +      // implementation just uses status_type as the internal representation
   1.102 +
   1.103 +      file_type m_value;
   1.104 +    };
   1.105 +
   1.106 +    inline bool status_known( file_status f ) { return f.type() != status_unknown; }
   1.107 +    inline bool exists( file_status f )       { return f.type() != status_unknown && f.type() != file_not_found; }
   1.108 +    inline bool is_regular( file_status f )   { return f.type() == regular_file; }
   1.109 +    inline bool is_directory( file_status f ) { return f.type() == directory_file; }
   1.110 +    inline bool is_symlink( file_status f )   { return f.type() == symlink_file; }
   1.111 +    inline bool is_other( file_status f )     { return exists(f) && !is_regular(f) && !is_directory(f) && !is_symlink(f); }
   1.112 +
   1.113 +    struct space_info
   1.114 +    {
   1.115 +      // all values are byte counts
   1.116 +      boost::uintmax_t capacity;
   1.117 +      boost::uintmax_t free;      // <= capacity
   1.118 +      boost::uintmax_t available; // <= free
   1.119 +    };
   1.120 +
   1.121 +    namespace detail
   1.122 +    {
   1.123 +      typedef std::pair< boost::filesystem::system_error_type, bool >
   1.124 +        query_pair;
   1.125 +
   1.126 +      typedef std::pair< boost::filesystem::system_error_type, boost::uintmax_t >
   1.127 +        uintmax_pair;
   1.128 +
   1.129 +      typedef std::pair< boost::filesystem::system_error_type, std::time_t >
   1.130 +        time_pair;
   1.131 +
   1.132 +      typedef std::pair< boost::filesystem::system_error_type, space_info >
   1.133 +        space_pair;
   1.134 +
   1.135 +      template< class Path >
   1.136 +      struct directory_pair
   1.137 +      {
   1.138 +        typedef std::pair< boost::filesystem::system_error_type,
   1.139 +          typename Path::external_string_type > type;
   1.140 +      };
   1.141 +
   1.142 +#   ifndef BOOST_FILESYSTEM_NO_DEPRECATED
   1.143 +      BOOST_FILESYSTEM_DECL bool
   1.144 +        symbolic_link_exists_api( const std::string & ); // deprecated
   1.145 +#   endif
   1.146 +
   1.147 +      BOOST_FILESYSTEM_DECL file_status
   1.148 +        status_api( const std::string & ph, system_error_type & ec );
   1.149 +#   ifndef BOOST_WINDOWS_API
   1.150 +      BOOST_FILESYSTEM_DECL file_status
   1.151 +        symlink_status_api( const std::string & ph, system_error_type & ec );
   1.152 +#   endif
   1.153 +      BOOST_FILESYSTEM_DECL query_pair
   1.154 +        is_empty_api( const std::string & ph );
   1.155 +      BOOST_FILESYSTEM_DECL query_pair
   1.156 +        equivalent_api( const std::string & ph1, const std::string & ph2 );
   1.157 +      BOOST_FILESYSTEM_DECL uintmax_pair
   1.158 +        file_size_api( const std::string & ph );
   1.159 +      BOOST_FILESYSTEM_DECL space_pair
   1.160 +        space_api( const std::string & ph );
   1.161 +      BOOST_FILESYSTEM_DECL time_pair 
   1.162 +        last_write_time_api( const std::string & ph );
   1.163 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.164 +        last_write_time_api( const std::string & ph, std::time_t new_value );
   1.165 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.166 +        get_current_path_api( std::string & ph );
   1.167 +      BOOST_FILESYSTEM_DECL query_pair
   1.168 +        create_directory_api( const std::string & ph );
   1.169 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.170 +        create_hard_link_api( const std::string & to_ph,
   1.171 +          const std::string & from_ph );
   1.172 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.173 +        create_symlink_api( const std::string & to_ph,
   1.174 +          const std::string & from_ph );
   1.175 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.176 +        remove_api( const std::string & ph );
   1.177 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.178 +        rename_api( const std::string & from, const std::string & to );
   1.179 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.180 +        copy_file_api( const std::string & from, const std::string & to );
   1.181 +
   1.182 +#   if defined(BOOST_WINDOWS_API)
   1.183 +      
   1.184 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.185 +        get_full_path_name_api( const std::string & ph, std::string & target );
   1.186 +
   1.187 +#     if !defined(BOOST_FILESYSTEM_NARROW_ONLY)
   1.188 +
   1.189 +      BOOST_FILESYSTEM_DECL  boost::filesystem::file_status
   1.190 +        status_api( const std::wstring & ph, system_error_type & ec );
   1.191 +      BOOST_FILESYSTEM_DECL query_pair 
   1.192 +        is_empty_api( const std::wstring & ph );
   1.193 +      BOOST_FILESYSTEM_DECL query_pair
   1.194 +        equivalent_api( const std::wstring & ph1, const std::wstring & ph2 );
   1.195 +      BOOST_FILESYSTEM_DECL uintmax_pair 
   1.196 +        file_size_api( const std::wstring & ph );
   1.197 +      BOOST_FILESYSTEM_DECL space_pair 
   1.198 +        space_api( const std::wstring & ph );
   1.199 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.200 +        get_full_path_name_api( const std::wstring & ph, std::wstring & target );
   1.201 +      BOOST_FILESYSTEM_DECL time_pair 
   1.202 +        last_write_time_api( const std::wstring & ph );
   1.203 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.204 +        last_write_time_api( const std::wstring & ph, std::time_t new_value );
   1.205 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type 
   1.206 +        get_current_path_api( std::wstring & ph );
   1.207 +      BOOST_FILESYSTEM_DECL query_pair
   1.208 +        create_directory_api( const std::wstring & ph );
   1.209 +# ifdef BOOST_FS_HARD_LINK
   1.210 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.211 +        create_hard_link_api( const std::wstring & existing_ph,
   1.212 +          const std::wstring & new_ph );
   1.213 +# endif
   1.214 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.215 +        create_symlink_api( const std::wstring & to_ph,
   1.216 +          const std::wstring & from_ph );
   1.217 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.218 +        remove_api( const std::wstring & ph );
   1.219 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.220 +        rename_api( const std::wstring & from, const std::wstring & to );
   1.221 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.222 +        copy_file_api( const std::wstring & from, const std::wstring & to );
   1.223 +
   1.224 +#     endif
   1.225 +#   endif
   1.226 +
   1.227 +      template<class Path>
   1.228 +      unsigned long remove_all_aux( const Path & ph );
   1.229 +
   1.230 +    } // namespace detail
   1.231 +
   1.232 +//  operations functions  ----------------------------------------------------//
   1.233 +
   1.234 +    //  The non-template overloads enable automatic conversion from std and
   1.235 +    //  C-style strings. See basic_path constructors. The enable_if for the
   1.236 +    //  templates implements the famous "do-the-right-thing" rule.
   1.237 +
   1.238 +//  query functions  ---------------------------------------------------------//
   1.239 +
   1.240 +    BOOST_INLINE_FS_FUNC(file_status)
   1.241 +    status( const Path & ph, system_error_type & ec )
   1.242 +      { return detail::status_api( ph.external_file_string(), ec ); }
   1.243 +
   1.244 +    BOOST_FS_FUNC(file_status)
   1.245 +    status( const Path & ph )
   1.246 +    { 
   1.247 +      system_error_type ec;
   1.248 +      file_status result( detail::status_api( ph.external_file_string(), ec ) );
   1.249 +      if ( ec )
   1.250 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.251 +        "boost::filesystem::status", ph, ec ) );
   1.252 +      return result;
   1.253 +    }
   1.254 +
   1.255 +    BOOST_INLINE_FS_FUNC(file_status)
   1.256 +    symlink_status( const Path & ph, system_error_type & ec )
   1.257 +#   ifdef BOOST_WINDOWS_API
   1.258 +      { return detail::status_api( ph.external_file_string(), ec ); }
   1.259 +#   else
   1.260 +      { return detail::symlink_status_api( ph.external_file_string(), ec ); }
   1.261 +#   endif
   1.262 +
   1.263 +    BOOST_FS_FUNC(file_status)
   1.264 +    symlink_status( const Path & ph )
   1.265 +    { 
   1.266 +      system_error_type ec;
   1.267 +      file_status result( symlink_status( ph, ec ) );
   1.268 +      if ( ec )
   1.269 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.270 +        "boost::filesystem::symlink_status", ph, ec ) );
   1.271 +      return result;
   1.272 +    }
   1.273 +
   1.274 +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
   1.275 +    inline bool symbolic_link_exists( const path & ph )
   1.276 +      { return is_symlink( symlink_status(ph) ); }
   1.277 +#endif
   1.278 +
   1.279 +    BOOST_FS_FUNC(bool) exists( const Path & ph )
   1.280 +    { 
   1.281 +      system_error_type ec;
   1.282 +      file_status result( detail::status_api( ph.external_file_string(), ec ) );
   1.283 +      if ( ec )
   1.284 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.285 +          "boost::filesystem::exists", ph, ec ) );
   1.286 +      return exists( result );
   1.287 +    }
   1.288 +
   1.289 +    BOOST_FS_FUNC(bool) is_directory( const Path & ph )
   1.290 +    { 
   1.291 +      system_error_type ec;
   1.292 +      file_status result( detail::status_api( ph.external_file_string(), ec ) );
   1.293 +      if ( ec )
   1.294 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.295 +          "boost::filesystem::is_directory", ph, ec ) );
   1.296 +      return is_directory( result );
   1.297 +    }
   1.298 +
   1.299 +    BOOST_FS_FUNC(bool) is_regular( const Path & ph )
   1.300 +    { 
   1.301 +      system_error_type ec;
   1.302 +      file_status result( detail::status_api( ph.external_file_string(), ec ) );
   1.303 +      if ( ec )
   1.304 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.305 +          "boost::filesystem::is_regular", ph, ec ) );
   1.306 +      return is_regular( result );
   1.307 +    }
   1.308 +
   1.309 +    BOOST_FS_FUNC(bool) is_other( const Path & ph )
   1.310 +    { 
   1.311 +      system_error_type ec;
   1.312 +      file_status result( detail::status_api( ph.external_file_string(), ec ) );
   1.313 +      if ( ec )
   1.314 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.315 +          "boost::filesystem::is_other", ph, ec ) );
   1.316 +      return is_other( result );
   1.317 +    }
   1.318 +
   1.319 +    BOOST_FS_FUNC(bool) is_symlink(
   1.320 +#   ifdef BOOST_WINDOWS_API
   1.321 +      const Path & )
   1.322 +    {
   1.323 +      return false;
   1.324 +#   else
   1.325 +      const Path & ph)
   1.326 +    {
   1.327 +      system_error_type ec;
   1.328 +      file_status result( detail::symlink_status_api( ph.external_file_string(), ec ) );
   1.329 +      if ( ec )
   1.330 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.331 +          "boost::filesystem::is_symlink", ph, ec ) );
   1.332 +      return is_symlink( result );
   1.333 +#   endif
   1.334 +    }
   1.335 +
   1.336 +    // VC++ 7.0 and earlier has a serious namespace bug that causes a clash
   1.337 +    // between boost::filesystem::is_empty and the unrelated type trait
   1.338 +    // boost::is_empty.
   1.339 +
   1.340 +# if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300
   1.341 +    BOOST_FS_FUNC(bool) is_empty( const Path & ph )
   1.342 +# else
   1.343 +    BOOST_FS_FUNC(bool) _is_empty( const Path & ph )
   1.344 +# endif
   1.345 +    {
   1.346 +      detail::query_pair result = detail::is_empty_api( ph.external_file_string() );
   1.347 +      if ( result.first != 0 )
   1.348 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.349 +          "boost::filesystem::is_empty", ph, result.first ) );
   1.350 +      return result.second;
   1.351 +    }
   1.352 +
   1.353 +    BOOST_FS_FUNC(bool) equivalent( const Path & ph1, const Path & ph2 )
   1.354 +    {
   1.355 +      detail::query_pair result = detail::equivalent_api(
   1.356 +        ph1.external_file_string(), ph2.external_file_string() );
   1.357 +      if ( result.first != 0 )
   1.358 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.359 +          "boost::filesystem::equivalent", ph1, ph2, result.first ) );
   1.360 +      return result.second;
   1.361 +    }
   1.362 +
   1.363 +    BOOST_FS_FUNC(boost::uintmax_t) file_size( const Path & ph )
   1.364 +    {
   1.365 +      detail::uintmax_pair result
   1.366 +        = detail::file_size_api( ph.external_file_string() );
   1.367 +      if ( result.first != 0 )
   1.368 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.369 +          "boost::filesystem::file_size", ph, result.first ) );
   1.370 +      return result.second;
   1.371 +    }
   1.372 +
   1.373 +    BOOST_FS_FUNC(space_info) space( const Path & ph )
   1.374 +    {
   1.375 +      detail::space_pair result
   1.376 +        = detail::space_api( ph.external_file_string() );
   1.377 +      if ( result.first != 0 )
   1.378 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.379 +          "boost::filesystem::space", ph, result.first ) );
   1.380 +      return result.second;
   1.381 +    }
   1.382 +
   1.383 +    BOOST_FS_FUNC(std::time_t) last_write_time( const Path & ph )
   1.384 +    {
   1.385 +      detail::time_pair result
   1.386 +        = detail::last_write_time_api( ph.external_file_string() );
   1.387 +      if ( result.first != 0 )
   1.388 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.389 +          "boost::filesystem::last_write_time", ph, result.first ) );
   1.390 +      return result.second;
   1.391 +    }
   1.392 +
   1.393 +
   1.394 +//  operations  --------------------------------------------------------------//
   1.395 +
   1.396 +    BOOST_FS_FUNC(bool) create_directory( const Path & dir_ph )
   1.397 +    {
   1.398 +      detail::query_pair result(
   1.399 +        detail::create_directory_api( dir_ph.external_directory_string() ) );
   1.400 +      if ( result.first != 0 )
   1.401 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.402 +          "boost::filesystem::create_directory",
   1.403 +          dir_ph, result.first ) );
   1.404 +      return result.second;
   1.405 +    }
   1.406 +
   1.407 +#if !defined(BOOST_WINDOWS_API) || defined(BOOST_FS_HARD_LINK)
   1.408 +    BOOST_FS_FUNC(void)
   1.409 +    create_hard_link( const Path & to_ph, const Path & from_ph )
   1.410 +    {
   1.411 +      system_error_type result( 
   1.412 +        detail::create_hard_link_api(
   1.413 +          to_ph.external_file_string(),
   1.414 +          from_ph.external_file_string() ) );
   1.415 +      if ( result != 0 )
   1.416 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.417 +          "boost::filesystem::create_hard_link",
   1.418 +          to_ph, from_ph, result ) );
   1.419 +    }
   1.420 +
   1.421 +    BOOST_FS_FUNC(system_error_type)
   1.422 +    create_hard_link( const Path & to_ph, const Path & from_ph,
   1.423 +      system_error_type & ec )
   1.424 +    {
   1.425 +      ec = detail::create_hard_link_api(
   1.426 +            to_ph.external_file_string(),
   1.427 +            from_ph.external_file_string() );
   1.428 +      return ec;
   1.429 +    }
   1.430 +#endif
   1.431 +
   1.432 +    BOOST_FS_FUNC(void)
   1.433 +    create_symlink( const Path & to_ph, const Path & from_ph )
   1.434 +    {
   1.435 +      system_error_type result( 
   1.436 +        detail::create_symlink_api(
   1.437 +          to_ph.external_file_string(),
   1.438 +          from_ph.external_file_string() ) );
   1.439 +      if ( result )
   1.440 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.441 +          "boost::filesystem::create_symlink",
   1.442 +          to_ph, from_ph, result ) );
   1.443 +    }
   1.444 +
   1.445 +    BOOST_FS_FUNC(system_error_type)
   1.446 +    create_symlink( const Path & to_ph, const Path & from_ph,
   1.447 +      system_error_type & ec )
   1.448 +    {
   1.449 +      ec = detail::create_symlink_api(
   1.450 +             to_ph.external_file_string(),
   1.451 +             from_ph.external_file_string() );
   1.452 +      return ec;
   1.453 +    }
   1.454 +
   1.455 +    BOOST_FS_FUNC(bool) remove( const Path & ph )
   1.456 +    {
   1.457 +      if ( exists( ph )
   1.458 +        || is_symlink( ph ) ) // handle dangling symbolic links
   1.459 +        // note that the POSIX behavior for symbolic links is what we want;
   1.460 +        // the link rather than what it points to is deleted. Windows behavior
   1.461 +        // doesn't matter; is_symlink() is always false on Windows.
   1.462 +      {
   1.463 +        system_error_type result = detail::remove_api( ph.external_file_string() );
   1.464 +        if ( result != 0 )
   1.465 +          boost::throw_exception( basic_filesystem_error<Path>(
   1.466 +            "boost::filesystem::remove",
   1.467 +            ph, result ) );
   1.468 +        return true;
   1.469 +      }
   1.470 +      return false;
   1.471 +    }
   1.472 +
   1.473 +    BOOST_FS_FUNC(unsigned long) remove_all( const Path & ph )
   1.474 +    {
   1.475 +      return exists( ph )|| is_symlink( ph )
   1.476 +        ? detail::remove_all_aux( ph ) : 0;
   1.477 +    }
   1.478 +
   1.479 +    BOOST_FS_FUNC(void) rename( const Path & from_path, const Path & to_path )
   1.480 +    {
   1.481 +      system_error_type result = detail::rename_api(
   1.482 +        from_path.external_directory_string(),
   1.483 +        to_path.external_directory_string() );
   1.484 +      if ( result != 0 )
   1.485 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.486 +          "boost::filesystem::rename",
   1.487 +          from_path, to_path, result ) );
   1.488 +    }
   1.489 +
   1.490 +    BOOST_FS_FUNC(void) copy_file( const Path & from_path, const Path & to_path )
   1.491 +    {
   1.492 +      system_error_type result = detail::copy_file_api(
   1.493 +        from_path.external_directory_string(),
   1.494 +        to_path.external_directory_string() );
   1.495 +      if ( result != 0 )
   1.496 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.497 +          "boost::filesystem::copy_file",
   1.498 +          from_path, to_path, result ) );
   1.499 +    }
   1.500 +
   1.501 +    template< class Path >
   1.502 +    Path current_path()
   1.503 +    {
   1.504 +      typename Path::external_string_type ph;
   1.505 +      boost::filesystem::system_error_type result;
   1.506 +      if ( (result = detail::get_current_path_api( ph )) != 0 )
   1.507 +          boost::throw_exception( basic_filesystem_error<Path>(
   1.508 +            "boost::filesystem::current_path", result ) );
   1.509 +      return Path( Path::traits_type::to_internal( ph ) );
   1.510 +    }
   1.511 +
   1.512 +    template< class Path >
   1.513 +    const Path & initial_path()
   1.514 +    {
   1.515 +      static Path init_path;
   1.516 +      if ( init_path.empty() ) init_path = current_path<Path>();
   1.517 +      return init_path;
   1.518 +    }
   1.519 +
   1.520 +# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
   1.521 +    // legacy support
   1.522 +    inline path current_path()  // overload supports pre-i18n apps
   1.523 +      { return current_path<boost::filesystem::path>(); }
   1.524 +    inline const path & initial_path() // overload supports pre-i18n apps
   1.525 +      { return initial_path<boost::filesystem::path>(); }
   1.526 +# endif
   1.527 +
   1.528 +    BOOST_FS_FUNC(Path) system_complete( const Path & ph )
   1.529 +    {
   1.530 +# ifdef BOOST_WINDOWS_API
   1.531 +      if ( ph.empty() ) return ph;
   1.532 +      BOOST_FS_TYPENAME Path::external_string_type sys_ph;
   1.533 +      boost::filesystem::system_error_type result;
   1.534 +      if ( (result = detail::get_full_path_name_api( ph.external_file_string(),
   1.535 +              sys_ph )) != 0 )
   1.536 +          boost::throw_exception( basic_filesystem_error<Path>(
   1.537 +            "boost::filesystem::system_complete", ph, result ) );
   1.538 +      return Path( Path::traits_type::to_internal( sys_ph ) );
   1.539 +# else
   1.540 +      return (ph.empty() || ph.is_complete())
   1.541 +        ? ph : current_path<Path>() / ph;
   1.542 +# endif
   1.543 +    }
   1.544 +
   1.545 +    BOOST_FS_FUNC(Path)
   1.546 +    complete( const Path & ph,
   1.547 +      const Path & base/* = initial_path<Path>() */)
   1.548 +    {
   1.549 +      BOOST_ASSERT( base.is_complete()
   1.550 +        && (ph.is_complete() || !ph.has_root_name())
   1.551 +        && "boost::filesystem::complete() precondition not met" );
   1.552 +#   ifdef BOOST_WINDOWS_PATH
   1.553 +      if (ph.empty() || ph.is_complete()) return ph;
   1.554 +      if ( !ph.has_root_name() )
   1.555 +        return ph.has_root_directory()
   1.556 +          ? Path( base.root_name() ) / ph
   1.557 +          : base / ph;
   1.558 +      return base / ph;
   1.559 +#   else
   1.560 +      return (ph.empty() || ph.is_complete()) ? ph : base / ph;
   1.561 +#   endif
   1.562 +    }
   1.563 +
   1.564 +    // VC++ 7.1 had trouble with default arguments, so separate one argument
   1.565 +    // signatures are provided as workarounds; the effect is the same.
   1.566 +    BOOST_FS_FUNC(Path) complete( const Path & ph )
   1.567 +      { return complete( ph, initial_path<Path>() ); }
   1.568 +
   1.569 +    BOOST_FS_FUNC(void)
   1.570 +    last_write_time( const Path & ph, const std::time_t new_time )
   1.571 +    {
   1.572 +      boost::filesystem::system_error_type result;
   1.573 +      if ( (result = detail::last_write_time_api( ph.external_file_string(),
   1.574 +          new_time )) != 0 )
   1.575 +        boost::throw_exception( basic_filesystem_error<Path>(
   1.576 +          "boost::filesystem::last_write_time", ph, result ) );
   1.577 +    }
   1.578 +
   1.579 +# ifndef BOOST_FILESYSTEM_NARROW_ONLY
   1.580 +
   1.581 +    // "do-the-right-thing" overloads  ---------------------------------------//
   1.582 +
   1.583 +    inline file_status status( const path & ph )
   1.584 +      { return status<path>( ph ); }
   1.585 +    inline file_status status( const wpath & ph )
   1.586 +      { return status<wpath>( ph ); }
   1.587 +
   1.588 +    inline file_status status( const path & ph, system_error_type & ec )
   1.589 +      { return status<path>( ph, ec ); }
   1.590 +    inline file_status status( const wpath & ph, system_error_type & ec )
   1.591 +      { return status<wpath>( ph, ec ); }
   1.592 +
   1.593 +    inline file_status symlink_status( const path & ph )
   1.594 +      { return symlink_status<path>( ph ); }
   1.595 +    inline file_status symlink_status( const wpath & ph )
   1.596 +      { return symlink_status<wpath>( ph ); }
   1.597 +
   1.598 +    inline file_status symlink_status( const path & ph, system_error_type & ec )
   1.599 +      { return symlink_status<path>( ph, ec ); }
   1.600 +    inline file_status symlink_status( const wpath & ph, system_error_type & ec )
   1.601 +      { return symlink_status<wpath>( ph, ec ); }
   1.602 +
   1.603 +    inline bool exists( const path & ph ) { return exists<path>( ph ); }
   1.604 +    inline bool exists( const wpath & ph ) { return exists<wpath>( ph ); }
   1.605 +
   1.606 +    inline bool is_directory( const path & ph )
   1.607 +      { return is_directory<path>( ph ); }
   1.608 +    inline bool is_directory( const wpath & ph )
   1.609 +      { return is_directory<wpath>( ph ); }
   1.610 + 
   1.611 +    inline bool is_regular( const path & ph )
   1.612 +      { return is_regular<path>( ph ); }
   1.613 +    inline bool is_regular( const wpath & ph )
   1.614 +      { return is_regular<wpath>( ph ); }
   1.615 +
   1.616 +    inline bool is_other( const path & ph )
   1.617 +      { return is_other<path>( ph ); }
   1.618 +    inline bool is_other( const wpath & ph )
   1.619 +      { return is_other<wpath>( ph ); }
   1.620 +
   1.621 +    inline bool is_symlink( const path & ph )
   1.622 +      { return is_symlink<path>( ph ); }
   1.623 +    inline bool is_symlink( const wpath & ph )
   1.624 +      { return is_symlink<wpath>( ph ); }
   1.625 +
   1.626 +    inline bool is_empty( const path & ph )
   1.627 +      { return is_empty<path>( ph ); }
   1.628 +    inline bool is_empty( const wpath & ph )
   1.629 +      { return is_empty<wpath>( ph ); }
   1.630 +
   1.631 +    inline bool equivalent( const path & ph1, const path & ph2 )
   1.632 +      { return equivalent<path>( ph1, ph2 ); }
   1.633 +    inline bool equivalent( const wpath & ph1, const wpath & ph2 )
   1.634 +      { return equivalent<wpath>( ph1, ph2 ); }
   1.635 +
   1.636 +    inline boost::uintmax_t file_size( const path & ph )
   1.637 +      { return file_size<path>( ph ); }
   1.638 +    inline boost::uintmax_t file_size( const wpath & ph )
   1.639 +      { return file_size<wpath>( ph ); }
   1.640 +
   1.641 +    inline space_info space( const path & ph )
   1.642 +      { return space<path>( ph ); }
   1.643 +    inline space_info space( const wpath & ph )
   1.644 +      { return space<wpath>( ph ); }
   1.645 +
   1.646 +    inline std::time_t last_write_time( const path & ph )
   1.647 +      { return last_write_time<path>( ph ); }
   1.648 +    inline std::time_t last_write_time( const wpath & ph )
   1.649 +      { return last_write_time<wpath>( ph ); }
   1.650 +
   1.651 +    inline bool create_directory( const path & dir_ph )
   1.652 +      { return create_directory<path>( dir_ph ); }
   1.653 +    inline bool create_directory( const wpath & dir_ph )
   1.654 +      { return create_directory<wpath>( dir_ph ); }
   1.655 +
   1.656 +#if !defined(BOOST_WINDOWS_API) || defined(BOOST_FS_HARD_LINK)
   1.657 +    inline void create_hard_link( const path & to_ph,
   1.658 +      const path & from_ph )
   1.659 +      { return create_hard_link<path>( to_ph, from_ph ); }
   1.660 +    inline void create_hard_link( const wpath & to_ph,
   1.661 +      const wpath & from_ph )
   1.662 +      { return create_hard_link<wpath>( to_ph, from_ph ); }
   1.663 +
   1.664 +    inline system_error_type create_hard_link( const path & to_ph,
   1.665 +      const path & from_ph, system_error_type & ec )
   1.666 +      { return create_hard_link<path>( to_ph, from_ph, ec ); }
   1.667 +    inline system_error_type create_hard_link( const wpath & to_ph,
   1.668 +      const wpath & from_ph, system_error_type & ec )
   1.669 +      { return create_hard_link<wpath>( to_ph, from_ph, ec ); }
   1.670 +#endif
   1.671 +    
   1.672 +    inline void create_symlink( const path & to_ph,
   1.673 +      const path & from_ph )
   1.674 +      { return create_symlink<path>( to_ph, from_ph ); }
   1.675 +    inline void create_symlink( const wpath & to_ph,
   1.676 +      const wpath & from_ph )
   1.677 +      { return create_symlink<wpath>( to_ph, from_ph ); }
   1.678 +
   1.679 +    inline system_error_type create_symlink( const path & to_ph,
   1.680 +      const path & from_ph, system_error_type & ec )
   1.681 +      { return create_symlink<path>( to_ph, from_ph, ec ); }
   1.682 +    inline system_error_type create_symlink( const wpath & to_ph,
   1.683 +      const wpath & from_ph, system_error_type & ec )
   1.684 +      { return create_symlink<wpath>( to_ph, from_ph, ec ); }
   1.685 +
   1.686 +    inline bool remove( const path & ph )
   1.687 +      { return remove<path>( ph ); }
   1.688 +    inline bool remove( const wpath & ph )
   1.689 +      { return remove<wpath>( ph ); }
   1.690 +
   1.691 +    inline unsigned long remove_all( const path & ph )
   1.692 +      { return remove_all<path>( ph ); }
   1.693 +    inline unsigned long remove_all( const wpath & ph )
   1.694 +      { return remove_all<wpath>( ph ); }
   1.695 +
   1.696 +    inline void rename( const path & from_path, const path & to_path )
   1.697 +      { return rename<path>( from_path, to_path ); }
   1.698 +    inline void rename( const wpath & from_path, const wpath & to_path )
   1.699 +      { return rename<wpath>( from_path, to_path ); }
   1.700 +
   1.701 +    inline void copy_file( const path & from_path, const path & to_path )
   1.702 +      { return copy_file<path>( from_path, to_path ); }
   1.703 +    inline void copy_file( const wpath & from_path, const wpath & to_path )
   1.704 +      { return copy_file<wpath>( from_path, to_path ); }
   1.705 +
   1.706 +    inline path system_complete( const path & ph )
   1.707 +      { return system_complete<path>( ph ); }
   1.708 +    inline wpath system_complete( const wpath & ph )
   1.709 +      { return system_complete<wpath>( ph ); }
   1.710 +
   1.711 +    inline path complete( const path & ph,
   1.712 +      const path & base/* = initial_path<path>()*/ )
   1.713 +      { return complete<path>( ph, base ); }
   1.714 +    inline wpath complete( const wpath & ph,
   1.715 +      const wpath & base/* = initial_path<wpath>()*/ )
   1.716 +      { return complete<wpath>( ph, base ); }
   1.717 +
   1.718 +    inline path complete( const path & ph )
   1.719 +      { return complete<path>( ph, initial_path<path>() ); }
   1.720 +    inline wpath complete( const wpath & ph )
   1.721 +      { return complete<wpath>( ph, initial_path<wpath>() ); }
   1.722 +
   1.723 +    inline void last_write_time( const path & ph, const std::time_t new_time )
   1.724 +      { last_write_time<path>( ph, new_time ); }
   1.725 +    inline void last_write_time( const wpath & ph, const std::time_t new_time )
   1.726 +      { last_write_time<wpath>( ph, new_time ); }
   1.727 +
   1.728 +# endif // BOOST_FILESYSTEM_NARROW_ONLY
   1.729 +
   1.730 +    namespace detail
   1.731 +    {
   1.732 +      template<class Path>
   1.733 +      unsigned long remove_all_aux( const Path & ph )
   1.734 +      {
   1.735 +        static const boost::filesystem::basic_directory_iterator<Path> end_itr;
   1.736 +        unsigned long count = 1;
   1.737 +        if ( !boost::filesystem::is_symlink( ph ) // don't recurse symbolic links
   1.738 +          && boost::filesystem::is_directory( ph ) )
   1.739 +        {
   1.740 +          for ( boost::filesystem::basic_directory_iterator<Path> itr( ph );
   1.741 +                itr != end_itr; ++itr )
   1.742 +          {
   1.743 +            count += remove_all_aux( itr->path() );
   1.744 +          }
   1.745 +        }
   1.746 +        boost::filesystem::remove( ph );
   1.747 +        return count;
   1.748 +      }
   1.749 +
   1.750 +//  test helper  -------------------------------------------------------------//
   1.751 +
   1.752 +    // not part of the documented interface because false positives are possible;
   1.753 +    // there is no law that says that an OS that has large stat.st_size
   1.754 +    // actually supports large file sizes.
   1.755 +      BOOST_FILESYSTEM_DECL bool possible_large_file_size_support();
   1.756 +
   1.757 +//  directory_iterator helpers  ----------------------------------------------//
   1.758 +
   1.759 +//    forwarding functions avoid need for BOOST_FILESYSTEM_DECL for class
   1.760 +//    basic_directory_iterator, and so avoid iterator_facade DLL template
   1.761 +//    problems. They also overload to the proper external path character type.
   1.762 +
   1.763 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.764 +        dir_itr_first( void *& handle,
   1.765 +#if       defined(BOOST_POSIX_API)
   1.766 +            void *& buffer,
   1.767 +#endif
   1.768 +          const std::string & dir_path,
   1.769 +          std::string & target, file_status & fs, file_status & symlink_fs );
   1.770 +      // eof: return==0 && handle==0
   1.771 +
   1.772 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.773 +        dir_itr_increment( void *& handle,
   1.774 +#if       defined(BOOST_POSIX_API)
   1.775 +            void *& buffer,
   1.776 +#endif
   1.777 +          std::string & target, file_status & fs, file_status & symlink_fs );
   1.778 +      // eof: return==0 && handle==0
   1.779 +
   1.780 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.781 +        dir_itr_close( void *& handle
   1.782 +#if       defined(BOOST_POSIX_API)
   1.783 +            , void *& buffer
   1.784 +#endif
   1.785 +          );
   1.786 +      // Effects: none if handle==0, otherwise close handle, set handle=0
   1.787 +
   1.788 +#     if defined(BOOST_WINDOWS_API) && !defined(BOOST_FILESYSTEM_NARROW_ONLY)
   1.789 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.790 +        dir_itr_first( void *& handle, const std::wstring & ph,
   1.791 +          std::wstring & target, file_status & fs, file_status & symlink_fs );
   1.792 +      BOOST_FILESYSTEM_DECL boost::filesystem::system_error_type
   1.793 +        dir_itr_increment( void *& handle, std::wstring & target,
   1.794 +          file_status & fs, file_status & symlink_fs );
   1.795 +#     endif
   1.796 +
   1.797 +      template< class Path >
   1.798 +      class dir_itr_imp
   1.799 +      {
   1.800 +      public:  
   1.801 +        basic_directory_entry<Path> m_directory_entry;
   1.802 +        void *        m_handle;
   1.803 +#       ifdef BOOST_POSIX_API
   1.804 +          void *      m_buffer;  // see dir_itr_increment implementation
   1.805 +#       endif
   1.806 +        dir_itr_imp() : m_handle(0)
   1.807 +#       ifdef BOOST_POSIX_API
   1.808 +          , m_buffer(0)
   1.809 +#       endif
   1.810 +        {}
   1.811 +
   1.812 +        ~dir_itr_imp() { dir_itr_close( m_handle
   1.813 +#if       defined(BOOST_POSIX_API)
   1.814 +            , m_buffer
   1.815 +#endif
   1.816 +          ); }
   1.817 +      };
   1.818 +
   1.819 +    BOOST_FILESYSTEM_DECL extern system_error_type not_found_error;
   1.820 +    } // namespace detail
   1.821 +
   1.822 +//  basic_directory_iterator  ------------------------------------------------//
   1.823 +
   1.824 +    template< class Path >
   1.825 +    class basic_directory_iterator
   1.826 +      : public boost::iterator_facade<
   1.827 +          basic_directory_iterator<Path>,
   1.828 +          basic_directory_entry<Path>,
   1.829 +          boost::single_pass_traversal_tag >
   1.830 +    {
   1.831 +    public:
   1.832 +      typedef Path path_type;
   1.833 +
   1.834 +      basic_directory_iterator(){}  // creates the "end" iterator
   1.835 +
   1.836 +      explicit basic_directory_iterator( const Path & dir_path );
   1.837 +      basic_directory_iterator( const Path & dir_path, system_error_type & ec );
   1.838 +
   1.839 +    private:
   1.840 +
   1.841 +      // shared_ptr provides shallow-copy semantics required for InputIterators.
   1.842 +      // m_imp.get()==0 indicates the end iterator.
   1.843 +      boost::shared_ptr< detail::dir_itr_imp< Path > >  m_imp;
   1.844 +
   1.845 +      friend class boost::iterator_core_access;
   1.846 +
   1.847 +      typename boost::iterator_facade<
   1.848 +        basic_directory_iterator<Path>,
   1.849 +        basic_directory_entry<Path>,
   1.850 +        boost::single_pass_traversal_tag >::reference dereference() const 
   1.851 +      {
   1.852 +        BOOST_ASSERT( m_imp.get() && "attempt to dereference end iterator" );
   1.853 +        return m_imp->m_directory_entry;
   1.854 +      }
   1.855 +
   1.856 +      void increment();
   1.857 +
   1.858 +      bool equal( const basic_directory_iterator & rhs ) const
   1.859 +        { return m_imp == rhs.m_imp; }
   1.860 +
   1.861 +      system_error_type m_init( const Path & dir_path );
   1.862 +    };
   1.863 +
   1.864 +    typedef basic_directory_iterator< path > directory_iterator;
   1.865 +# ifndef BOOST_FILESYSTEM_NARROW_ONLY
   1.866 +    typedef basic_directory_iterator< wpath > wdirectory_iterator;
   1.867 +# endif
   1.868 +
   1.869 +    //  basic_directory_iterator implementation  ---------------------------//
   1.870 +
   1.871 +    template<class Path>
   1.872 +    system_error_type basic_directory_iterator<Path>::m_init(
   1.873 +      const Path & dir_path )
   1.874 +    {
   1.875 +      if ( dir_path.empty() )
   1.876 +      {
   1.877 +        m_imp.reset();
   1.878 +        return detail::not_found_error;
   1.879 +      }
   1.880 +      system_error_type sys_err;
   1.881 +      typename Path::external_string_type name;
   1.882 +      file_status fs, symlink_fs;
   1.883 +
   1.884 +      if ( (sys_err = detail::dir_itr_first( m_imp->m_handle,
   1.885 +#if   defined(BOOST_POSIX_API)
   1.886 +        m_imp->m_buffer,
   1.887 +#endif
   1.888 +        dir_path.external_directory_string(),
   1.889 +        name, fs, symlink_fs )) != 0 )
   1.890 +      {
   1.891 +        m_imp.reset();
   1.892 +        return sys_err;
   1.893 +      }
   1.894 +      
   1.895 +      if ( m_imp->m_handle == 0 ) m_imp.reset(); // eof, so make end iterator
   1.896 +      else // not eof
   1.897 +      {
   1.898 +        m_imp->m_directory_entry.assign( dir_path
   1.899 +          / Path::traits_type::to_internal( name ), fs, symlink_fs );
   1.900 +        if ( name[0] == dot<Path>::value // dot or dot-dot
   1.901 +          && (name.size() == 1
   1.902 +            || (name[1] == dot<Path>::value
   1.903 +              && name.size() == 2)) )
   1.904 +          {  increment(); }
   1.905 +      }
   1.906 +      return 0;
   1.907 +    }
   1.908 +
   1.909 +    template<class Path>
   1.910 +    basic_directory_iterator<Path>::basic_directory_iterator(
   1.911 +      const Path & dir_path )
   1.912 +      : m_imp( new detail::dir_itr_imp<Path> )
   1.913 +    {
   1.914 +      system_error_type ec( m_init(dir_path) );
   1.915 +      if ( ec != 0 )
   1.916 +      {
   1.917 +        boost::throw_exception( basic_filesystem_error<Path>(  
   1.918 +          "boost::filesystem::basic_directory_iterator constructor",
   1.919 +          dir_path, ec ) );
   1.920 +      }
   1.921 +    }
   1.922 +
   1.923 +    template<class Path>
   1.924 +    basic_directory_iterator<Path>::basic_directory_iterator(
   1.925 +      const Path & dir_path, system_error_type & ec )
   1.926 +      : m_imp( new detail::dir_itr_imp<Path> )
   1.927 +    {
   1.928 +      ec = m_init(dir_path);
   1.929 +    }
   1.930 +
   1.931 +    template<class Path>
   1.932 +    void basic_directory_iterator<Path>::increment()
   1.933 +    {
   1.934 +      BOOST_ASSERT( m_imp.get() && "attempt to increment end iterator" );
   1.935 +      BOOST_ASSERT( m_imp->m_handle != 0 && "internal program error" );
   1.936 +      
   1.937 +      system_error_type sys_err(0);
   1.938 +      typename Path::external_string_type name;
   1.939 +      file_status fs, symlink_fs;
   1.940 +
   1.941 +      for (;;)
   1.942 +      {
   1.943 +        if ( (sys_err = detail::dir_itr_increment( m_imp->m_handle,
   1.944 +#if     defined(BOOST_POSIX_API)
   1.945 +          m_imp->m_buffer,
   1.946 +#endif
   1.947 +          name, fs, symlink_fs )) != 0 )
   1.948 +        {
   1.949 +          boost::throw_exception( basic_filesystem_error<Path>(  
   1.950 +            "boost::filesystem::basic_directory_iterator increment",
   1.951 +            m_imp->m_directory_entry.path().branch_path(), sys_err ) );
   1.952 +        }
   1.953 +        if ( m_imp->m_handle == 0 ) { m_imp.reset(); return; } // eof, make end
   1.954 +        if ( !(name[0] == dot<Path>::value // !(dot or dot-dot)
   1.955 +          && (name.size() == 1
   1.956 +            || (name[1] == dot<Path>::value
   1.957 +              && name.size() == 2))) )
   1.958 +        {
   1.959 +          m_imp->m_directory_entry.replace_leaf(
   1.960 +            Path::traits_type::to_internal( name ), fs, symlink_fs );
   1.961 +          return;
   1.962 +        }
   1.963 +      }
   1.964 +    }
   1.965 +
   1.966 +    //  basic_directory_entry  -----------------------------------------------//
   1.967 +    
   1.968 +    template<class Path>
   1.969 +    class basic_directory_entry
   1.970 +    {
   1.971 +    public:
   1.972 +      typedef Path path_type;
   1.973 +      typedef typename Path::string_type string_type;
   1.974 +
   1.975 +      // compiler generated copy-ctor, copy assignment, and destructor apply
   1.976 +
   1.977 +      basic_directory_entry() {}
   1.978 +      explicit basic_directory_entry( const path_type & p,
   1.979 +        file_status st = file_status(), file_status symlink_st=file_status() )
   1.980 +        : m_path(p), m_status(st), m_symlink_status(symlink_st)
   1.981 +        {}
   1.982 +
   1.983 +      void assign( const path_type & p,
   1.984 +        file_status st, file_status symlink_st )
   1.985 +        { m_path = p; m_status = st; m_symlink_status = symlink_st; }
   1.986 +
   1.987 +      void replace_leaf( const string_type & s,
   1.988 +        file_status st, file_status symlink_st )
   1.989 +     {
   1.990 +       m_path.remove_leaf();
   1.991 +       m_path /= s;
   1.992 +       m_status = st;
   1.993 +       m_symlink_status = symlink_st;
   1.994 +     }
   1.995 +
   1.996 +      const Path &   path() const { return m_path; }
   1.997 +      file_status   status() const;
   1.998 +      file_status   status( system_error_type & ec ) const;
   1.999 +      file_status   symlink_status() const;
  1.1000 +      file_status   symlink_status( system_error_type & ec ) const;
  1.1001 +
  1.1002 +      // conversion simplifies the most common use of basic_directory_entry
  1.1003 +      operator const path_type &() const { return m_path; }
  1.1004 +
  1.1005 +#   ifndef BOOST_FILESYSTEM_NO_DEPRECATED
  1.1006 +      // deprecated functions preserve common use cases in legacy code
  1.1007 +      typename Path::string_type leaf() const
  1.1008 +      {
  1.1009 +        return path().leaf();
  1.1010 +      }
  1.1011 +      typename Path::string_type string() const
  1.1012 +      {
  1.1013 +        return path().string();
  1.1014 +      }
  1.1015 +#   endif
  1.1016 +
  1.1017 +    private:
  1.1018 +      path_type             m_path;
  1.1019 +      mutable file_status  m_status;           // stat()-like
  1.1020 +      mutable file_status  m_symlink_status;   // lstat()-like
  1.1021 +        // note: m_symlink_status is not used by Windows implementation
  1.1022 +
  1.1023 +    }; // basic_directory_status
  1.1024 +
  1.1025 +    typedef basic_directory_entry<path> directory_entry;
  1.1026 +# ifndef BOOST_FILESYSTEM_NARROW_ONLY
  1.1027 +    typedef basic_directory_entry<wpath> wdirectory_entry;
  1.1028 +# endif
  1.1029 +
  1.1030 +    //  basic_directory_entry implementation  --------------------------------//
  1.1031 +
  1.1032 +    template<class Path>
  1.1033 +    file_status
  1.1034 +    basic_directory_entry<Path>::status() const
  1.1035 +    {
  1.1036 +      if ( !status_known( m_status ) )
  1.1037 +      {
  1.1038 +#     ifndef BOOST_WINDOWS_API
  1.1039 +        if ( status_known( m_symlink_status )
  1.1040 +          && !is_symlink( m_symlink_status ) )
  1.1041 +          { m_status = m_symlink_status; }
  1.1042 +        else { m_status = boost::filesystem::status( m_path ); }
  1.1043 +#     else
  1.1044 +        m_status = boost::filesystem::status( m_path );
  1.1045 +#     endif
  1.1046 +      }
  1.1047 +      return m_status;
  1.1048 +    }
  1.1049 +
  1.1050 +    template<class Path>
  1.1051 +    file_status
  1.1052 +    basic_directory_entry<Path>::status( system_error_type & ec ) const
  1.1053 +    {
  1.1054 +      if ( !status_known( m_status ) )
  1.1055 +      {
  1.1056 +#     ifndef BOOST_WINDOWS_API
  1.1057 +        if ( status_known( m_symlink_status )
  1.1058 +          && !is_symlink( m_symlink_status ) )
  1.1059 +          { ec = 0; m_status = m_symlink_status; }
  1.1060 +        else { m_status = boost::filesystem::status( m_path, ec ); }
  1.1061 +#     else
  1.1062 +        m_status = boost::filesystem::status( m_path, ec );
  1.1063 +#     endif
  1.1064 +      }
  1.1065 +      else ec = 0;
  1.1066 +      return m_status;
  1.1067 +    }
  1.1068 +
  1.1069 +    template<class Path>
  1.1070 +    file_status
  1.1071 +    basic_directory_entry<Path>::symlink_status() const
  1.1072 +    {
  1.1073 +#   ifndef BOOST_WINDOWS_API
  1.1074 +      if ( !status_known( m_symlink_status ) )
  1.1075 +        { m_symlink_status = boost::filesystem::symlink_status( m_path ); }
  1.1076 +      return m_symlink_status;
  1.1077 +#   else
  1.1078 +      return status();
  1.1079 +#   endif
  1.1080 +    }
  1.1081 +
  1.1082 +    template<class Path>
  1.1083 +    file_status
  1.1084 +    basic_directory_entry<Path>::symlink_status( system_error_type & ec ) const
  1.1085 +    {
  1.1086 +#   ifndef BOOST_WINDOWS_API
  1.1087 +      if ( !status_known( m_symlink_status ) )
  1.1088 +        { m_symlink_status = boost::filesystem::symlink_status( m_path, ec ); }
  1.1089 +      else ec = 0;
  1.1090 +      return m_symlink_status;
  1.1091 +#   else
  1.1092 +      return status( ec );
  1.1093 +#   endif
  1.1094 +    }
  1.1095 +  } // namespace filesystem
  1.1096 +} // namespace boost
  1.1097 +
  1.1098 +#undef BOOST_FS_FUNC
  1.1099 +
  1.1100 +
  1.1101 +#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
  1.1102 +#endif // BOOST_FILESYSTEM_OPERATIONS_HPP