imgtools/imglib/boostlibrary/boost/filesystem/operations.hpp
author lorewang
Wed, 17 Nov 2010 11:21:28 +0800
changeset 684 2defe8c85348
parent 600 6d08f4a05d93
permissions -rw-r--r--
elf2e32 treatment of ARM$$INIT_ARRAY$$Base can break GCCE builds
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     1
//  boost/filesystem/operations.hpp  -----------------------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     2
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     3
//  Copyright 2002-2005 Beman Dawes
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     4
//  Copyright 2002 Jan Langer
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     5
//  Copyright 2001 Dietmar Kuehl                                        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     6
//  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     7
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     8
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     9
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    10
//  See library home page at http://www.boost.org/libs/filesystem
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    11
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    12
//----------------------------------------------------------------------------// 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    13
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    14
#ifndef BOOST_FILESYSTEM_OPERATIONS_HPP
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    15
#define BOOST_FILESYSTEM_OPERATIONS_HPP
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    16
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    17
#include <boost/filesystem/path.hpp>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    18
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    19
#include <boost/shared_ptr.hpp>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    20
#include <boost/utility/enable_if.hpp>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    21
#include <boost/type_traits/is_same.hpp>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    22
#include <boost/iterator.hpp>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    23
#include <boost/cstdint.hpp>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    24
#include <boost/assert.hpp>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    25
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    26
#include <string>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    27
#include <utility> // for pair
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    28
#include <ctime>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    29
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    30
#ifdef BOOST_WINDOWS_API
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    31
#  include <fstream>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    32
#  if !defined(_WIN32_WINNT) || _WIN32_WINNT >= 0x0500
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    33
#    define BOOST_FS_HARD_LINK // Default for Windows 2K or later 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    34
#  endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    35
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    36
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    37
#include <boost/config/abi_prefix.hpp> // must be the last #include
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    38
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    39
# ifdef BOOST_NO_STDC_NAMESPACE
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    40
    namespace std { using ::time_t; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    41
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    42
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    43
//----------------------------------------------------------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    44
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    45
namespace boost
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    46
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    47
  namespace filesystem
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    48
  {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    49
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    50
// typedef boost::filesystem::path Path; needs to be in namespace boost::filesystem
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    51
# ifndef BOOST_FILESYSTEM_NARROW_ONLY
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    52
#   define BOOST_FS_FUNC(BOOST_FS_TYPE) \
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    53
      template<class Path> typename boost::enable_if<is_basic_path<Path>, \
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    54
      BOOST_FS_TYPE>::type
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    55
#   define BOOST_INLINE_FS_FUNC(BOOST_FS_TYPE) \
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    56
      template<class Path> inline typename boost::enable_if<is_basic_path<Path>, \
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    57
      BOOST_FS_TYPE>::type
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    58
#   define BOOST_FS_TYPENAME typename
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    59
# else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    60
#   define BOOST_FS_FUNC(BOOST_FS_TYPE) inline BOOST_FS_TYPE
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    61
#   define BOOST_INLINE_FS_FUNC(BOOST_FS_TYPE) inline BOOST_FS_TYPE
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    62
    typedef boost::filesystem::path Path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    63
#   define BOOST_FS_TYPENAME
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    64
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    65
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    66
    template<class Path> class basic_directory_iterator;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    67
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    68
    // BOOST_FILESYSTEM_NARROW_ONLY needs this:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    69
    typedef basic_directory_iterator<path> directory_iterator;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    70
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    71
    template<class Path> class basic_directory_entry;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    72
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    73
    enum file_type
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    74
    { 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    75
      status_unknown,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    76
      file_not_found,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    77
      regular_file,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    78
      directory_file,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    79
      // the following will never be reported by some operating or file systems
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    80
      symlink_file,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    81
      block_file,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    82
      character_file,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    83
      fifo_file,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    84
      socket_file,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    85
      type_unknown // file does exist, but isn't one of the above types or
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    86
                   // we don't have strong enough permission to find its type
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    87
    };
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    88
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    89
    class file_status
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    90
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    91
    public:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    92
      explicit file_status( file_type v = status_unknown ) : m_value(v) {}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    93
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    94
      void type( file_type v )  { m_value = v; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    95
      file_type type() const    { return m_value; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    96
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    97
    private:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    98
      // the internal representation is unspecified so that additional state
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    99
      // information such as permissions can be added in the future; this
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   100
      // implementation just uses status_type as the internal representation
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   101
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   102
      file_type m_value;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   103
    };
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   104
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   105
    inline bool status_known( file_status f ) { return f.type() != status_unknown; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   106
    inline bool exists( file_status f )       { return f.type() != status_unknown && f.type() != file_not_found; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   107
    inline bool is_regular_file(file_status f){ return f.type() == regular_file; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   108
    inline bool is_directory( file_status f ) { return f.type() == directory_file; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   109
    inline bool is_symlink( file_status f )   { return f.type() == symlink_file; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   110
    inline bool is_other( file_status f )     { return exists(f) && !is_regular_file(f) && !is_directory(f) && !is_symlink(f); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   111
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   112
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   113
    inline bool is_regular( file_status f )   { return f.type() == regular_file; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   114
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   115
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   116
    struct space_info
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   117
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   118
      // all values are byte counts
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   119
      boost::uintmax_t capacity;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   120
      boost::uintmax_t free;      // <= capacity
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   121
      boost::uintmax_t available; // <= free
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   122
    };
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   123
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   124
    namespace detail
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   125
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   126
      typedef std::pair< system::error_code, bool >
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   127
        query_pair;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   128
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   129
      typedef std::pair< system::error_code, boost::uintmax_t >
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   130
        uintmax_pair;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   131
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   132
      typedef std::pair< system::error_code, std::time_t >
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   133
        time_pair;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   134
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   135
      typedef std::pair< system::error_code, space_info >
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   136
        space_pair;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   137
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   138
      template< class Path >
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   139
      struct directory_pair
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   140
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   141
        typedef std::pair< system::error_code,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   142
          typename Path::external_string_type > type;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   143
      };
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   144
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   145
#   ifndef BOOST_FILESYSTEM_NO_DEPRECATED
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   146
      BOOST_FILESYSTEM_DECL bool
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   147
        symbolic_link_exists_api( const std::string & ); // deprecated
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   148
#   endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   149
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   150
      BOOST_FILESYSTEM_DECL file_status
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   151
        status_api( const std::string & ph, system::error_code & ec );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   152
#   ifndef BOOST_WINDOWS_API
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   153
      BOOST_FILESYSTEM_DECL file_status
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   154
        symlink_status_api( const std::string & ph, system::error_code & ec );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   155
#   endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   156
      BOOST_FILESYSTEM_DECL query_pair
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   157
        is_empty_api( const std::string & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   158
      BOOST_FILESYSTEM_DECL query_pair
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   159
        equivalent_api( const std::string & ph1, const std::string & ph2 );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   160
      BOOST_FILESYSTEM_DECL uintmax_pair
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   161
        file_size_api( const std::string & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   162
      BOOST_FILESYSTEM_DECL space_pair
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   163
        space_api( const std::string & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   164
      BOOST_FILESYSTEM_DECL time_pair 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   165
        last_write_time_api( const std::string & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   166
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   167
        last_write_time_api( const std::string & ph, std::time_t new_value );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   168
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   169
        get_current_path_api( std::string & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   170
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   171
        set_current_path_api( const std::string & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   172
      BOOST_FILESYSTEM_DECL query_pair
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   173
        create_directory_api( const std::string & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   174
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   175
        create_hard_link_api( const std::string & to_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   176
          const std::string & from_ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   177
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   178
        create_symlink_api( const std::string & to_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   179
          const std::string & from_ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   180
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   181
        remove_api( const std::string & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   182
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   183
        rename_api( const std::string & from, const std::string & to );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   184
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   185
        copy_file_api( const std::string & from, const std::string & to );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   186
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   187
#   if defined(BOOST_WINDOWS_API)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   188
      
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   189
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   190
        get_full_path_name_api( const std::string & ph, std::string & target );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   191
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   192
#     if !defined(BOOST_FILESYSTEM_NARROW_ONLY)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   193
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   194
      BOOST_FILESYSTEM_DECL  boost::filesystem::file_status
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   195
        status_api( const std::wstring & ph, system::error_code & ec );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   196
      BOOST_FILESYSTEM_DECL query_pair 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   197
        is_empty_api( const std::wstring & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   198
      BOOST_FILESYSTEM_DECL query_pair
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   199
        equivalent_api( const std::wstring & ph1, const std::wstring & ph2 );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   200
      BOOST_FILESYSTEM_DECL uintmax_pair 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   201
        file_size_api( const std::wstring & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   202
      BOOST_FILESYSTEM_DECL space_pair 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   203
        space_api( const std::wstring & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   204
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   205
        get_full_path_name_api( const std::wstring & ph, std::wstring & target );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   206
      BOOST_FILESYSTEM_DECL time_pair 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   207
        last_write_time_api( const std::wstring & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   208
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   209
        last_write_time_api( const std::wstring & ph, std::time_t new_value );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   210
      BOOST_FILESYSTEM_DECL system::error_code 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   211
        get_current_path_api( std::wstring & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   212
      BOOST_FILESYSTEM_DECL system::error_code 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   213
        set_current_path_api( const std::wstring & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   214
      BOOST_FILESYSTEM_DECL query_pair
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   215
        create_directory_api( const std::wstring & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   216
# ifdef BOOST_FS_HARD_LINK
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   217
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   218
        create_hard_link_api( const std::wstring & existing_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   219
          const std::wstring & new_ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   220
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   221
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   222
        create_symlink_api( const std::wstring & to_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   223
          const std::wstring & from_ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   224
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   225
        remove_api( const std::wstring & ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   226
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   227
        rename_api( const std::wstring & from, const std::wstring & to );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   228
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   229
        copy_file_api( const std::wstring & from, const std::wstring & to );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   230
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   231
#     endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   232
#   endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   233
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   234
      template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   235
      bool remove_aux( const Path & ph, file_status f );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   236
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   237
      template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   238
      unsigned long remove_all_aux( const Path & ph, file_status f );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   239
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   240
    } // namespace detail
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   241
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   242
//  operations functions  ----------------------------------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   243
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   244
    //  The non-template overloads enable automatic conversion from std and
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   245
    //  C-style strings. See basic_path constructors. The enable_if for the
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   246
    //  templates implements the famous "do-the-right-thing" rule.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   247
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   248
//  query functions  ---------------------------------------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   249
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   250
    BOOST_INLINE_FS_FUNC(file_status)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   251
    status( const Path & ph, system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   252
      { return detail::status_api( ph.external_file_string(), ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   253
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   254
    BOOST_FS_FUNC(file_status)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   255
    status( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   256
    { 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   257
      system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   258
      file_status result( detail::status_api( ph.external_file_string(), ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   259
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   260
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   261
        "boost::filesystem::status", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   262
      return result;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   263
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   264
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   265
    BOOST_INLINE_FS_FUNC(file_status)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   266
    symlink_status( const Path & ph, system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   267
#   ifdef BOOST_WINDOWS_API
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   268
      { return detail::status_api( ph.external_file_string(), ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   269
#   else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   270
      { return detail::symlink_status_api( ph.external_file_string(), ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   271
#   endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   272
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   273
    BOOST_FS_FUNC(file_status)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   274
    symlink_status( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   275
    { 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   276
      system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   277
      file_status result( symlink_status( ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   278
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   279
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   280
        "boost::filesystem::symlink_status", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   281
      return result;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   282
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   283
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   284
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   285
    inline bool symbolic_link_exists( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   286
      { return is_symlink( symlink_status(ph) ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   287
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   288
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   289
    BOOST_FS_FUNC(bool) exists( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   290
    { 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   291
      system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   292
      file_status result( detail::status_api( ph.external_file_string(), ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   293
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   294
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   295
          "boost::filesystem::exists", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   296
      return exists( result );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   297
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   298
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   299
    BOOST_FS_FUNC(bool) is_directory( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   300
    { 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   301
      system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   302
      file_status result( detail::status_api( ph.external_file_string(), ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   303
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   304
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   305
          "boost::filesystem::is_directory", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   306
      return is_directory( result );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   307
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   308
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   309
    BOOST_FS_FUNC(bool) is_regular_file( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   310
    { 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   311
      system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   312
      file_status result( detail::status_api( ph.external_file_string(), ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   313
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   314
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   315
          "boost::filesystem::is_regular_file", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   316
      return is_regular_file( result );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   317
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   318
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   319
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   320
    BOOST_FS_FUNC(bool) is_regular( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   321
    { 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   322
      system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   323
      file_status result( detail::status_api( ph.external_file_string(), ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   324
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   325
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   326
          "boost::filesystem::is_regular", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   327
      return is_regular( result );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   328
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   329
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   330
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   331
    BOOST_FS_FUNC(bool) is_other( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   332
    { 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   333
      system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   334
      file_status result( detail::status_api( ph.external_file_string(), ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   335
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   336
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   337
          "boost::filesystem::is_other", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   338
      return is_other( result );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   339
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   340
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   341
    BOOST_FS_FUNC(bool) is_symlink(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   342
#   ifdef BOOST_WINDOWS_API
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   343
      const Path & )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   344
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   345
      return false;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   346
#   else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   347
      const Path & ph)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   348
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   349
      system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   350
      file_status result( detail::symlink_status_api( ph.external_file_string(), ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   351
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   352
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   353
          "boost::filesystem::is_symlink", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   354
      return is_symlink( result );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   355
#   endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   356
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   357
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   358
    // VC++ 7.0 and earlier has a serious namespace bug that causes a clash
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   359
    // between boost::filesystem::is_empty and the unrelated type trait
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   360
    // boost::is_empty.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   361
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   362
# if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   363
    BOOST_FS_FUNC(bool) is_empty( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   364
# else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   365
    BOOST_FS_FUNC(bool) _is_empty( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   366
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   367
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   368
      detail::query_pair result(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   369
        detail::is_empty_api( ph.external_file_string() ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   370
      if ( result.first )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   371
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   372
          "boost::filesystem::is_empty", ph, result.first ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   373
      return result.second;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   374
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   375
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   376
    BOOST_FS_FUNC(bool) equivalent( const Path & ph1, const Path & ph2 )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   377
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   378
      detail::query_pair result( detail::equivalent_api(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   379
        ph1.external_file_string(), ph2.external_file_string() ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   380
      if ( result.first )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   381
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   382
          "boost::filesystem::equivalent", ph1, ph2, result.first ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   383
      return result.second;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   384
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   385
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   386
    BOOST_FS_FUNC(boost::uintmax_t) file_size( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   387
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   388
      detail::uintmax_pair result
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   389
        ( detail::file_size_api( ph.external_file_string() ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   390
      if ( result.first )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   391
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   392
          "boost::filesystem::file_size", ph, result.first ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   393
      return result.second;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   394
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   395
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   396
    BOOST_FS_FUNC(space_info) space( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   397
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   398
      detail::space_pair result
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   399
        ( detail::space_api( ph.external_file_string() ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   400
      if ( result.first )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   401
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   402
          "boost::filesystem::space", ph, result.first ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   403
      return result.second;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   404
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   405
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   406
    BOOST_FS_FUNC(std::time_t) last_write_time( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   407
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   408
      detail::time_pair result
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   409
        ( detail::last_write_time_api( ph.external_file_string() ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   410
      if ( result.first )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   411
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   412
          "boost::filesystem::last_write_time", ph, result.first ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   413
      return result.second;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   414
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   415
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   416
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   417
//  operations  --------------------------------------------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   418
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   419
    BOOST_FS_FUNC(bool) create_directory( const Path & dir_ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   420
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   421
      detail::query_pair result(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   422
        detail::create_directory_api( dir_ph.external_directory_string() ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   423
      if ( result.first )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   424
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   425
          "boost::filesystem::create_directory",
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   426
          dir_ph, result.first ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   427
      return result.second;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   428
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   429
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   430
#if !defined(BOOST_WINDOWS_API) || defined(BOOST_FS_HARD_LINK)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   431
    BOOST_FS_FUNC(void)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   432
    create_hard_link( const Path & to_ph, const Path & from_ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   433
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   434
      system::error_code ec( 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   435
        detail::create_hard_link_api(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   436
          to_ph.external_file_string(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   437
          from_ph.external_file_string() ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   438
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   439
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   440
          "boost::filesystem::create_hard_link",
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   441
          to_ph, from_ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   442
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   443
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   444
    BOOST_FS_FUNC(system::error_code)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   445
    create_hard_link( const Path & to_ph, const Path & from_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   446
      system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   447
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   448
      ec = detail::create_hard_link_api(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   449
            to_ph.external_file_string(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   450
            from_ph.external_file_string() );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   451
      return ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   452
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   453
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   454
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   455
    BOOST_FS_FUNC(void)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   456
    create_symlink( const Path & to_ph, const Path & from_ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   457
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   458
      system::error_code ec( 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   459
        detail::create_symlink_api(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   460
          to_ph.external_file_string(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   461
          from_ph.external_file_string() ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   462
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   463
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   464
          "boost::filesystem::create_symlink",
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   465
          to_ph, from_ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   466
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   467
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   468
    BOOST_FS_FUNC(system::error_code)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   469
    create_symlink( const Path & to_ph, const Path & from_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   470
      system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   471
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   472
      ec = detail::create_symlink_api(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   473
             to_ph.external_file_string(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   474
             from_ph.external_file_string() );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   475
      return ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   476
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   477
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   478
    BOOST_FS_FUNC(bool) remove( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   479
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   480
      system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   481
      file_status f = symlink_status( ph, ec );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   482
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   483
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   484
          "boost::filesystem::remove", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   485
      return detail::remove_aux( ph, f );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   486
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   487
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   488
    BOOST_FS_FUNC(unsigned long) remove_all( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   489
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   490
      system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   491
      file_status f = symlink_status( ph, ec );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   492
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   493
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   494
          "boost::filesystem::remove_all", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   495
      return exists( f ) ? detail::remove_all_aux( ph, f ) : 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   496
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   497
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   498
    BOOST_FS_FUNC(void) rename( const Path & from_path, const Path & to_path )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   499
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   500
      system::error_code ec( detail::rename_api(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   501
        from_path.external_directory_string(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   502
        to_path.external_directory_string() ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   503
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   504
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   505
          "boost::filesystem::rename",
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   506
          from_path, to_path, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   507
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   508
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   509
    BOOST_FS_FUNC(void) copy_file( const Path & from_path, const Path & to_path )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   510
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   511
      system::error_code ec( detail::copy_file_api(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   512
        from_path.external_directory_string(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   513
        to_path.external_directory_string() ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   514
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   515
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   516
          "boost::filesystem::copy_file",
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   517
          from_path, to_path, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   518
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   519
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   520
    template< class Path >
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   521
    Path current_path()
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   522
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   523
      typename Path::external_string_type ph;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   524
      system::error_code ec( detail::get_current_path_api( ph ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   525
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   526
          boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   527
            "boost::filesystem::current_path", ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   528
      return Path( Path::traits_type::to_internal( ph ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   529
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   530
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   531
    BOOST_FS_FUNC(void) current_path( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   532
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   533
      system::error_code ec( detail::set_current_path_api(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   534
        ph.external_directory_string() ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   535
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   536
          boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   537
            "boost::filesystem::current_path", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   538
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   539
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   540
    template< class Path >
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   541
    const Path & initial_path()
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   542
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   543
      static Path init_path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   544
      if ( init_path.empty() ) init_path = current_path<Path>();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   545
      return init_path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   546
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   547
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   548
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   549
    // legacy support
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   550
    inline path current_path()  // overload supports pre-i18n apps
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   551
      { return current_path<boost::filesystem::path>(); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   552
    inline const path & initial_path() // overload supports pre-i18n apps
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   553
      { return initial_path<boost::filesystem::path>(); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   554
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   555
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   556
    BOOST_FS_FUNC(Path) system_complete( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   557
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   558
# ifdef BOOST_WINDOWS_API
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   559
      if ( ph.empty() ) return ph;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   560
      BOOST_FS_TYPENAME Path::external_string_type sys_ph;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   561
      system::error_code ec( detail::get_full_path_name_api( ph.external_file_string(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   562
              sys_ph ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   563
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   564
          boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   565
            "boost::filesystem::system_complete", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   566
      return Path( Path::traits_type::to_internal( sys_ph ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   567
# else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   568
      return (ph.empty() || ph.is_complete())
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   569
        ? ph : current_path<Path>() / ph;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   570
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   571
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   572
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   573
    BOOST_FS_FUNC(Path)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   574
    complete( const Path & ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   575
      const Path & base/* = initial_path<Path>() */)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   576
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   577
      BOOST_ASSERT( base.is_complete()
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   578
        && (ph.is_complete() || !ph.has_root_name())
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   579
        && "boost::filesystem::complete() precondition not met" );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   580
#   ifdef BOOST_WINDOWS_PATH
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   581
      if (ph.empty() || ph.is_complete()) return ph;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   582
      if ( !ph.has_root_name() )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   583
        return ph.has_root_directory()
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   584
          ? Path( base.root_name() ) / ph
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   585
          : base / ph;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   586
      return base / ph;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   587
#   else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   588
      return (ph.empty() || ph.is_complete()) ? ph : base / ph;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   589
#   endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   590
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   591
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   592
    // VC++ 7.1 had trouble with default arguments, so separate one argument
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   593
    // signatures are provided as workarounds; the effect is the same.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   594
    BOOST_FS_FUNC(Path) complete( const Path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   595
      { return complete( ph, initial_path<Path>() ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   596
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   597
    BOOST_FS_FUNC(void)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   598
    last_write_time( const Path & ph, const std::time_t new_time )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   599
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   600
      system::error_code ec( detail::last_write_time_api( ph.external_file_string(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   601
          new_time ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   602
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   603
        boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   604
          "boost::filesystem::last_write_time", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   605
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   606
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   607
# ifndef BOOST_FILESYSTEM_NARROW_ONLY
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   608
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   609
    // "do-the-right-thing" overloads  ---------------------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   610
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   611
    inline file_status status( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   612
      { return status<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   613
    inline file_status status( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   614
      { return status<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   615
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   616
    inline file_status status( const path & ph, system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   617
      { return status<path>( ph, ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   618
    inline file_status status( const wpath & ph, system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   619
      { return status<wpath>( ph, ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   620
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   621
    inline file_status symlink_status( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   622
      { return symlink_status<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   623
    inline file_status symlink_status( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   624
      { return symlink_status<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   625
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   626
    inline file_status symlink_status( const path & ph, system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   627
      { return symlink_status<path>( ph, ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   628
    inline file_status symlink_status( const wpath & ph, system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   629
      { return symlink_status<wpath>( ph, ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   630
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   631
    inline bool exists( const path & ph ) { return exists<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   632
    inline bool exists( const wpath & ph ) { return exists<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   633
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   634
    inline bool is_directory( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   635
      { return is_directory<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   636
    inline bool is_directory( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   637
      { return is_directory<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   638
 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   639
    inline bool is_regular_file( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   640
      { return is_regular_file<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   641
    inline bool is_regular_file( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   642
      { return is_regular_file<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   643
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   644
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   645
    inline bool is_regular( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   646
      { return is_regular<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   647
    inline bool is_regular( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   648
      { return is_regular<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   649
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   650
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   651
    inline bool is_other( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   652
      { return is_other<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   653
    inline bool is_other( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   654
      { return is_other<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   655
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   656
    inline bool is_symlink( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   657
      { return is_symlink<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   658
    inline bool is_symlink( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   659
      { return is_symlink<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   660
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   661
    inline bool is_empty( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   662
      { return is_empty<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   663
    inline bool is_empty( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   664
      { return is_empty<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   665
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   666
    inline bool equivalent( const path & ph1, const path & ph2 )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   667
      { return equivalent<path>( ph1, ph2 ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   668
    inline bool equivalent( const wpath & ph1, const wpath & ph2 )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   669
      { return equivalent<wpath>( ph1, ph2 ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   670
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   671
    inline boost::uintmax_t file_size( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   672
      { return file_size<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   673
    inline boost::uintmax_t file_size( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   674
      { return file_size<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   675
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   676
    inline space_info space( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   677
      { return space<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   678
    inline space_info space( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   679
      { return space<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   680
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   681
    inline std::time_t last_write_time( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   682
      { return last_write_time<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   683
    inline std::time_t last_write_time( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   684
      { return last_write_time<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   685
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   686
    inline bool create_directory( const path & dir_ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   687
      { return create_directory<path>( dir_ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   688
    inline bool create_directory( const wpath & dir_ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   689
      { return create_directory<wpath>( dir_ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   690
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   691
#if !defined(BOOST_WINDOWS_API) || defined(BOOST_FS_HARD_LINK)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   692
    inline void create_hard_link( const path & to_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   693
      const path & from_ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   694
      { return create_hard_link<path>( to_ph, from_ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   695
    inline void create_hard_link( const wpath & to_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   696
      const wpath & from_ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   697
      { return create_hard_link<wpath>( to_ph, from_ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   698
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   699
    inline system::error_code create_hard_link( const path & to_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   700
      const path & from_ph, system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   701
      { return create_hard_link<path>( to_ph, from_ph, ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   702
    inline system::error_code create_hard_link( const wpath & to_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   703
      const wpath & from_ph, system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   704
      { return create_hard_link<wpath>( to_ph, from_ph, ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   705
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   706
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   707
    inline void create_symlink( const path & to_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   708
      const path & from_ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   709
      { return create_symlink<path>( to_ph, from_ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   710
    inline void create_symlink( const wpath & to_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   711
      const wpath & from_ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   712
      { return create_symlink<wpath>( to_ph, from_ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   713
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   714
    inline system::error_code create_symlink( const path & to_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   715
      const path & from_ph, system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   716
      { return create_symlink<path>( to_ph, from_ph, ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   717
    inline system::error_code create_symlink( const wpath & to_ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   718
      const wpath & from_ph, system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   719
      { return create_symlink<wpath>( to_ph, from_ph, ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   720
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   721
    inline bool remove( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   722
      { return remove<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   723
    inline bool remove( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   724
      { return remove<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   725
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   726
    inline unsigned long remove_all( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   727
      { return remove_all<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   728
    inline unsigned long remove_all( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   729
      { return remove_all<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   730
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   731
    inline void rename( const path & from_path, const path & to_path )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   732
      { return rename<path>( from_path, to_path ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   733
    inline void rename( const wpath & from_path, const wpath & to_path )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   734
      { return rename<wpath>( from_path, to_path ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   735
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   736
    inline void copy_file( const path & from_path, const path & to_path )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   737
      { return copy_file<path>( from_path, to_path ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   738
    inline void copy_file( const wpath & from_path, const wpath & to_path )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   739
      { return copy_file<wpath>( from_path, to_path ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   740
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   741
    inline path system_complete( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   742
      { return system_complete<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   743
    inline wpath system_complete( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   744
      { return system_complete<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   745
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   746
    inline path complete( const path & ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   747
      const path & base/* = initial_path<path>()*/ )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   748
      { return complete<path>( ph, base ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   749
    inline wpath complete( const wpath & ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   750
      const wpath & base/* = initial_path<wpath>()*/ )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   751
      { return complete<wpath>( ph, base ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   752
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   753
    inline path complete( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   754
      { return complete<path>( ph, initial_path<path>() ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   755
    inline wpath complete( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   756
      { return complete<wpath>( ph, initial_path<wpath>() ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   757
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   758
    inline void last_write_time( const path & ph, const std::time_t new_time )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   759
      { last_write_time<path>( ph, new_time ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   760
    inline void last_write_time( const wpath & ph, const std::time_t new_time )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   761
      { last_write_time<wpath>( ph, new_time ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   762
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   763
    inline void current_path( const path & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   764
      { current_path<path>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   765
    inline void current_path( const wpath & ph )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   766
      { current_path<wpath>( ph ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   767
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   768
# endif // ifndef BOOST_FILESYSTEM_NARROW_ONLY
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   769
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   770
    namespace detail
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   771
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   772
      template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   773
      bool remove_aux( const Path & ph, file_status f )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   774
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   775
        if ( exists( f ) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   776
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   777
          system::error_code ec = remove_api( ph.external_file_string() );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   778
          if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   779
            boost::throw_exception( basic_filesystem_error<Path>(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   780
              "boost::filesystem::remove", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   781
          return true;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   782
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   783
        return false;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   784
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   785
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   786
      template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   787
      unsigned long remove_all_aux( const Path & ph, file_status f )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   788
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   789
        static const boost::filesystem::basic_directory_iterator<Path> end_itr;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   790
        unsigned long count = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   791
        if ( !boost::filesystem::is_symlink( f ) // don't recurse symbolic links
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   792
          && boost::filesystem::is_directory( f ) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   793
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   794
          for ( boost::filesystem::basic_directory_iterator<Path> itr( ph );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   795
                itr != end_itr; ++itr )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   796
          {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   797
            boost::system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   798
            boost::filesystem::file_status fn = boost::filesystem::symlink_status( itr->path(), ec );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   799
            if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   800
              boost::throw_exception( basic_filesystem_error<Path>( 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   801
                "boost::filesystem:remove_all", ph, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   802
            count += remove_all_aux( itr->path(), fn );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   803
          }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   804
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   805
        remove_aux( ph, f );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   806
        return count;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   807
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   808
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   809
//  test helper  -------------------------------------------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   810
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   811
    // not part of the documented interface because false positives are possible;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   812
    // there is no law that says that an OS that has large stat.st_size
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   813
    // actually supports large file sizes.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   814
      BOOST_FILESYSTEM_DECL bool possible_large_file_size_support();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   815
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   816
//  directory_iterator helpers  ----------------------------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   817
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   818
//    forwarding functions avoid need for BOOST_FILESYSTEM_DECL for class
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   819
//    basic_directory_iterator, and so avoid iterator_facade DLL template
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   820
//    problems. They also overload to the proper external path character type.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   821
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   822
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   823
        dir_itr_first( void *& handle,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   824
#if       defined(BOOST_POSIX_API)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   825
            void *& buffer,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   826
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   827
          const std::string & dir_path,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   828
          std::string & target, file_status & fs, file_status & symlink_fs );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   829
      // eof: return==0 && handle==0
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   830
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   831
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   832
        dir_itr_increment( void *& handle,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   833
#if       defined(BOOST_POSIX_API)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   834
            void *& buffer,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   835
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   836
          std::string & target, file_status & fs, file_status & symlink_fs );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   837
      // eof: return==0 && handle==0
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   838
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   839
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   840
        dir_itr_close( void *& handle
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   841
#if       defined(BOOST_POSIX_API)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   842
            , void *& buffer
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   843
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   844
          );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   845
      // Effects: none if handle==0, otherwise close handle, set handle=0
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   846
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   847
#     if defined(BOOST_WINDOWS_API) && !defined(BOOST_FILESYSTEM_NARROW_ONLY)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   848
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   849
        dir_itr_first( void *& handle, const std::wstring & ph,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   850
          std::wstring & target, file_status & fs, file_status & symlink_fs );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   851
      BOOST_FILESYSTEM_DECL system::error_code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   852
        dir_itr_increment( void *& handle, std::wstring & target,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   853
          file_status & fs, file_status & symlink_fs );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   854
#     endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   855
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   856
      template< class Path >
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   857
      class dir_itr_imp
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   858
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   859
      public:  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   860
        basic_directory_entry<Path> m_directory_entry;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   861
        void *        m_handle;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   862
#       ifdef BOOST_POSIX_API
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   863
          void *      m_buffer;  // see dir_itr_increment implementation
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   864
#       endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   865
        dir_itr_imp() : m_handle(0)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   866
#       ifdef BOOST_POSIX_API
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   867
          , m_buffer(0)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   868
#       endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   869
        {}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   870
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   871
        ~dir_itr_imp() { dir_itr_close( m_handle
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   872
#if       defined(BOOST_POSIX_API)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   873
            , m_buffer
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   874
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   875
          ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   876
      };
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   877
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   878
      BOOST_FILESYSTEM_DECL system::error_code not_found_error();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   879
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   880
    } // namespace detail
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   881
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   882
//  basic_directory_iterator  ------------------------------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   883
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   884
    template< class Path >
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   885
    class basic_directory_iterator
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   886
      : public boost::iterator_facade<
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   887
          basic_directory_iterator<Path>,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   888
          basic_directory_entry<Path>,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   889
          boost::single_pass_traversal_tag >
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   890
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   891
    public:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   892
      typedef Path path_type;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   893
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   894
      basic_directory_iterator(){}  // creates the "end" iterator
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   895
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   896
      explicit basic_directory_iterator( const Path & dir_path );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   897
      basic_directory_iterator( const Path & dir_path, system::error_code & ec );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   898
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   899
    private:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   900
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   901
      // shared_ptr provides shallow-copy semantics required for InputIterators.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   902
      // m_imp.get()==0 indicates the end iterator.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   903
      boost::shared_ptr< detail::dir_itr_imp< Path > >  m_imp;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   904
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   905
      friend class boost::iterator_core_access;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   906
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   907
      typename boost::iterator_facade<
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   908
        basic_directory_iterator<Path>,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   909
        basic_directory_entry<Path>,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   910
        boost::single_pass_traversal_tag >::reference dereference() const 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   911
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   912
        BOOST_ASSERT( m_imp.get() && "attempt to dereference end iterator" );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   913
        return m_imp->m_directory_entry;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   914
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   915
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   916
      void increment();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   917
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   918
      bool equal( const basic_directory_iterator & rhs ) const
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   919
        { return m_imp == rhs.m_imp; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   920
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   921
      system::error_code m_init( const Path & dir_path );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   922
    };
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   923
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   924
    typedef basic_directory_iterator< path > directory_iterator;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   925
# ifndef BOOST_FILESYSTEM_NARROW_ONLY
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   926
    typedef basic_directory_iterator< wpath > wdirectory_iterator;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   927
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   928
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   929
    //  basic_directory_iterator implementation  ---------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   930
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   931
    template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   932
    system::error_code basic_directory_iterator<Path>::m_init(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   933
      const Path & dir_path )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   934
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   935
      if ( dir_path.empty() )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   936
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   937
        m_imp.reset();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   938
        return detail::not_found_error();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   939
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   940
      typename Path::external_string_type name;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   941
      file_status fs, symlink_fs;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   942
      system::error_code ec( detail::dir_itr_first( m_imp->m_handle,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   943
#if   defined(BOOST_POSIX_API)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   944
        m_imp->m_buffer,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   945
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   946
        dir_path.external_directory_string(),
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   947
        name, fs, symlink_fs ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   948
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   949
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   950
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   951
        m_imp.reset();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   952
        return ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   953
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   954
      
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   955
      if ( m_imp->m_handle == 0 ) m_imp.reset(); // eof, so make end iterator
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   956
      else // not eof
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   957
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   958
        m_imp->m_directory_entry.assign( dir_path
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   959
          / Path::traits_type::to_internal( name ), fs, symlink_fs );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   960
        if ( name[0] == dot<Path>::value // dot or dot-dot
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   961
          && (name.size() == 1
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   962
            || (name[1] == dot<Path>::value
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   963
              && name.size() == 2)) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   964
          {  increment(); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   965
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   966
      return boost::system::error_code();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   967
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   968
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   969
    template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   970
    basic_directory_iterator<Path>::basic_directory_iterator(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   971
      const Path & dir_path )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   972
      : m_imp( new detail::dir_itr_imp<Path> )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   973
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   974
      system::error_code ec( m_init(dir_path) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   975
      if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   976
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   977
        boost::throw_exception( basic_filesystem_error<Path>( 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   978
          "boost::filesystem::basic_directory_iterator constructor",
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   979
          dir_path, ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   980
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   981
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   982
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   983
    template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   984
    basic_directory_iterator<Path>::basic_directory_iterator(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   985
      const Path & dir_path, system::error_code & ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   986
      : m_imp( new detail::dir_itr_imp<Path> )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   987
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   988
      ec = m_init(dir_path);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   989
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   990
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   991
    template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   992
    void basic_directory_iterator<Path>::increment()
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   993
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   994
      BOOST_ASSERT( m_imp.get() && "attempt to increment end iterator" );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   995
      BOOST_ASSERT( m_imp->m_handle != 0 && "internal program error" );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   996
      
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   997
      typename Path::external_string_type name;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   998
      file_status fs, symlink_fs;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   999
      system::error_code ec;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1000
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1001
      for (;;)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1002
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1003
        ec = detail::dir_itr_increment( m_imp->m_handle,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1004
#if     defined(BOOST_POSIX_API)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1005
          m_imp->m_buffer,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1006
#endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1007
          name, fs, symlink_fs );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1008
        if ( ec )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1009
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1010
          boost::throw_exception( basic_filesystem_error<Path>(  
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1011
            "boost::filesystem::basic_directory_iterator increment",
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1012
            m_imp->m_directory_entry.path().parent_path(), ec ) );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1013
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1014
        if ( m_imp->m_handle == 0 ) { m_imp.reset(); return; } // eof, make end
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1015
        if ( !(name[0] == dot<Path>::value // !(dot or dot-dot)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1016
          && (name.size() == 1
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1017
            || (name[1] == dot<Path>::value
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1018
              && name.size() == 2))) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1019
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1020
          m_imp->m_directory_entry.replace_filename(
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1021
            Path::traits_type::to_internal( name ), fs, symlink_fs );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1022
          return;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1023
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1024
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1025
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1026
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1027
    //  basic_directory_entry  -----------------------------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1028
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1029
    template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1030
    class basic_directory_entry
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1031
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1032
    public:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1033
      typedef Path path_type;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1034
      typedef typename Path::string_type string_type;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1035
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1036
      // compiler generated copy-ctor, copy assignment, and destructor apply
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1037
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1038
      basic_directory_entry() {}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1039
      explicit basic_directory_entry( const path_type & p,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1040
        file_status st = file_status(), file_status symlink_st=file_status() )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1041
        : m_path(p), m_status(st), m_symlink_status(symlink_st)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1042
        {}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1043
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1044
      void assign( const path_type & p,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1045
        file_status st, file_status symlink_st )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1046
        { m_path = p; m_status = st; m_symlink_status = symlink_st; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1047
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1048
      void replace_filename( const string_type & s,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1049
        file_status st, file_status symlink_st )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1050
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1051
        m_path.remove_filename();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1052
        m_path /= s;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1053
        m_status = st;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1054
        m_symlink_status = symlink_st;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1055
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1056
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1057
#   ifndef BOOST_FILESYSTEM_NO_DEPRECATED
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1058
      void replace_leaf( const string_type & s,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1059
        file_status st, file_status symlink_st )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1060
          { replace_filename( s, st, symlink_st ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1061
#   endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1062
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1063
      const Path &  path() const { return m_path; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1064
      file_status   status() const;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1065
      file_status   status( system::error_code & ec ) const;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1066
      file_status   symlink_status() const;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1067
      file_status   symlink_status( system::error_code & ec ) const;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1068
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1069
      // conversion simplifies the most common use of basic_directory_entry
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1070
      operator const path_type &() const { return m_path; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1071
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1072
#   ifndef BOOST_FILESYSTEM_NO_DEPRECATED
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1073
      // deprecated functions preserve common use cases in legacy code
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1074
      typename Path::string_type filename() const
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1075
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1076
        return path().filename();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1077
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1078
      typename Path::string_type leaf() const
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1079
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1080
        return path().filename();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1081
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1082
      typename Path::string_type string() const
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1083
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1084
        return path().string();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1085
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1086
#   endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1087
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1088
    private:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1089
      path_type             m_path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1090
      mutable file_status  m_status;           // stat()-like
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1091
      mutable file_status  m_symlink_status;   // lstat()-like
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1092
        // note: m_symlink_status is not used by Windows implementation
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1093
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1094
    }; // basic_directory_status
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1095
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1096
    typedef basic_directory_entry<path> directory_entry;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1097
# ifndef BOOST_FILESYSTEM_NARROW_ONLY
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1098
    typedef basic_directory_entry<wpath> wdirectory_entry;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1099
# endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1100
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1101
    //  basic_directory_entry implementation  --------------------------------//
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1102
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1103
    template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1104
    file_status
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1105
    basic_directory_entry<Path>::status() const
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1106
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1107
      if ( !status_known( m_status ) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1108
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1109
#     ifndef BOOST_WINDOWS_API
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1110
        if ( status_known( m_symlink_status )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1111
          && !is_symlink( m_symlink_status ) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1112
          { m_status = m_symlink_status; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1113
        else { m_status = boost::filesystem::status( m_path ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1114
#     else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1115
        m_status = boost::filesystem::status( m_path );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1116
#     endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1117
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1118
      return m_status;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1119
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1120
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1121
    template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1122
    file_status
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1123
    basic_directory_entry<Path>::status( system::error_code & ec ) const
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1124
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1125
      if ( !status_known( m_status ) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1126
      {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1127
#     ifndef BOOST_WINDOWS_API
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1128
        if ( status_known( m_symlink_status )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1129
          && !is_symlink( m_symlink_status ) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1130
          { ec = boost::system::error_code();; m_status = m_symlink_status; }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1131
        else { m_status = boost::filesystem::status( m_path, ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1132
#     else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1133
        m_status = boost::filesystem::status( m_path, ec );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1134
#     endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1135
      }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1136
      else ec = boost::system::error_code();;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1137
      return m_status;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1138
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1139
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1140
    template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1141
    file_status
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1142
    basic_directory_entry<Path>::symlink_status() const
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1143
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1144
#   ifndef BOOST_WINDOWS_API
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1145
      if ( !status_known( m_symlink_status ) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1146
        { m_symlink_status = boost::filesystem::symlink_status( m_path ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1147
      return m_symlink_status;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1148
#   else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1149
      return status();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1150
#   endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1151
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1152
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1153
    template<class Path>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1154
    file_status
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1155
    basic_directory_entry<Path>::symlink_status( system::error_code & ec ) const
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1156
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1157
#   ifndef BOOST_WINDOWS_API
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1158
      if ( !status_known( m_symlink_status ) )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1159
        { m_symlink_status = boost::filesystem::symlink_status( m_path, ec ); }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1160
      else ec = boost::system::error_code();;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1161
      return m_symlink_status;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1162
#   else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1163
      return status( ec );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1164
#   endif
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1165
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1166
  } // namespace filesystem
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1167
} // namespace boost
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1168
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1169
#undef BOOST_FS_FUNC
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1170
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1171
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1172
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
  1173
#endif // BOOST_FILESYSTEM_OPERATIONS_HPP