1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-09-08 23:36:34 -05:00

Initial commit

This commit is contained in:
Crimson-Hawk
2024-03-05 16:42:40 +08:00
commit f1e4595ebf
39576 changed files with 7006612 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
// boost/filesystem.hpp --------------------------------------------------------------//
// Copyright Beman Dawes 2010
// 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 BOOST_FILESYSTEM_FILESYSTEM_HPP
#define BOOST_FILESYSTEM_FILESYSTEM_HPP
#include <boost/filesystem/config.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/directory.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/file_status.hpp>
#include <boost/filesystem/convenience.hpp>
#if defined(BOOST_FILESYSTEM_DEPRECATED)
#include <boost/filesystem/string_file.hpp>
#endif
#endif // BOOST_FILESYSTEM_FILESYSTEM_HPP

View File

@@ -0,0 +1,125 @@
// boost/filesystem/v3/config.hpp ----------------------------------------------------//
// Copyright Beman Dawes 2003
// Copyright Andrey Semashev 2021
// 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 BOOST_FILESYSTEM_CONFIG_HPP
#define BOOST_FILESYSTEM_CONFIG_HPP
// This header implements separate compilation features as described in
// http://www.boost.org/more/separate_compilation.html
#include <boost/config.hpp>
#include <boost/system/api_config.hpp> // for BOOST_POSIX_API or BOOST_WINDOWS_API
#include <boost/detail/workaround.hpp>
#if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION != 3 && BOOST_FILESYSTEM_VERSION != 4
#error Compiling Boost.Filesystem file with BOOST_FILESYSTEM_VERSION defined != 3 or 4
#endif
#if defined(BOOST_FILESYSTEM_SOURCE)
#undef BOOST_FILESYSTEM_VERSION
#define BOOST_FILESYSTEM_VERSION 4
#elif !defined(BOOST_FILESYSTEM_VERSION)
#define BOOST_FILESYSTEM_VERSION 3
#endif
#define BOOST_FILESYSTEM_VERSIONED_SYM(sym) BOOST_JOIN(sym, BOOST_JOIN(_v, BOOST_FILESYSTEM_VERSION))
#if BOOST_FILESYSTEM_VERSION == 4
#undef BOOST_FILESYSTEM_DEPRECATED
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
#define BOOST_FILESYSTEM_NO_DEPRECATED
#endif
#endif
#define BOOST_FILESYSTEM_I18N // aid users wishing to compile several versions
// BOOST_FILESYSTEM_DEPRECATED needed for source compiles -----------------------------//
#ifdef BOOST_FILESYSTEM_SOURCE
#define BOOST_FILESYSTEM_DEPRECATED
#undef BOOST_FILESYSTEM_NO_DEPRECATED // fixes #9454, src bld fails if NO_DEP defined
#endif
#if defined(BOOST_FILESYSTEM_DEPRECATED) && defined(BOOST_FILESYSTEM_NO_DEPRECATED)
#error Both BOOST_FILESYSTEM_DEPRECATED and BOOST_FILESYSTEM_NO_DEPRECATED are defined
#endif
// throw an exception ----------------------------------------------------------------//
//
// Exceptions were originally thrown via boost::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 BOOST_FILESYSTEM_THROW(EX) throw EX
#if defined(BOOST_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(BOOST_FILESYSTEM_DYN_LINK) && !defined(BOOST_FILESYSTEM_STATIC_LINK) && !defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_ALL_STATIC_LINK)
#define BOOST_FILESYSTEM_STATIC_LINK
#endif
#if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_FILESYSTEM_DYN_LINK)
#define BOOST_FILESYSTEM_DYN_LINK
#elif defined(BOOST_ALL_STATIC_LINK) && !defined(BOOST_FILESYSTEM_STATIC_LINK)
#define BOOST_FILESYSTEM_STATIC_LINK
#endif
#if defined(BOOST_FILESYSTEM_DYN_LINK) && defined(BOOST_FILESYSTEM_STATIC_LINK)
#error Must not define both BOOST_FILESYSTEM_DYN_LINK and BOOST_FILESYSTEM_STATIC_LINK
#endif
#if defined(BOOST_ALL_NO_LIB) && !defined(BOOST_FILESYSTEM_NO_LIB)
#define BOOST_FILESYSTEM_NO_LIB
#endif
// enable dynamic linking ------------------------------------------------------------//
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK)
#if defined(BOOST_FILESYSTEM_SOURCE)
#define BOOST_FILESYSTEM_DECL BOOST_SYMBOL_EXPORT
#else
#define BOOST_FILESYSTEM_DECL BOOST_SYMBOL_IMPORT
#endif
#else
#define BOOST_FILESYSTEM_DECL
#endif
// enable automatic library variant selection ----------------------------------------//
#if !defined(BOOST_FILESYSTEM_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_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 BOOST_LIB_NAME boost_filesystem
//
// If we're importing code from a dll, then tell auto_link.hpp about it:
//
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_FILESYSTEM_DYN_LINK)
#define BOOST_DYN_LINK
#endif
//
// And include the header that does the work:
//
#include <boost/config/auto_link.hpp>
#endif // auto-linking disabled
#endif // BOOST_FILESYSTEM_CONFIG_HPP

View File

@@ -0,0 +1,52 @@
// boost/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 BOOST_FILESYSTEM_CONVENIENCE_HPP
#define BOOST_FILESYSTEM_CONVENIENCE_HPP
#include <boost/filesystem/config.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/system/error_code.hpp>
#include <boost/filesystem/detail/header.hpp> // must be the last #include
namespace boost {
namespace filesystem {
#ifndef BOOST_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 boost
#include <boost/filesystem/detail/footer.hpp>
#endif // BOOST_FILESYSTEM_CONVENIENCE_HPP

View File

@@ -0,0 +1,23 @@
/*
* Copyright Andrey Semashev 2021.
* Distributed under 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)
*/
#if !defined(BOOST_FILESYSTEM_ENABLE_WARNINGS)
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#elif (defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) \
&& (__GNUC__ * 100 + __GNUC_MINOR__) >= 406) || defined(__clang__)
#pragma GCC diagnostic pop
#endif
#endif // !defined(BOOST_FILESYSTEM_ENABLE_WARNINGS)
#include <boost/config/abi_suffix.hpp>

View File

@@ -0,0 +1,43 @@
/*
* Copyright Andrey Semashev 2021.
* Distributed under 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)
*/
#include <boost/config/abi_prefix.hpp>
#if !defined(BOOST_FILESYSTEM_ENABLE_WARNINGS)
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push, 3)
// 'm_A' : class 'A' needs to have dll-interface to be used by clients of class 'B'
#pragma warning(disable: 4251)
// non dll-interface class 'A' used as base for dll-interface class 'B'
#pragma warning(disable: 4275)
// 'int' : forcing value to bool 'true' or 'false' (performance warning)
#pragma warning(disable: 4800)
// unreferenced formal parameter
#pragma warning(disable: 4100)
// conditional expression is constant
#pragma warning(disable: 4127)
// function marked as __forceinline not inlined
#pragma warning(disable: 4714)
// decorated name length exceeded, name was truncated
#pragma warning(disable: 4503)
// 'X': This function or variable may be unsafe. Consider using Y instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
#pragma warning(disable: 4996)
#elif (defined(__GNUC__) && !(defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)) \
&& (__GNUC__ * 100 + __GNUC_MINOR__) >= 406) || defined(__clang__)
// Note: clang-cl goes here as well, as it seems to support gcc-style warning control pragmas.
#pragma GCC diagnostic push
// unused parameter 'arg'
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
#endif // !defined(BOOST_FILESYSTEM_ENABLE_WARNINGS)

View File

@@ -0,0 +1,42 @@
// boost/filesystem/detail/macro_value.hpp -------------------------------------------//
// (C) Copyright John Maddock 2001 - 2003
// (C) Copyright Jens Maurer 2001
// (C) Copyright Peter Dimov 2001
// (C) Copyright Darin Adler 2001
// (C) Copyright Beman Dawes 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 BOOST_FILESYSTEM_MACRO_VALUE_HPP
#define BOOST_FILESYSTEM_MACRO_VALUE_HPP
#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <cstdlib>
namespace boost {
namespace detail {
inline const char* macro_value(const char* name, const char* value)
{
static const char* no_value = "[no value]";
static const char* not_defined = "[not defined]";
BOOST_ASSERT_MSG(name, "name argument must not be a null pointer");
BOOST_ASSERT_MSG(value, "value argument must not be a null pointer");
return strcmp(name, value + 1) ? ((*value && *(value + 1)) ? (value + 1) : no_value) : not_defined; // name == value+1 so the macro is not defined
}
} // namespace detail
} // namespace boost
#define BOOST_MACRO_VALUE(X) boost::detail::macro_value(#X, BOOST_STRINGIZE(=X))
#endif // BOOST_FILESYSTEM_MACRO_VALUE_HPP

View File

