ndnboost: Include boost::iostreams for internal use.
diff --git a/include/ndnboost/filesystem/config.hpp b/include/ndnboost/filesystem/config.hpp
new file mode 100644
index 0000000..f70bec2
--- /dev/null
+++ b/include/ndnboost/filesystem/config.hpp
@@ -0,0 +1,109 @@
+// ndnboost/filesystem/v3/config.hpp ----------------------------------------------------//
+
+// Copyright Beman Dawes 2003
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
+
+//--------------------------------------------------------------------------------------//
+
+#ifndef NDNBOOST_FILESYSTEM3_CONFIG_HPP
+#define NDNBOOST_FILESYSTEM3_CONFIG_HPP
+
+# if defined(NDNBOOST_FILESYSTEM_VERSION) && NDNBOOST_FILESYSTEM_VERSION != 3
+# error Compiling Filesystem version 3 file with NDNBOOST_FILESYSTEM_VERSION defined != 3
+# endif
+
+# if !defined(NDNBOOST_FILESYSTEM_VERSION)
+# define NDNBOOST_FILESYSTEM_VERSION 3
+# endif
+
+#define NDNBOOST_FILESYSTEM_I18N // aid users wishing to compile several versions
+
+// This header implements separate compilation features as described in
+// http://www.boost.org/more/separate_compilation.html
+
+#include <ndnboost/config.hpp>
+#include <ndnboost/system/api_config.hpp> // for NDNBOOST_POSIX_API or NDNBOOST_WINDOWS_API
+#include <ndnboost/detail/workaround.hpp>
+
+// NDNBOOST_FILESYSTEM_DEPRECATED needed for source compiles -----------------------------//
+
+# ifdef NDNBOOST_FILESYSTEM_SOURCE
+# define NDNBOOST_FILESYSTEM_DEPRECATED
+# endif
+
+// throw an exception ----------------------------------------------------------------//
+//
+// Exceptions were originally thrown via ndnboost::throw_exception().
+// As throw_exception() became more complex, it caused user error reporting
+// to be harder to interpret, since the exception reported became much more complex.
+// The immediate fix was to throw directly, wrapped in a macro to make any later change
+// easier.
+
+#define NDNBOOST_FILESYSTEM_THROW(EX) throw EX
+
+# if defined( NDNBOOST_NO_STD_WSTRING )
+# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
+# endif
+
+// This header implements separate compilation features as described in
+// http://www.boost.org/more/separate_compilation.html
+
+// normalize macros ------------------------------------------------------------------//
+
+#if !defined(NDNBOOST_FILESYSTEM_DYN_LINK) && !defined(NDNBOOST_FILESYSTEM_STATIC_LINK) \
+ && !defined(NDNBOOST_ALL_DYN_LINK) && !defined(NDNBOOST_ALL_STATIC_LINK)
+# define NDNBOOST_FILESYSTEM_STATIC_LINK
+#endif
+
+#if defined(NDNBOOST_ALL_DYN_LINK) && !defined(NDNBOOST_FILESYSTEM_DYN_LINK)
+# define NDNBOOST_FILESYSTEM_DYN_LINK
+#elif defined(NDNBOOST_ALL_STATIC_LINK) && !defined(NDNBOOST_FILESYSTEM_STATIC_LINK)
+# define NDNBOOST_FILESYSTEM_STATIC_LINK
+#endif
+
+#if defined(NDNBOOST_FILESYSTEM_DYN_LINK) && defined(NDNBOOST_FILESYSTEM_STATIC_LINK)
+# error Must not define both NDNBOOST_FILESYSTEM_DYN_LINK and NDNBOOST_FILESYSTEM_STATIC_LINK
+#endif
+
+#if defined(NDNBOOST_ALL_NO_LIB) && !defined(NDNBOOST_FILESYSTEM_NO_LIB)
+# define NDNBOOST_FILESYSTEM_NO_LIB
+#endif
+
+// enable dynamic linking ------------------------------------------------------------//
+
+#if defined(NDNBOOST_ALL_DYN_LINK) || defined(NDNBOOST_FILESYSTEM_DYN_LINK)
+# if defined(NDNBOOST_FILESYSTEM_SOURCE)
+# define NDNBOOST_FILESYSTEM_DECL NDNBOOST_SYMBOL_EXPORT
+# else
+# define NDNBOOST_FILESYSTEM_DECL NDNBOOST_SYMBOL_IMPORT
+# endif
+#else
+# define NDNBOOST_FILESYSTEM_DECL
+#endif
+
+// enable automatic library variant selection ----------------------------------------//
+
+#if !defined(NDNBOOST_FILESYSTEM_SOURCE) && !defined(NDNBOOST_ALL_NO_LIB) \
+ && !defined(NDNBOOST_FILESYSTEM_NO_LIB)
+//
+// Set the name of our library, this will get undef'ed by auto_link.hpp
+// once it's done with it:
+//
+#define NDNBOOST_LIB_NAME ndnboost_filesystem
+//
+// If we're importing code from a dll, then tell auto_link.hpp about it:
+//
+#if defined(NDNBOOST_ALL_DYN_LINK) || defined(NDNBOOST_FILESYSTEM_DYN_LINK)
+# define NDNBOOST_DYN_LINK
+#endif
+//
+// And include the header that does the work:
+//
+#include <ndnboost/config/auto_link.hpp>
+#endif // auto-linking disabled
+
+#endif // NDNBOOST_FILESYSTEM3_CONFIG_HPP
diff --git a/include/ndnboost/filesystem/convenience.hpp b/include/ndnboost/filesystem/convenience.hpp
new file mode 100644
index 0000000..5e91750
--- /dev/null
+++ b/include/ndnboost/filesystem/convenience.hpp
@@ -0,0 +1,58 @@
+// ndnboost/filesystem/convenience.hpp ----------------------------------------//
+
+// Copyright Beman Dawes, 2002-2005
+// Copyright Vladimir Prus, 2002
+// Use, modification, and distribution is subject to the Boost Software
+// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See library home page at http://www.boost.org/libs/filesystem
+
+//----------------------------------------------------------------------------//
+
+#ifndef NDNBOOST_FILESYSTEM3_CONVENIENCE_HPP
+#define NDNBOOST_FILESYSTEM3_CONVENIENCE_HPP
+
+#include <ndnboost/config.hpp>
+
+# if defined( NDNBOOST_NO_STD_WSTRING )
+# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
+# endif
+
+#include <ndnboost/filesystem/operations.hpp>
+#include <ndnboost/system/error_code.hpp>
+
+#include <ndnboost/config/abi_prefix.hpp> // must be the last #include
+
+namespace ndnboost
+{
+ namespace filesystem
+ {
+
+# ifndef NDNBOOST_FILESYSTEM_NO_DEPRECATED
+
+ inline std::string extension(const path & p)
+ {
+ return p.extension().string();
+ }
+
+ inline std::string basename(const path & p)
+ {
+ return p.stem().string();
+ }
+
+ inline path change_extension( const path & p, const path & new_extension )
+ {
+ path new_p( p );
+ new_p.replace_extension( new_extension );
+ return new_p;
+ }
+
+# endif
+
+
+ } // namespace filesystem
+} // namespace ndnboost
+
+#include <ndnboost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
+#endif // NDNBOOST_FILESYSTEM3_CONVENIENCE_HPP
diff --git a/include/ndnboost/filesystem/detail/utf8_codecvt_facet.hpp b/include/ndnboost/filesystem/detail/utf8_codecvt_facet.hpp
new file mode 100644
index 0000000..5e8251c
--- /dev/null
+++ b/include/ndnboost/filesystem/detail/utf8_codecvt_facet.hpp
@@ -0,0 +1,24 @@
+// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
+// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
+
+// Distributed under the Boost Software License, Version 1.0.
+// (See http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef NDNBOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP
+#define NDNBOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP
+
+#include <ndnboost/filesystem/config.hpp>
+
+#define NDNBOOST_UTF8_BEGIN_NAMESPACE \
+ namespace ndnboost { namespace filesystem { namespace detail {
+
+#define NDNBOOST_UTF8_END_NAMESPACE }}}
+#define NDNBOOST_UTF8_DECL NDNBOOST_FILESYSTEM_DECL
+
+#include <ndnboost/detail/utf8_codecvt_facet.hpp>
+
+#undef NDNBOOST_UTF8_BEGIN_NAMESPACE
+#undef NDNBOOST_UTF8_END_NAMESPACE
+#undef NDNBOOST_UTF8_DECL
+
+#endif
diff --git a/include/ndnboost/filesystem/operations.hpp b/include/ndnboost/filesystem/operations.hpp
new file mode 100644
index 0000000..b395e49
--- /dev/null
+++ b/include/ndnboost/filesystem/operations.hpp
@@ -0,0 +1,1096 @@
+// ndnboost/filesystem/operations.hpp ---------------------------------------------------//
+
+// Copyright Beman Dawes 2002-2009
+// Copyright Jan Langer 2002
+// Copyright Dietmar Kuehl 2001
+// Copyright Vladimir Prus 2002
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
+
+//--------------------------------------------------------------------------------------//
+
+#ifndef NDNBOOST_FILESYSTEM3_OPERATIONS_HPP
+#define NDNBOOST_FILESYSTEM3_OPERATIONS_HPP
+
+#include <ndnboost/config.hpp>
+
+# if defined( NDNBOOST_NO_STD_WSTRING )
+# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
+# endif
+
+#include <ndnboost/filesystem/config.hpp>
+#include <ndnboost/filesystem/path.hpp>
+
+#include <ndnboost/detail/scoped_enum_emulation.hpp>
+#include <ndnboost/detail/bitmask.hpp>
+#include <ndnboost/system/error_code.hpp>
+#include <ndnboost/system/system_error.hpp>
+#include <ndnboost/shared_ptr.hpp>
+#include <ndnboost/utility/enable_if.hpp>
+#include <ndnboost/type_traits/is_same.hpp>
+#include <ndnboost/iterator.hpp>
+#include <ndnboost/cstdint.hpp>
+#include <ndnboost/assert.hpp>
+
+#include <string>
+#include <utility> // for pair
+#include <ctime>
+#include <vector>
+#include <stack>
+
+#ifdef NDNBOOST_WINDOWS_API
+# include <fstream>
+#endif
+
+#include <ndnboost/config/abi_prefix.hpp> // must be the last #include
+
+//--------------------------------------------------------------------------------------//
+
+namespace ndnboost
+{
+ namespace filesystem
+ {
+
+//--------------------------------------------------------------------------------------//
+// file_type //
+//--------------------------------------------------------------------------------------//
+
+ enum file_type
+ {
+ status_error,
+# ifndef NDNBOOST_FILESYSTEM_NO_DEPRECATED
+ status_unknown = status_error,
+# endif
+ file_not_found,
+ regular_file,
+ directory_file,
+ // the following may not apply to some operating systems or file systems
+ symlink_file,
+ block_file,
+ character_file,
+ fifo_file,
+ socket_file,
+ reparse_file, // Windows: FILE_ATTRIBUTE_REPARSE_POINT that is not a symlink
+ type_unknown, // file does exist, but isn't one of the above types or
+ // we don't have strong enough permission to find its type
+
+ _detail_directory_symlink // internal use only; never exposed to users
+ };
+
+//--------------------------------------------------------------------------------------//
+// perms //
+//--------------------------------------------------------------------------------------//
+
+ enum perms
+ {
+ no_perms = 0, // file_not_found is no_perms rather than perms_not_known
+
+ // POSIX equivalent macros given in comments.
+ // Values are from POSIX and are given in octal per the POSIX standard.
+
+ // permission bits
+
+ owner_read = 0400, // S_IRUSR, Read permission, owner
+ owner_write = 0200, // S_IWUSR, Write permission, owner
+ owner_exe = 0100, // S_IXUSR, Execute/search permission, owner
+ owner_all = 0700, // S_IRWXU, Read, write, execute/search by owner
+
+ group_read = 040, // S_IRGRP, Read permission, group
+ group_write = 020, // S_IWGRP, Write permission, group
+ group_exe = 010, // S_IXGRP, Execute/search permission, group
+ group_all = 070, // S_IRWXG, Read, write, execute/search by group
+
+ others_read = 04, // S_IROTH, Read permission, others
+ others_write = 02, // S_IWOTH, Write permission, others
+ others_exe = 01, // S_IXOTH, Execute/search permission, others
+ others_all = 07, // S_IRWXO, Read, write, execute/search by others
+
+ all_all = owner_all|group_all|others_all, // 0777
+
+ // other POSIX bits
+
+ set_uid_on_exe = 04000, // S_ISUID, Set-user-ID on execution
+ set_gid_on_exe = 02000, // S_ISGID, Set-group-ID on execution
+ sticky_bit = 01000, // S_ISVTX,
+ // (POSIX XSI) On directories, restricted deletion flag
+ // (V7) 'sticky bit': save swapped text even after use
+ // (SunOS) On non-directories: don't cache this file
+ // (SVID-v4.2) On directories: restricted deletion flag
+ // Also see http://en.wikipedia.org/wiki/Sticky_bit
+
+ perms_mask = all_all|set_uid_on_exe|set_gid_on_exe|sticky_bit, // 07777
+
+ perms_not_known = 0xFFFF, // present when directory_entry cache not loaded
+
+ // options for permissions() function
+
+ add_perms = 0x1000, // adds the given permission bits to the current bits
+ remove_perms = 0x2000, // removes the given permission bits from the current bits;
+ // choose add_perms or remove_perms, not both; if neither add_perms
+ // nor remove_perms is given, replace the current bits with
+ // the given bits.
+
+ symlink_perms = 0x4000 // on POSIX, don't resolve symlinks; implied on Windows
+ };
+
+ NDNBOOST_BITMASK(perms)
+
+//--------------------------------------------------------------------------------------//
+// file_status //
+//--------------------------------------------------------------------------------------//
+
+ class NDNBOOST_FILESYSTEM_DECL file_status
+ {
+ public:
+ file_status() : m_value(status_error), m_perms(perms_not_known) {}
+ explicit file_status(file_type v, perms prms = perms_not_known)
+ : m_value(v), m_perms(prms) {}
+
+ // observers
+ file_type type() const { return m_value; }
+ perms permissions() const { return m_perms; }
+
+ // modifiers
+ void type(file_type v) { m_value = v; }
+ void permissions(perms prms) { m_perms = prms; }
+
+ bool operator==(const file_status& rhs) const { return type() == rhs.type() &&
+ permissions() == rhs.permissions(); }
+ bool operator!=(const file_status& rhs) const { return !(*this == rhs); }
+
+ private:
+ file_type m_value;
+ enum perms m_perms;
+ };
+
+ inline bool type_present(file_status f) { return f.type() != status_error; }
+ inline bool permissions_present(file_status f)
+ {return f.permissions() != perms_not_known;}
+ inline bool status_known(file_status f) { return type_present(f) && permissions_present(f); }
+ inline bool exists(file_status f) { return f.type() != status_error
+ && f.type() != file_not_found; }
+ inline bool is_regular_file(file_status f){ return f.type() == regular_file; }
+ inline bool is_directory(file_status f) { return f.type() == directory_file; }
+ inline bool is_symlink(file_status f) { return f.type() == symlink_file; }
+ inline bool is_other(file_status f) { return exists(f) && !is_regular_file(f)
+ && !is_directory(f) && !is_symlink(f); }
+
+# ifndef NDNBOOST_FILESYSTEM_NO_DEPRECATED
+ inline bool is_regular(file_status f) { return f.type() == regular_file; }
+# endif
+
+ struct space_info
+ {
+ // all values are byte counts
+ ndnboost::uintmax_t capacity;
+ ndnboost::uintmax_t free; // <= capacity
+ ndnboost::uintmax_t available; // <= free
+ };
+
+ NDNBOOST_SCOPED_ENUM_START(copy_option)
+ {none, fail_if_exists = none, overwrite_if_exists};
+ NDNBOOST_SCOPED_ENUM_END
+
+//--------------------------------------------------------------------------------------//
+// implementation details //
+//--------------------------------------------------------------------------------------//
+
+ namespace detail
+ {
+ NDNBOOST_FILESYSTEM_DECL
+ file_status status(const path&p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ file_status symlink_status(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ bool is_empty(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ path initial_path(system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ path canonical(const path& p, const path& base, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void copy(const path& from, const path& to, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void copy_directory(const path& from, const path& to, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void copy_file(const path& from, const path& to,
+ NDNBOOST_SCOPED_ENUM(copy_option) option, // See ticket #2925
+ system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void copy_symlink(const path& existing_symlink, const path& new_symlink, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ bool create_directories(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ bool create_directory(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void create_directory_symlink(const path& to, const path& from,
+ system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void create_hard_link(const path& to, const path& from, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void create_symlink(const path& to, const path& from, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ path current_path(system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void current_path(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ bool equivalent(const path& p1, const path& p2, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ ndnboost::uintmax_t file_size(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ ndnboost::uintmax_t hard_link_count(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ std::time_t last_write_time(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void last_write_time(const path& p, const std::time_t new_time,
+ system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void permissions(const path& p, perms prms, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ path read_symlink(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ // For standardization, if the committee doesn't like "remove", consider "eliminate"
+ bool remove(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ ndnboost::uintmax_t remove_all(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void rename(const path& old_p, const path& new_p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ void resize_file(const path& p, uintmax_t size, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ space_info space(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ path system_complete(const path& p, system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ path temp_directory_path(system::error_code* ec=0);
+ NDNBOOST_FILESYSTEM_DECL
+ path unique_path(const path& p, system::error_code* ec=0);
+ } // namespace detail
+
+//--------------------------------------------------------------------------------------//
+// //
+// status query functions //
+// //
+//--------------------------------------------------------------------------------------//
+
+ inline
+ file_status status(const path& p) {return detail::status(p);}
+ inline
+ file_status status(const path& p, system::error_code& ec)
+ {return detail::status(p, &ec);}
+ inline
+ file_status symlink_status(const path& p) {return detail::symlink_status(p);}
+ inline
+ file_status symlink_status(const path& p, system::error_code& ec)
+ {return detail::symlink_status(p, &ec);}
+ inline
+ bool exists(const path& p) {return exists(detail::status(p));}
+ inline
+ bool exists(const path& p, system::error_code& ec)
+ {return exists(detail::status(p, &ec));}
+ inline
+ bool is_directory(const path& p) {return is_directory(detail::status(p));}
+ inline
+ bool is_directory(const path& p, system::error_code& ec)
+ {return is_directory(detail::status(p, &ec));}
+ inline
+ bool is_regular_file(const path& p) {return is_regular_file(detail::status(p));}
+ inline
+ bool is_regular_file(const path& p, system::error_code& ec)
+ {return is_regular_file(detail::status(p, &ec));}
+ inline
+ bool is_other(const path& p) {return is_other(detail::status(p));}
+ inline
+ bool is_other(const path& p, system::error_code& ec)
+ {return is_other(detail::status(p, &ec));}
+ inline
+ bool is_symlink(const path& p) {return is_symlink(detail::symlink_status(p));}
+ inline
+ bool is_symlink(const path& p, system::error_code& ec)
+ {return is_symlink(detail::symlink_status(p, &ec));}
+# ifndef NDNBOOST_FILESYSTEM_NO_DEPRECATED
+ inline
+ bool is_regular(const path& p) {return is_regular(detail::status(p));}
+ inline
+ bool is_regular(const path& p, system::error_code& ec)
+ {return is_regular(detail::status(p, &ec));}
+# endif
+
+ inline
+ bool is_empty(const path& p) {return detail::is_empty(p);}
+ inline
+ bool is_empty(const path& p, system::error_code& ec)
+ {return detail::is_empty(p, &ec);}
+
+//--------------------------------------------------------------------------------------//
+// //
+// operational functions //
+// in alphabetical order, unless otherwise noted //
+// //
+//--------------------------------------------------------------------------------------//
+
+ // forward declarations
+ path current_path(); // fwd declaration
+ path initial_path();
+
+ NDNBOOST_FILESYSTEM_DECL
+ path absolute(const path& p, const path& base=current_path());
+ // If base.is_absolute(), throws nothing. Thus no need for ec argument
+
+ inline
+ path canonical(const path& p, const path& base=current_path())
+ {return detail::canonical(p, base);}
+ inline
+ path canonical(const path& p, system::error_code& ec)
+ {return detail::canonical(p, current_path(), &ec);}
+ inline
+ path canonical(const path& p, const path& base, system::error_code& ec)
+ {return detail::canonical(p, base, &ec);}
+
+# ifndef NDNBOOST_FILESYSTEM_NO_DEPRECATED
+ inline
+ path complete(const path& p)
+ {
+ return absolute(p, initial_path());
+ }
+
+ inline
+ path complete(const path& p, const path& base)
+ {
+ return absolute(p, base);
+ }
+# endif
+
+ inline
+ void copy(const path& from, const path& to) {detail::copy(from, to);}
+
+ inline
+ void copy(const path& from, const path& to, system::error_code& ec)
+ {detail::copy(from, to, &ec);}
+ inline
+ void copy_directory(const path& from, const path& to)
+ {detail::copy_directory(from, to);}
+ inline
+ void copy_directory(const path& from, const path& to, system::error_code& ec)
+ {detail::copy_directory(from, to, &ec);}
+ inline
+ void copy_file(const path& from, const path& to, // See ticket #2925
+ NDNBOOST_SCOPED_ENUM(copy_option) option)
+ {detail::copy_file(from, to, option);}
+ inline
+ void copy_file(const path& from, const path& to)
+ {detail::copy_file(from, to, copy_option::fail_if_exists);}
+ inline
+ void copy_file(const path& from, const path& to, // See ticket #2925
+ NDNBOOST_SCOPED_ENUM(copy_option) option, system::error_code& ec)
+ {detail::copy_file(from, to, option, &ec);}
+ inline
+ void copy_file(const path& from, const path& to, system::error_code& ec)
+ {detail::copy_file(from, to, copy_option::fail_if_exists, &ec);}
+ inline
+ void copy_symlink(const path& existing_symlink, const path& new_symlink) {detail::copy_symlink(existing_symlink, new_symlink);}
+
+ inline
+ void copy_symlink(const path& existing_symlink, const path& new_symlink, system::error_code& ec)
+ {detail::copy_symlink(existing_symlink, new_symlink, &ec);}
+ inline
+ bool create_directories(const path& p) {return detail::create_directories(p);}
+
+ inline
+ bool create_directories(const path& p, system::error_code& ec)
+ {return detail::create_directories(p, &ec);}
+ inline
+ bool create_directory(const path& p) {return detail::create_directory(p);}
+
+ inline
+ bool create_directory(const path& p, system::error_code& ec)
+ {return detail::create_directory(p, &ec);}
+ inline
+ void create_directory_symlink(const path& to, const path& from)
+ {detail::create_directory_symlink(to, from);}
+ inline
+ void create_directory_symlink(const path& to, const path& from, system::error_code& ec)
+ {detail::create_directory_symlink(to, from, &ec);}
+ inline
+ void create_hard_link(const path& to, const path& new_hard_link) {detail::create_hard_link(to, new_hard_link);}
+
+ inline
+ void create_hard_link(const path& to, const path& new_hard_link, system::error_code& ec)
+ {detail::create_hard_link(to, new_hard_link, &ec);}
+ inline
+ void create_symlink(const path& to, const path& new_symlink) {detail::create_symlink(to, new_symlink);}
+
+ inline
+ void create_symlink(const path& to, const path& new_symlink, system::error_code& ec)
+ {detail::create_symlink(to, new_symlink, &ec);}
+ inline
+ path current_path() {return detail::current_path();}
+
+ inline
+ path current_path(system::error_code& ec) {return detail::current_path(&ec);}
+
+ inline
+ void current_path(const path& p) {detail::current_path(p);}
+
+ inline
+ void current_path(const path& p, system::error_code& ec) {detail::current_path(p, &ec);}
+
+ inline
+ bool equivalent(const path& p1, const path& p2) {return detail::equivalent(p1, p2);}
+
+ inline
+ bool equivalent(const path& p1, const path& p2, system::error_code& ec)
+ {return detail::equivalent(p1, p2, &ec);}
+ inline
+ ndnboost::uintmax_t file_size(const path& p) {return detail::file_size(p);}
+
+ inline
+ ndnboost::uintmax_t file_size(const path& p, system::error_code& ec)
+ {return detail::file_size(p, &ec);}
+ inline
+ ndnboost::uintmax_t hard_link_count(const path& p) {return detail::hard_link_count(p);}
+
+ inline
+ ndnboost::uintmax_t hard_link_count(const path& p, system::error_code& ec)
+ {return detail::hard_link_count(p, &ec);}
+ inline
+ path initial_path() {return detail::initial_path();}
+
+ inline
+ path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}
+
+ template <class Path>
+ path initial_path() {return initial_path();}
+ template <class Path>
+ path initial_path(system::error_code& ec) {return detail::initial_path(&ec);}
+
+ inline
+ std::time_t last_write_time(const path& p) {return detail::last_write_time(p);}
+
+ inline
+ std::time_t last_write_time(const path& p, system::error_code& ec)
+ {return detail::last_write_time(p, &ec);}
+ inline
+ void last_write_time(const path& p, const std::time_t new_time)
+ {detail::last_write_time(p, new_time);}
+ inline
+ void last_write_time(const path& p, const std::time_t new_time, system::error_code& ec)
+ {detail::last_write_time(p, new_time, &ec);}
+ inline
+ void permissions(const path& p, perms prms)
+ {detail::permissions(p, prms);}
+ inline
+ void permissions(const path& p, perms prms, system::error_code& ec)
+ {detail::permissions(p, prms, &ec);}
+
+ inline
+ path read_symlink(const path& p) {return detail::read_symlink(p);}
+
+ inline
+ path read_symlink(const path& p, system::error_code& ec)
+ {return detail::read_symlink(p, &ec);}
+ inline
+ // For standardization, if the committee doesn't like "remove", consider "eliminate"
+ bool remove(const path& p) {return detail::remove(p);}
+
+ inline
+ bool remove(const path& p, system::error_code& ec) {return detail::remove(p, &ec);}
+
+ inline
+ ndnboost::uintmax_t remove_all(const path& p) {return detail::remove_all(p);}
+
+ inline
+ ndnboost::uintmax_t remove_all(const path& p, system::error_code& ec)
+ {return detail::remove_all(p, &ec);}
+ inline
+ void rename(const path& old_p, const path& new_p) {detail::rename(old_p, new_p);}
+
+ inline
+ void rename(const path& old_p, const path& new_p, system::error_code& ec)
+ {detail::rename(old_p, new_p, &ec);}
+ inline // name suggested by Scott McMurray
+ void resize_file(const path& p, uintmax_t size) {detail::resize_file(p, size);}
+
+ inline
+ void resize_file(const path& p, uintmax_t size, system::error_code& ec)
+ {detail::resize_file(p, size, &ec);}
+ inline
+ space_info space(const path& p) {return detail::space(p);}
+
+ inline
+ space_info space(const path& p, system::error_code& ec) {return detail::space(p, &ec);}
+
+# ifndef NDNBOOST_FILESYSTEM_NO_DEPRECATED
+ inline bool symbolic_link_exists(const path& p)
+ { return is_symlink(symlink_status(p)); }
+# endif
+
+ inline
+ path system_complete(const path& p) {return detail::system_complete(p);}
+
+ inline
+ path system_complete(const path& p, system::error_code& ec)
+ {return detail::system_complete(p, &ec);}
+ inline
+ path temp_directory_path() {return detail::temp_directory_path();}
+
+ inline
+ path temp_directory_path(system::error_code& ec)
+ {return detail::temp_directory_path(&ec);}
+ inline
+ path unique_path(const path& p="%%%%-%%%%-%%%%-%%%%")
+ { return detail::unique_path(p); }
+ inline
+ path unique_path(const path& p, system::error_code& ec)
+ { return detail::unique_path(p, &ec); }
+
+//--------------------------------------------------------------------------------------//
+// //
+// directory_entry //
+// //
+//--------------------------------------------------------------------------------------//
+
+// GCC has a problem with a member function named path within a namespace or
+// sub-namespace that also has a class named path. The workaround is to always
+// fully qualify the name path when it refers to the class name.
+
+class NDNBOOST_FILESYSTEM_DECL directory_entry
+{
+public:
+
+ // compiler generated copy constructor, copy assignment, and destructor apply
+
+ directory_entry() {}
+ explicit directory_entry(const ndnboost::filesystem::path& p,
+ file_status st = file_status(), file_status symlink_st=file_status())
+ : m_path(p), m_status(st), m_symlink_status(symlink_st)
+ {}
+
+ void assign(const ndnboost::filesystem::path& p,
+ file_status st = file_status(), file_status symlink_st = file_status())
+ { m_path = p; m_status = st; m_symlink_status = symlink_st; }
+
+ void replace_filename(const ndnboost::filesystem::path& p,
+ file_status st = file_status(), file_status symlink_st = file_status())
+ {
+ m_path.remove_filename();
+ m_path /= p;
+ m_status = st;
+ m_symlink_status = symlink_st;
+ }
+
+# ifndef NDNBOOST_FILESYSTEM_NO_DEPRECATED
+ void replace_leaf(const ndnboost::filesystem::path& p,
+ file_status st, file_status symlink_st)
+ { replace_filename(p, st, symlink_st); }
+# endif
+
+ const ndnboost::filesystem::path& path() const {return m_path;}
+ file_status status() const {return m_get_status();}
+ file_status status(system::error_code& ec) const {return m_get_status(&ec);}
+ file_status symlink_status() const {return m_get_symlink_status();}
+ file_status symlink_status(system::error_code& ec) const {return m_get_symlink_status(&ec);}
+
+ bool operator==(const directory_entry& rhs) {return m_path == rhs.m_path;}
+ bool operator!=(const directory_entry& rhs) {return m_path != rhs.m_path;}
+ bool operator< (const directory_entry& rhs) {return m_path < rhs.m_path;}
+ bool operator<=(const directory_entry& rhs) {return m_path <= rhs.m_path;}
+ bool operator> (const directory_entry& rhs) {return m_path > rhs.m_path;}
+ bool operator>=(const directory_entry& rhs) {return m_path >= rhs.m_path;}
+
+private:
+ ndnboost::filesystem::path m_path;
+ mutable file_status m_status; // stat()-like
+ mutable file_status m_symlink_status; // lstat()-like
+
+ file_status m_get_status(system::error_code* ec=0) const;
+ file_status m_get_symlink_status(system::error_code* ec=0) const;
+}; // directory_entry
+
+//--------------------------------------------------------------------------------------//
+// //
+// directory_iterator helpers //
+// //
+//--------------------------------------------------------------------------------------//
+
+class directory_iterator;
+
+namespace detail
+{
+ NDNBOOST_FILESYSTEM_DECL
+ system::error_code dir_itr_close(// never throws()
+ void *& handle
+# if defined(NDNBOOST_POSIX_API)
+ , void *& buffer
+# endif
+ );
+
+ struct dir_itr_imp
+ {
+ directory_entry dir_entry;
+ void* handle;
+
+# ifdef NDNBOOST_POSIX_API
+ void* buffer; // see dir_itr_increment implementation
+# endif
+
+ dir_itr_imp() : handle(0)
+# ifdef NDNBOOST_POSIX_API
+ , buffer(0)
+# endif
+ {}
+
+ ~dir_itr_imp() // never throws
+ {
+ dir_itr_close(handle
+# if defined(NDNBOOST_POSIX_API)
+ , buffer
+# endif
+ );
+ }
+ };
+
+ // see path::iterator: comment below
+ NDNBOOST_FILESYSTEM_DECL void directory_iterator_construct(directory_iterator& it,
+ const path& p, system::error_code* ec);
+ NDNBOOST_FILESYSTEM_DECL void directory_iterator_increment(directory_iterator& it,
+ system::error_code* ec);
+
+} // namespace detail
+
+//--------------------------------------------------------------------------------------//
+// //
+// directory_iterator //
+// //
+//--------------------------------------------------------------------------------------//
+
+ class directory_iterator
+ : public ndnboost::iterator_facade< directory_iterator,
+ directory_entry,
+ ndnboost::single_pass_traversal_tag >
+ {
+ public:
+
+ directory_iterator(){} // creates the "end" iterator
+
+ // iterator_facade derived classes don't seem to like implementations in
+ // separate translation unit dll's, so forward to detail functions
+ explicit directory_iterator(const path& p)
+ : m_imp(new detail::dir_itr_imp)
+ { detail::directory_iterator_construct(*this, p, 0); }
+
+ directory_iterator(const path& p, system::error_code& ec)
+ : m_imp(new detail::dir_itr_imp)
+ { detail::directory_iterator_construct(*this, p, &ec); }
+
+ ~directory_iterator() {} // never throws
+
+ directory_iterator& increment(system::error_code& ec)
+ {
+ detail::directory_iterator_increment(*this, &ec);
+ return *this;
+ }
+
+ private:
+ friend struct detail::dir_itr_imp;
+ friend NDNBOOST_FILESYSTEM_DECL void detail::directory_iterator_construct(directory_iterator& it,
+ const path& p, system::error_code* ec);
+ friend NDNBOOST_FILESYSTEM_DECL void detail::directory_iterator_increment(directory_iterator& it,
+ system::error_code* ec);
+
+ // shared_ptr provides shallow-copy semantics required for InputIterators.
+ // m_imp.get()==0 indicates the end iterator.
+ ndnboost::shared_ptr< detail::dir_itr_imp > m_imp;
+
+ friend class ndnboost::iterator_core_access;
+
+ ndnboost::iterator_facade<
+ directory_iterator,
+ directory_entry,
+ ndnboost::single_pass_traversal_tag >::reference dereference() const
+ {
+ NDNBOOST_ASSERT_MSG(m_imp.get(), "attempt to dereference end iterator");
+ return m_imp->dir_entry;
+ }
+
+ void increment() { detail::directory_iterator_increment(*this, 0); }
+
+ bool equal(const directory_iterator& rhs) const
+ { return m_imp == rhs.m_imp; }
+ };
+
+//--------------------------------------------------------------------------------------//
+// //
+// recursive_directory_iterator helpers //
+// //
+//--------------------------------------------------------------------------------------//
+
+ NDNBOOST_SCOPED_ENUM_START(symlink_option)
+ {
+ none,
+ no_recurse = none, // don't follow directory symlinks (default behavior)
+ recurse, // follow directory symlinks
+ _detail_no_push = recurse << 1 // internal use only
+ };
+ NDNBOOST_SCOPED_ENUM_END
+
+ NDNBOOST_BITMASK(NDNBOOST_SCOPED_ENUM(symlink_option))
+
+ namespace detail
+ {
+ struct recur_dir_itr_imp
+ {
+ typedef directory_iterator element_type;
+ std::stack< element_type, std::vector< element_type > > m_stack;
+ int m_level;
+ NDNBOOST_SCOPED_ENUM(symlink_option) m_options;
+
+ recur_dir_itr_imp() : m_level(0), m_options(symlink_option::none) {}
+
+ void increment(system::error_code* ec); // ec == 0 means throw on error
+
+ void pop();
+
+ };
+
+ // Implementation is inline to avoid dynamic linking difficulties with m_stack:
+ // Microsoft warning C4251, m_stack needs to have dll-interface to be used by
+ // clients of struct 'ndnboost::filesystem::detail::recur_dir_itr_imp'
+
+ inline
+ void recur_dir_itr_imp::increment(system::error_code* ec)
+ // ec == 0 means throw on error
+ {
+ if ((m_options & symlink_option::_detail_no_push) == symlink_option::_detail_no_push)
+ m_options &= ~symlink_option::_detail_no_push;
+
+ else
+ {
+ // Logic for following predicate was contributed by Daniel Aarno to handle cyclic
+ // symlinks correctly and efficiently, fixing ticket #5652.
+ // if (((m_options & symlink_option::recurse) == symlink_option::recurse
+ // || !is_symlink(m_stack.top()->symlink_status()))
+ // && is_directory(m_stack.top()->status())) ...
+ // The predicate code has since been rewritten to pass error_code arguments,
+ // per ticket #5653.
+ bool or_pred = (m_options & symlink_option::recurse) == symlink_option::recurse
+ || (ec == 0 ? !is_symlink(m_stack.top()->symlink_status())
+ : !is_symlink(m_stack.top()->symlink_status(*ec)));
+ if (ec != 0 && *ec)
+ return;
+ bool and_pred = or_pred && (ec == 0 ? is_directory(m_stack.top()->status())
+ : is_directory(m_stack.top()->status(*ec)));
+ if (ec != 0 && *ec)
+ return;
+
+ if (and_pred)
+ {
+ if (ec == 0)
+ m_stack.push(directory_iterator(m_stack.top()->path()));
+ else
+ {
+ m_stack.push(directory_iterator(m_stack.top()->path(), *ec));
+ if (*ec)
+ return;
+ }
+ if (m_stack.top() != directory_iterator())
+ {
+ ++m_level;
+ return;
+ }
+ m_stack.pop();
+ }
+ }
+
+ while (!m_stack.empty() && ++m_stack.top() == directory_iterator())
+ {
+ m_stack.pop();
+ --m_level;
+ }
+ }
+
+ inline
+ void recur_dir_itr_imp::pop()
+ {
+ NDNBOOST_ASSERT_MSG(m_level > 0,
+ "pop() on recursive_directory_iterator with level < 1");
+
+ do
+ {
+ m_stack.pop();
+ --m_level;
+ }
+ while (!m_stack.empty() && ++m_stack.top() == directory_iterator());
+ }
+ } // namespace detail
+
+//--------------------------------------------------------------------------------------//
+// //
+// recursive_directory_iterator //
+// //
+//--------------------------------------------------------------------------------------//
+
+ class recursive_directory_iterator
+ : public ndnboost::iterator_facade<
+ recursive_directory_iterator,
+ directory_entry,
+ ndnboost::single_pass_traversal_tag >
+ {
+ public:
+
+ recursive_directory_iterator(){} // creates the "end" iterator
+
+ explicit recursive_directory_iterator(const path& dir_path,
+ NDNBOOST_SCOPED_ENUM(symlink_option) opt = symlink_option::none)
+ : m_imp(new detail::recur_dir_itr_imp)
+ {
+ m_imp->m_options = opt;
+ m_imp->m_stack.push(directory_iterator(dir_path));
+ if (m_imp->m_stack.top() == directory_iterator())
+ { m_imp.reset (); }
+ }
+
+ recursive_directory_iterator(const path& dir_path,
+ NDNBOOST_SCOPED_ENUM(symlink_option) opt,
+ system::error_code & ec)
+ : m_imp(new detail::recur_dir_itr_imp)
+ {
+ m_imp->m_options = opt;
+ m_imp->m_stack.push(directory_iterator(dir_path, ec));
+ if (m_imp->m_stack.top() == directory_iterator())
+ { m_imp.reset (); }
+ }
+
+ recursive_directory_iterator(const path& dir_path,
+ system::error_code & ec)
+ : m_imp(new detail::recur_dir_itr_imp)
+ {
+ m_imp->m_options = symlink_option::none;
+ m_imp->m_stack.push(directory_iterator(dir_path, ec));
+ if (m_imp->m_stack.top() == directory_iterator())
+ { m_imp.reset (); }
+ }
+
+ recursive_directory_iterator& increment(system::error_code& ec)
+ {
+ NDNBOOST_ASSERT_MSG(m_imp.get(),
+ "increment() on end recursive_directory_iterator");
+ m_imp->increment(&ec);
+ if (m_imp->m_stack.empty())
+ m_imp.reset(); // done, so make end iterator
+ return *this;
+ }
+
+ int level() const
+ {
+ NDNBOOST_ASSERT_MSG(m_imp.get(),
+ "level() on end recursive_directory_iterator");
+ return m_imp->m_level;
+ }
+
+ bool no_push_pending() const
+ {
+ NDNBOOST_ASSERT_MSG(m_imp.get(),
+ "is_no_push_requested() on end recursive_directory_iterator");
+ return (m_imp->m_options & symlink_option::_detail_no_push)
+ == symlink_option::_detail_no_push;
+ }
+
+# ifndef NDNBOOST_FILESYSTEM_NO_DEPRECATED
+ bool no_push_request() const { return no_push_pending(); }
+# endif
+
+ void pop()
+ {
+ NDNBOOST_ASSERT_MSG(m_imp.get(),
+ "pop() on end recursive_directory_iterator");
+ m_imp->pop();
+ if (m_imp->m_stack.empty()) m_imp.reset(); // done, so make end iterator
+ }
+
+ void no_push(bool value=true)
+ {
+ NDNBOOST_ASSERT_MSG(m_imp.get(),
+ "no_push() on end recursive_directory_iterator");
+ if (value)
+ m_imp->m_options |= symlink_option::_detail_no_push;
+ else
+ m_imp->m_options &= ~symlink_option::_detail_no_push;
+ }
+
+ file_status status() const
+ {
+ NDNBOOST_ASSERT_MSG(m_imp.get(),
+ "status() on end recursive_directory_iterator");
+ return m_imp->m_stack.top()->status();
+ }
+
+ file_status symlink_status() const
+ {
+ NDNBOOST_ASSERT_MSG(m_imp.get(),
+ "symlink_status() on end recursive_directory_iterator");
+ return m_imp->m_stack.top()->symlink_status();
+ }
+
+ private:
+
+ // shared_ptr provides shallow-copy semantics required for InputIterators.
+ // m_imp.get()==0 indicates the end iterator.
+ ndnboost::shared_ptr< detail::recur_dir_itr_imp > m_imp;
+
+ friend class ndnboost::iterator_core_access;
+
+ ndnboost::iterator_facade<
+ recursive_directory_iterator,
+ directory_entry,
+ ndnboost::single_pass_traversal_tag >::reference
+ dereference() const
+ {
+ NDNBOOST_ASSERT_MSG(m_imp.get(),
+ "dereference of end recursive_directory_iterator");
+ return *m_imp->m_stack.top();
+ }
+
+ void increment()
+ {
+ NDNBOOST_ASSERT_MSG(m_imp.get(),
+ "increment of end recursive_directory_iterator");
+ m_imp->increment(0);
+ if (m_imp->m_stack.empty())
+ m_imp.reset(); // done, so make end iterator
+ }
+
+ bool equal(const recursive_directory_iterator& rhs) const
+ { return m_imp == rhs.m_imp; }
+
+ };
+
+# if !defined(NDNBOOST_FILESYSTEM_NO_DEPRECATED)
+ typedef recursive_directory_iterator wrecursive_directory_iterator;
+# endif
+
+//--------------------------------------------------------------------------------------//
+// //
+// class filesystem_error //
+// //
+//--------------------------------------------------------------------------------------//
+
+ class NDNBOOST_SYMBOL_VISIBLE filesystem_error : public system::system_error
+ {
+ // see http://www.boost.org/more/error_handling.html for design rationale
+
+ // all functions are inline to avoid issues with crossing dll boundaries
+
+ public:
+ // compiler generates copy constructor and copy assignment
+
+ filesystem_error(
+ const std::string & what_arg, system::error_code ec)
+ : system::system_error(ec, what_arg)
+ {
+ try
+ {
+ m_imp_ptr.reset(new m_imp);
+ }
+ catch (...) { m_imp_ptr.reset(); }
+ }
+
+ filesystem_error(
+ const std::string & what_arg, const path& path1_arg,
+ system::error_code ec)
+ : system::system_error(ec, what_arg)
+ {
+ try
+ {
+ m_imp_ptr.reset(new m_imp);
+ m_imp_ptr->m_path1 = path1_arg;
+ }
+ catch (...) { m_imp_ptr.reset(); }
+ }
+
+ filesystem_error(
+ const std::string & what_arg, const path& path1_arg,
+ const path& path2_arg, system::error_code ec)
+ : system::system_error(ec, what_arg)
+ {
+ try
+ {
+ m_imp_ptr.reset(new m_imp);
+ m_imp_ptr->m_path1 = path1_arg;
+ m_imp_ptr->m_path2 = path2_arg;
+ }
+ catch (...) { m_imp_ptr.reset(); }
+ }
+
+ ~filesystem_error() throw() {}
+
+ const path& path1() const
+ {
+ static const path empty_path;
+ return m_imp_ptr.get() ? m_imp_ptr->m_path1 : empty_path ;
+ }
+ const path& path2() const
+ {
+ static const path empty_path;
+ return m_imp_ptr.get() ? m_imp_ptr->m_path2 : empty_path ;
+ }
+
+ const char* what() const throw()
+ {
+ if (!m_imp_ptr.get())
+ return system::system_error::what();
+
+ try
+ {
+ if (m_imp_ptr->m_what.empty())
+ {
+ m_imp_ptr->m_what = system::system_error::what();
+ if (!m_imp_ptr->m_path1.empty())
+ {
+ m_imp_ptr->m_what += ": \"";
+ m_imp_ptr->m_what += m_imp_ptr->m_path1.string();
+ m_imp_ptr->m_what += "\"";
+ }
+ if (!m_imp_ptr->m_path2.empty())
+ {
+ m_imp_ptr->m_what += ", \"";
+ m_imp_ptr->m_what += m_imp_ptr->m_path2.string();
+ m_imp_ptr->m_what += "\"";
+ }
+ }
+ return m_imp_ptr->m_what.c_str();
+ }
+ catch (...)
+ {
+ return system::system_error::what();
+ }
+ }
+
+ private:
+ struct m_imp
+ {
+ path m_path1; // may be empty()
+ path m_path2; // may be empty()
+ std::string m_what; // not built until needed
+ };
+ ndnboost::shared_ptr<m_imp> m_imp_ptr;
+ };
+
+// test helper -----------------------------------------------------------------------//
+
+// Not part of the documented interface since false positives are possible;
+// there is no law that says that an OS that has large stat.st_size
+// actually supports large file sizes.
+
+ namespace detail
+ {
+ NDNBOOST_FILESYSTEM_DECL bool possible_large_file_size_support();
+ }
+
+ } // namespace filesystem
+} // namespace ndnboost
+
+#include <ndnboost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
+#endif // NDNBOOST_FILESYSTEM3_OPERATIONS_HPP
diff --git a/include/ndnboost/filesystem/path.hpp b/include/ndnboost/filesystem/path.hpp
new file mode 100644
index 0000000..8dee66f
--- /dev/null
+++ b/include/ndnboost/filesystem/path.hpp
@@ -0,0 +1,758 @@
+// filesystem path.hpp ---------------------------------------------------------------//
+
+// Copyright Beman Dawes 2002-2005, 2009
+// Copyright Vladimir Prus 2002
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
+
+// path::stem(), extension(), and replace_extension() are based on
+// basename(), extension(), and change_extension() from the original
+// filesystem/convenience.hpp header by Vladimir Prus.
+
+#ifndef NDNBOOST_FILESYSTEM_PATH_HPP
+#define NDNBOOST_FILESYSTEM_PATH_HPP
+
+#include <ndnboost/config.hpp>
+
+# if defined( NDNBOOST_NO_STD_WSTRING )
+# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
+# endif
+
+#include <ndnboost/filesystem/config.hpp>
+#include <ndnboost/filesystem/path_traits.hpp> // includes <cwchar>
+#include <ndnboost/system/error_code.hpp>
+#include <ndnboost/system/system_error.hpp>
+#include <ndnboost/iterator/iterator_facade.hpp>
+#include <ndnboost/shared_ptr.hpp>
+#include <ndnboost/io/detail/quoted_manip.hpp>
+#include <ndnboost/static_assert.hpp>
+#include <ndnboost/functional/hash_fwd.hpp>
+#include <ndnboost/type_traits/is_integral.hpp>
+#include <string>
+#include <iterator>
+#include <cstring>
+#include <iosfwd>
+#include <stdexcept>
+#include <cassert>
+#include <locale>
+#include <algorithm>
+
+#include <ndnboost/config/abi_prefix.hpp> // must be the last #include
+
+namespace ndnboost
+{
+namespace filesystem
+{
+ //------------------------------------------------------------------------------------//
+ // //
+ // class path //
+ // //
+ //------------------------------------------------------------------------------------//
+
+ class NDNBOOST_FILESYSTEM_DECL path
+ {
+ public:
+
+ // value_type is the character type used by the operating system API to
+ // represent paths.
+
+# ifdef NDNBOOST_WINDOWS_API
+ typedef wchar_t value_type;
+ NDNBOOST_STATIC_CONSTEXPR value_type preferred_separator = L'\\';
+# else
+ typedef char value_type;
+ NDNBOOST_STATIC_CONSTEXPR value_type preferred_separator = '/';
+# endif
+ typedef std::basic_string<value_type> string_type;
+ typedef std::codecvt<wchar_t, char,
+ std::mbstate_t> codecvt_type;
+
+
+ // ----- character encoding conversions -----
+
+ // Following the principle of least astonishment, path input arguments
+ // passed to or obtained from the operating system via objects of
+ // class path behave as if they were directly passed to or
+ // obtained from the O/S API, unless conversion is explicitly requested.
+ //
+ // POSIX specfies that path strings are passed unchanged to and from the
+ // API. Note that this is different from the POSIX command line utilities,
+ // which convert according to a locale.
+ //
+ // Thus for POSIX, char strings do not undergo conversion. wchar_t strings
+ // are converted to/from char using the path locale or, if a conversion
+ // argument is given, using a conversion object modeled on
+ // std::wstring_convert.
+ //
+ // The path locale, which is global to the thread, can be changed by the
+ // imbue() function. It is initialized to an implementation defined locale.
+ //
+ // For Windows, wchar_t strings do not undergo conversion. char strings
+ // are converted using the "ANSI" or "OEM" code pages, as determined by
+ // the AreFileApisANSI() function, or, if a conversion argument is given,
+ // using a conversion object modeled on std::wstring_convert.
+ //
+ // See m_pathname comments for further important rationale.
+
+ // TODO: rules needed for operating systems that use / or .
+ // differently, or format directory paths differently from file paths.
+ //
+ // **********************************************************************************
+ //
+ // More work needed: How to handle an operating system that may have
+ // slash characters or dot characters in valid filenames, either because
+ // it doesn't follow the POSIX standard, or because it allows MBCS
+ // filename encodings that may contain slash or dot characters. For
+ // example, ISO/IEC 2022 (JIS) encoding which allows switching to
+ // JIS x0208-1983 encoding. A valid filename in this set of encodings is
+ // 0x1B 0x24 0x42 [switch to X0208-1983] 0x24 0x2F [U+304F Kiragana letter KU]
+ // ^^^^
+ // Note that 0x2F is the ASCII slash character
+ //
+ // **********************************************************************************
+
+ // Supported source arguments: half-open iterator range, container, c-array,
+ // and single pointer to null terminated string.
+
+ // All source arguments except pointers to null terminated byte strings support
+ // multi-byte character strings which may have embedded nulls. Embedded null
+ // support is required for some Asian languages on Windows.
+
+ // [defaults] "const codecvt_type& cvt=codecvt()" default arguments are not used
+ // because some compilers, such as Microsoft prior to VC++ 10, do not handle defaults
+ // correctly in templates.
+
+ // ----- constructors -----
+
+ path(){}
+
+ path(const path& p) : m_pathname(p.m_pathname) {}
+
+ template <class Source>
+ path(Source const& source,
+ typename ndnboost::enable_if<path_traits::is_pathable<
+ typename ndnboost::decay<Source>::type> >::type* =0)
+ {
+ path_traits::dispatch(source, m_pathname, codecvt());
+ }
+
+ // Overloads for the operating system API's native character type. Rationale:
+ // - Avoids use of codecvt() for native value_type strings. This limits the
+ // impact of locale("") initialization failures on POSIX systems to programs
+ // that actually depend on locale(""). It further ensures that exceptions thrown
+ // as a result of such failues occur after main() has started, so can be caught.
+ // This is a partial resolution of tickets 4688, 5100, and 5289.
+ // - A slight optimization for a common use case, particularly on POSIX since
+ // value_type is char and that is the most common useage.
+ path(const value_type* s) : m_pathname(s) {}
+ path(const std::basic_string<value_type>& s) : m_pathname(s) {}
+
+ template <class Source>
+ path(Source const& source, const codecvt_type& cvt)
+ // see [defaults] note above explaining why codecvt() default arguments are not used
+ {
+ path_traits::dispatch(source, m_pathname, cvt);
+ }
+
+ template <class InputIterator>
+ path(InputIterator begin, InputIterator end)
+ {
+ if (begin != end)
+ {
+ std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
+ s(begin, end);
+ path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, codecvt());
+ }
+ }
+
+ template <class InputIterator>
+ path(InputIterator begin, InputIterator end, const codecvt_type& cvt)
+ {
+ if (begin != end)
+ {
+ std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
+ s(begin, end);
+ path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
+ }
+ }
+
+ // ----- assignments -----
+
+ path& operator=(const path& p)
+ {
+ m_pathname = p.m_pathname;
+ return *this;
+ }
+
+ path& operator=(const value_type* ptr) // required in case ptr overlaps *this
+ {
+ m_pathname = ptr;
+ return *this;
+ }
+
+ template <class Source>
+ typename ndnboost::enable_if<path_traits::is_pathable<
+ typename ndnboost::decay<Source>::type>, path&>::type
+ operator=(Source const& source)
+ {
+ m_pathname.clear();
+ path_traits::dispatch(source, m_pathname, codecvt());
+ return *this;
+ }
+
+ path& assign(const value_type* ptr, const codecvt_type&) // required in case ptr overlaps *this
+ {
+ m_pathname = ptr;
+ return *this;
+ }
+
+ template <class Source>
+ path& assign(Source const& source, const codecvt_type& cvt)
+ {
+ m_pathname.clear();
+ path_traits::dispatch(source, m_pathname, cvt);
+ return *this;
+ }
+
+ template <class InputIterator>
+ path& assign(InputIterator begin, InputIterator end)
+ {
+ return assign(begin, end, codecvt());
+ }
+
+ template <class InputIterator>
+ path& assign(InputIterator begin, InputIterator end, const codecvt_type& cvt)
+ {
+ m_pathname.clear();
+ if (begin != end)
+ {
+ std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
+ s(begin, end);
+ path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
+ }
+ return *this;
+ }
+
+ // ----- concatenation -----
+
+ path& operator+=(const path& p) {m_pathname += p.m_pathname; return *this;}
+ path& operator+=(const string_type& s) {m_pathname += s; return *this;}
+ path& operator+=(const value_type* ptr) {m_pathname += ptr; return *this;}
+ path& operator+=(value_type c) {m_pathname += c; return *this;}
+
+ template <class Source>
+ typename ndnboost::enable_if<path_traits::is_pathable<
+ typename ndnboost::decay<Source>::type>, path&>::type
+ operator+=(Source const& source)
+ {
+ return concat(source, codecvt());
+ }
+
+ template <class CharT>
+ typename ndnboost::enable_if<is_integral<CharT>, path&>::type
+ operator+=(CharT c)
+ {
+ CharT tmp[2];
+ tmp[0] = c;
+ tmp[1] = 0;
+ return concat(tmp, codecvt());
+ }
+
+ template <class Source>
+ path& concat(Source const& source, const codecvt_type& cvt)
+ {
+ path_traits::dispatch(source, m_pathname, cvt);
+ return *this;
+ }
+
+ template <class InputIterator>
+ path& concat(InputIterator begin, InputIterator end)
+ {
+ return concat(begin, end, codecvt());
+ }
+
+ template <class InputIterator>
+ path& concat(InputIterator begin, InputIterator end, const codecvt_type& cvt)
+ {
+ if (begin == end)
+ return *this;
+ std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
+ s(begin, end);
+ path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
+ return *this;
+ }
+
+ // ----- appends -----
+
+ // if a separator is added, it is the preferred separator for the platform;
+ // slash for POSIX, backslash for Windows
+
+ path& operator/=(const path& p);
+
+ path& operator/=(const value_type* ptr);
+
+ template <class Source>
+ typename ndnboost::enable_if<path_traits::is_pathable<
+ typename ndnboost::decay<Source>::type>, path&>::type
+ operator/=(Source const& source)
+ {
+ return append(source, codecvt());
+ }
+
+ path& append(const value_type* ptr, const codecvt_type&) // required in case ptr overlaps *this
+ {
+ this->operator/=(ptr);
+ return *this;
+ }
+
+ template <class Source>
+ path& append(Source const& source, const codecvt_type& cvt);
+
+ template <class InputIterator>
+ path& append(InputIterator begin, InputIterator end)
+ {
+ return append(begin, end, codecvt());
+ }
+
+ template <class InputIterator>
+ path& append(InputIterator begin, InputIterator end, const codecvt_type& cvt);
+
+ // ----- modifiers -----
+
+ void clear() { m_pathname.clear(); }
+ path& make_preferred()
+# ifdef NDNBOOST_POSIX_API
+ { return *this; } // POSIX no effect
+# else // NDNBOOST_WINDOWS_API
+ ; // change slashes to backslashes
+# endif
+ path& remove_filename();
+ path& replace_extension(const path& new_extension = path());
+ void swap(path& rhs) { m_pathname.swap(rhs.m_pathname); }
+
+ // ----- observers -----
+
+ // For operating systems that format file paths differently than directory
+ // paths, return values from observers are formatted as file names unless there
+ // is a trailing separator, in which case returns are formatted as directory
+ // paths. POSIX and Windows make no such distinction.
+
+ // Implementations are permitted to return const values or const references.
+
+ // The string or path returned by an observer are specified as being formatted
+ // as "native" or "generic".
+ //
+ // For POSIX, these are all the same format; slashes and backslashes are as input and
+ // are not modified.
+ //
+ // For Windows, native: as input; slashes and backslashes are not modified;
+ // this is the format of the internally stored string.
+ // generic: backslashes are converted to slashes
+
+ // ----- native format observers -----
+
+ const string_type& native() const { return m_pathname; } // Throws: nothing
+ const value_type* c_str() const { return m_pathname.c_str(); } // Throws: nothing
+
+ template <class String>
+ String string() const;
+
+ template <class String>
+ String string(const codecvt_type& cvt) const;
+
+# ifdef NDNBOOST_WINDOWS_API
+ const std::string string() const { return string(codecvt()); }
+ const std::string string(const codecvt_type& cvt) const
+ {
+ std::string tmp;
+ if (!m_pathname.empty())
+ path_traits::convert(&*m_pathname.begin(), &*m_pathname.begin()+m_pathname.size(),
+ tmp, cvt);
+ return tmp;
+ }
+
+ // string_type is std::wstring, so there is no conversion
+ const std::wstring& wstring() const { return m_pathname; }
+ const std::wstring& wstring(const codecvt_type&) const { return m_pathname; }
+
+# else // NDNBOOST_POSIX_API
+ // string_type is std::string, so there is no conversion
+ const std::string& string() const { return m_pathname; }
+ const std::string& string(const codecvt_type&) const { return m_pathname; }
+
+ const std::wstring wstring() const { return wstring(codecvt()); }
+ const std::wstring wstring(const codecvt_type& cvt) const
+ {
+ std::wstring tmp;
+ if (!m_pathname.empty())
+ path_traits::convert(&*m_pathname.begin(), &*m_pathname.begin()+m_pathname.size(),
+ tmp, cvt);
+ return tmp;
+ }
+
+# endif
+
+ // ----- generic format observers -----
+
+ template <class String>
+ String generic_string() const;
+
+ template <class String>
+ String generic_string(const codecvt_type& cvt) const;
+
+# ifdef NDNBOOST_WINDOWS_API
+ const std::string generic_string() const { return generic_string(codecvt()); }
+ const std::string generic_string(const codecvt_type& cvt) const;
+ const std::wstring generic_wstring() const;
+ const std::wstring generic_wstring(const codecvt_type&) const { return generic_wstring(); };
+
+# else // NDNBOOST_POSIX_API
+ // On POSIX-like systems, the generic format is the same as the native format
+ const std::string& generic_string() const { return m_pathname; }
+ const std::string& generic_string(const codecvt_type&) const { return m_pathname; }
+ const std::wstring generic_wstring() const { return wstring(codecvt()); }
+ const std::wstring generic_wstring(const codecvt_type& cvt) const { return wstring(cvt); }
+
+# endif
+
+ // ----- compare -----
+
+ int compare(const path& p) const NDNBOOST_NOEXCEPT; // generic, lexicographical
+ int compare(const std::string& s) const { return compare(path(s)); }
+ int compare(const value_type* s) const { return compare(path(s)); }
+
+ // ----- decomposition -----
+
+ path root_path() const;
+ path root_name() const; // returns 0 or 1 element path
+ // even on POSIX, root_name() is non-empty() for network paths
+ path root_directory() const; // returns 0 or 1 element path
+ path relative_path() const;
+ path parent_path() const;
+ path filename() const; // returns 0 or 1 element path
+ path stem() const; // returns 0 or 1 element path
+ path extension() const; // returns 0 or 1 element path
+
+ // ----- query -----
+
+ bool empty() const { return m_pathname.empty(); } // name consistent with std containers
+ bool has_root_path() const { return has_root_directory() || has_root_name(); }
+ bool has_root_name() const { return !root_name().empty(); }
+ bool has_root_directory() const { return !root_directory().empty(); }
+ bool has_relative_path() const { return !relative_path().empty(); }
+ bool has_parent_path() const { return !parent_path().empty(); }
+ bool has_filename() const { return !m_pathname.empty(); }
+ bool has_stem() const { return !stem().empty(); }
+ bool has_extension() const { return !extension().empty(); }
+ bool is_absolute() const
+ {
+# ifdef NDNBOOST_WINDOWS_API
+ return has_root_name() && has_root_directory();
+# else
+ return has_root_directory();
+# endif
+ }
+ bool is_relative() const { return !is_absolute(); }
+
+ // ----- iterators -----
+
+ class iterator;
+ typedef iterator const_iterator;
+
+ iterator begin() const;
+ iterator end() const;
+
+ // ----- static member functions -----
+
+ static std::locale imbue(const std::locale& loc);
+ static const codecvt_type& codecvt();
+
+ // ----- deprecated functions -----
+
+# if defined(NDNBOOST_FILESYSTEM_DEPRECATED) && defined(NDNBOOST_FILESYSTEM_NO_DEPRECATED)
+# error both NDNBOOST_FILESYSTEM_DEPRECATED and NDNBOOST_FILESYSTEM_NO_DEPRECATED are defined
+# endif
+
+# if !defined(NDNBOOST_FILESYSTEM_NO_DEPRECATED)
+ // recently deprecated functions supplied by default
+ path& normalize() { return m_normalize(); }
+ path& remove_leaf() { return remove_filename(); }
+ path leaf() const { return filename(); }
+ path branch_path() const { return parent_path(); }
+ bool has_leaf() const { return !m_pathname.empty(); }
+ bool has_branch_path() const { return !parent_path().empty(); }
+ bool is_complete() const { return is_absolute(); }
+# endif
+
+# if defined(NDNBOOST_FILESYSTEM_DEPRECATED)
+ // deprecated functions with enough signature or semantic changes that they are
+ // not supplied by default
+ const std::string file_string() const { return string(); }
+ const std::string directory_string() const { return string(); }
+ const std::string native_file_string() const { return string(); }
+ const std::string native_directory_string() const { return string(); }
+ const string_type external_file_string() const { return native(); }
+ const string_type external_directory_string() const { return native(); }
+
+ // older functions no longer supported
+ //typedef bool (*name_check)(const std::string & name);
+ //basic_path(const string_type& str, name_check) { operator/=(str); }
+ //basic_path(const typename string_type::value_type* s, name_check)
+ // { operator/=(s);}
+ //static bool default_name_check_writable() { return false; }
+ //static void default_name_check(name_check) {}
+ //static name_check default_name_check() { return 0; }
+ //basic_path& canonize();
+# endif
+
+//--------------------------------------------------------------------------------------//
+// class path private members //
+//--------------------------------------------------------------------------------------//
+
+ private:
+# if defined(_MSC_VER)
+# pragma warning(push) // Save warning settings
+# pragma warning(disable : 4251) // disable warning: class 'std::basic_string<_Elem,_Traits,_Ax>'
+# endif // needs to have dll-interface...
+/*
+ m_pathname has the type, encoding, and format required by the native
+ operating system. Thus for POSIX and Windows there is no conversion for
+ passing m_pathname.c_str() to the O/S API or when obtaining a path from the
+ O/S API. POSIX encoding is unspecified other than for dot and slash
+ characters; POSIX just treats paths as a sequence of bytes. Windows
+ encoding is UCS-2 or UTF-16 depending on the version.
+*/
+ string_type m_pathname; // Windows: as input; backslashes NOT converted to slashes,
+ // slashes NOT converted to backslashes
+# if defined(_MSC_VER)
+# pragma warning(pop) // restore warning settings.
+# endif
+
+ string_type::size_type m_append_separator_if_needed();
+ // Returns: If separator is to be appended, m_pathname.size() before append. Otherwise 0.
+ // Note: An append is never performed if size()==0, so a returned 0 is unambiguous.
+
+ void m_erase_redundant_separator(string_type::size_type sep_pos);
+ string_type::size_type m_parent_path_end() const;
+
+ path& m_normalize();
+
+ // Was qualified; como433beta8 reports:
+ // warning #427-D: qualified name is not allowed in member declaration
+ friend class iterator;
+ friend bool operator<(const path& lhs, const path& rhs);
+
+ // see path::iterator::increment/decrement comment below
+ static void m_path_iterator_increment(path::iterator & it);
+ static void m_path_iterator_decrement(path::iterator & it);
+
+ }; // class path
+
+ namespace detail
+ {
+ NDNBOOST_FILESYSTEM_DECL
+ int lex_compare(path::iterator first1, path::iterator last1,
+ path::iterator first2, path::iterator last2);
+ }
+
+# ifndef NDNBOOST_FILESYSTEM_NO_DEPRECATED
+ typedef path wpath;
+# endif
+
+ //------------------------------------------------------------------------------------//
+ // class path::iterator //
+ //------------------------------------------------------------------------------------//
+
+ class path::iterator
+ : public ndnboost::iterator_facade<
+ path::iterator,
+ path const,
+ ndnboost::bidirectional_traversal_tag >
+ {
+ private:
+ friend class ndnboost::iterator_core_access;
+ friend class ndnboost::filesystem::path;
+ friend void m_path_iterator_increment(path::iterator & it);
+ friend void m_path_iterator_decrement(path::iterator & it);
+
+ const path& dereference() const { return m_element; }
+
+ bool equal(const iterator & rhs) const
+ {
+ return m_path_ptr == rhs.m_path_ptr && m_pos == rhs.m_pos;
+ }
+
+ // iterator_facade derived classes don't seem to like implementations in
+ // separate translation unit dll's, so forward to class path static members
+ void increment() { m_path_iterator_increment(*this); }
+ void decrement() { m_path_iterator_decrement(*this); }
+
+ path m_element; // current element
+ const path* m_path_ptr; // path being iterated over
+ string_type::size_type m_pos; // position of m_element in
+ // m_path_ptr->m_pathname.
+ // if m_element is implicit dot, m_pos is the
+ // position of the last separator in the path.
+ // end() iterator is indicated by
+ // m_pos == m_path_ptr->m_pathname.size()
+ }; // path::iterator
+
+ //------------------------------------------------------------------------------------//
+ // //
+ // non-member functions //
+ // //
+ //------------------------------------------------------------------------------------//
+
+ // std::lexicographical_compare would infinately recurse because path iterators
+ // yield paths, so provide a path aware version
+ inline bool lexicographical_compare(path::iterator first1, path::iterator last1,
+ path::iterator first2, path::iterator last2)
+ { return detail::lex_compare(first1, last1, first2, last2) < 0; }
+
+ inline bool operator==(const path& lhs, const path& rhs) {return lhs.compare(rhs) == 0;}
+ inline bool operator==(const path& lhs, const path::string_type& rhs) {return lhs.compare(rhs) == 0;}
+ inline bool operator==(const path::string_type& lhs, const path& rhs) {return rhs.compare(lhs) == 0;}
+ inline bool operator==(const path& lhs, const path::value_type* rhs) {return lhs.compare(rhs) == 0;}
+ inline bool operator==(const path::value_type* lhs, const path& rhs) {return rhs.compare(lhs) == 0;}
+
+ inline bool operator!=(const path& lhs, const path& rhs) {return lhs.compare(rhs) != 0;}
+ inline bool operator!=(const path& lhs, const path::string_type& rhs) {return lhs.compare(rhs) != 0;}
+ inline bool operator!=(const path::string_type& lhs, const path& rhs) {return rhs.compare(lhs) != 0;}
+ inline bool operator!=(const path& lhs, const path::value_type* rhs) {return lhs.compare(rhs) != 0;}
+ inline bool operator!=(const path::value_type* lhs, const path& rhs) {return rhs.compare(lhs) != 0;}
+
+ // TODO: why do == and != have additional overloads, but the others don't?
+
+ inline bool operator<(const path& lhs, const path& rhs) {return lhs.compare(rhs) < 0;}
+ inline bool operator<=(const path& lhs, const path& rhs) {return !(rhs < lhs);}
+ inline bool operator> (const path& lhs, const path& rhs) {return rhs < lhs;}
+ inline bool operator>=(const path& lhs, const path& rhs) {return !(lhs < rhs);}
+
+ inline std::size_t hash_value(const path& x)
+ {
+# ifdef NDNBOOST_WINDOWS_API
+ std::size_t seed = 0;
+ for(const path::value_type* it = x.c_str(); *it; ++it)
+ hash_combine(seed, *it == '/' ? L'\\' : *it);
+ return seed;
+# else // NDNBOOST_POSIX_API
+ return hash_range(x.native().begin(), x.native().end());
+# endif
+ }
+
+ inline void swap(path& lhs, path& rhs) { lhs.swap(rhs); }
+
+ inline path operator/(const path& lhs, const path& rhs) { return path(lhs) /= rhs; }
+
+ // inserters and extractors
+ // use ndnboost::io::quoted() to handle spaces in paths
+ // use '&' as escape character to ease use for Windows paths
+
+ template <class Char, class Traits>
+ inline std::basic_ostream<Char, Traits>&
+ operator<<(std::basic_ostream<Char, Traits>& os, const path& p)
+ {
+ return os
+ << ndnboost::io::quoted(p.template string<std::basic_string<Char> >(), static_cast<Char>('&'));
+ }
+
+ template <class Char, class Traits>
+ inline std::basic_istream<Char, Traits>&
+ operator>>(std::basic_istream<Char, Traits>& is, path& p)
+ {
+ std::basic_string<Char> str;
+ is >> ndnboost::io::quoted(str, static_cast<Char>('&'));
+ p = str;
+ return is;
+ }
+
+ // name_checks
+
+ // These functions are holdovers from version 1. It isn't clear they have much
+ // usefulness, or how to generalize them for later versions.
+
+ NDNBOOST_FILESYSTEM_DECL bool portable_posix_name(const std::string & name);
+ NDNBOOST_FILESYSTEM_DECL bool windows_name(const std::string & name);
+ NDNBOOST_FILESYSTEM_DECL bool portable_name(const std::string & name);
+ NDNBOOST_FILESYSTEM_DECL bool portable_directory_name(const std::string & name);
+ NDNBOOST_FILESYSTEM_DECL bool portable_file_name(const std::string & name);
+ NDNBOOST_FILESYSTEM_DECL bool native(const std::string & name);
+
+//--------------------------------------------------------------------------------------//
+// class path member template implementation //
+//--------------------------------------------------------------------------------------//
+
+ template <class InputIterator>
+ path& path::append(InputIterator begin, InputIterator end, const codecvt_type& cvt)
+ {
+ if (begin == end)
+ return *this;
+ string_type::size_type sep_pos(m_append_separator_if_needed());
+ std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
+ s(begin, end);
+ path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
+ if (sep_pos)
+ m_erase_redundant_separator(sep_pos);
+ return *this;
+ }
+
+ template <class Source>
+ path& path::append(Source const& source, const codecvt_type& cvt)
+ {
+ if (path_traits::empty(source))
+ return *this;
+ string_type::size_type sep_pos(m_append_separator_if_needed());
+ path_traits::dispatch(source, m_pathname, cvt);
+ if (sep_pos)
+ m_erase_redundant_separator(sep_pos);
+ return *this;
+ }
+
+//--------------------------------------------------------------------------------------//
+// class path member template specializations //
+//--------------------------------------------------------------------------------------//
+
+ template <> inline
+ std::string path::string<std::string>() const
+ { return string(); }
+
+ template <> inline
+ std::wstring path::string<std::wstring>() const
+ { return wstring(); }
+
+ template <> inline
+ std::string path::string<std::string>(const codecvt_type& cvt) const
+ { return string(cvt); }
+
+ template <> inline
+ std::wstring path::string<std::wstring>(const codecvt_type& cvt) const
+ { return wstring(cvt); }
+
+ template <> inline
+ std::string path::generic_string<std::string>() const
+ { return generic_string(); }
+
+ template <> inline
+ std::wstring path::generic_string<std::wstring>() const
+ { return generic_wstring(); }
+
+ template <> inline
+ std::string path::generic_string<std::string>(const codecvt_type& cvt) const
+ { return generic_string(cvt); }
+
+ template <> inline
+ std::wstring path::generic_string<std::wstring>(const codecvt_type& cvt) const
+ { return generic_wstring(cvt); }
+
+
+} // namespace filesystem
+} // namespace ndnboost
+
+//----------------------------------------------------------------------------//
+
+#include <ndnboost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
+
+#endif // NDNBOOST_FILESYSTEM_PATH_HPP
diff --git a/include/ndnboost/filesystem/path_traits.hpp b/include/ndnboost/filesystem/path_traits.hpp
new file mode 100644
index 0000000..34e13a9
--- /dev/null
+++ b/include/ndnboost/filesystem/path_traits.hpp
@@ -0,0 +1,235 @@
+// filesystem path_traits.hpp --------------------------------------------------------//
+
+// Copyright Beman Dawes 2009
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
+
+#ifndef NDNBOOST_FILESYSTEM_PATH_TRAITS_HPP
+#define NDNBOOST_FILESYSTEM_PATH_TRAITS_HPP
+
+#include <ndnboost/config.hpp>
+
+# if defined( NDNBOOST_NO_STD_WSTRING )
+# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
+# endif
+
+#include <ndnboost/filesystem/config.hpp>
+#include <ndnboost/utility/enable_if.hpp>
+#include <ndnboost/type_traits/is_array.hpp>
+#include <ndnboost/type_traits/decay.hpp>
+#include <ndnboost/system/error_code.hpp>
+#include <cwchar> // for mbstate_t
+#include <string>
+#include <vector>
+#include <list>
+#include <iterator>
+#include <locale>
+#include <ndnboost/assert.hpp>
+// #include <iostream> //**** comment me out ****
+
+#include <ndnboost/config/abi_prefix.hpp> // must be the last #include
+
+namespace ndnboost { namespace filesystem {
+
+ NDNBOOST_FILESYSTEM_DECL const system::error_category& codecvt_error_category();
+ // uses std::codecvt_base::result used for error codes:
+ //
+ // ok: Conversion successful.
+ // partial: Not all source characters converted; one or more additional source
+ // characters are needed to produce the final target character, or the
+ // size of the target intermediate buffer was too small to hold the result.
+ // error: A character in the source could not be converted to the target encoding.
+ // noconv: The source and target characters have the same type and encoding, so no
+ // conversion was necessary.
+
+ class directory_entry;
+
+namespace path_traits {
+
+ typedef std::codecvt<wchar_t, char, std::mbstate_t> codecvt_type;
+
+ // is_pathable type trait; allows disabling over-agressive class path member templates
+
+ template <class T>
+ struct is_pathable { static const bool value = false; };
+
+ template<> struct is_pathable<char*> { static const bool value = true; };
+ template<> struct is_pathable<const char*> { static const bool value = true; };
+ template<> struct is_pathable<wchar_t*> { static const bool value = true; };
+ template<> struct is_pathable<const wchar_t*> { static const bool value = true; };
+ template<> struct is_pathable<std::string> { static const bool value = true; };
+ template<> struct is_pathable<std::wstring> { static const bool value = true; };
+ template<> struct is_pathable<std::vector<char> > { static const bool value = true; };
+ template<> struct is_pathable<std::vector<wchar_t> > { static const bool value = true; };
+ template<> struct is_pathable<std::list<char> > { static const bool value = true; };
+ template<> struct is_pathable<std::list<wchar_t> > { static const bool value = true; };
+ template<> struct is_pathable<directory_entry> { static const bool value = true; };
+
+ // Pathable empty
+
+ template <class Container> inline
+ // disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
+ // conforming compilers. Replace by plain "bool" at some future date (2012?)
+ typename ndnboost::disable_if<ndnboost::is_array<Container>, bool>::type
+ empty(const Container & c)
+ { return c.begin() == c.end(); }
+
+ template <class T> inline
+ bool empty(T * const & c_str)
+ {
+ NDNBOOST_ASSERT(c_str);
+ return !*c_str;
+ }
+
+ template <typename T, size_t N> inline
+ bool empty(T (&x)[N])
+ { return !x[0]; }
+
+ // value types differ ---------------------------------------------------------------//
+ //
+ // A from_end argument of 0 is less efficient than a known end, so use only if needed
+
+ NDNBOOST_FILESYSTEM_DECL
+ void convert(const char* from,
+ const char* from_end, // 0 for null terminated MBCS
+ std::wstring & to,
+ const codecvt_type& cvt);
+
+ NDNBOOST_FILESYSTEM_DECL
+ void convert(const wchar_t* from,
+ const wchar_t* from_end, // 0 for null terminated MBCS
+ std::string & to,
+ const codecvt_type& cvt);
+
+ inline
+ void convert(const char* from,
+ std::wstring & to,
+ const codecvt_type& cvt)
+ {
+ NDNBOOST_ASSERT(from);
+ convert(from, 0, to, cvt);
+ }
+
+ inline
+ void convert(const wchar_t* from,
+ std::string & to,
+ const codecvt_type& cvt)
+ {
+ NDNBOOST_ASSERT(from);
+ convert(from, 0, to, cvt);
+ }
+
+ // value types same -----------------------------------------------------------------//
+
+ // char
+
+ inline
+ void convert(const char* from, const char* from_end, std::string & to,
+ const codecvt_type&)
+ {
+ NDNBOOST_ASSERT(from);
+ NDNBOOST_ASSERT(from_end);
+ to.append(from, from_end);
+ }
+
+ inline
+ void convert(const char* from,
+ std::string & to,
+ const codecvt_type&)
+ {
+ NDNBOOST_ASSERT(from);
+ to += from;
+ }
+
+ // wchar_t
+
+ inline
+ void convert(const wchar_t* from, const wchar_t* from_end, std::wstring & to,
+ const codecvt_type&)
+ {
+ NDNBOOST_ASSERT(from);
+ NDNBOOST_ASSERT(from_end);
+ to.append(from, from_end);
+ }
+
+ inline
+ void convert(const wchar_t* from,
+ std::wstring & to,
+ const codecvt_type&)
+ {
+ NDNBOOST_ASSERT(from);
+ to += from;
+ }
+
+ // Source dispatch -----------------------------------------------------------------//
+
+ // contiguous containers
+ template <class U> inline
+ void dispatch(const std::string& c, U& to, const codecvt_type& cvt)
+ {
+ if (c.size())
+ convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
+ }
+ template <class U> inline
+ void dispatch(const std::wstring& c, U& to, const codecvt_type& cvt)
+ {
+ if (c.size())
+ convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
+ }
+ template <class U> inline
+ void dispatch(const std::vector<char>& c, U& to, const codecvt_type& cvt)
+ {
+ if (c.size())
+ convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
+ }
+ template <class U> inline
+ void dispatch(const std::vector<wchar_t>& c, U& to, const codecvt_type& cvt)
+ {
+ if (c.size())
+ convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
+ }
+
+ // non-contiguous containers
+ template <class Container, class U> inline
+ // disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
+ // conforming compilers. Replace by plain "void" at some future date (2012?)
+ typename ndnboost::disable_if<ndnboost::is_array<Container>, void>::type
+ dispatch(const Container & c, U& to, const codecvt_type& cvt)
+ {
+ if (c.size())
+ {
+ std::basic_string<typename Container::value_type> s(c.begin(), c.end());
+ convert(s.c_str(), s.c_str()+s.size(), to, cvt);
+ }
+ }
+
+ // c_str
+ template <class T, class U> inline
+ void dispatch(T * const & c_str, U& to, const codecvt_type& cvt)
+ {
+// std::cout << "dispatch() const T *\n";
+ NDNBOOST_ASSERT(c_str);
+ convert(c_str, to, cvt);
+ }
+
+ // Note: there is no dispatch on C-style arrays because the array may
+ // contain a string smaller than the array size.
+
+ NDNBOOST_FILESYSTEM_DECL
+ void dispatch(const directory_entry & de,
+# ifdef NDNBOOST_WINDOWS_API
+ std::wstring & to,
+# else
+ std::string & to,
+# endif
+ const codecvt_type&);
+
+
+}}} // namespace ndnboost::filesystem::path_traits
+
+#include <ndnboost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
+
+#endif // NDNBOOST_FILESYSTEM_PATH_TRAITS_HPP