|
|
|
|
@@ -21,14 +21,14 @@
|
|
|
|
|
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
#include <boost/assert.hpp>
|
|
|
|
|
#include <boost/filesystem/config.hpp>
|
|
|
|
|
#include <boost/filesystem/path_traits.hpp> // includes <cwchar>
|
|
|
|
|
#include <boost/system/error_code.hpp>
|
|
|
|
|
#include <boost/system/system_error.hpp>
|
|
|
|
|
#include <boost/iterator/iterator_facade.hpp>
|
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
#include <boost/core/enable_if.hpp>
|
|
|
|
|
#include <boost/io/detail/quoted_manip.hpp>
|
|
|
|
|
#include <boost/static_assert.hpp>
|
|
|
|
|
#include <boost/functional/hash_fwd.hpp>
|
|
|
|
|
#include <boost/type_traits/is_integral.hpp>
|
|
|
|
|
#include <string>
|
|
|
|
|
@@ -46,6 +46,30 @@ namespace boost
|
|
|
|
|
{
|
|
|
|
|
namespace filesystem
|
|
|
|
|
{
|
|
|
|
|
namespace path_detail // intentionally don't use filesystem::detail to not bring internal Boost.Filesystem functions into ADL via path_constants
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
template< typename Char, Char Separator, Char PreferredSeparator, Char Dot >
|
|
|
|
|
struct path_constants
|
|
|
|
|
{
|
|
|
|
|
typedef path_constants< Char, Separator, PreferredSeparator, Dot > path_constants_base;
|
|
|
|
|
typedef Char value_type;
|
|
|
|
|
static BOOST_CONSTEXPR_OR_CONST value_type separator = Separator;
|
|
|
|
|
static BOOST_CONSTEXPR_OR_CONST value_type preferred_separator = PreferredSeparator;
|
|
|
|
|
static BOOST_CONSTEXPR_OR_CONST value_type dot = Dot;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template< typename Char, Char Separator, Char PreferredSeparator, Char Dot >
|
|
|
|
|
BOOST_CONSTEXPR_OR_CONST typename path_constants< Char, Separator, PreferredSeparator, Dot >::value_type
|
|
|
|
|
path_constants< Char, Separator, PreferredSeparator, Dot >::separator;
|
|
|
|
|
template< typename Char, Char Separator, Char PreferredSeparator, Char Dot >
|
|
|
|
|
BOOST_CONSTEXPR_OR_CONST typename path_constants< Char, Separator, PreferredSeparator, Dot >::value_type
|
|
|
|
|
path_constants< Char, Separator, PreferredSeparator, Dot >::preferred_separator;
|
|
|
|
|
template< typename Char, Char Separator, Char PreferredSeparator, Char Dot >
|
|
|
|
|
BOOST_CONSTEXPR_OR_CONST typename path_constants< Char, Separator, PreferredSeparator, Dot >::value_type
|
|
|
|
|
path_constants< Char, Separator, PreferredSeparator, Dot >::dot;
|
|
|
|
|
|
|
|
|
|
} // namespace path_detail
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------//
|
|
|
|
|
// //
|
|
|
|
|
@@ -53,25 +77,22 @@ namespace filesystem
|
|
|
|
|
// //
|
|
|
|
|
//------------------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
|
|
class BOOST_FILESYSTEM_DECL path
|
|
|
|
|
class path :
|
|
|
|
|
public filesystem::path_detail::path_constants<
|
|
|
|
|
#ifdef BOOST_WINDOWS_API
|
|
|
|
|
wchar_t, L'/', L'\\', L'.'
|
|
|
|
|
#else
|
|
|
|
|
char, '/', '/', '.'
|
|
|
|
|
#endif
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// value_type is the character type used by the operating system API to
|
|
|
|
|
// represent paths.
|
|
|
|
|
|
|
|
|
|
# ifdef BOOST_WINDOWS_API
|
|
|
|
|
typedef wchar_t value_type;
|
|
|
|
|
BOOST_STATIC_CONSTEXPR value_type separator = L'/';
|
|
|
|
|
BOOST_STATIC_CONSTEXPR value_type preferred_separator = L'\\';
|
|
|
|
|
BOOST_STATIC_CONSTEXPR value_type dot = L'.';
|
|
|
|
|
# else
|
|
|
|
|
typedef char value_type;
|
|
|
|
|
BOOST_STATIC_CONSTEXPR value_type separator = '/';
|
|
|
|
|
BOOST_STATIC_CONSTEXPR value_type preferred_separator = '/';
|
|
|
|
|
BOOST_STATIC_CONSTEXPR value_type dot = '.';
|
|
|
|
|
# endif
|
|
|
|
|
typedef std::basic_string<value_type> string_type;
|
|
|
|
|
typedef path_constants_base::value_type value_type;
|
|
|
|
|
typedef std::basic_string<value_type> string_type;
|
|
|
|
|
typedef std::codecvt<wchar_t, char,
|
|
|
|
|
std::mbstate_t> codecvt_type;
|
|
|
|
|
|
|
|
|
|
@@ -94,7 +115,7 @@ namespace filesystem
|
|
|
|
|
//
|
|
|
|
|
// 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,
|
|
|
|
|
@@ -103,7 +124,7 @@ namespace filesystem
|
|
|
|
|
// 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.
|
|
|
|
|
// differently, or format directory paths differently from file paths.
|
|
|
|
|
//
|
|
|
|
|
// **********************************************************************************
|
|
|
|
|
//
|
|
|
|
|
@@ -129,11 +150,11 @@ namespace filesystem
|
|
|
|
|
// "const codecvt_type& cvt=codecvt()" default arguments are not used because 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.
|
|
|
|
|
// as a result of such failues occur after main() has started, so can be caught.
|
|
|
|
|
|
|
|
|
|
// ----- constructors -----
|
|
|
|
|
|
|
|
|
|
path() BOOST_NOEXCEPT {}
|
|
|
|
|
path() BOOST_NOEXCEPT {}
|
|
|
|
|
path(const path& p) : m_pathname(p.m_pathname) {}
|
|
|
|
|
|
|
|
|
|
template <class Source>
|
|
|
|
|
@@ -154,7 +175,7 @@ namespace filesystem
|
|
|
|
|
// functions. GCC is not even consistent for the same release on different platforms.
|
|
|
|
|
|
|
|
|
|
# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
|
|
|
|
path(path&& p) BOOST_NOEXCEPT { m_pathname = std::move(p.m_pathname); }
|
|
|
|
|
path(path&& p) BOOST_NOEXCEPT : m_pathname(std::move(p.m_pathname)) {}
|
|
|
|
|
path& operator=(path&& p) BOOST_NOEXCEPT
|
|
|
|
|
{ m_pathname = std::move(p.m_pathname); return *this; }
|
|
|
|
|
# endif
|
|
|
|
|
@@ -167,7 +188,7 @@ namespace filesystem
|
|
|
|
|
|
|
|
|
|
template <class InputIterator>
|
|
|
|
|
path(InputIterator begin, InputIterator end)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
if (begin != end)
|
|
|
|
|
{
|
|
|
|
|
// convert requires contiguous string, so copy
|
|
|
|
|
@@ -179,7 +200,7 @@ namespace filesystem
|
|
|
|
|
|
|
|
|
|
template <class InputIterator>
|
|
|
|
|
path(InputIterator begin, InputIterator end, const codecvt_type& cvt)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
if (begin != end)
|
|
|
|
|
{
|
|
|
|
|
// convert requires contiguous string, so copy
|
|
|
|
|
@@ -241,7 +262,7 @@ namespace filesystem
|
|
|
|
|
|
|
|
|
|
template <class InputIterator>
|
|
|
|
|
path& assign(InputIterator begin, InputIterator end, const codecvt_type& cvt)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
m_pathname.clear();
|
|
|
|
|
if (begin != end)
|
|
|
|
|
{
|
|
|
|
|
@@ -271,7 +292,7 @@ namespace filesystem
|
|
|
|
|
path& operator+=(value_type c) { m_pathname += c; return *this; }
|
|
|
|
|
|
|
|
|
|
template <class CharT>
|
|
|
|
|
typename boost::enable_if<is_integral<CharT>, path&>::type
|
|
|
|
|
typename boost::enable_if<boost::is_integral<CharT>, path&>::type
|
|
|
|
|
operator+=(CharT c)
|
|
|
|
|
{
|
|
|
|
|
CharT tmp[2];
|
|
|
|
|
@@ -296,7 +317,7 @@ namespace filesystem
|
|
|
|
|
|
|
|
|
|
template <class InputIterator>
|
|
|
|
|
path& concat(InputIterator begin, InputIterator end)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
if (begin == end)
|
|
|
|
|
return *this;
|
|
|
|
|
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
|
|
|
|
|
@@ -307,7 +328,7 @@ namespace filesystem
|
|
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
@@ -321,7 +342,7 @@ namespace filesystem
|
|
|
|
|
// if a separator is added, it is the preferred separator for the platform;
|
|
|
|
|
// slash for POSIX, backslash for Windows
|
|
|
|
|
|
|
|
|
|
path& operator/=(const path& p);
|
|
|
|
|
BOOST_FILESYSTEM_DECL path& operator/=(const path& p);
|
|
|
|
|
|
|
|
|
|
template <class Source>
|
|
|
|
|
typename boost::enable_if<path_traits::is_pathable<
|
|
|
|
|
@@ -331,7 +352,7 @@ namespace filesystem
|
|
|
|
|
return append(source);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path& operator/=(const value_type* ptr);
|
|
|
|
|
BOOST_FILESYSTEM_DECL path& operator/=(const value_type* ptr);
|
|
|
|
|
path& operator/=(value_type* ptr)
|
|
|
|
|
{
|
|
|
|
|
return this->operator/=(const_cast<const value_type*>(ptr));
|
|
|
|
|
@@ -365,20 +386,19 @@ namespace filesystem
|
|
|
|
|
|
|
|
|
|
// ----- modifiers -----
|
|
|
|
|
|
|
|
|
|
void clear() BOOST_NOEXCEPT { m_pathname.clear(); }
|
|
|
|
|
path& make_preferred()
|
|
|
|
|
void clear() BOOST_NOEXCEPT { m_pathname.clear(); }
|
|
|
|
|
# ifdef BOOST_POSIX_API
|
|
|
|
|
{ return *this; } // POSIX no effect
|
|
|
|
|
path& make_preferred() { return *this; } // POSIX no effect
|
|
|
|
|
# else // BOOST_WINDOWS_API
|
|
|
|
|
; // change slashes to backslashes
|
|
|
|
|
BOOST_FILESYSTEM_DECL path& make_preferred(); // change slashes to backslashes
|
|
|
|
|
# endif
|
|
|
|
|
path& remove_filename();
|
|
|
|
|
path& remove_trailing_separator();
|
|
|
|
|
path& replace_extension(const path& new_extension = path());
|
|
|
|
|
void swap(path& rhs) BOOST_NOEXCEPT { m_pathname.swap(rhs.m_pathname); }
|
|
|
|
|
BOOST_FILESYSTEM_DECL path& remove_filename();
|
|
|
|
|
BOOST_FILESYSTEM_DECL path& remove_trailing_separator();
|
|
|
|
|
BOOST_FILESYSTEM_DECL path& replace_extension(const path& new_extension = path());
|
|
|
|
|
void swap(path& rhs) BOOST_NOEXCEPT { 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
|
|
|
|
|
@@ -413,45 +433,43 @@ namespace filesystem
|
|
|
|
|
{
|
|
|
|
|
std::string tmp;
|
|
|
|
|
if (!m_pathname.empty())
|
|
|
|
|
path_traits::convert(&*m_pathname.begin(), &*m_pathname.begin()+m_pathname.size(),
|
|
|
|
|
path_traits::convert(m_pathname.c_str(), m_pathname.c_str()+m_pathname.size(),
|
|
|
|
|
tmp);
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
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(),
|
|
|
|
|
path_traits::convert(m_pathname.c_str(), m_pathname.c_str()+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; }
|
|
|
|
|
|
|
|
|
|
// 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 // BOOST_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::string& string() const { return m_pathname; }
|
|
|
|
|
const std::string& string(const codecvt_type&) const { return m_pathname; }
|
|
|
|
|
|
|
|
|
|
const std::wstring wstring() const
|
|
|
|
|
const std::wstring wstring() const
|
|
|
|
|
{
|
|
|
|
|
std::wstring tmp;
|
|
|
|
|
if (!m_pathname.empty())
|
|
|
|
|
path_traits::convert(&*m_pathname.begin(), &*m_pathname.begin()+m_pathname.size(),
|
|
|
|
|
path_traits::convert(m_pathname.c_str(), m_pathname.c_str()+m_pathname.size(),
|
|
|
|
|
tmp);
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
const std::wstring wstring(const codecvt_type& cvt) const
|
|
|
|
|
{
|
|
|
|
|
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(),
|
|
|
|
|
path_traits::convert(m_pathname.c_str(), m_pathname.c_str()+m_pathname.size(),
|
|
|
|
|
tmp, cvt);
|
|
|
|
|
return tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
// ----- generic format observers -----
|
|
|
|
|
@@ -459,17 +477,11 @@ namespace filesystem
|
|
|
|
|
// Experimental generic function returning generic formatted path (i.e. separators
|
|
|
|
|
// are forward slashes). Motivation: simpler than a family of generic_*string
|
|
|
|
|
// functions.
|
|
|
|
|
path generic_path() const
|
|
|
|
|
{
|
|
|
|
|
# ifdef BOOST_WINDOWS_API
|
|
|
|
|
path tmp;
|
|
|
|
|
std::replace_copy(m_pathname.begin(), m_pathname.end(),
|
|
|
|
|
std::back_inserter(tmp.m_pathname), L'\\', L'/');
|
|
|
|
|
return tmp;
|
|
|
|
|
BOOST_FILESYSTEM_DECL path generic_path() const;
|
|
|
|
|
# else
|
|
|
|
|
return path(*this);
|
|
|
|
|
path generic_path() const { return path(*this); }
|
|
|
|
|
# endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class String>
|
|
|
|
|
String generic_string() const;
|
|
|
|
|
@@ -478,41 +490,39 @@ namespace filesystem
|
|
|
|
|
String generic_string(const codecvt_type& cvt) const;
|
|
|
|
|
|
|
|
|
|
# ifdef BOOST_WINDOWS_API
|
|
|
|
|
const std::string generic_string() const;
|
|
|
|
|
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(); };
|
|
|
|
|
|
|
|
|
|
const std::string generic_string() const { return generic_path().string(); }
|
|
|
|
|
const std::string generic_string(const codecvt_type& cvt) const { return generic_path().string(cvt); }
|
|
|
|
|
const std::wstring generic_wstring() const { return generic_path().wstring(); }
|
|
|
|
|
const std::wstring generic_wstring(const codecvt_type&) const { return generic_wstring(); }
|
|
|
|
|
# else // BOOST_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(); }
|
|
|
|
|
const std::wstring generic_wstring(const codecvt_type& cvt) const { return wstring(cvt); }
|
|
|
|
|
|
|
|
|
|
const std::wstring generic_wstring() const { return this->wstring(); }
|
|
|
|
|
const std::wstring generic_wstring(const codecvt_type& cvt) const { return this->wstring(cvt); }
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
// ----- compare -----
|
|
|
|
|
|
|
|
|
|
int compare(const path& p) const BOOST_NOEXCEPT; // generic, lexicographical
|
|
|
|
|
BOOST_FILESYSTEM_DECL int compare(const path& p) const BOOST_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
|
|
|
|
|
BOOST_FILESYSTEM_DECL path root_path() const;
|
|
|
|
|
BOOST_FILESYSTEM_DECL path root_name() const; // returns 0 or 1 element path
|
|
|
|
|
// even on POSIX, root_name() is non-empty() for network paths
|
|
|
|
|
BOOST_FILESYSTEM_DECL path root_directory() const; // returns 0 or 1 element path
|
|
|
|
|
BOOST_FILESYSTEM_DECL path relative_path() const;
|
|
|
|
|
BOOST_FILESYSTEM_DECL path parent_path() const;
|
|
|
|
|
BOOST_FILESYSTEM_DECL path filename() const; // returns 0 or 1 element path
|
|
|
|
|
BOOST_FILESYSTEM_DECL path stem() const; // returns 0 or 1 element path
|
|
|
|
|
BOOST_FILESYSTEM_DECL path extension() const; // returns 0 or 1 element path
|
|
|
|
|
|
|
|
|
|
// ----- query -----
|
|
|
|
|
|
|
|
|
|
bool empty() const BOOST_NOEXCEPT{ return m_pathname.empty(); }
|
|
|
|
|
bool empty() const BOOST_NOEXCEPT { return m_pathname.empty(); }
|
|
|
|
|
bool filename_is_dot() const;
|
|
|
|
|
bool filename_is_dot_dot() const;
|
|
|
|
|
bool has_root_path() const { return has_root_directory() || has_root_name(); }
|
|
|
|
|
@@ -523,7 +533,7 @@ namespace filesystem
|
|
|
|
|
bool has_filename() const { return !m_pathname.empty(); }
|
|
|
|
|
bool has_stem() const { return !stem().empty(); }
|
|
|
|
|
bool has_extension() const { return !extension().empty(); }
|
|
|
|
|
bool is_relative() const { return !is_absolute(); }
|
|
|
|
|
bool is_relative() const { return !is_absolute(); }
|
|
|
|
|
bool is_absolute() const
|
|
|
|
|
{
|
|
|
|
|
# ifdef BOOST_WINDOWS_API
|
|
|
|
|
@@ -535,9 +545,9 @@ namespace filesystem
|
|
|
|
|
|
|
|
|
|
// ----- lexical operations -----
|
|
|
|
|
|
|
|
|
|
path lexically_normal() const;
|
|
|
|
|
path lexically_relative(const path& base) const;
|
|
|
|
|
path lexically_proximate(const path& base) const
|
|
|
|
|
BOOST_FILESYSTEM_DECL path lexically_normal() const;
|
|
|
|
|
BOOST_FILESYSTEM_DECL path lexically_relative(const path& base) const;
|
|
|
|
|
path lexically_proximate(const path& base) const
|
|
|
|
|
{
|
|
|
|
|
path tmp(lexically_relative(base));
|
|
|
|
|
return tmp.empty() ? *this : tmp;
|
|
|
|
|
@@ -550,15 +560,15 @@ namespace filesystem
|
|
|
|
|
class reverse_iterator;
|
|
|
|
|
typedef reverse_iterator const_reverse_iterator;
|
|
|
|
|
|
|
|
|
|
iterator begin() const;
|
|
|
|
|
iterator end() const;
|
|
|
|
|
BOOST_FILESYSTEM_DECL iterator begin() const;
|
|
|
|
|
BOOST_FILESYSTEM_DECL iterator end() const;
|
|
|
|
|
reverse_iterator rbegin() const;
|
|
|
|
|
reverse_iterator rend() const;
|
|
|
|
|
|
|
|
|
|
// ----- static member functions -----
|
|
|
|
|
|
|
|
|
|
static std::locale imbue(const std::locale& loc);
|
|
|
|
|
static const codecvt_type& codecvt();
|
|
|
|
|
static BOOST_FILESYSTEM_DECL std::locale imbue(const std::locale& loc);
|
|
|
|
|
static BOOST_FILESYSTEM_DECL const codecvt_type& codecvt();
|
|
|
|
|
|
|
|
|
|
// ----- deprecated functions -----
|
|
|
|
|
|
|
|
|
|
@@ -568,7 +578,7 @@ namespace filesystem
|
|
|
|
|
|
|
|
|
|
# if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
|
|
|
|
|
// recently deprecated functions supplied by default
|
|
|
|
|
path& normalize() {
|
|
|
|
|
path& normalize() {
|
|
|
|
|
path tmp(lexically_normal());
|
|
|
|
|
m_pathname.swap(tmp.m_pathname);
|
|
|
|
|
return *this;
|
|
|
|
|
@@ -584,7 +594,7 @@ namespace filesystem
|
|
|
|
|
|
|
|
|
|
# if defined(BOOST_FILESYSTEM_DEPRECATED)
|
|
|
|
|
// deprecated functions with enough signature or semantic changes that they are
|
|
|
|
|
// not supplied by default
|
|
|
|
|
// 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(); }
|
|
|
|
|
@@ -597,7 +607,7 @@ namespace filesystem
|
|
|
|
|
//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 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();
|
|
|
|
|
@@ -625,25 +635,23 @@ namespace filesystem
|
|
|
|
|
// slashes NOT converted to backslashes
|
|
|
|
|
# if defined(_MSC_VER)
|
|
|
|
|
# pragma warning(pop) // restore warning settings.
|
|
|
|
|
# endif
|
|
|
|
|
# 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.
|
|
|
|
|
BOOST_FILESYSTEM_DECL string_type::size_type m_append_separator_if_needed();
|
|
|
|
|
|
|
|
|
|
void m_erase_redundant_separator(string_type::size_type sep_pos);
|
|
|
|
|
string_type::size_type m_parent_path_end() const;
|
|
|
|
|
|
|
|
|
|
path& m_normalize();
|
|
|
|
|
BOOST_FILESYSTEM_DECL void m_erase_redundant_separator(string_type::size_type sep_pos);
|
|
|
|
|
BOOST_FILESYSTEM_DECL string_type::size_type m_parent_path_end() const;
|
|
|
|
|
|
|
|
|
|
// Was qualified; como433beta8 reports:
|
|
|
|
|
// warning #427-D: qualified name is not allowed in member declaration
|
|
|
|
|
// 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);
|
|
|
|
|
static BOOST_FILESYSTEM_DECL void m_path_iterator_increment(path::iterator& it);
|
|
|
|
|
static BOOST_FILESYSTEM_DECL void m_path_iterator_decrement(path::iterator& it);
|
|
|
|
|
|
|
|
|
|
}; // class path
|
|
|
|
|
|
|
|
|
|
@@ -665,7 +673,7 @@ namespace filesystem
|
|
|
|
|
//------------------------------------------------------------------------------------//
|
|
|
|
|
// class path::iterator //
|
|
|
|
|
//------------------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class path::iterator
|
|
|
|
|
: public boost::iterator_facade<
|
|
|
|
|
path::iterator,
|
|
|
|
|
@@ -697,14 +705,14 @@ namespace filesystem
|
|
|
|
|
// 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
|
|
|
|
|
// end() iterator is indicated by
|
|
|
|
|
// m_pos == m_path_ptr->m_pathname.size()
|
|
|
|
|
}; // path::iterator
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------//
|
|
|
|
|
// class path::reverse_iterator //
|
|
|
|
|
//------------------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class path::reverse_iterator
|
|
|
|
|
: public boost::iterator_facade<
|
|
|
|
|
path::reverse_iterator,
|
|
|
|
|
@@ -712,12 +720,12 @@ namespace filesystem
|
|
|
|
|
boost::bidirectional_traversal_tag >
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
explicit reverse_iterator(iterator itr) : m_itr(itr)
|
|
|
|
|
{
|
|
|
|
|
if (itr != itr.m_path_ptr->begin())
|
|
|
|
|
m_element = *--itr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
friend class boost::iterator_core_access;
|
|
|
|
|
friend class boost::filesystem::path;
|
|
|
|
|
@@ -725,7 +733,7 @@ namespace filesystem
|
|
|
|
|
const path& dereference() const { return m_element; }
|
|
|
|
|
bool equal(const reverse_iterator& rhs) const { return m_itr == rhs.m_itr; }
|
|
|
|
|
void increment()
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
--m_itr;
|
|
|
|
|
if (m_itr != m_itr.m_path_ptr->begin())
|
|
|
|
|
{
|
|
|
|
|
@@ -750,20 +758,20 @@ namespace filesystem
|
|
|
|
|
// //
|
|
|
|
|
//------------------------------------------------------------------------------------//
|
|
|
|
|
|
|
|
|
|
// std::lexicographical_compare would infinately recurse because path iterators
|
|
|
|
|
// std::lexicographical_compare would infinitely 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& 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& 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;}
|
|
|
|
|
@@ -780,16 +788,19 @@ namespace filesystem
|
|
|
|
|
# ifdef BOOST_WINDOWS_API
|
|
|
|
|
std::size_t seed = 0;
|
|
|
|
|
for(const path::value_type* it = x.c_str(); *it; ++it)
|
|
|
|
|
hash_combine(seed, *it == '/' ? L'\\' : *it);
|
|
|
|
|
hash_combine(seed, *it == L'/' ? L'\\' : *it);
|
|
|
|
|
return seed;
|
|
|
|
|
# else // BOOST_POSIX_API
|
|
|
|
|
return hash_range(x.native().begin(), x.native().end());
|
|
|
|
|
# endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void swap(path& lhs, path& rhs) { lhs.swap(rhs); }
|
|
|
|
|
inline void swap(path& lhs, path& rhs) BOOST_NOEXCEPT { lhs.swap(rhs); }
|
|
|
|
|
|
|
|
|
|
inline path operator/(const path& lhs, const path& rhs) { return path(lhs) /= rhs; }
|
|
|
|
|
inline path operator/(const path& lhs, const path& rhs) { return path(lhs) /= rhs; }
|
|
|
|
|
# if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
|
|
|
|
inline path&& operator/(path&& lhs, const path& rhs) { lhs /= rhs; return std::move(lhs); }
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
// inserters and extractors
|
|
|
|
|
// use boost::io::quoted() to handle spaces in paths
|
|
|
|
|
@@ -802,7 +813,7 @@ namespace filesystem
|
|
|
|
|
return os
|
|
|
|
|
<< boost::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)
|
|
|
|
|
@@ -812,7 +823,7 @@ namespace filesystem
|
|
|
|
|
p = str;
|
|
|
|
|
return is;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// name_checks
|
|
|
|
|
|
|
|
|
|
// These functions are holdovers from version 1. It isn't clear they have much
|
|
|
|
|
@@ -860,7 +871,7 @@ namespace filesystem
|
|
|
|
|
inline bool path::filename_is_dot() const
|
|
|
|
|
{
|
|
|
|
|
// implicit dot is tricky, so actually call filename(); see path::filename() example
|
|
|
|
|
// in reference.html
|
|
|
|
|
// in reference.html
|
|
|
|
|
path p(filename());
|
|
|
|
|
return p.size() == 1 && *p.c_str() == dot;
|
|
|
|
|
}
|
|
|
|
|
@@ -872,7 +883,7 @@ namespace filesystem
|
|
|
|
|
// use detail::is_element_separator() rather than detail::is_directory_separator
|
|
|
|
|
// to deal with "c:.." edge case on Windows when ':' acts as a separator
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------//
|
|
|
|
|
// class path member template implementation //
|
|
|
|
|
//--------------------------------------------------------------------------------------//
|
|
|
|
|
@@ -993,7 +1004,7 @@ namespace path_traits
|
|
|
|
|
void convert(const char* from,
|
|
|
|
|
std::wstring & to)
|
|
|
|
|
{
|
|
|
|
|
BOOST_ASSERT(from);
|
|
|
|
|
BOOST_ASSERT(!!from);
|
|
|
|
|
convert(from, 0, to, path::codecvt());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1001,7 +1012,7 @@ namespace path_traits
|
|
|
|
|
void convert(const wchar_t* from,
|
|
|
|
|
std::string & to)
|
|
|
|
|
{
|
|
|
|
|
BOOST_ASSERT(from);
|
|
|
|
|
BOOST_ASSERT(!!from);
|
|
|
|
|
convert(from, 0, to, path::codecvt());
|
|
|
|
|
}
|
|
|
|
|
} // namespace path_traits
|
|
|
|
|
|