@@ -0,0 +1,29 @@
// 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 BOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP
#define BOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP
#include <boost/filesystem/config.hpp>
#define BOOST_UTF8_BEGIN_NAMESPACE \
namespace boost { \
namespace filesystem { \
namespace detail {
#define BOOST_UTF8_END_NAMESPACE \
} \
} \
}
#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL
#include <boost/detail/utf8_codecvt_facet.hpp>
#undef BOOST_UTF8_BEGIN_NAMESPACE
#undef BOOST_UTF8_END_NAMESPACE
#undef BOOST_UTF8_DECL
#endif

View File

@@ -0,0 +1,733 @@
// boost/filesystem/directory.hpp ---------------------------------------------------//
// Copyright Beman Dawes 2002-2009
// Copyright Jan Langer 2002
// Copyright Dietmar Kuehl 2001
// Copyright Vladimir Prus 2002
// Copyright Andrey Semashev 2019
// 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 BOOST_FILESYSTEM_DIRECTORY_HPP
#define BOOST_FILESYSTEM_DIRECTORY_HPP
#include <boost/filesystem/config.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/file_status.hpp>
#include <cstddef>
#include <string>
#include <vector>
#include <utility> // std::move
#include <boost/assert.hpp>
#include <boost/core/scoped_enum.hpp>
#include <boost/detail/bitmask.hpp>
#include <boost/system/error_code.hpp>
#include <boost/smart_ptr/intrusive_ptr.hpp>
#include <boost/smart_ptr/intrusive_ref_counter.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/filesystem/detail/header.hpp> // must be the last #include
//--------------------------------------------------------------------------------------//
namespace boost {
namespace filesystem {
//--------------------------------------------------------------------------------------//
// //
// 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 directory_entry
{
public:
typedef boost::filesystem::path::value_type value_type; // enables class path ctor taking directory_entry
directory_entry() BOOST_NOEXCEPT {}
explicit directory_entry(boost::filesystem::path const& p) :
m_path(p), m_status(file_status()), m_symlink_status(file_status())
{
}
directory_entry(boost::filesystem::path const& p, file_status st, file_status symlink_st = file_status()) :
m_path(p), m_status(st), m_symlink_status(symlink_st)
{
}
directory_entry(directory_entry const& rhs) :
m_path(rhs.m_path), m_status(rhs.m_status), m_symlink_status(rhs.m_symlink_status)
{
}
directory_entry& operator=(directory_entry const& rhs)
{
m_path = rhs.m_path;
m_status = rhs.m_status;
m_symlink_status = rhs.m_symlink_status;
return *this;
}
// As of October 2015 the interaction between noexcept and =default is so troublesome
// for VC++, GCC, and probably other compilers, that =default is not used with noexcept
// functions. GCC is not even consistent for the same release on different platforms.
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
directory_entry(directory_entry&& rhs) BOOST_NOEXCEPT :
m_path(std::move(rhs.m_path)),
m_status(std::move(rhs.m_status)),
m_symlink_status(std::move(rhs.m_symlink_status))
{
}
directory_entry& operator=(directory_entry&& rhs) BOOST_NOEXCEPT
{
m_path = std::move(rhs.m_path);
m_status = std::move(rhs.m_status);
m_symlink_status = std::move(rhs.m_symlink_status);
return *this;
}
#endif
void assign(boost::filesystem::path const& 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(boost::filesystem::path const& 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 BOOST_FILESYSTEM_NO_DEPRECATED
void replace_leaf(boost::filesystem::path const& p, file_status st, file_status symlink_st)
{
replace_filename(p, st, symlink_st);
}
#endif
boost::filesystem::path const& path() const BOOST_NOEXCEPT
{
return m_path;
}
operator boost::filesystem::path const&() const BOOST_NOEXCEPT { return m_path; }
file_status status() const { return get_status(); }
file_status status(system::error_code& ec) const BOOST_NOEXCEPT { return get_status(&ec); }
file_status symlink_status() const { return get_symlink_status(); }
file_status symlink_status(system::error_code& ec) const BOOST_NOEXCEPT { return get_symlink_status(&ec); }
bool operator==(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path == rhs.m_path; }
bool operator!=(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path != rhs.m_path; }
bool operator<(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path < rhs.m_path; }
bool operator<=(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path <= rhs.m_path; }
bool operator>(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path > rhs.m_path; }
bool operator>=(directory_entry const& rhs) const BOOST_NOEXCEPT { return m_path >= rhs.m_path; }
private:
BOOST_FILESYSTEM_DECL file_status get_status(system::error_code* ec = 0) const;
BOOST_FILESYSTEM_DECL file_status get_symlink_status(system::error_code* ec = 0) const;
private:
boost::filesystem::path m_path;
mutable file_status m_status; // stat()-like
mutable file_status m_symlink_status; // lstat()-like
}; // directory_entry
//--------------------------------------------------------------------------------------//
// //
// directory_entry overloads //
// //
//--------------------------------------------------------------------------------------//
// Without these functions, calling (for example) 'is_directory' with a 'directory_entry' results in:
// - a conversion to 'path' using 'operator boost::filesystem::path const&()',
// - then a call to 'is_directory(path const& p)' which recomputes the status with 'detail::status(p)'.
//
// These functions avoid a costly recomputation of the status if one calls 'is_directory(e)' instead of 'is_directory(e.status())'
inline file_status status(directory_entry const& e)
{
return e.status();
}
inline file_status status(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
{
return e.status(ec);
}
inline bool type_present(directory_entry const& e)
{
return filesystem::type_present(e.status());
}
inline bool type_present(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
{
return filesystem::type_present(e.status(ec));
}
inline bool status_known(directory_entry const& e)
{
return filesystem::status_known(e.status());
}
inline bool status_known(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
{
return filesystem::status_known(e.status(ec));
}
inline bool exists(directory_entry const& e)
{
return filesystem::exists(e.status());
}
inline bool exists(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
{
return filesystem::exists(e.status(ec));
}
inline bool is_regular_file(directory_entry const& e)
{
return filesystem::is_regular_file(e.status());
}
inline bool is_regular_file(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
{
return filesystem::is_regular_file(e.status(ec));
}
inline bool is_directory(directory_entry const& e)
{
return filesystem::is_directory(e.status());
}
inline bool is_directory(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
{
return filesystem::is_directory(e.status(ec));
}
inline bool is_symlink(directory_entry const& e)
{
return filesystem::is_symlink(e.symlink_status());
}
inline bool is_symlink(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
{
return filesystem::is_symlink(e.symlink_status(ec));
}
inline bool is_other(directory_entry const& e)
{
return filesystem::is_other(e.status());
}
inline bool is_other(directory_entry const& e, system::error_code& ec) BOOST_NOEXCEPT
{
return filesystem::is_other(e.status(ec));
}
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
inline bool is_regular(directory_entry const& e)
{
return filesystem::is_regular(e.status());
}
#endif
//--------------------------------------------------------------------------------------//
// //
// directory_iterator helpers //
// //
//--------------------------------------------------------------------------------------//
BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(directory_options, unsigned int)
{
none = 0u,
skip_permission_denied = 1u, // if a directory cannot be opened because of insufficient permissions, pretend that the directory is empty
follow_directory_symlink = 1u << 1, // recursive_directory_iterator: follow directory symlinks
skip_dangling_symlinks = 1u << 2, // non-standard extension for recursive_directory_iterator: don't follow dangling directory symlinks,
pop_on_error = 1u << 3, // non-standard extension for recursive_directory_iterator: instead of producing an end iterator on errors,
// repeatedly invoke pop() until it succeeds or the iterator becomes equal to end iterator
_detail_no_follow = 1u << 4, // internal use only
_detail_no_push = 1u << 5 // internal use only
}
BOOST_SCOPED_ENUM_DECLARE_END(directory_options)
BOOST_BITMASK(BOOST_SCOPED_ENUM_NATIVE(directory_options))
class directory_iterator;
namespace detail {
struct dir_itr_imp :
public boost::intrusive_ref_counter< dir_itr_imp >
{
#ifdef BOOST_WINDOWS_API
unsigned char extra_data_format;
std::size_t current_offset;
#endif
directory_entry dir_entry;
void* handle;
dir_itr_imp() BOOST_NOEXCEPT :
#ifdef BOOST_WINDOWS_API
extra_data_format(0u),
current_offset(0u),
#endif
handle(NULL)
{
}
BOOST_FILESYSTEM_DECL ~dir_itr_imp() BOOST_NOEXCEPT;
BOOST_FILESYSTEM_DECL static void* operator new(std::size_t class_size, std::size_t extra_size) BOOST_NOEXCEPT;
BOOST_FILESYSTEM_DECL static void operator delete(void* p, std::size_t extra_size) BOOST_NOEXCEPT;
BOOST_FILESYSTEM_DECL static void operator delete(void* p) BOOST_NOEXCEPT;
};
BOOST_FILESYSTEM_DECL void directory_iterator_construct(directory_iterator& it, path const& p, unsigned int opts, system::error_code* ec);
BOOST_FILESYSTEM_DECL void directory_iterator_increment(directory_iterator& it, system::error_code* ec);
} // namespace detail
//--------------------------------------------------------------------------------------//
// //
// directory_iterator //
// //
//--------------------------------------------------------------------------------------//
class directory_iterator :
public boost::iterator_facade<
directory_iterator,
directory_entry,
boost::single_pass_traversal_tag
>
{
friend class boost::iterator_core_access;
friend BOOST_FILESYSTEM_DECL void detail::directory_iterator_construct(directory_iterator& it, path const& p, unsigned int opts, system::error_code* ec);
friend BOOST_FILESYSTEM_DECL void detail::directory_iterator_increment(directory_iterator& it, system::error_code* ec);
public:
directory_iterator() BOOST_NOEXCEPT {} // 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(path const& p, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts = directory_options::none)
{
detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(opts), 0);
}
directory_iterator(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(directory_options::none), &ec);
}
directory_iterator(path const& p, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts, system::error_code& ec) BOOST_NOEXCEPT
{
detail::directory_iterator_construct(*this, p, static_cast< unsigned int >(opts), &ec);
}
BOOST_DEFAULTED_FUNCTION(directory_iterator(directory_iterator const& that), : m_imp(that.m_imp) {})
BOOST_DEFAULTED_FUNCTION(directory_iterator& operator=(directory_iterator const& that), { m_imp = that.m_imp; return *this; })
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
directory_iterator(directory_iterator&& that) BOOST_NOEXCEPT :
m_imp(std::move(that.m_imp))
{
}
directory_iterator& operator=(directory_iterator&& that) BOOST_NOEXCEPT
{
m_imp = std::move(that.m_imp);
return *this;
}
#endif // !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
directory_iterator& increment(system::error_code& ec) BOOST_NOEXCEPT
{
detail::directory_iterator_increment(*this, &ec);
return *this;
}
private:
boost::iterator_facade<
directory_iterator,
directory_entry,
boost::single_pass_traversal_tag
>::reference dereference() const
{
BOOST_ASSERT_MSG(!is_end(), "attempt to dereference end directory iterator");
return m_imp->dir_entry;
}
void increment() { detail::directory_iterator_increment(*this, 0); }
bool equal(directory_iterator const& rhs) const BOOST_NOEXCEPT
{
return m_imp == rhs.m_imp || (is_end() && rhs.is_end());
}
bool is_end() const BOOST_NOEXCEPT
{
// Note: The check for handle is needed because the iterator can be copied and the copy
// can be incremented to end while the original iterator still refers to the same dir_itr_imp.
return !m_imp || !m_imp->handle;
}
private:
// intrusive_ptr provides the shallow-copy semantics required for single pass iterators
// (i.e. InputIterators). The end iterator is indicated by is_end().
boost::intrusive_ptr< detail::dir_itr_imp > m_imp;
};
// enable directory_iterator C++11 range-based for statement use --------------------//
// begin() and end() are only used by a range-based for statement in the context of
// auto - thus the top-level const is stripped - so returning const is harmless and
// emphasizes begin() is just a pass through.
inline directory_iterator const& begin(directory_iterator const& iter) BOOST_NOEXCEPT
{
return iter;
}
inline directory_iterator end(directory_iterator const&) BOOST_NOEXCEPT
{
return directory_iterator();
}
// enable C++14 generic accessors for range const iterators
inline directory_iterator const& cbegin(directory_iterator const& iter) BOOST_NOEXCEPT
{
return iter;
}
inline directory_iterator cend(directory_iterator const&) BOOST_NOEXCEPT
{
return directory_iterator();
}
// enable directory_iterator BOOST_FOREACH -----------------------------------------//
inline directory_iterator& range_begin(directory_iterator& iter) BOOST_NOEXCEPT
{
return iter;
}
inline directory_iterator range_begin(directory_iterator const& iter) BOOST_NOEXCEPT
{
return iter;
}
inline directory_iterator range_end(directory_iterator&) BOOST_NOEXCEPT
{
return directory_iterator();
}
inline directory_iterator range_end(directory_iterator const&) BOOST_NOEXCEPT
{
return directory_iterator();
}
} // namespace filesystem
// namespace boost template specializations
template< typename C, typename Enabler >
struct range_mutable_iterator;
template<>
struct range_mutable_iterator< boost::filesystem::directory_iterator, void >
{
typedef boost::filesystem::directory_iterator type;
};
template< typename C, typename Enabler >
struct range_const_iterator;
template<>
struct range_const_iterator< boost::filesystem::directory_iterator, void >
{
typedef boost::filesystem::directory_iterator type;
};
namespace filesystem {
//--------------------------------------------------------------------------------------//
// //
// recursive_directory_iterator helpers //
// //
//--------------------------------------------------------------------------------------//
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
// Deprecated enum, use directory_options instead
BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(symlink_option, unsigned int)
{
none = static_cast< unsigned int >(directory_options::none),
no_recurse = none, // don't follow directory symlinks (default behavior)
recurse = static_cast< unsigned int >(directory_options::follow_directory_symlink), // follow directory symlinks
_detail_no_push = static_cast< unsigned int >(directory_options::_detail_no_push) // internal use only
}
BOOST_SCOPED_ENUM_DECLARE_END(symlink_option)
BOOST_BITMASK(BOOST_SCOPED_ENUM_NATIVE(symlink_option))
#endif // BOOST_FILESYSTEM_NO_DEPRECATED
class recursive_directory_iterator;
namespace detail {
struct recur_dir_itr_imp :
public boost::intrusive_ref_counter< recur_dir_itr_imp >
{
typedef directory_iterator element_type;
std::vector< element_type > m_stack;
// directory_options values, declared as unsigned int for ABI compatibility
unsigned int m_options;
explicit recur_dir_itr_imp(unsigned int opts) BOOST_NOEXCEPT : m_options(opts) {}
};
BOOST_FILESYSTEM_DECL void recursive_directory_iterator_construct(recursive_directory_iterator& it, path const& dir_path, unsigned int opts, system::error_code* ec);
BOOST_FILESYSTEM_DECL void recursive_directory_iterator_increment(recursive_directory_iterator& it, system::error_code* ec);
BOOST_FILESYSTEM_DECL void recursive_directory_iterator_pop(recursive_directory_iterator& it, system::error_code* ec);
} // namespace detail
//--------------------------------------------------------------------------------------//
// //
// recursive_directory_iterator //
// //
//--------------------------------------------------------------------------------------//
class recursive_directory_iterator :
public boost::iterator_facade<
recursive_directory_iterator,
directory_entry,
boost::single_pass_traversal_tag
>
{
friend class boost::iterator_core_access;
friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_construct(recursive_directory_iterator& it, path const& dir_path, unsigned int opts, system::error_code* ec);
friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_increment(recursive_directory_iterator& it, system::error_code* ec);
friend BOOST_FILESYSTEM_DECL void detail::recursive_directory_iterator_pop(recursive_directory_iterator& it, system::error_code* ec);
public:
recursive_directory_iterator() BOOST_NOEXCEPT {} // creates the "end" iterator
explicit recursive_directory_iterator(path const& dir_path)
{
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(directory_options::none), 0);
}
recursive_directory_iterator(path const& dir_path, system::error_code& ec)
{
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(directory_options::none), &ec);
}
recursive_directory_iterator(path const& dir_path, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts)
{
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), 0);
}
recursive_directory_iterator(path const& dir_path, BOOST_SCOPED_ENUM_NATIVE(directory_options) opts, system::error_code& ec)
{
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), &ec);
}
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
// Deprecated constructors
recursive_directory_iterator(path const& dir_path, BOOST_SCOPED_ENUM_NATIVE(symlink_option) opts)
{
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), 0);
}
recursive_directory_iterator(path const& dir_path, BOOST_SCOPED_ENUM_NATIVE(symlink_option) opts, system::error_code& ec) BOOST_NOEXCEPT
{
detail::recursive_directory_iterator_construct(*this, dir_path, static_cast< unsigned int >(opts), &ec);
}
#endif // BOOST_FILESYSTEM_NO_DEPRECATED
BOOST_DEFAULTED_FUNCTION(recursive_directory_iterator(recursive_directory_iterator const& that), : m_imp(that.m_imp) {})
BOOST_DEFAULTED_FUNCTION(recursive_directory_iterator& operator=(recursive_directory_iterator const& that), { m_imp = that.m_imp; return *this; })
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
recursive_directory_iterator(recursive_directory_iterator&& that) BOOST_NOEXCEPT :
m_imp(std::move(that.m_imp))
{
}
recursive_directory_iterator& operator=(recursive_directory_iterator&& that) BOOST_NOEXCEPT
{
m_imp = std::move(that.m_imp);
return *this;
}
#endif // !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
recursive_directory_iterator& increment(system::error_code& ec) BOOST_NOEXCEPT
{
detail::recursive_directory_iterator_increment(*this, &ec);
return *this;
}
int depth() const BOOST_NOEXCEPT
{
BOOST_ASSERT_MSG(!is_end(), "depth() on end recursive_directory_iterator");
return static_cast< int >(m_imp->m_stack.size() - 1u);
}
bool recursion_pending() const BOOST_NOEXCEPT
{
BOOST_ASSERT_MSG(!is_end(), "recursion_pending() on end recursive_directory_iterator");
return (m_imp->m_options & static_cast< unsigned int >(directory_options::_detail_no_push)) == 0u;
}
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
int level() const BOOST_NOEXCEPT
{
return depth();
}
bool no_push_pending() const BOOST_NOEXCEPT { return !recursion_pending(); }
bool no_push_request() const BOOST_NOEXCEPT { return !recursion_pending(); }
#endif
void pop()
{
detail::recursive_directory_iterator_pop(*this, 0);
}
void pop(system::error_code& ec) BOOST_NOEXCEPT
{
detail::recursive_directory_iterator_pop(*this, &ec);
}
void disable_recursion_pending(bool value = true) BOOST_NOEXCEPT
{
BOOST_ASSERT_MSG(!is_end(), "disable_recursion_pending() on end recursive_directory_iterator");
if (value)
m_imp->m_options |= static_cast< unsigned int >(directory_options::_detail_no_push);
else
m_imp->m_options &= ~static_cast< unsigned int >(directory_options::_detail_no_push);
}
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
void no_push(bool value = true) BOOST_NOEXCEPT
{
disable_recursion_pending(value);
}
#endif
file_status status() const
{
BOOST_ASSERT_MSG(!is_end(), "status() on end recursive_directory_iterator");
return m_imp->m_stack.back()->status();
}
file_status symlink_status() const
{
BOOST_ASSERT_MSG(!is_end(), "symlink_status() on end recursive_directory_iterator");
return m_imp->m_stack.back()->symlink_status();
}
private:
boost::iterator_facade<
recursive_directory_iterator,
directory_entry,
boost::single_pass_traversal_tag
>::reference dereference() const
{
BOOST_ASSERT_MSG(!is_end(), "dereference of end recursive_directory_iterator");
return *m_imp->m_stack.back();
}
void increment() { detail::recursive_directory_iterator_increment(*this, 0); }
bool equal(recursive_directory_iterator const& rhs) const BOOST_NOEXCEPT
{
return m_imp == rhs.m_imp || (is_end() && rhs.is_end());
}
bool is_end() const BOOST_NOEXCEPT
{
// Note: The check for m_stack.empty() is needed because the iterator can be copied and the copy
// can be incremented to end while the original iterator still refers to the same recur_dir_itr_imp.
return !m_imp || m_imp->m_stack.empty();
}
private:
// intrusive_ptr provides the shallow-copy semantics required for single pass iterators
// (i.e. InputIterators). The end iterator is indicated by is_end().
boost::intrusive_ptr< detail::recur_dir_itr_imp > m_imp;
};
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
typedef recursive_directory_iterator wrecursive_directory_iterator;
#endif
// enable recursive directory iterator C++11 range-base for statement use ----------//
// begin() and end() are only used by a range-based for statement in the context of
// auto - thus the top-level const is stripped - so returning const is harmless and
// emphasizes begin() is just a pass through.
inline recursive_directory_iterator const& begin(recursive_directory_iterator const& iter) BOOST_NOEXCEPT
{
return iter;
}
inline recursive_directory_iterator end(recursive_directory_iterator const&) BOOST_NOEXCEPT
{
return recursive_directory_iterator();
}
// enable C++14 generic accessors for range const iterators
inline recursive_directory_iterator const& cbegin(recursive_directory_iterator const& iter) BOOST_NOEXCEPT
{
return iter;
}
inline recursive_directory_iterator cend(recursive_directory_iterator const&) BOOST_NOEXCEPT
{
return recursive_directory_iterator();
}
// enable recursive directory iterator BOOST_FOREACH -------------------------------//
inline recursive_directory_iterator& range_begin(recursive_directory_iterator& iter) BOOST_NOEXCEPT
{
return iter;
}
inline recursive_directory_iterator range_begin(recursive_directory_iterator const& iter) BOOST_NOEXCEPT
{
return iter;
}
inline recursive_directory_iterator range_end(recursive_directory_iterator&) BOOST_NOEXCEPT
{
return recursive_directory_iterator();
}
inline recursive_directory_iterator range_end(recursive_directory_iterator const&) BOOST_NOEXCEPT
{
return recursive_directory_iterator();
}
} // namespace filesystem
// namespace boost template specializations
template<>
struct range_mutable_iterator< boost::filesystem::recursive_directory_iterator, void >
{
typedef boost::filesystem::recursive_directory_iterator type;
};
template<>
struct range_const_iterator< boost::filesystem::recursive_directory_iterator, void >
{
typedef boost::filesystem::recursive_directory_iterator type;
};
} // namespace boost
#include <boost/filesystem/detail/footer.hpp>
#endif // BOOST_FILESYSTEM_DIRECTORY_HPP

View File

@@ -0,0 +1,92 @@
// boost/filesystem/exception.hpp -----------------------------------------------------//
// Copyright Beman Dawes 2003
// Copyright Andrey Semashev 2019
// 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 BOOST_FILESYSTEM_EXCEPTION_HPP
#define BOOST_FILESYSTEM_EXCEPTION_HPP
#include <boost/filesystem/config.hpp>
#include <boost/filesystem/path.hpp>
#include <string>
#include <boost/system/error_code.hpp>
#include <boost/system/system_error.hpp>
#include <boost/smart_ptr/intrusive_ptr.hpp>
#include <boost/smart_ptr/intrusive_ref_counter.hpp>
#include <boost/filesystem/detail/header.hpp> // must be the last #include
namespace boost {
namespace filesystem {
//--------------------------------------------------------------------------------------//
// //
// class filesystem_error //
// //
//--------------------------------------------------------------------------------------//
class BOOST_SYMBOL_VISIBLE filesystem_error :
public system::system_error
{
// see http://www.boost.org/more/error_handling.html for design rationale
public:
BOOST_FILESYSTEM_DECL filesystem_error(const char* what_arg, system::error_code ec);
BOOST_FILESYSTEM_DECL filesystem_error(std::string const& what_arg, system::error_code ec);
BOOST_FILESYSTEM_DECL filesystem_error(const char* what_arg, path const& path1_arg, system::error_code ec);
BOOST_FILESYSTEM_DECL filesystem_error(std::string const& what_arg, path const& path1_arg, system::error_code ec);
BOOST_FILESYSTEM_DECL filesystem_error(const char* what_arg, path const& path1_arg, path const& path2_arg, system::error_code ec);
BOOST_FILESYSTEM_DECL filesystem_error(std::string const& what_arg, path const& path1_arg, path const& path2_arg, system::error_code ec);
BOOST_FILESYSTEM_DECL filesystem_error(filesystem_error const& that);
BOOST_FILESYSTEM_DECL filesystem_error& operator=(filesystem_error const& that);
BOOST_FILESYSTEM_DECL ~filesystem_error() BOOST_NOEXCEPT_OR_NOTHROW;
path const& path1() const BOOST_NOEXCEPT
{
return m_imp_ptr.get() ? m_imp_ptr->m_path1 : get_empty_path();
}
path const& path2() const BOOST_NOEXCEPT
{
return m_imp_ptr.get() ? m_imp_ptr->m_path2 : get_empty_path();
}
BOOST_FILESYSTEM_DECL const char* what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE;
private:
BOOST_FILESYSTEM_DECL static path const& get_empty_path() BOOST_NOEXCEPT;
private:
struct impl :
public boost::intrusive_ref_counter< impl >
{
path m_path1; // may be empty()
path m_path2; // may be empty()
std::string m_what; // not built until needed
BOOST_DEFAULTED_FUNCTION(impl(), {})
explicit impl(path const& path1) :
m_path1(path1)
{
}
impl(path const& path1, path const& path2) :
m_path1(path1), m_path2(path2)
{
}
};
boost::intrusive_ptr< impl > m_imp_ptr;
};
} // namespace filesystem
} // namespace boost
#include <boost/filesystem/detail/footer.hpp>
#endif // BOOST_FILESYSTEM_EXCEPTION_HPP

View File

@@ -0,0 +1,243 @@
// boost/filesystem/file_status.hpp --------------------------------------------------//
// Copyright Beman Dawes 2002-2009
// Copyright Jan Langer 2002
// Copyright Dietmar Kuehl 2001
// Copyright Vladimir Prus 2002
// Copyright Andrey Semashev 2019
// 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 BOOST_FILESYSTEM_FILE_STATUS_HPP
#define BOOST_FILESYSTEM_FILE_STATUS_HPP
#include <boost/filesystem/config.hpp>
#include <boost/detail/bitmask.hpp>
#include <boost/filesystem/detail/header.hpp> // must be the last #include
//--------------------------------------------------------------------------------------//
namespace boost {
namespace filesystem {
//--------------------------------------------------------------------------------------//
// file_type //
//--------------------------------------------------------------------------------------//
enum file_type
{
status_error,
#ifndef BOOST_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
};
//--------------------------------------------------------------------------------------//
// 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 = 0777, // owner_all|group_all|others_all
// 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 = 07777, // all_all|set_uid_on_exe|set_gid_on_exe|sticky_bit
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
// BOOST_BITMASK op~ casts to int32_least_t, producing invalid enum values
_detail_extend_perms_32_1 = 0x7fffffff,
_detail_extend_perms_32_2 = -0x7fffffff - 1
};
BOOST_BITMASK(perms)
//--------------------------------------------------------------------------------------//
// file_status //
//--------------------------------------------------------------------------------------//
class file_status
{
public:
BOOST_CONSTEXPR file_status() BOOST_NOEXCEPT :
m_value(status_error),
m_perms(perms_not_known)
{
}
explicit BOOST_CONSTEXPR file_status(file_type v) BOOST_NOEXCEPT :
m_value(v),
m_perms(perms_not_known)
{
}
BOOST_CONSTEXPR file_status(file_type v, perms prms) BOOST_NOEXCEPT :
m_value(v),
m_perms(prms)
{
}
// As of October 2015 the interaction between noexcept and =default is so troublesome
// for VC++, GCC, and probably other compilers, that =default is not used with noexcept
// functions. GCC is not even consistent for the same release on different platforms.
BOOST_CONSTEXPR file_status(const file_status& rhs) BOOST_NOEXCEPT :
m_value(rhs.m_value),
m_perms(rhs.m_perms)
{
}
BOOST_CXX14_CONSTEXPR file_status& operator=(const file_status& rhs) BOOST_NOEXCEPT
{
m_value = rhs.m_value;
m_perms = rhs.m_perms;
return *this;
}
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
// Note: std::move is not constexpr in C++11, that's why we're not using it here
BOOST_CONSTEXPR file_status(file_status&& rhs) BOOST_NOEXCEPT :
m_value(static_cast< file_type&& >(rhs.m_value)),
m_perms(static_cast< enum perms&& >(rhs.m_perms))
{
}
BOOST_CXX14_CONSTEXPR file_status& operator=(file_status&& rhs) BOOST_NOEXCEPT
{
m_value = static_cast< file_type&& >(rhs.m_value);
m_perms = static_cast< enum perms&& >(rhs.m_perms);
return *this;
}
#endif
// observers
BOOST_CONSTEXPR file_type type() const BOOST_NOEXCEPT { return m_value; }
BOOST_CONSTEXPR perms permissions() const BOOST_NOEXCEPT { return m_perms; }
// modifiers
BOOST_CXX14_CONSTEXPR void type(file_type v) BOOST_NOEXCEPT { m_value = v; }
BOOST_CXX14_CONSTEXPR void permissions(perms prms) BOOST_NOEXCEPT { m_perms = prms; }
BOOST_CONSTEXPR bool operator==(const file_status& rhs) const BOOST_NOEXCEPT
{
return type() == rhs.type() && permissions() == rhs.permissions();
}
BOOST_CONSTEXPR bool operator!=(const file_status& rhs) const BOOST_NOEXCEPT
{
return !(*this == rhs);
}
private:
file_type m_value;
enum perms m_perms;
};
inline BOOST_CONSTEXPR bool type_present(file_status f) BOOST_NOEXCEPT
{
return f.type() != status_error;
}
inline BOOST_CONSTEXPR bool permissions_present(file_status f) BOOST_NOEXCEPT
{
return f.permissions() != perms_not_known;
}
inline BOOST_CONSTEXPR bool status_known(file_status f) BOOST_NOEXCEPT
{
return filesystem::type_present(f) && filesystem::permissions_present(f);
}
inline BOOST_CONSTEXPR bool exists(file_status f) BOOST_NOEXCEPT
{
return f.type() != status_error && f.type() != file_not_found;
}
inline BOOST_CONSTEXPR bool is_regular_file(file_status f) BOOST_NOEXCEPT
{
return f.type() == regular_file;
}
inline BOOST_CONSTEXPR bool is_directory(file_status f) BOOST_NOEXCEPT
{
return f.type() == directory_file;
}
inline BOOST_CONSTEXPR bool is_symlink(file_status f) BOOST_NOEXCEPT
{
return f.type() == symlink_file;
}
inline BOOST_CONSTEXPR bool is_other(file_status f) BOOST_NOEXCEPT
{
return filesystem::exists(f) && !filesystem::is_regular_file(f) && !filesystem::is_directory(f) && !filesystem::is_symlink(f);
}
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
inline bool is_regular(file_status f) BOOST_NOEXCEPT
{
return filesystem::is_regular_file(f);
}
#endif
} // namespace filesystem
} // namespace boost
#include <boost/filesystem/detail/footer.hpp> // pops abi_prefix.hpp pragmas
#endif // BOOST_FILESYSTEM_FILE_STATUS_HPP

View File

@@ -0,0 +1,206 @@
// boost/filesystem/fstream.hpp ------------------------------------------------------//
// Copyright Beman Dawes 2002
// Copyright Andrey Semashev 2021
// 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 BOOST_FILESYSTEM_FSTREAM_HPP
#define BOOST_FILESYSTEM_FSTREAM_HPP
#include <boost/filesystem/config.hpp>
#include <boost/filesystem/path.hpp>
#include <iosfwd>
#include <fstream>
#include <boost/filesystem/detail/header.hpp> // must be the last #include
#if defined(BOOST_WINDOWS_API)
// On Windows, except for standard libaries known to have wchar_t overloads for
// file stream I/O, use path::string() to get a narrow character c_str()
#if (defined(_CPPLIB_VER) && _CPPLIB_VER >= 405 && !defined(_STLPORT_VERSION)) || \
(defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 7000 && defined(_LIBCPP_HAS_OPEN_WITH_WCHAR))
// Use wide characters directly
// Note: We don't use C++17 std::filesystem::path as a means to pass wide paths
// to file streams because of various problems:
// - std::filesystem is available in gcc 8 but it is broken there (fails to compile path definition
// on Windows). Compilation errors seem to be fixed since gcc 9.
// - In gcc 10.2 and clang 8.0.1 on Cygwin64, the path attempts to convert the wide string to narrow
// and fails in runtime. This may be system locale dependent, and performing character code conversion
// is against the purpose of using std::filesystem::path anyway.
// - Other std::filesystem implementations were not tested, so it is not known if they actually work
// with wide paths.
#define BOOST_FILESYSTEM_C_STR(p) p.c_str()
#else
// Use narrow characters, since wide not available
#define BOOST_FILESYSTEM_C_STR(p) p.string().c_str()
#endif
#endif // defined(BOOST_WINDOWS_API)
#if !defined(BOOST_FILESYSTEM_C_STR)
#define BOOST_FILESYSTEM_C_STR(p) p.c_str()
#endif
#if defined(BOOST_MSVC)
#pragma warning(push)
// 'boost::filesystem::basic_fstream<charT>' : inherits 'std::basic_istream<_Elem,_Traits>::std::basic_istream<_Elem,_Traits>::_Add_vtordisp1' via dominance
#pragma warning(disable : 4250)
#endif
namespace boost {
namespace filesystem {
//--------------------------------------------------------------------------------------//
// basic_filebuf //
//--------------------------------------------------------------------------------------//
template< class charT, class traits = std::char_traits< charT > >
class basic_filebuf :
public std::basic_filebuf< charT, traits >
{
public:
BOOST_DEFAULTED_FUNCTION(basic_filebuf(), {})
BOOST_DELETED_FUNCTION(basic_filebuf(basic_filebuf const&))
BOOST_DELETED_FUNCTION(basic_filebuf const& operator=(basic_filebuf const&))
public:
basic_filebuf< charT, traits >* open(path const& p, std::ios_base::openmode mode)
{
return std::basic_filebuf< charT, traits >::open(BOOST_FILESYSTEM_C_STR(p), mode) ? this : 0;
}
};
//--------------------------------------------------------------------------------------//
// basic_ifstream //
//--------------------------------------------------------------------------------------//
template< class charT, class traits = std::char_traits< charT > >
class basic_ifstream :
public std::basic_ifstream< charT, traits >
{
public:
BOOST_DEFAULTED_FUNCTION(basic_ifstream(), {})
// use two signatures, rather than one signature with default second
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
explicit basic_ifstream(path const& p) :
std::basic_ifstream< charT, traits >(BOOST_FILESYSTEM_C_STR(p), std::ios_base::in) {}
basic_ifstream(path const& p, std::ios_base::openmode mode) :
std::basic_ifstream< charT, traits >(BOOST_FILESYSTEM_C_STR(p), mode) {}
BOOST_DELETED_FUNCTION(basic_ifstream(basic_ifstream const&))
BOOST_DELETED_FUNCTION(basic_ifstream const& operator=(basic_ifstream const&))
public:
void open(path const& p)
{
std::basic_ifstream< charT, traits >::open(BOOST_FILESYSTEM_C_STR(p), std::ios_base::in);
}
void open(path const& p, std::ios_base::openmode mode)
{
std::basic_ifstream< charT, traits >::open(BOOST_FILESYSTEM_C_STR(p), mode);
}
};
//--------------------------------------------------------------------------------------//
// basic_ofstream //
//--------------------------------------------------------------------------------------//
template< class charT, class traits = std::char_traits< charT > >
class basic_ofstream :
public std::basic_ofstream< charT, traits >
{
public:
BOOST_DEFAULTED_FUNCTION(basic_ofstream(), {})
// use two signatures, rather than one signature with default second
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
explicit basic_ofstream(path const& p) :
std::basic_ofstream< charT, traits >(BOOST_FILESYSTEM_C_STR(p), std::ios_base::out) {}
basic_ofstream(path const& p, std::ios_base::openmode mode) :
std::basic_ofstream< charT, traits >(BOOST_FILESYSTEM_C_STR(p), mode) {}
BOOST_DELETED_FUNCTION(basic_ofstream(basic_ofstream const&))
BOOST_DELETED_FUNCTION(basic_ofstream const& operator=(basic_ofstream const&))
public:
void open(path const& p)
{
std::basic_ofstream< charT, traits >::open(BOOST_FILESYSTEM_C_STR(p), std::ios_base::out);
}
void open(path const& p, std::ios_base::openmode mode)
{
std::basic_ofstream< charT, traits >::open(BOOST_FILESYSTEM_C_STR(p), mode);
}
};
//--------------------------------------------------------------------------------------//
// basic_fstream //
//--------------------------------------------------------------------------------------//
template< class charT, class traits = std::char_traits< charT > >
class basic_fstream :
public std::basic_fstream< charT, traits >
{
public:
BOOST_DEFAULTED_FUNCTION(basic_fstream(), {})
// use two signatures, rather than one signature with default second
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
explicit basic_fstream(path const& p) :
std::basic_fstream< charT, traits >(BOOST_FILESYSTEM_C_STR(p), std::ios_base::in | std::ios_base::out) {}
basic_fstream(path const& p, std::ios_base::openmode mode) :
std::basic_fstream< charT, traits >(BOOST_FILESYSTEM_C_STR(p), mode) {}
BOOST_DELETED_FUNCTION(basic_fstream(basic_fstream const&))
BOOST_DELETED_FUNCTION(basic_fstream const& operator=(basic_fstream const&))
public:
void open(path const& p)
{
std::basic_fstream< charT, traits >::open(BOOST_FILESYSTEM_C_STR(p), std::ios_base::in | std::ios_base::out);
}
void open(path const& p, std::ios_base::openmode mode)
{
std::basic_fstream< charT, traits >::open(BOOST_FILESYSTEM_C_STR(p), mode);
}
};
//--------------------------------------------------------------------------------------//
// typedefs //
//--------------------------------------------------------------------------------------//
typedef basic_filebuf< char > filebuf;
typedef basic_ifstream< char > ifstream;
typedef basic_ofstream< char > ofstream;
typedef basic_fstream< char > fstream;
typedef basic_filebuf< wchar_t > wfilebuf;
typedef basic_ifstream< wchar_t > wifstream;
typedef basic_ofstream< wchar_t > wofstream;
typedef basic_fstream< wchar_t > wfstream;
} // namespace filesystem
} // namespace boost
#if defined(BOOST_MSVC)
#pragma warning(pop)
#endif
#include <boost/filesystem/detail/footer.hpp>
#endif // BOOST_FILESYSTEM_FSTREAM_HPP

View File

@@ -0,0 +1,719 @@
// boost/filesystem/operations.hpp ---------------------------------------------------//
// Copyright Beman Dawes 2002-2009
// Copyright Jan Langer 2002
// Copyright Dietmar Kuehl 2001
// Copyright Vladimir Prus 2002
// Copyright Andrey Semashev 2020-2021
// 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 BOOST_FILESYSTEM_OPERATIONS_HPP
#define BOOST_FILESYSTEM_OPERATIONS_HPP
#include <boost/filesystem/config.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/file_status.hpp>
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
// These includes are left for backward compatibility and should be included directly by users, as needed
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/directory.hpp>
#endif
#include <boost/detail/bitmask.hpp>
#include <boost/core/scoped_enum.hpp>
#include <boost/system/error_code.hpp>
#include <boost/cstdint.hpp>
#include <string>
#include <ctime>
#include <boost/filesystem/detail/header.hpp> // must be the last #include
//--------------------------------------------------------------------------------------//
namespace boost {
namespace filesystem {
struct space_info
{
// all values are byte counts
boost::uintmax_t capacity;
boost::uintmax_t free; // <= capacity
boost::uintmax_t available; // <= free
};
BOOST_SCOPED_ENUM_UT_DECLARE_BEGIN(copy_options, unsigned int)
{
none = 0u, // Default. For copy_file: error if the target file exists. For copy: do not recurse, follow symlinks, copy file contents.
// copy_file options:
skip_existing = 1u, // Don't overwrite the existing target file, don't report an error
overwrite_existing = 1u << 1, // Overwrite existing file
update_existing = 1u << 2, // Overwrite existing file if its last write time is older than the replacement file
synchronize_data = 1u << 3, // Flush all buffered data written to the target file to permanent storage
synchronize = 1u << 4, // Flush all buffered data and attributes written to the target file to permanent storage
// copy options:
recursive = 1u << 8, // Recurse into sub-directories
copy_symlinks = 1u << 9, // Copy symlinks as symlinks instead of copying the referenced file
skip_symlinks = 1u << 10, // Don't copy symlinks
directories_only = 1u << 11, // Only copy directory structure, do not copy non-directory files
create_symlinks = 1u << 12, // Create symlinks instead of copying files
create_hard_links = 1u << 13, // Create hard links instead of copying files
_detail_recursing = 1u << 14 // Internal use only, do not use
}
BOOST_SCOPED_ENUM_DECLARE_END(copy_options)
BOOST_BITMASK(BOOST_SCOPED_ENUM_NATIVE(copy_options))
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
BOOST_SCOPED_ENUM_DECLARE_BEGIN(copy_option)
{
none = static_cast< unsigned int >(copy_options::none),
fail_if_exists = none,
overwrite_if_exists = static_cast< unsigned int >(copy_options::overwrite_existing)
}
BOOST_SCOPED_ENUM_DECLARE_END(copy_option)
#endif
//--------------------------------------------------------------------------------------//
// implementation details //
//--------------------------------------------------------------------------------------//
namespace detail {
BOOST_FILESYSTEM_DECL
path absolute(path const& p, path const& base, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
file_status status(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
file_status symlink_status(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
bool is_empty(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
path initial_path(system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
path canonical(path const& p, path const& base, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
void copy(path const& from, path const& to, unsigned int options, system::error_code* ec = 0);
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
BOOST_FILESYSTEM_DECL
void copy_directory(path const& from, path const& to, system::error_code* ec = 0);
#endif
BOOST_FILESYSTEM_DECL
bool copy_file(path const& from, path const& to, // See ticket #2925
unsigned int options, system::error_code* ec = 0); // see copy_options for options
BOOST_FILESYSTEM_DECL
void copy_symlink(path const& existing_symlink, path const& new_symlink, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
bool create_directories(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
bool create_directory(path const& p, const path* existing, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
void create_directory_symlink(path const& to, path const& from, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
void create_hard_link(path const& to, path const& from, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
void create_symlink(path const& to, path const& from, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
path current_path(system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
void current_path(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
bool equivalent(path const& p1, path const& p2, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
boost::uintmax_t file_size(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
boost::uintmax_t hard_link_count(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
std::time_t creation_time(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
std::time_t last_write_time(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
void last_write_time(path const& p, const std::time_t new_time, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
void permissions(path const& p, perms prms, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
path read_symlink(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
path relative(path const& p, path const& base, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
bool remove(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
boost::uintmax_t remove_all(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
void rename(path const& old_p, path const& new_p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
void resize_file(path const& p, uintmax_t size, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
space_info space(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
path system_complete(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
path temp_directory_path(system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
path unique_path(path const& p, system::error_code* ec = 0);
BOOST_FILESYSTEM_DECL
path weakly_canonical(path const& p, path const& base, system::error_code* ec = 0);
} // namespace detail
//--------------------------------------------------------------------------------------//
// //
// status query functions //
// //
//--------------------------------------------------------------------------------------//
inline file_status status(path const& p)
{
return detail::status(p);
}
inline file_status status(path const& p, system::error_code& ec)
{
return detail::status(p, &ec);
}
inline file_status symlink_status(path const& p)
{
return detail::symlink_status(p);
}
inline file_status symlink_status(path const& p, system::error_code& ec)
{
return detail::symlink_status(p, &ec);
}
inline bool exists(path const& p)
{
return exists(detail::status(p));
}
inline bool exists(path const& p, system::error_code& ec)
{
return exists(detail::status(p, &ec));
}
inline bool is_directory(path const& p)
{
return is_directory(detail::status(p));
}
inline bool is_directory(path const& p, system::error_code& ec)
{
return is_directory(detail::status(p, &ec));
}
inline bool is_regular_file(path const& p)
{
return is_regular_file(detail::status(p));
}
inline bool is_regular_file(path const& p, system::error_code& ec)
{
return is_regular_file(detail::status(p, &ec));
}
inline bool is_other(path const& p)
{
return is_other(detail::status(p));
}
inline bool is_other(path const& p, system::error_code& ec)
{
return is_other(detail::status(p, &ec));
}
inline bool is_symlink(path const& p)
{
return is_symlink(detail::symlink_status(p));
}
inline bool is_symlink(path const& p, system::error_code& ec)
{
return is_symlink(detail::symlink_status(p, &ec));
}
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
inline bool is_regular(path const& p)
{
return is_regular(detail::status(p));
}
inline bool is_regular(path const& p, system::error_code& ec)
{
return is_regular(detail::status(p, &ec));
}
#endif
inline bool is_empty(path const& p)
{
return detail::is_empty(p);
}
inline bool is_empty(path const& p, system::error_code& ec)
{
return detail::is_empty(p, &ec);
}
//--------------------------------------------------------------------------------------//
// //
// operational functions //
// //
//--------------------------------------------------------------------------------------//
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 path current_path()
{
return detail::current_path();
}
inline path current_path(system::error_code& ec)
{
return detail::current_path(&ec);
}
inline void current_path(path const& p)
{
detail::current_path(p);
}
inline void current_path(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
detail::current_path(p, &ec);
}
inline path absolute(path const& p, path const& base = current_path())
{
return detail::absolute(p, base);
}
inline path absolute(path const& p, system::error_code& ec)
{
path base = current_path(ec);
if (ec)
return path();
return detail::absolute(p, base, &ec);
}
inline path absolute(path const& p, path const& base, system::error_code& ec)
{
return detail::absolute(p, base, &ec);
}
inline path canonical(path const& p, path const& base = current_path())
{
return detail::canonical(p, base);
}
inline path canonical(path const& p, system::error_code& ec)
{
path base = current_path(ec);
if (ec)
return path();
return detail::canonical(p, base, &ec);
}
inline path canonical(path const& p, path const& base, system::error_code& ec)
{
return detail::canonical(p, base, &ec);
}
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
inline path complete(path const& p)
{
return absolute(p, initial_path());
}
inline path complete(path const& p, path const& base)
{
return absolute(p, base);
}
#endif
inline void copy(path const& from, path const& to)
{
detail::copy(from, to, static_cast< unsigned int >(copy_options::none));
}
inline void copy(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
{
detail::copy(from, to, static_cast< unsigned int >(copy_options::none), &ec);
}
inline void copy(path const& from, path const& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
{
detail::copy(from, to, static_cast< unsigned int >(options));
}
inline void copy(path const& from, path const& to, BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
{
detail::copy(from, to, static_cast< unsigned int >(options), &ec);
}
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
inline void copy_directory(path const& from, path const& to)
{
detail::copy_directory(from, to);
}
inline void copy_directory(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
{
detail::copy_directory(from, to, &ec);
}
#endif
inline bool copy_file(path const& from, path const& to)
{
return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none));
}
inline bool copy_file(path const& from, path const& to, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::copy_file(from, to, static_cast< unsigned int >(copy_options::none), &ec);
}
inline bool copy_file(path const& from, path const& to, // See ticket #2925
BOOST_SCOPED_ENUM_NATIVE(copy_options) options)
{
return detail::copy_file(from, to, static_cast< unsigned int >(options));
}
inline bool copy_file(path const& from, path const& to, // See ticket #2925
BOOST_SCOPED_ENUM_NATIVE(copy_options) options, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
}
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
inline bool copy_file(path const& from, path const& to, // See ticket #2925
BOOST_SCOPED_ENUM_NATIVE(copy_option) options)
{
return detail::copy_file(from, to, static_cast< unsigned int >(options));
}
inline bool copy_file(path const& from, path const& to, // See ticket #2925
BOOST_SCOPED_ENUM_NATIVE(copy_option) options, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::copy_file(from, to, static_cast< unsigned int >(options), &ec);
}
#endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
inline void copy_symlink(path const& existing_symlink, path const& new_symlink)
{
detail::copy_symlink(existing_symlink, new_symlink);
}
inline void copy_symlink(path const& existing_symlink, path const& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
{
detail::copy_symlink(existing_symlink, new_symlink, &ec);
}
inline bool create_directories(path const& p)
{
return detail::create_directories(p);
}
inline bool create_directories(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::create_directories(p, &ec);
}
inline bool create_directory(path const& p)
{
return detail::create_directory(p, 0);
}
inline bool create_directory(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::create_directory(p, 0, &ec);
}
inline bool create_directory(path const& p, path const& existing)
{
return detail::create_directory(p, &existing);
}
inline bool create_directory(path const& p, path const& existing, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::create_directory(p, &existing, &ec);
}
inline void create_directory_symlink(path const& to, path const& from)
{
detail::create_directory_symlink(to, from);
}
inline void create_directory_symlink(path const& to, path const& from, system::error_code& ec) BOOST_NOEXCEPT
{
detail::create_directory_symlink(to, from, &ec);
}
inline void create_hard_link(path const& to, path const& new_hard_link)
{
detail::create_hard_link(to, new_hard_link);
}
inline void create_hard_link(path const& to, path const& new_hard_link, system::error_code& ec) BOOST_NOEXCEPT
{
detail::create_hard_link(to, new_hard_link, &ec);
}
inline void create_symlink(path const& to, path const& new_symlink)
{
detail::create_symlink(to, new_symlink);
}
inline void create_symlink(path const& to, path const& new_symlink, system::error_code& ec) BOOST_NOEXCEPT
{
detail::create_symlink(to, new_symlink, &ec);
}
inline bool equivalent(path const& p1, path const& p2)
{
return detail::equivalent(p1, p2);
}
inline bool equivalent(path const& p1, path const& p2, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::equivalent(p1, p2, &ec);
}
inline boost::uintmax_t file_size(path const& p)
{
return detail::file_size(p);
}
inline boost::uintmax_t file_size(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::file_size(p, &ec);
}
inline boost::uintmax_t hard_link_count(path const& p)
{
return detail::hard_link_count(p);
}
inline boost::uintmax_t hard_link_count(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::hard_link_count(p, &ec);
}
inline std::time_t creation_time(path const& p)
{
return detail::creation_time(p);
}
inline std::time_t creation_time(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::creation_time(p, &ec);
}
inline std::time_t last_write_time(path const& p)
{
return detail::last_write_time(p);
}
inline std::time_t last_write_time(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::last_write_time(p, &ec);
}
inline void last_write_time(path const& p, const std::time_t new_time)
{
detail::last_write_time(p, new_time);
}
inline void last_write_time(path const& p, const std::time_t new_time, system::error_code& ec) BOOST_NOEXCEPT
{
detail::last_write_time(p, new_time, &ec);
}
inline void permissions(path const& p, perms prms)
{
detail::permissions(p, prms);
}
inline void permissions(path const& p, perms prms, system::error_code& ec) BOOST_NOEXCEPT
{
detail::permissions(p, prms, &ec);
}
inline path read_symlink(path const& p)
{
return detail::read_symlink(p);
}
inline path read_symlink(path const& p, system::error_code& ec)
{
return detail::read_symlink(p, &ec);
}
inline bool remove(path const& p)
{
return detail::remove(p);
}
inline bool remove(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::remove(p, &ec);
}
inline boost::uintmax_t remove_all(path const& p)
{
return detail::remove_all(p);
}
inline boost::uintmax_t remove_all(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::remove_all(p, &ec);
}
inline void rename(path const& old_p, path const& new_p)
{
detail::rename(old_p, new_p);
}
inline void rename(path const& old_p, path const& new_p, system::error_code& ec) BOOST_NOEXCEPT
{
detail::rename(old_p, new_p, &ec);
}
// name suggested by Scott McMurray
inline void resize_file(path const& p, uintmax_t size)
{
detail::resize_file(p, size);
}
inline void resize_file(path const& p, uintmax_t size, system::error_code& ec) BOOST_NOEXCEPT
{
detail::resize_file(p, size, &ec);
}
inline path relative(path const& p, path const& base = current_path())
{
return detail::relative(p, base);
}
inline path relative(path const& p, system::error_code& ec)
{
path base = current_path(ec);
if (ec)
return path();
return detail::relative(p, base, &ec);
}
inline path relative(path const& p, path const& base, system::error_code& ec)
{
return detail::relative(p, base, &ec);
}
inline space_info space(path const& p)
{
return detail::space(p);
}
inline space_info space(path const& p, system::error_code& ec) BOOST_NOEXCEPT
{
return detail::space(p, &ec);
}
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
inline bool symbolic_link_exists(path const& p)
{
return is_symlink(filesystem::symlink_status(p));
}
#endif
inline path system_complete(path const& p)
{
return detail::system_complete(p);
}
inline path system_complete(path const& 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(path const& p = "%%%%-%%%%-%%%%-%%%%")
{
return detail::unique_path(p);
}
inline path unique_path(path const& p, system::error_code& ec)
{
return detail::unique_path(p, &ec);
}
inline path weakly_canonical(path const& p, path const& base = current_path())
{
return detail::weakly_canonical(p, base);
}
inline path weakly_canonical(path const& p, system::error_code& ec)
{
path base = current_path(ec);
if (ec)
return path();
return detail::weakly_canonical(p, base, &ec);
}
inline path weakly_canonical(path const& p, path const& base, system::error_code& ec)
{
return detail::weakly_canonical(p, base, &ec);
}
// 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 {
BOOST_FILESYSTEM_DECL bool possible_large_file_size_support();
} // namespace detail
} // namespace filesystem
} // namespace boost
#include <boost/filesystem/detail/footer.hpp>
#endif // BOOST_FILESYSTEM_OPERATIONS_HPP

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,384 @@
// 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 BOOST_FILESYSTEM_PATH_TRAITS_HPP
#define BOOST_FILESYSTEM_PATH_TRAITS_HPP
#include <boost/filesystem/config.hpp>
#include <boost/system/error_category.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/decay.hpp>
#include <boost/core/enable_if.hpp>
#include <cstddef>
#include <cwchar> // for mbstate_t
#include <string>
#include <vector>
#include <list>
#include <iterator>
#include <locale>
#include <boost/assert.hpp>
#include <boost/filesystem/detail/header.hpp> // must be the last #include
namespace boost {
namespace filesystem {
BOOST_FILESYSTEM_DECL system::error_category const& codecvt_error_category() BOOST_NOEXCEPT;
// 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 boost::disable_if< boost::is_array< Container >, bool >::type
empty(Container const& c)
{
return c.begin() == c.end();
}
template< class T >
inline bool empty(T* const& c_str)
{
BOOST_ASSERT(c_str);
return !*c_str;
}
template< typename T, std::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
// with codecvt
BOOST_FILESYSTEM_DECL
void convert(const char* from,
const char* from_end, // 0 for null terminated MBCS
std::wstring& to, codecvt_type const& cvt);
BOOST_FILESYSTEM_DECL
void convert(const wchar_t* from,
const wchar_t* from_end, // 0 for null terminated MBCS
std::string& to, codecvt_type const& cvt);
inline void convert(const char* from, std::wstring& to, codecvt_type const& cvt)
{
BOOST_ASSERT(from);
convert(from, 0, to, cvt);
}
inline void convert(const wchar_t* from, std::string& to, codecvt_type const& cvt)
{
BOOST_ASSERT(from);
convert(from, 0, to, cvt);
}
// without codecvt
inline void convert(const char* from,
const char* from_end, // 0 for null terminated MBCS
std::wstring& to);
inline void convert(const wchar_t* from,
const wchar_t* from_end, // 0 for null terminated MBCS
std::string& to);
inline void convert(const char* from, std::wstring& to);
inline void convert(const wchar_t* from, std::string& to);
// value types same -----------------------------------------------------------------//
// char with codecvt
inline void convert(const char* from, const char* from_end, std::string& to, codecvt_type const&)
{
BOOST_ASSERT(from);
BOOST_ASSERT(from_end);
to.append(from, from_end);
}
inline void convert(const char* from, std::string& to, codecvt_type const&)
{
BOOST_ASSERT(from);
to += from;
}
// wchar_t with codecvt
inline void convert(const wchar_t* from, const wchar_t* from_end, std::wstring& to, codecvt_type const&)
{
BOOST_ASSERT(from);
BOOST_ASSERT(from_end);
to.append(from, from_end);
}
inline void convert(const wchar_t* from, std::wstring& to, codecvt_type const&)
{
BOOST_ASSERT(from);
to += from;
}
// char without codecvt
inline void convert(const char* from, const char* from_end, std::string& to)
{
BOOST_ASSERT(from);
BOOST_ASSERT(from_end);
to.append(from, from_end);
}
inline void convert(const char* from, std::string& to)
{
BOOST_ASSERT(from);
to += from;
}
// wchar_t without codecvt
inline void convert(const wchar_t* from, const wchar_t* from_end, std::wstring& to)
{
BOOST_ASSERT(from);
BOOST_ASSERT(from_end);
to.append(from, from_end);
}
inline void convert(const wchar_t* from, std::wstring& to)
{
BOOST_ASSERT(from);
to += from;
}
// Source dispatch -----------------------------------------------------------------//
// contiguous containers with codecvt
template< class U >
inline void dispatch(std::string const& c, U& to, codecvt_type const& cvt)
{
if (!c.empty())
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
}
template< class U >
inline void dispatch(std::wstring const& c, U& to, codecvt_type const& cvt)
{
if (!c.empty())
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
}
template< class U >
inline void dispatch(std::vector< char > const& c, U& to, codecvt_type const& cvt)
{
if (!c.empty())
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
}
template< class U >
inline void dispatch(std::vector< wchar_t > const& c, U& to, codecvt_type const& cvt)
{
if (!c.empty())
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
}
// contiguous containers without codecvt
template< class U >
inline void dispatch(std::string const& c, U& to)
{
if (!c.empty())
convert(&*c.begin(), &*c.begin() + c.size(), to);
}
template< class U >
inline void dispatch(std::wstring const& c, U& to)
{
if (!c.empty())
convert(&*c.begin(), &*c.begin() + c.size(), to);
}
template< class U >
inline void dispatch(std::vector< char > const& c, U& to)
{
if (!c.empty())
convert(&*c.begin(), &*c.begin() + c.size(), to);
}
template< class U >
inline void dispatch(std::vector< wchar_t > const& c, U& to)
{
if (!c.empty())
convert(&*c.begin(), &*c.begin() + c.size(), to);
}
// non-contiguous containers with codecvt
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 boost::disable_if< boost::is_array< Container >, void >::type
dispatch(Container const& c, U& to, codecvt_type const& cvt)
{
if (!c.empty())
{
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, codecvt_type const& cvt)
{
// std::cout << "dispatch() const T *\n";
BOOST_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.
BOOST_FILESYSTEM_DECL
void dispatch(directory_entry const& de,
#ifdef BOOST_WINDOWS_API
std::wstring& to,
#else
std::string& to,
#endif
codecvt_type const&);
// non-contiguous containers without codecvt
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 boost::disable_if< boost::is_array< Container >, void >::type
dispatch(Container const& c, U& to)
{
if (!c.empty())
{
std::basic_string< typename Container::value_type > seq(c.begin(), c.end());
convert(seq.c_str(), seq.c_str() + seq.size(), to);
}
}
// c_str
template< class T, class U >
inline void dispatch(T* const& c_str, U& to)
{
// std::cout << "dispatch() const T *\n";
BOOST_ASSERT(c_str);
convert(c_str, to);
}
// Note: there is no dispatch on C-style arrays because the array may
// contain a string smaller than the array size.
BOOST_FILESYSTEM_DECL
void dispatch(directory_entry const& de,
#ifdef BOOST_WINDOWS_API
std::wstring& to
#else
std::string& to
#endif
);
} // namespace path_traits
} // namespace filesystem
} // namespace boost
#include <boost/filesystem/detail/footer.hpp>
#endif // BOOST_FILESYSTEM_PATH_TRAITS_HPP

View File

@@ -0,0 +1,68 @@
// filesystem/string_file.hpp --------------------------------------------------------//
// Copyright Beman Dawes 2015
// 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 BOOST_FILESYSTEM_STRING_FILE_HPP
#define BOOST_FILESYSTEM_STRING_FILE_HPP
#include <boost/filesystem/config.hpp>
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
#if !defined(BOOST_FILESYSTEM_DEPRECATED)
#include <boost/config/header_deprecated.hpp>
BOOST_HEADER_DEPRECATED("your own implementation")
#endif
#include <cstddef>
#include <limits>
#include <string>
#include <ios>
#include <stdexcept>
#include <boost/cstdint.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/detail/header.hpp> // must be the last #include
namespace boost {
namespace filesystem {
inline void save_string_file(path const& p, std::string const& str)
{
filesystem::ofstream file;
file.exceptions(std::ios_base::failbit | std::ios_base::badbit);
file.open(p, std::ios_base::binary);
const std::size_t sz = str.size();
if (BOOST_UNLIKELY(sz > static_cast< boost::uintmax_t >((std::numeric_limits< std::streamsize >::max)())))
BOOST_FILESYSTEM_THROW(std::length_error("String size exceeds max write size"));
file.write(str.c_str(), static_cast< std::streamsize >(sz));
}
inline void load_string_file(path const& p, std::string& str)
{
filesystem::ifstream file;
file.exceptions(std::ios_base::failbit | std::ios_base::badbit);
file.open(p, std::ios_base::binary);
const boost::uintmax_t sz = filesystem::file_size(p);
if (BOOST_UNLIKELY(sz > static_cast< boost::uintmax_t >((std::numeric_limits< std::streamsize >::max)())))
BOOST_FILESYSTEM_THROW(std::length_error("File size exceeds max read size"));
str.resize(static_cast< std::size_t >(sz), '\0');
if (sz > 0u)
file.read(&str[0], static_cast< std::streamsize >(sz));
}
} // namespace filesystem
} // namespace boost
#include <boost/filesystem/detail/footer.hpp>
#endif // !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
#endif // BOOST_FILESYSTEM_STRING_FILE_HPP