Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
// boost/filesystem/config.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_CONFIGX_HPP
#define BOOST_FILESYSTEM_CONFIGX_HPP
#include <boost/config.hpp> // for <boost/config/user.hpp>, in case
// BOOST_FILESYSTEM_VERSION defined there
# if defined(BOOST_FILESYSTEM_VERSION) \
&& BOOST_FILESYSTEM_VERSION != 2 && BOOST_FILESYSTEM_VERSION != 3
# error BOOST_FILESYSTEM_VERSION defined, but not as 2 or 3
# endif
# if !defined(BOOST_FILESYSTEM_VERSION)
# define BOOST_FILESYSTEM_VERSION 3
# endif
#if BOOST_FILESYSTEM_VERSION == 2
# include <boost/filesystem/v2/config.hpp>
# else
# include <boost/filesystem/v3/config.hpp>
# endif
#endif // BOOST_FILESYSTEM_CONFIGX_HPP

View File

@@ -0,0 +1,35 @@
// boost/filesystem/convenience.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_CONVENIENCEX_HPP
#define BOOST_FILESYSTEM_CONVENIENCEX_HPP
#include <boost/config.hpp> // for <boost/config/user.hpp>, in case
// BOOST_FILESYSTEM_VERSION defined there
# if defined(BOOST_FILESYSTEM_VERSION) \
&& BOOST_FILESYSTEM_VERSION != 2 && BOOST_FILESYSTEM_VERSION != 3
# error BOOST_FILESYSTEM_VERSION defined, but not as 2 or 3
# endif
# if !defined(BOOST_FILESYSTEM_VERSION)
# define BOOST_FILESYSTEM_VERSION 3
# endif
#if BOOST_FILESYSTEM_VERSION == 2
# include <boost/filesystem/v2/convenience.hpp>
# else
# include <boost/filesystem/v3/convenience.hpp>
# endif
#endif // BOOST_FILESYSTEM_CONVENIENCEX_HPP

View File

@@ -0,0 +1,24 @@
// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
// Distributed under the Boost Software License, Version 1.0.
// (See http://www.boost.org/LICENSE_1_0.txt)
#ifndef 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,35 @@
// boost/filesystem/exception.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_EXCEPTIONX_HPP
#define BOOST_FILESYSTEM_EXCEPTIONX_HPP
#include <boost/config.hpp> // for <boost/config/user.hpp>, in case
// BOOST_FILESYSTEM_VERSION defined there
# if defined(BOOST_FILESYSTEM_VERSION) \
&& BOOST_FILESYSTEM_VERSION != 2 && BOOST_FILESYSTEM_VERSION != 3
# error BOOST_FILESYSTEM_VERSION defined, but not as 2 or 3
# endif
# if !defined(BOOST_FILESYSTEM_VERSION)
# define BOOST_FILESYSTEM_VERSION 3
# endif
#if BOOST_FILESYSTEM_VERSION == 2
# include <boost/filesystem/v2/exception.hpp>
# else
# include <boost/filesystem/v3/exception.hpp>
# endif
#endif // BOOST_FILESYSTEM_EXCEPTIONX_HPP

View File

@@ -0,0 +1,35 @@
// boost/filesystem/fstream.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_FSTREAMX_HPP
#define BOOST_FILESYSTEM_FSTREAMX_HPP
#include <boost/config.hpp> // for <boost/config/user.hpp>, in case
// BOOST_FILESYSTEM_VERSION defined there
# if defined(BOOST_FILESYSTEM_VERSION) \
&& BOOST_FILESYSTEM_VERSION != 2 && BOOST_FILESYSTEM_VERSION != 3
# error BOOST_FILESYSTEM_VERSION defined, but not as 2 or 3
# endif
# if !defined(BOOST_FILESYSTEM_VERSION)
# define BOOST_FILESYSTEM_VERSION 3
# endif
#if BOOST_FILESYSTEM_VERSION == 2
# include <boost/filesystem/v2/fstream.hpp>
# else
# include <boost/filesystem/v3/fstream.hpp>
# endif
#endif // BOOST_FILESYSTEM_FSTREAMX_HPP

View File

@@ -0,0 +1,35 @@
// boost/filesystem/operations.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_OPERATIONSX_HPP
#define BOOST_FILESYSTEM_OPERATIONSX_HPP
#include <boost/config.hpp> // for <boost/config/user.hpp>, in case
// BOOST_FILESYSTEM_VERSION defined there
# if defined(BOOST_FILESYSTEM_VERSION) \
&& BOOST_FILESYSTEM_VERSION != 2 && BOOST_FILESYSTEM_VERSION != 3
# error BOOST_FILESYSTEM_VERSION defined, but not as 2 or 3
# endif
# if !defined(BOOST_FILESYSTEM_VERSION)
# define BOOST_FILESYSTEM_VERSION 3
# endif
#if BOOST_FILESYSTEM_VERSION == 2
# include <boost/filesystem/v2/operations.hpp>
# else
# include <boost/filesystem/v3/operations.hpp>
# endif
#endif // BOOST_FILESYSTEM_OPERATIONSX_HPP

35
test/external/boost/filesystem/path.hpp vendored Normal file
View File

@@ -0,0 +1,35 @@
// boost/filesystem/path.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_PATHX_HPP
#define BOOST_FILESYSTEM_PATHX_HPP
#include <boost/config.hpp> // for <boost/config/user.hpp>, in case
// BOOST_FILESYSTEM_VERSION defined there
# if defined(BOOST_FILESYSTEM_VERSION) \
&& BOOST_FILESYSTEM_VERSION != 2 && BOOST_FILESYSTEM_VERSION != 3
# error BOOST_FILESYSTEM_VERSION defined, but not as 2 or 3
# endif
# if !defined(BOOST_FILESYSTEM_VERSION)
# define BOOST_FILESYSTEM_VERSION 3
# endif
#if BOOST_FILESYSTEM_VERSION == 2
# include <boost/filesystem/v2/path.hpp>
# else
# include <boost/filesystem/v3/path.hpp>
# endif
#endif // BOOST_FILESYSTEM_PATHX_HPP

View File

@@ -0,0 +1,106 @@
// boost/filesystem/v2/config.hpp ------------------------------------------//
// Copyright Beman Dawes 2003
// 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)
// See library home page at http://www.boost.org/libs/filesystem
//----------------------------------------------------------------------------//
#ifndef BOOST_FILESYSTEM2_CONFIG_HPP
#define BOOST_FILESYSTEM2_CONFIG_HPP
# if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION != 2
# error Compiling Filesystem version 2 file with BOOST_FILESYSTEM_VERSION defined != 2
# endif
# if !defined(BOOST_FILESYSTEM_VERSION)
# define BOOST_FILESYSTEM_VERSION 2
# endif
#define BOOST_FILESYSTEM_I18N // aid users wishing to compile several versions
// ability to change namespace aids path_table.cpp ------------------------//
#ifndef BOOST_FILESYSTEM2_NAMESPACE
# define BOOST_FILESYSTEM2_NAMESPACE filesystem2
#endif
#include <boost/config.hpp>
#include <boost/system/api_config.hpp> // for BOOST_POSIX_API or BOOST_WINDOWS_API
#include <boost/detail/workaround.hpp>
// BOOST_POSIX_PATH or BOOST_WINDOWS_PATH specify which path syntax to recognise
# if defined(BOOST_WINDOWS_API) && defined(BOOST_POSIX_PATH)
# error builds with Windows API do not support BOOST_POSIX_PATH
# endif
# if !defined(_WIN32) && !defined(__CYGWIN__) && defined(BOOST_WINDOWS_PATH)
# error builds on non-Windows platforms do not support BOOST_WINDOWS_PATH
# endif
# if defined(BOOST_WINDOWS_PATH) && defined(BOOST_POSIX_PATH)
# error both BOOST_WINDOWS_PATH and BOOST_POSIX_PATH are defined
# elif !defined(BOOST_WINDOWS_PATH) && !defined(BOOST_POSIX_PATH)
# if !defined(BOOST_POSIX_PATH) && (defined(_WIN32) || defined(__CYGWIN__))
# define BOOST_WINDOWS_PATH
# else
# define BOOST_POSIX_PATH
# endif
# 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
// narrow support only for badly broken compilers or libraries -------------//
# if defined(BOOST_NO_STD_WSTRING) || defined(BOOST_NO_SFINAE) || defined(BOOST_NO_STD_LOCALE) || BOOST_WORKAROUND(__BORLANDC__, <0x610)
# define BOOST_FILESYSTEM2_NARROW_ONLY
# endif
// This header implements separate compilation features as described in
// http://www.boost.org/more/separate_compilation.html
// 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_FILESYSTEM2_CONFIG_HPP

View File

@@ -0,0 +1,339 @@
// 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_FILESYSTEM2_CONVENIENCE_HPP
#define BOOST_FILESYSTEM2_CONVENIENCE_HPP
#include <boost/filesystem/v2/config.hpp>
#include <boost/filesystem/v2/operations.hpp>
#include <boost/system/error_code.hpp>
#include <vector>
#include <stack>
#include <boost/config/abi_prefix.hpp> // must be the last #include
# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
# define BOOST_FS_FUNC(BOOST_FS_TYPE) \
template<class Path> typename boost::enable_if<is_basic_path<Path>, \
BOOST_FS_TYPE>::type
# define BOOST_FS_FUNC_STRING BOOST_FS_FUNC(typename Path::string_type)
# define BOOST_FS_TYPENAME typename
# else
# define BOOST_FS_FUNC(BOOST_FS_TYPE) inline BOOST_FS_TYPE
typedef boost::filesystem::path Path;
# define BOOST_FS_FUNC_STRING inline std::string
# define BOOST_FS_TYPENAME
# endif
namespace boost
{
namespace filesystem2
{
BOOST_FS_FUNC(bool) create_directories(const Path& ph)
{
if (ph.empty() || exists(ph))
{
if ( !ph.empty() && !is_directory(ph) )
boost::throw_exception( basic_filesystem_error<Path>(
"boost::filesystem::create_directories", ph,
make_error_code( boost::system::errc::file_exists ) ) );
return false;
}
// First create branch, by calling ourself recursively
create_directories(ph.parent_path());
// Now that parent's path exists, create the directory
create_directory(ph);
return true;
}
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
BOOST_FS_FUNC_STRING extension(const Path& ph)
{
typedef BOOST_FS_TYPENAME Path::string_type string_type;
string_type filename = ph.filename();
BOOST_FS_TYPENAME string_type::size_type n = filename.rfind('.');
if (n != string_type::npos)
return filename.substr(n);
else
return string_type();
}
BOOST_FS_FUNC_STRING basename(const Path& ph)
{
typedef BOOST_FS_TYPENAME Path::string_type string_type;
string_type filename = ph.filename();
BOOST_FS_TYPENAME string_type::size_type n = filename.rfind('.');
return filename.substr(0, n);
}
BOOST_FS_FUNC(Path) change_extension( const Path & ph,
const BOOST_FS_TYPENAME Path::string_type & new_extension )
{
# if !defined(_STLPORT_VERSION)
return ph.parent_path() / (basename(ph) + new_extension);
# else
typedef BOOST_FS_TYPENAME Path::string_type string_type;
string_type filename = basename(ph) + new_extension;
return ph.parent_path() / filename;
# endif
}
# endif
# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
// "do-the-right-thing" overloads ---------------------------------------//
inline bool create_directories(const path& ph)
{ return create_directories<path>(ph); }
inline bool create_directories(const wpath& ph)
{ return create_directories<wpath>(ph); }
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
inline std::string extension(const path& ph)
{ return extension<path>(ph); }
inline std::wstring extension(const wpath& ph)
{ return extension<wpath>(ph); }
inline std::string basename(const path& ph)
{ return basename<path>( ph ); }
inline std::wstring basename(const wpath& ph)
{ return basename<wpath>( ph ); }
inline path change_extension( const path & ph, const std::string& new_ex )
{ return change_extension<path>( ph, new_ex ); }
inline wpath change_extension( const wpath & ph, const std::wstring& new_ex )
{ return change_extension<wpath>( ph, new_ex ); }
# endif
# endif
// basic_recursive_directory_iterator helpers --------------------------//
namespace detail
{
template< class Path >
struct recur_dir_itr_imp
{
typedef basic_directory_iterator< Path > element_type;
std::stack< element_type, std::vector< element_type > > m_stack;
int m_level;
bool m_no_push;
bool m_no_throw;
recur_dir_itr_imp() : m_level(0), m_no_push(false), m_no_throw(false) {}
};
} // namespace detail
// basic_recursive_directory_iterator ----------------------------------//
template< class Path >
class basic_recursive_directory_iterator
: public boost::iterator_facade<
basic_recursive_directory_iterator<Path>,
basic_directory_entry<Path>,
boost::single_pass_traversal_tag >
{
public:
typedef Path path_type;
basic_recursive_directory_iterator(){} // creates the "end" iterator
explicit basic_recursive_directory_iterator( const Path & dir_path );
basic_recursive_directory_iterator( const Path & dir_path,
system::error_code & ec );
int level() const { return m_imp->m_level; }
void pop();
void no_push()
{
BOOST_ASSERT( m_imp.get() && "attempt to no_push() on end iterator" );
m_imp->m_no_push = true;
}
file_status status() const
{
BOOST_ASSERT( m_imp.get()
&& "attempt to call status() on end recursive_iterator" );
return m_imp->m_stack.top()->status();
}
file_status symlink_status() const
{
BOOST_ASSERT( m_imp.get()
&& "attempt to call symlink_status() on end recursive_iterator" );
return m_imp->m_stack.top()->symlink_status();
}
private:
// shared_ptr provides shallow-copy semantics required for InputIterators.
// m_imp.get()==0 indicates the end iterator.
boost::shared_ptr< detail::recur_dir_itr_imp< Path > > m_imp;
friend class boost::iterator_core_access;
typename boost::iterator_facade<
basic_recursive_directory_iterator<Path>,
basic_directory_entry<Path>,
boost::single_pass_traversal_tag >::reference
dereference() const
{
BOOST_ASSERT( m_imp.get() && "attempt to dereference end iterator" );
return *m_imp->m_stack.top();
}
void increment();
bool equal( const basic_recursive_directory_iterator & rhs ) const
{ return m_imp == rhs.m_imp; }
};
typedef basic_recursive_directory_iterator<path> recursive_directory_iterator;
# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
typedef basic_recursive_directory_iterator<wpath> wrecursive_directory_iterator;
# endif
// basic_recursive_directory_iterator implementation -------------------//
// constructors
template<class Path>
basic_recursive_directory_iterator<Path>::
basic_recursive_directory_iterator( const Path & dir_path )
: m_imp( new detail::recur_dir_itr_imp<Path> )
{
m_imp->m_stack.push( basic_directory_iterator<Path>( dir_path ) );
if ( m_imp->m_stack.top () == basic_directory_iterator<Path>() )
{ m_imp.reset (); }
}
template<class Path>
basic_recursive_directory_iterator<Path>::
basic_recursive_directory_iterator( const Path & dir_path,
system::error_code & ec )
: m_imp( new detail::recur_dir_itr_imp<Path> )
{
m_imp->m_no_throw = true;
m_imp->m_stack.push( basic_directory_iterator<Path>( dir_path, ec ) );
if ( m_imp->m_stack.top () == basic_directory_iterator<Path>() )
{ m_imp.reset (); }
}
// increment
template<class Path>
void basic_recursive_directory_iterator<Path>::increment()
{
BOOST_ASSERT( m_imp.get() && "increment on end iterator" );
static const basic_directory_iterator<Path> end_itr;
if ( m_imp->m_no_push )
{ m_imp->m_no_push = false; }
else if ( is_directory( m_imp->m_stack.top()->status() ) )
{
system::error_code ec;
#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x610))
if( m_imp->m_no_throw ) {
m_imp->m_stack.push(
basic_directory_iterator<Path>( *m_imp->m_stack.top(), ec )
);
}
else {
m_imp->m_stack.push(
basic_directory_iterator<Path>( *m_imp->m_stack.top() )
);
}
#else
m_imp->m_stack.push(
m_imp->m_no_throw
? basic_directory_iterator<Path>( *m_imp->m_stack.top(), ec )
: basic_directory_iterator<Path>( *m_imp->m_stack.top() ) );
#endif
if ( m_imp->m_stack.top() != end_itr )
{
++m_imp->m_level;
return;
}
m_imp->m_stack.pop();
}
while ( !m_imp->m_stack.empty()
&& ++m_imp->m_stack.top() == end_itr )
{
m_imp->m_stack.pop();
--m_imp->m_level;
}
if ( m_imp->m_stack.empty() ) m_imp.reset(); // done, so make end iterator
}
// pop
template<class Path>
void basic_recursive_directory_iterator<Path>::pop()
{
BOOST_ASSERT( m_imp.get() && "pop on end iterator" );
BOOST_ASSERT( m_imp->m_level > 0 && "pop with level < 1" );
static const basic_directory_iterator<Path> end_itr;
do
{
m_imp->m_stack.pop();
--m_imp->m_level;
}
while ( !m_imp->m_stack.empty()
&& ++m_imp->m_stack.top() == end_itr );
if ( m_imp->m_stack.empty() ) m_imp.reset(); // done, so make end iterator
}
} // namespace filesystem2
} // namespace boost
#undef BOOST_FS_FUNC_STRING
#undef BOOST_FS_FUNC
//----------------------------------------------------------------------------//
namespace boost
{
namespace filesystem
{
using filesystem2::create_directories;
using filesystem2::basic_recursive_directory_iterator;
using filesystem2::recursive_directory_iterator;
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
using filesystem2::extension;
using filesystem2::basename;
using filesystem2::change_extension;
# endif
# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
using filesystem2::wrecursive_directory_iterator;
# endif
}
}
//----------------------------------------------------------------------------//
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
#endif // BOOST_FILESYSTEM2_CONVENIENCE_HPP

View File

@@ -0,0 +1,9 @@
// boost/filesystem/exception.hpp -------------------------------------------//
// Copyright Beman Dawes 2003
// 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)
// This header is no long used. The contents have been moved to path.hpp.
// It is provided so that user code #includes do not have to be changed.

View File

@@ -0,0 +1,613 @@
// boost/filesystem/fstream.hpp --------------------------------------------//
// Copyright Beman Dawes 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_FILESYSTEM2_FSTREAM_HPP
#define BOOST_FILESYSTEM2_FSTREAM_HPP
#include <boost/filesystem/v2/config.hpp>
#include <boost/filesystem/v2/operations.hpp> // for 8.3 hack (see below)
#include <boost/utility/enable_if.hpp>
#include <boost/detail/workaround.hpp>
#include <iosfwd>
#include <fstream>
#include <boost/config/abi_prefix.hpp> // must be the last #include
// NOTE: fstream.hpp for Boost 1.32.0 and earlier supplied workarounds for
// various compiler problems. They have been removed to ease development of the
// basic i18n functionality. Once the new interface is stable, the workarounds
// will be reinstated for any compilers that otherwise can support the rest of
// the library after internationalization.
namespace boost
{
namespace filesystem2
{
namespace detail
{
# if defined(BOOST_WINDOWS_API) && !defined(BOOST_FILESYSTEM2_NARROW_ONLY)
# if !defined(BOOST_DINKUMWARE_STDLIB) || BOOST_DINKUMWARE_STDLIB < 405
// The 8.3 hack:
// C++98 does not supply a wchar_t open, so try to get an equivalent
// narrow char name based on the short, so-called 8.3, name.
// Not needed for Dinkumware 405 and later as they do supply wchar_t open.
BOOST_FILESYSTEM_DECL bool create_file_api( const std::wstring & ph,
std::ios_base::openmode mode ); // true if succeeds
BOOST_FILESYSTEM_DECL std::string narrow_path_api(
const std::wstring & ph ); // return is empty if fails
inline std::string path_proxy( const std::wstring & file_ph,
std::ios_base::openmode mode )
// Return a non-existant path if cannot supply narrow short path.
// An empty path doesn't work because some Dinkumware versions
// assert the path is non-empty.
{
std::string narrow_ph;
bool created_file( false );
if ( !exists( file_ph )
&& (mode & std::ios_base::out) != 0
&& create_file_api( file_ph, mode ) )
{
created_file = true;
}
narrow_ph = narrow_path_api( file_ph );
if ( narrow_ph.empty() )
{
if ( created_file ) remove_api( file_ph );
narrow_ph = "\x01";
}
return narrow_ph;
}
# else
// Dinkumware 405 and later does supply wchar_t functions
inline const std::wstring & path_proxy( const std::wstring & file_ph,
std::ios_base::openmode )
{ return file_ph; }
# endif
# endif
inline const std::string & path_proxy( const std::string & file_ph,
std::ios_base::openmode )
{ return file_ph; }
} // namespace detail
template < class charT, class traits = std::char_traits<charT> >
class basic_filebuf : public std::basic_filebuf<charT,traits>
{
private: // disallow copying
basic_filebuf( const basic_filebuf & );
const basic_filebuf & operator=( const basic_filebuf & );
public:
basic_filebuf() {}
virtual ~basic_filebuf() {}
# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
template<class Path>
typename boost::enable_if<is_basic_path<Path>,
basic_filebuf<charT,traits> *>::type
open( const Path & file_ph, std::ios_base::openmode mode );
basic_filebuf<charT,traits> *
open( const wpath & file_ph, std::ios_base::openmode mode );
# endif
# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
basic_filebuf<charT,traits> *
open( const path & file_ph, std::ios_base::openmode mode );
# endif
};
template < class charT, class traits = std::char_traits<charT> >
class basic_ifstream : public std::basic_ifstream<charT,traits>
{
private: // disallow copying
basic_ifstream( const basic_ifstream & );
const basic_ifstream & operator=( const basic_ifstream & );
public:
basic_ifstream() {}
// use two signatures, rather than one signature with default second
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
template<class Path>
explicit basic_ifstream( const Path & file_ph,
typename boost::enable_if<is_basic_path<Path> >::type* dummy = 0 );
template<class Path>
basic_ifstream( const Path & file_ph, std::ios_base::openmode mode,
typename boost::enable_if<is_basic_path<Path> >::type* dummy = 0 );
template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
open( const Path & file_ph );
template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
open( const Path & file_ph, std::ios_base::openmode mode );
explicit basic_ifstream( const wpath & file_ph );
basic_ifstream( const wpath & file_ph, std::ios_base::openmode mode );
void open( const wpath & file_ph );
void open( const wpath & file_ph, std::ios_base::openmode mode );
# endif
explicit basic_ifstream( const path & file_ph );
basic_ifstream( const path & file_ph, std::ios_base::openmode mode );
# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
void open( const path & file_ph );
void open( const path & file_ph, std::ios_base::openmode mode );
# endif
virtual ~basic_ifstream() {}
};
template < class charT, class traits = std::char_traits<charT> >
class basic_ofstream : public std::basic_ofstream<charT,traits>
{
private: // disallow copying
basic_ofstream( const basic_ofstream & );
const basic_ofstream & operator=( const basic_ofstream & );
public:
basic_ofstream() {}
// use two signatures, rather than one signature with default second
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
template<class Path>
explicit basic_ofstream( const Path & file_ph,
typename boost::enable_if<is_basic_path<Path> >::type* dummy = 0 );
explicit basic_ofstream( const wpath & file_ph );
template<class Path>
basic_ofstream( const Path & file_ph, std::ios_base::openmode mode,
typename boost::enable_if<is_basic_path<Path> >::type* dummy = 0 );
basic_ofstream( const wpath & file_ph, std::ios_base::openmode mode );
template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
open( const Path & file_ph );
void open( const wpath & file_ph );
template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
open( const Path & file_ph, std::ios_base::openmode mode );
void open( const wpath & file_ph, std::ios_base::openmode mode );
# endif
explicit basic_ofstream( const path & file_ph );
basic_ofstream( const path & file_ph, std::ios_base::openmode mode );
# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
void open( const path & file_ph );
void open( const path & file_ph, std::ios_base::openmode mode );
# endif
virtual ~basic_ofstream() {}
};
template < class charT, class traits = std::char_traits<charT> >
class basic_fstream : public std::basic_fstream<charT,traits>
{
private: // disallow copying
basic_fstream( const basic_fstream & );
const basic_fstream & operator=( const basic_fstream & );
public:
basic_fstream() {}
// use two signatures, rather than one signature with default second
// argument, to workaround VC++ 7.1 bug (ID VSWhidbey 38416)
# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
template<class Path>
explicit basic_fstream( const Path & file_ph,
typename boost::enable_if<is_basic_path<Path> >::type* dummy = 0 );
explicit basic_fstream( const wpath & file_ph );
template<class Path>
basic_fstream( const Path & file_ph, std::ios_base::openmode mode,
typename boost::enable_if<is_basic_path<Path> >::type* dummy = 0 );
basic_fstream( const wpath & file_ph, std::ios_base::openmode mode );
template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
open( const Path & file_ph );
void open( const wpath & file_ph );
template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
open( const Path & file_ph, std::ios_base::openmode mode );
void open( const wpath & file_ph, std::ios_base::openmode mode );
# endif
explicit basic_fstream( const path & file_ph );
basic_fstream( const path & file_ph, std::ios_base::openmode mode );
# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
void open( const path & file_ph );
void open( const path & file_ph, std::ios_base::openmode mode );
# endif
virtual ~basic_fstream() {}
};
typedef basic_filebuf<char> filebuf;
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;
typedef basic_fstream<char> fstream;
# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
typedef basic_filebuf<wchar_t> wfilebuf;
typedef basic_ifstream<wchar_t> wifstream;
typedef basic_fstream<wchar_t> wfstream;
typedef basic_ofstream<wchar_t> wofstream;
# endif
# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
// basic_filebuf definitions -----------------------------------------------//
template <class charT, class traits>
template<class Path>
typename boost::enable_if<is_basic_path<Path>,
basic_filebuf<charT,traits> *>::type
basic_filebuf<charT,traits>::open( const Path & file_ph,
std::ios_base::openmode mode )
{
return (std::basic_filebuf<charT,traits>::open( detail::path_proxy(
file_ph.external_file_string(), mode ).c_str(), mode )
== 0) ? 0 : this;
}
template <class charT, class traits>
basic_filebuf<charT,traits> *
basic_filebuf<charT, traits>::open( const wpath & file_ph,
std::ios_base::openmode mode )
{
return this->BOOST_NESTED_TEMPLATE open<wpath>( file_ph, mode );
}
// basic_ifstream definitions ----------------------------------------------//
template <class charT, class traits> template<class Path>
basic_ifstream<charT,traits>::basic_ifstream(const Path & file_ph,
typename boost::enable_if<is_basic_path<Path> >::type* )
: std::basic_ifstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::in ).c_str(), std::ios_base::in ) {}
template <class charT, class traits>
basic_ifstream<charT,traits>::basic_ifstream( const wpath & file_ph )
: std::basic_ifstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::in ).c_str(), std::ios_base::in ) {}
template <class charT, class traits> template<class Path>
basic_ifstream<charT,traits>::basic_ifstream( const Path & file_ph,
std::ios_base::openmode mode,
typename boost::enable_if<is_basic_path<Path> >::type* )
: std::basic_ifstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode ) {}
template <class charT, class traits>
basic_ifstream<charT,traits>::basic_ifstream( const wpath & file_ph,
std::ios_base::openmode mode )
: std::basic_ifstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode ) {}
template <class charT, class traits> template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
basic_ifstream<charT,traits>::open( const Path & file_ph )
{
std::basic_ifstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::in ).c_str(), std::ios_base::in );
}
template <class charT, class traits>
void basic_ifstream<charT,traits>::open( const wpath & file_ph )
{
std::basic_ifstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::in ).c_str(), std::ios_base::in );
}
template <class charT, class traits> template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
basic_ifstream<charT,traits>::open( const Path & file_ph,
std::ios_base::openmode mode )
{
std::basic_ifstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode );
}
template <class charT, class traits>
void basic_ifstream<charT,traits>::open( const wpath & file_ph,
std::ios_base::openmode mode )
{
std::basic_ifstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode );
}
// basic_ofstream definitions ----------------------------------------------//
template <class charT, class traits> template<class Path>
basic_ofstream<charT,traits>::basic_ofstream(const Path & file_ph,
typename boost::enable_if<is_basic_path<Path> >::type* )
: std::basic_ofstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::out ).c_str(), std::ios_base::out ) {}
template <class charT, class traits>
basic_ofstream<charT,traits>::basic_ofstream( const wpath & file_ph )
: std::basic_ofstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::out ).c_str(), std::ios_base::out ) {}
template <class charT, class traits> template<class Path>
basic_ofstream<charT,traits>::basic_ofstream( const Path & file_ph,
std::ios_base::openmode mode,
typename boost::enable_if<is_basic_path<Path> >::type* )
: std::basic_ofstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode ) {}
template <class charT, class traits>
basic_ofstream<charT,traits>::basic_ofstream( const wpath & file_ph,
std::ios_base::openmode mode )
: std::basic_ofstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode ) {}
template <class charT, class traits> template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
basic_ofstream<charT,traits>::open( const Path & file_ph )
{
std::basic_ofstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::out ).c_str(), std::ios_base::out );
}
template <class charT, class traits>
void basic_ofstream<charT,traits>::open( const wpath & file_ph )
{
std::basic_ofstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::out ).c_str(), std::ios_base::out );
}
template <class charT, class traits> template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
basic_ofstream<charT,traits>::open( const Path & file_ph,
std::ios_base::openmode mode )
{
std::basic_ofstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode );
}
template <class charT, class traits>
void basic_ofstream<charT,traits>::open( const wpath & file_ph,
std::ios_base::openmode mode )
{
std::basic_ofstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode );
}
// basic_fstream definitions -----------------------------------------------//
template <class charT, class traits> template<class Path>
basic_fstream<charT,traits>::basic_fstream(const Path & file_ph,
typename boost::enable_if<is_basic_path<Path> >::type* )
: std::basic_fstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::in|std::ios_base::out ).c_str(),
std::ios_base::in|std::ios_base::out ) {}
template <class charT, class traits>
basic_fstream<charT,traits>::basic_fstream( const wpath & file_ph )
: std::basic_fstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::in|std::ios_base::out ).c_str(),
std::ios_base::in|std::ios_base::out ) {}
template <class charT, class traits> template<class Path>
basic_fstream<charT,traits>::basic_fstream( const Path & file_ph,
std::ios_base::openmode mode,
typename boost::enable_if<is_basic_path<Path> >::type* )
: std::basic_fstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode ) {}
template <class charT, class traits>
basic_fstream<charT,traits>::basic_fstream( const wpath & file_ph,
std::ios_base::openmode mode )
: std::basic_fstream<charT,traits>(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode ) {}
template <class charT, class traits> template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
basic_fstream<charT,traits>::open( const Path & file_ph )
{
std::basic_fstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::in|std::ios_base::out ).c_str(),
std::ios_base::in|std::ios_base::out );
}
template <class charT, class traits>
void basic_fstream<charT,traits>::open( const wpath & file_ph )
{
std::basic_fstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
std::ios_base::in|std::ios_base::out ).c_str(),
std::ios_base::in|std::ios_base::out );
}
template <class charT, class traits> template<class Path>
typename boost::enable_if<is_basic_path<Path>, void>::type
basic_fstream<charT,traits>::open( const Path & file_ph,
std::ios_base::openmode mode )
{
std::basic_fstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode );
}
template <class charT, class traits>
void basic_fstream<charT,traits>::open( const wpath & file_ph,
std::ios_base::openmode mode )
{
std::basic_fstream<charT,traits>::open(
detail::path_proxy( file_ph.external_file_string(),
mode ).c_str(), mode );
}
# endif
# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
template <class charT, class traits>
basic_filebuf<charT,traits> *
basic_filebuf<charT, traits>::open( const path & file_ph,
std::ios_base::openmode mode )
{
return std::basic_filebuf<charT,traits>::open(
file_ph.file_string().c_str(), mode ) == 0 ? 0 : this;
}
# endif
template <class charT, class traits>
basic_ifstream<charT,traits>::basic_ifstream( const path & file_ph )
: std::basic_ifstream<charT,traits>(
file_ph.file_string().c_str(), std::ios_base::in ) {}
template <class charT, class traits>
basic_ifstream<charT,traits>::basic_ifstream( const path & file_ph,
std::ios_base::openmode mode )
: std::basic_ifstream<charT,traits>(
file_ph.file_string().c_str(), mode ) {}
# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
template <class charT, class traits>
void basic_ifstream<charT,traits>::open( const path & file_ph )
{
std::basic_ifstream<charT,traits>::open(
file_ph.file_string().c_str(), std::ios_base::in );
}
template <class charT, class traits>
void basic_ifstream<charT,traits>::open( const path & file_ph,
std::ios_base::openmode mode )
{
std::basic_ifstream<charT,traits>::open(
file_ph.file_string().c_str(), mode );
}
# endif
template <class charT, class traits>
basic_ofstream<charT,traits>::basic_ofstream( const path & file_ph )
: std::basic_ofstream<charT,traits>(
file_ph.file_string().c_str(), std::ios_base::out ) {}
template <class charT, class traits>
basic_ofstream<charT,traits>::basic_ofstream( const path & file_ph,
std::ios_base::openmode mode )
: std::basic_ofstream<charT,traits>(
file_ph.file_string().c_str(), mode ) {}
# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
template <class charT, class traits>
void basic_ofstream<charT,traits>::open( const path & file_ph )
{
std::basic_ofstream<charT,traits>::open(
file_ph.file_string().c_str(), std::ios_base::out );
}
template <class charT, class traits>
void basic_ofstream<charT,traits>::open( const path & file_ph,
std::ios_base::openmode mode )
{
std::basic_ofstream<charT,traits>::open(
file_ph.file_string().c_str(), mode );
}
# endif
template <class charT, class traits>
basic_fstream<charT,traits>::basic_fstream( const path & file_ph )
: std::basic_fstream<charT,traits>(
file_ph.file_string().c_str(),
std::ios_base::in|std::ios_base::out ) {}
template <class charT, class traits>
basic_fstream<charT,traits>::basic_fstream( const path & file_ph,
std::ios_base::openmode mode )
: std::basic_fstream<charT,traits>(
file_ph.file_string().c_str(), mode ) {}
# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle this
template <class charT, class traits>
void basic_fstream<charT,traits>::open( const path & file_ph )
{
std::basic_fstream<charT,traits>::open(
file_ph.file_string().c_str(), std::ios_base::in|std::ios_base::out );
}
template <class charT, class traits>
void basic_fstream<charT,traits>::open( const path & file_ph,
std::ios_base::openmode mode )
{
std::basic_fstream<charT,traits>::open(
file_ph.file_string().c_str(), mode );
}
# endif
} // namespace filesystem2
} // namespace boost
//----------------------------------------------------------------------------//
namespace boost
{
namespace filesystem
{
# ifndef BOOST_FILESYSTEM2_NARROW_ONLY
using filesystem2::wfilebuf;
using filesystem2::wifstream;
using filesystem2::wfstream;
using filesystem2::wofstream;
# endif
using filesystem2::filebuf;
using filesystem2::ifstream;
using filesystem2::ofstream;
using filesystem2::fstream;
using filesystem2::basic_filebuf;
using filesystem2::basic_ifstream;
using filesystem2::basic_ofstream;
using filesystem2::basic_fstream;
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
# endif
}
}
//----------------------------------------------------------------------------//
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
#endif // BOOST_FILESYSTEM2_FSTREAM_HPP

File diff suppressed because it is too large Load Diff

1571
test/external/boost/filesystem/v2/path.hpp vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,85 @@
// boost/filesystem/v3/config.hpp ----------------------------------------------------//
// Copyright Beman Dawes 2003
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// Library home page: http://www.boost.org/libs/filesystem
//--------------------------------------------------------------------------------------//
#ifndef BOOST_FILESYSTEM3_CONFIG_HPP
#define BOOST_FILESYSTEM3_CONFIG_HPP
# if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION != 3
# error Compiling Filesystem version 3 file with BOOST_FILESYSTEM_VERSION defined != 3
# endif
# if !defined(BOOST_FILESYSTEM_VERSION)
# define BOOST_FILESYSTEM_VERSION 3
# endif
#define BOOST_FILESYSTEM_I18N // aid users wishing to compile several versions
// This header implements separate compilation features as described in
// http://www.boost.org/more/separate_compilation.html
#include <boost/config.hpp>
#include <boost/system/api_config.hpp> // for BOOST_POSIX_API or BOOST_WINDOWS_API
#include <boost/detail/workaround.hpp>
// BOOST_FILESYSTEM_DEPRECATED needed for source compiles -----------------------------//
# ifdef BOOST_FILESYSTEM_SOURCE
# define BOOST_FILESYSTEM_DEPRECATED
# 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
// 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_FILESYSTEM3_CONFIG_HPP

View File

@@ -0,0 +1,74 @@
// 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_FILESYSTEM3_CONVENIENCE_HPP
#define BOOST_FILESYSTEM3_CONVENIENCE_HPP
#include <boost/config.hpp>
# if defined( BOOST_NO_STD_WSTRING )
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
# endif
#include <boost/filesystem/v3/operations.hpp>
#include <boost/system/error_code.hpp>
#include <boost/config/abi_prefix.hpp> // must be the last #include
namespace boost
{
namespace filesystem3
{
# 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 filesystem3
} // namespace boost
//----------------------------------------------------------------------------//
namespace boost
{
namespace filesystem
{
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
using filesystem3::extension;
using filesystem3::basename;
using filesystem3::change_extension;
# endif
}
}
//----------------------------------------------------------------------------//
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
#endif // BOOST_FILESYSTEM3_CONVENIENCE_HPP

View File

@@ -0,0 +1,9 @@
// boost/filesystem/exception.hpp -----------------------------------------------------//
// Copyright Beman Dawes 2003
// 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)
// This header is no longer used. The contents have been moved to path.hpp.
// It is provided so that user code #includes do not have to be changed.

View File

@@ -0,0 +1,208 @@
// boost/filesystem/fstream.hpp ------------------------------------------------------//
// 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_FILESYSTEM3_FSTREAM_HPP
#define BOOST_FILESYSTEM3_FSTREAM_HPP
#include <boost/config.hpp>
# if defined( BOOST_NO_STD_WSTRING )
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
# endif
#include <boost/filesystem/v3/path.hpp>
#include <iosfwd>
#include <fstream>
#include <boost/config/abi_prefix.hpp> // must be the last #include
// 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(BOOST_WINDOWS_API) \
&& (!defined(_CPPLIB_VER) || _CPPLIB_VER < 405 || defined(_STLPORT_VERSION))
// !Dinkumware || early Dinkumware || STLPort masquerading as Dinkumware
# define BOOST_FILESYSTEM_C_STR string().c_str() // use narrow, since wide not available
#else // use the native c_str, which will be narrow on POSIX, wide on Windows
# define BOOST_FILESYSTEM_C_STR c_str()
#endif
namespace boost
{
namespace filesystem3
{
//--------------------------------------------------------------------------------------//
// basic_filebuf //
//--------------------------------------------------------------------------------------//
template < class charT, class traits = std::char_traits<charT> >
class basic_filebuf : public std::basic_filebuf<charT,traits>
{
private: // disallow copying
basic_filebuf(const basic_filebuf&);
const basic_filebuf& operator=(const basic_filebuf&);
public:
basic_filebuf() {}
virtual ~basic_filebuf() {}
basic_filebuf<charT,traits>*
open(const path& p, std::ios_base::openmode mode)
{
return std::basic_filebuf<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode)
? this : 0;
}
};
//--------------------------------------------------------------------------------------//
// basic_ifstream //
//--------------------------------------------------------------------------------------//
template < class charT, class traits = std::char_traits<charT> >
class basic_ifstream : public std::basic_ifstream<charT,traits>
{
private: // disallow copying
basic_ifstream(const basic_ifstream&);
const basic_ifstream& operator=(const basic_ifstream&);
public:
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(const path& p)
: std::basic_ifstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in) {}
basic_ifstream(const path& p, std::ios_base::openmode mode)
: std::basic_ifstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
void open(const path& p)
{ std::basic_ifstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, std::ios_base::in); }
void open(const path& p, std::ios_base::openmode mode)
{ std::basic_ifstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
virtual ~basic_ifstream() {}
};
//--------------------------------------------------------------------------------------//
// basic_ofstream //
//--------------------------------------------------------------------------------------//
template < class charT, class traits = std::char_traits<charT> >
class basic_ofstream : public std::basic_ofstream<charT,traits>
{
private: // disallow copying
basic_ofstream(const basic_ofstream&);
const basic_ofstream& operator=(const basic_ofstream&);
public:
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(const path& p)
: std::basic_ofstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, std::ios_base::out) {}
basic_ofstream(const path& p, std::ios_base::openmode mode)
: std::basic_ofstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
void open(const path& p)
{ std::basic_ofstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, std::ios_base::out); }
void open(const path& p, std::ios_base::openmode mode)
{ std::basic_ofstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
virtual ~basic_ofstream() {}
};
//--------------------------------------------------------------------------------------//
// basic_fstream //
//--------------------------------------------------------------------------------------//
template < class charT, class traits = std::char_traits<charT> >
class basic_fstream : public std::basic_fstream<charT,traits>
{
private: // disallow copying
basic_fstream(const basic_fstream&);
const basic_fstream & operator=(const basic_fstream&);
public:
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(const path& p)
: std::basic_fstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR,
std::ios_base::in | std::ios_base::out) {}
basic_fstream(const path& p, std::ios_base::openmode mode)
: std::basic_fstream<charT,traits>(p.BOOST_FILESYSTEM_C_STR, mode) {}
void open(const path& p)
{ std::basic_fstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR,
std::ios_base::in | std::ios_base::out); }
void open(const path& p, std::ios_base::openmode mode)
{ std::basic_fstream<charT,traits>::open(p.BOOST_FILESYSTEM_C_STR, mode); }
virtual ~basic_fstream() {}
};
//--------------------------------------------------------------------------------------//
// 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 filesystem3
} // namespace boost
//----------------------------------------------------------------------------//
namespace boost
{
namespace filesystem
{
using filesystem3::filebuf;
using filesystem3::ifstream;
using filesystem3::ofstream;
using filesystem3::fstream;
using filesystem3::wfilebuf;
using filesystem3::wifstream;
using filesystem3::wfstream;
using filesystem3::wofstream;
using filesystem3::basic_filebuf;
using filesystem3::basic_ifstream;
using filesystem3::basic_ofstream;
using filesystem3::basic_fstream;
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
# endif
}
}
//----------------------------------------------------------------------------//
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
#endif // BOOST_FILESYSTEM3_FSTREAM_HPP

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,738 @@
// filesystem path.hpp ---------------------------------------------------------------//
// Copyright Beman Dawes 2002-2005, 2009
// Copyright Vladimir Prus 2002
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// Library home page: http://www.boost.org/libs/filesystem
// path::stem(), extension(), and replace_extension() are based on
// basename(), extension(), and change_extension() from the original
// filesystem/convenience.hpp header by Vladimir Prus.
#ifndef BOOST_FILESYSTEM_PATH_HPP
#define BOOST_FILESYSTEM_PATH_HPP
#include <boost/config.hpp>
# if defined( BOOST_NO_STD_WSTRING )
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
# endif
#include <boost/filesystem/v3/config.hpp>
#include <boost/filesystem/v3/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/io/detail/quoted_manip.hpp>
#include <boost/static_assert.hpp>
#include <boost/functional/hash_fwd.hpp>
#include <string>
#include <iterator>
#include <cstring>
#include <iosfwd>
#include <stdexcept>
#include <cassert>
#include <locale>
#include <algorithm>
#include <boost/config/abi_prefix.hpp> // must be the last #include
namespace boost
{
namespace filesystem3
{
//------------------------------------------------------------------------------------//
// //
// class path //
// //
//------------------------------------------------------------------------------------//
class BOOST_FILESYSTEM_DECL path
{
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;
# else
typedef char value_type;
# endif
typedef std::basic_string<value_type> string_type;
typedef std::codecvt<wchar_t, char, std::mbstate_t> codecvt_type;
// ----- character encoding conversions -----
// Following the principle of least astonishment, path input arguments
// passed to or obtained from the operating system via objects of
// class path behave as if they were directly passed to or
// obtained from the O/S API, unless conversion is explicitly requested.
//
// POSIX specfies that path strings are passed unchanged to and from the
// API. Note that this is different from the POSIX command line utilities,
// which convert according to a locale.
//
// Thus for POSIX, char strings do not undergo conversion. wchar_t strings
// are converted to/from char using the path locale or, if a conversion
// argument is given, using a conversion object modeled on
// std::wstring_convert.
//
// The path locale, which is global to the thread, can be changed by the
// imbue() function. It is initialized to an implementation defined locale.
//
// For Windows, wchar_t strings do not undergo conversion. char strings
// are converted using the "ANSI" or "OEM" code pages, as determined by
// the AreFileApisANSI() function, or, if a conversion argument is given,
// using a conversion object modeled on std::wstring_convert.
//
// See m_pathname comments for further important rationale.
// TODO: rules needed for operating systems that use / or .
// differently, or format directory paths differently from file paths.
//
// **********************************************************************************
//
// More work needed: How to handle an operating system that may have
// slash characters or dot characters in valid filenames, either because
// it doesn't follow the POSIX standard, or because it allows MBCS
// filename encodings that may contain slash or dot characters. For
// example, ISO/IEC 2022 (JIS) encoding which allows switching to
// JIS x0208-1983 encoding. A valid filename in this set of encodings is
// 0x1B 0x24 0x42 [switch to X0208-1983] 0x24 0x2F [U+304F Kiragana letter KU]
// ^^^^
// Note that 0x2F is the ASCII slash character
//
// **********************************************************************************
// Supported source arguments: half-open iterator range, container, c-array,
// and single pointer to null terminated string.
// All source arguments except pointers to null terminated byte strings support
// multi-byte character strings which may have embedded nulls. Embedded null
// support is required for some Asian languages on Windows.
// [defaults] "const codecvt_type& cvt=codecvt()" default arguments are not used
// because some compilers, such as Microsoft prior to VC++ 10, do not handle defaults
// correctly in templates.
// ----- constructors -----
path(){}
path(const path& p) : m_pathname(p.m_pathname) {}
template <class Source>
path(Source const& source,
typename boost::enable_if<path_traits::is_pathable<
typename boost::decay<Source>::type> >::type* =0)
{
path_traits::dispatch(source, m_pathname, codecvt());
}
// Overloads for the operating system API's native character type. Rationale:
// - Avoids use of codecvt() for native value_type strings. This limits the
// impact of locale("") initialization failures on POSIX systems to programs
// that actually depend on locale(""). It further ensures that exceptions thrown
// as a result of such failues occur after main() has started, so can be caught.
// This is a partial resolution of tickets 4688, 5100, and 5289.
// - A slight optimization for a common use case, particularly on POSIX since
// value_type is char and that is the most common useage.
path(const value_type* s) : m_pathname(s) {}
path(const std::basic_string<value_type>& s) : m_pathname(s) {}
template <class Source>
path(Source const& source, const codecvt_type& cvt)
// see [defaults] note above explaining why codecvt() default arguments are not used
{
path_traits::dispatch(source, m_pathname, cvt);
}
template <class InputIterator>
path(InputIterator begin, InputIterator end)
{
if (begin != end)
{
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
s(begin, end);
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, codecvt());
}
}
template <class InputIterator>
path(InputIterator begin, InputIterator end, const codecvt_type& cvt)
{
if (begin != end)
{
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
s(begin, end);
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
}
}
// ----- assignments -----
path& operator=(const path& p)
{
m_pathname = p.m_pathname;
return *this;
}
template <class Source>
typename boost::enable_if<path_traits::is_pathable<
typename boost::decay<Source>::type>, path&>::type
operator=(Source const& source)
{
m_pathname.clear();
path_traits::dispatch(source, m_pathname, codecvt());
return *this;
}
template <class Source>
path& assign(Source const& source, const codecvt_type& cvt)
{
m_pathname.clear();
path_traits::dispatch(source, m_pathname, cvt);
return *this;
}
template <class InputIterator>
path& assign(InputIterator begin, InputIterator end)
{
return assign(begin, end, codecvt());
}
template <class InputIterator>
path& assign(InputIterator begin, InputIterator end, const codecvt_type& cvt)
{
m_pathname.clear();
if (begin != end)
{
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
s(begin, end);
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
}
return *this;
}
// ----- appends -----
// if a separator is added, it is the preferred separator for the platform;
// slash for POSIX, backslash for Windows
path& operator/=(const path& p);
template <class Source>
typename boost::enable_if<path_traits::is_pathable<
typename boost::decay<Source>::type>, path&>::type
operator/=(Source const& source)
{
return append(source, codecvt());
}
template <class Source>
path& append(Source const& source, const codecvt_type& cvt);
template <class InputIterator>
path& append(InputIterator begin, InputIterator end)
{
return append(begin, end, codecvt());
}
template <class InputIterator>
path& append(InputIterator begin, InputIterator end, const codecvt_type& cvt);
// ----- modifiers -----
void clear() { m_pathname.clear(); }
path& make_preferred()
# ifdef BOOST_POSIX_API
{ return *this; } // POSIX no effect
# else // BOOST_WINDOWS_API
; // change slashes to backslashes
# endif
path& remove_filename();
path& replace_extension(const path& new_extension = path());
void swap(path& rhs) { m_pathname.swap(rhs.m_pathname); }
// ----- observers -----
// For operating systems that format file paths differently than directory
// paths, return values from observers are formatted as file names unless there
// is a trailing separator, in which case returns are formatted as directory
// paths. POSIX and Windows make no such distinction.
// Implementations are permitted to return const values or const references.
// The string or path returned by an observer are specified as being formatted
// as "native" or "generic".
//
// For POSIX, these are all the same format; slashes and backslashes are as input and
// are not modified.
//
// For Windows, native: as input; slashes and backslashes are not modified;
// this is the format of the internally stored string.
// generic: backslashes are converted to slashes
// ----- native format observers -----
const string_type& native() const { return m_pathname; } // Throws: nothing
const value_type* c_str() const { return m_pathname.c_str(); } // Throws: nothing
template <class String>
String string() const;
template <class String>
String string(const codecvt_type& cvt) const;
# ifdef BOOST_WINDOWS_API
const std::string string() const { return string(codecvt()); }
const std::string string(const codecvt_type& cvt) const
{
std::string tmp;
if (!m_pathname.empty())
path_traits::convert(&*m_pathname.begin(), &*m_pathname.begin()+m_pathname.size(),
tmp, cvt);
return tmp;
}
// string_type is std::wstring, so there is no conversion
const std::wstring& wstring() const { return m_pathname; }
const std::wstring& wstring(const codecvt_type&) const { return m_pathname; }
# else // 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::wstring wstring() const { return wstring(codecvt()); }
const std::wstring wstring(const codecvt_type& cvt) const
{
std::wstring tmp;
if (!m_pathname.empty())
path_traits::convert(&*m_pathname.begin(), &*m_pathname.begin()+m_pathname.size(),
tmp, cvt);
return tmp;
}
# endif
// ----- generic format observers -----
template <class String>
String generic_string() const;
template <class String>
String generic_string(const codecvt_type& cvt) const;
# ifdef BOOST_WINDOWS_API
const std::string generic_string() const { return generic_string(codecvt()); }
const std::string generic_string(const codecvt_type& cvt) const;
const std::wstring generic_wstring() const;
const std::wstring generic_wstring(const codecvt_type&) const { return generic_wstring(); };
# else // 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(codecvt()); }
const std::wstring generic_wstring(const codecvt_type& cvt) const { return wstring(cvt); }
# endif
// ----- decomposition -----
path root_path() const;
path root_name() const; // returns 0 or 1 element path
// even on POSIX, root_name() is non-empty() for network paths
path root_directory() const; // returns 0 or 1 element path
path relative_path() const;
path parent_path() const;
path filename() const; // returns 0 or 1 element path
path stem() const; // returns 0 or 1 element path
path extension() const; // returns 0 or 1 element path
// ----- query -----
bool empty() const { return m_pathname.empty(); } // name consistent with std containers
bool has_root_path() const { return has_root_directory() || has_root_name(); }
bool has_root_name() const { return !root_name().empty(); }
bool has_root_directory() const { return !root_directory().empty(); }
bool has_relative_path() const { return !relative_path().empty(); }
bool has_parent_path() const { return !parent_path().empty(); }
bool has_filename() const { return !m_pathname.empty(); }
bool has_stem() const { return !stem().empty(); }
bool has_extension() const { return !extension().empty(); }
bool is_absolute() const
{
# ifdef BOOST_WINDOWS_API
return has_root_name() && has_root_directory();
# else
return has_root_directory();
# endif
}
bool is_relative() const { return !is_absolute(); }
// ----- imbue -----
static std::locale imbue(const std::locale& loc);
// ----- codecvt -----
static const codecvt_type& codecvt()
{
return *wchar_t_codecvt_facet();
}
// ----- iterators -----
class iterator;
typedef iterator const_iterator;
iterator begin() const;
iterator end() const;
// ----- deprecated functions -----
# if defined(BOOST_FILESYSTEM_DEPRECATED) && defined(BOOST_FILESYSTEM_NO_DEPRECATED)
# error both BOOST_FILESYSTEM_DEPRECATED and BOOST_FILESYSTEM_NO_DEPRECATED are defined
# endif
# if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
// recently deprecated functions supplied by default
path& normalize() { return m_normalize(); }
path& remove_leaf() { return remove_filename(); }
path leaf() const { return filename(); }
path branch_path() const { return parent_path(); }
bool has_leaf() const { return !m_pathname.empty(); }
bool has_branch_path() const { return !parent_path().empty(); }
bool is_complete() const { return is_absolute(); }
# endif
# if defined(BOOST_FILESYSTEM_DEPRECATED)
// deprecated functions with enough signature or semantic changes that they are
// not supplied by default
const std::string file_string() const { return string(); }
const std::string directory_string() const { return string(); }
const std::string native_file_string() const { return string(); }
const std::string native_directory_string() const { return string(); }
const string_type external_file_string() const { return native(); }
const string_type external_directory_string() const { return native(); }
// older functions no longer supported
//typedef bool (*name_check)(const std::string & name);
//basic_path(const string_type& str, name_check) { operator/=(str); }
//basic_path(const typename string_type::value_type* s, name_check)
// { operator/=(s);}
//static bool default_name_check_writable() { return false; }
//static void default_name_check(name_check) {}
//static name_check default_name_check() { return 0; }
//basic_path& canonize();
# endif
//--------------------------------------------------------------------------------------//
// class path private members //
//--------------------------------------------------------------------------------------//
private:
# if defined(_MSC_VER)
# pragma warning(push) // Save warning settings
# pragma warning(disable : 4251) // disable warning: class 'std::basic_string<_Elem,_Traits,_Ax>'
# endif // needs to have dll-interface...
/*
m_pathname has the type, encoding, and format required by the native
operating system. Thus for POSIX and Windows there is no conversion for
passing m_pathname.c_str() to the O/S API or when obtaining a path from the
O/S API. POSIX encoding is unspecified other than for dot and slash
characters; POSIX just treats paths as a sequence of bytes. Windows
encoding is UCS-2 or UTF-16 depending on the version.
*/
string_type m_pathname; // Windows: as input; backslashes NOT converted to slashes,
// slashes NOT converted to backslashes
# if defined(_MSC_VER)
# pragma warning(pop) // restore warning settings.
# endif
string_type::size_type m_append_separator_if_needed();
// Returns: If separator is to be appended, m_pathname.size() before append. Otherwise 0.
// Note: An append is never performed if size()==0, so a returned 0 is unambiguous.
void m_erase_redundant_separator(string_type::size_type sep_pos);
string_type::size_type m_parent_path_end() const;
path& m_normalize();
// Was qualified; como433beta8 reports:
// warning #427-D: qualified name is not allowed in member declaration
friend class iterator;
friend bool operator<(const path& lhs, const path& rhs);
// see path::iterator::increment/decrement comment below
static void m_path_iterator_increment(path::iterator & it);
static void m_path_iterator_decrement(path::iterator & it);
static const codecvt_type *& wchar_t_codecvt_facet();
}; // class path
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
typedef path wpath;
# endif
//------------------------------------------------------------------------------------//
// class path::iterator //
//------------------------------------------------------------------------------------//
class path::iterator
: public boost::iterator_facade<
path::iterator,
path const,
boost::bidirectional_traversal_tag >
{
private:
friend class boost::iterator_core_access;
friend class boost::filesystem3::path;
friend void m_path_iterator_increment(path::iterator & it);
friend void m_path_iterator_decrement(path::iterator & it);
const path& dereference() const { return m_element; }
bool equal(const iterator & rhs) const
{
return m_path_ptr == rhs.m_path_ptr && m_pos == rhs.m_pos;
}
// iterator_facade derived classes don't seem to like implementations in
// separate translation unit dll's, so forward to class path static members
void increment() { m_path_iterator_increment(*this); }
void decrement() { m_path_iterator_decrement(*this); }
path m_element; // current element
const path * m_path_ptr; // path being iterated over
string_type::size_type m_pos; // position of name in
// m_path_ptr->m_pathname. The
// end() iterator is indicated by
// m_pos == m_path_ptr->m_pathname.size()
}; // path::iterator
//------------------------------------------------------------------------------------//
// //
// non-member functions //
// //
//------------------------------------------------------------------------------------//
// std::lexicographical_compare would infinately recurse because path iterators
// yield paths, so provide a path aware version
inline bool lexicographical_compare(path::iterator first1, path::iterator last1,
path::iterator first2, path::iterator last2)
{
for (; first1 != last1 && first2 != last2 ; ++first1, ++first2)
{
if (first1->native() < first2->native()) return true;
if (first2->native() < first1->native()) return false;
}
return first1 == last1 && first2 != last2;
}
inline bool operator<(const path& lhs, const path& rhs)
{
return lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
inline bool operator<=(const path& lhs, const path& rhs) { return !(rhs < lhs); }
inline bool operator> (const path& lhs, const path& rhs) { return rhs < lhs; }
inline bool operator>=(const path& lhs, const path& rhs) { return !(lhs < rhs); }
// equality operators act as if comparing generic format strings, to achieve the
// effect of lexicographical_compare element by element compare.
// operator==() efficiency is a concern; a user reported the original version 2
// !(lhs < rhs) && !(rhs < lhs) implementation caused a serious performance problem
// for a map of 10,000 paths.
# ifdef BOOST_WINDOWS_API
inline bool operator==(const path& lhs, const path::value_type* rhs)
{
const path::value_type* l(lhs.c_str());
while ((*l == *rhs || (*l == L'\\' && *rhs == L'/') || (*l == L'/' && *rhs == L'\\'))
&& *l) { ++l; ++rhs; }
return *l == *rhs;
}
inline bool operator==(const path& lhs, const path& rhs) { return lhs == rhs.c_str(); }
inline bool operator==(const path& lhs, const path::string_type& rhs) { return lhs == rhs.c_str(); }
inline bool operator==(const path::string_type& lhs, const path& rhs) { return rhs == lhs.c_str(); }
inline bool operator==(const path::value_type* lhs, const path& rhs) { return rhs == lhs; }
inline std::size_t hash_value(const path& x)
{
std::size_t seed = 0;
for(const path::value_type* it = x.c_str(); *it; ++it)
hash_combine(seed, *it == '/' ? L'\\' : *it);
return seed;
}
# else // BOOST_POSIX_API
inline bool operator==(const path& lhs, const path& rhs) { return lhs.native() == rhs.native(); }
inline bool operator==(const path& lhs, const path::string_type& rhs) { return lhs.native() == rhs; }
inline bool operator==(const path& lhs, const path::value_type* rhs) { return lhs.native() == rhs; }
inline bool operator==(const path::string_type& lhs, const path& rhs) { return lhs == rhs.native(); }
inline bool operator==(const path::value_type* lhs, const path& rhs) { return lhs == rhs.native(); }
inline std::size_t hash_value(const path& x)
{
return hash_range(x.native().begin(), x.native().end());
}
# endif
inline bool operator!=(const path& lhs, const path& rhs) { return !(lhs == rhs); }
inline bool operator!=(const path& lhs, const path::string_type& rhs) { return !(lhs == rhs); }
inline bool operator!=(const path& lhs, const path::value_type* rhs) { return !(lhs == rhs); }
inline bool operator!=(const path::string_type& lhs, const path& rhs) { return !(lhs == rhs); }
inline bool operator!=(const path::value_type* lhs, const path& rhs) { return !(lhs == rhs); }
inline void swap(path& lhs, path& rhs) { lhs.swap(rhs); }
inline path operator/(const path& lhs, const path& rhs) { return path(lhs) /= rhs; }
// inserters and extractors
// use boost::io::quoted() to handle spaces in paths
// use '&' as escape character to ease use for Windows paths
template <class Char, class Traits>
inline std::basic_ostream<Char, Traits>&
operator<<(std::basic_ostream<Char, Traits>& os, const path& p)
{
return os
<< 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)
{
std::basic_string<Char> str;
is >> boost::io::quoted(str, static_cast<Char>('&'));
p = str;
return is;
}
// name_checks
// These functions are holdovers from version 1. It isn't clear they have much
// usefulness, or how to generalize them for later versions.
BOOST_FILESYSTEM_DECL bool portable_posix_name(const std::string & name);
BOOST_FILESYSTEM_DECL bool windows_name(const std::string & name);
BOOST_FILESYSTEM_DECL bool portable_name(const std::string & name);
BOOST_FILESYSTEM_DECL bool portable_directory_name(const std::string & name);
BOOST_FILESYSTEM_DECL bool portable_file_name(const std::string & name);
BOOST_FILESYSTEM_DECL bool native(const std::string & name);
//--------------------------------------------------------------------------------------//
// class path member template implementation //
//--------------------------------------------------------------------------------------//
template <class InputIterator>
path& path::append(InputIterator begin, InputIterator end, const codecvt_type& cvt)
{
if (begin == end)
return *this;
string_type::size_type sep_pos(m_append_separator_if_needed());
std::basic_string<typename std::iterator_traits<InputIterator>::value_type>
s(begin, end);
path_traits::convert(s.c_str(), s.c_str()+s.size(), m_pathname, cvt);
if (sep_pos)
m_erase_redundant_separator(sep_pos);
return *this;
}
template <class Source>
path& path::append(Source const & source, const codecvt_type& cvt)
{
if (path_traits::empty(source))
return *this;
string_type::size_type sep_pos(m_append_separator_if_needed());
path_traits::dispatch(source, m_pathname, cvt);
if (sep_pos)
m_erase_redundant_separator(sep_pos);
return *this;
}
//--------------------------------------------------------------------------------------//
// class path member template specializations //
//--------------------------------------------------------------------------------------//
template <> inline
std::string path::string<std::string>() const
{ return string(); }
template <> inline
std::wstring path::string<std::wstring>() const
{ return wstring(); }
template <> inline
std::string path::string<std::string>(const codecvt_type& cvt) const
{ return string(cvt); }
template <> inline
std::wstring path::string<std::wstring>(const codecvt_type& cvt) const
{ return wstring(cvt); }
template <> inline
std::string path::generic_string<std::string>() const
{ return generic_string(); }
template <> inline
std::wstring path::generic_string<std::wstring>() const
{ return generic_wstring(); }
template <> inline
std::string path::generic_string<std::string>(const codecvt_type& cvt) const
{ return generic_string(cvt); }
template <> inline
std::wstring path::generic_string<std::wstring>(const codecvt_type& cvt) const
{ return generic_wstring(cvt); }
} // namespace filesystem3
} // namespace boost
//----------------------------------------------------------------------------//
namespace boost
{
namespace filesystem
{
using filesystem3::path;
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
using filesystem3::wpath;
# endif
using filesystem3::lexicographical_compare;
using filesystem3::portable_posix_name;
using filesystem3::windows_name;
using filesystem3::portable_name;
using filesystem3::portable_directory_name;
using filesystem3::portable_file_name;
using filesystem3::native;
using filesystem3::swap;
using filesystem3::operator<;
using filesystem3::operator==;
using filesystem3::operator!=;
using filesystem3::operator>;
using filesystem3::operator<=;
using filesystem3::operator>=;
using filesystem3::operator/;
using filesystem3::operator<<;
using filesystem3::operator>>;
}
}
//----------------------------------------------------------------------------//
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
#endif // BOOST_FILESYSTEM_PATH_HPP

View File

@@ -0,0 +1,247 @@
// 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/config.hpp>
# if defined( BOOST_NO_STD_WSTRING )
# error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
# endif
#include <boost/filesystem/v3/config.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/decay.hpp>
#include <boost/system/error_code.hpp>
#include <cwchar> // for mbstate_t
#include <string>
#include <vector>
#include <list>
#include <iterator>
#include <locale>
#include <boost/assert.hpp>
// #include <iostream> //**** comment me out ****
#include <boost/config/abi_prefix.hpp> // must be the last #include
namespace boost { namespace filesystem3 {
BOOST_FILESYSTEM_DECL const system::error_category& codecvt_error_category();
// uses std::codecvt_base::result used for error codes:
//
// ok: Conversion successful.
// partial: Not all source characters converted; one or more additional source
// characters are needed to produce the final target character, or the
// size of the target intermediate buffer was too small to hold the result.
// error: A character in the source could not be converted to the target encoding.
// noconv: The source and target characters have the same type and encoding, so no
// conversion was necessary.
class directory_entry;
namespace path_traits {
typedef std::codecvt<wchar_t, char, std::mbstate_t> codecvt_type;
// is_pathable type trait; allows disabling over-agressive class path member templates
template <class T>
struct is_pathable { static const bool value = false; };
template<> struct is_pathable<char*> { static const bool value = true; };
template<> struct is_pathable<const char*> { static const bool value = true; };
template<> struct is_pathable<wchar_t*> { static const bool value = true; };
template<> struct is_pathable<const wchar_t*> { static const bool value = true; };
template<> struct is_pathable<std::string> { static const bool value = true; };
template<> struct is_pathable<std::wstring> { static const bool value = true; };
template<> struct is_pathable<std::vector<char> > { static const bool value = true; };
template<> struct is_pathable<std::vector<wchar_t> > { static const bool value = true; };
template<> struct is_pathable<std::list<char> > { static const bool value = true; };
template<> struct is_pathable<std::list<wchar_t> > { static const bool value = true; };
template<> struct is_pathable<directory_entry> { static const bool value = true; };
// Pathable empty
template <class Container> inline
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
// conforming compilers. Replace by plain "bool" at some future date (2012?)
typename boost::disable_if<boost::is_array<Container>, bool>::type
empty(const Container & 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, size_t N> inline
bool empty(T (&)[N])
{ return N <= 1; }
// value types differ ---------------------------------------------------------------//
//
// A from_end argument of 0 is less efficient than a known end, so use only if needed
BOOST_FILESYSTEM_DECL
void convert(const char* from,
const char* from_end, // 0 for null terminated MBCS
std::wstring & to,
const codecvt_type& cvt);
BOOST_FILESYSTEM_DECL
void convert(const wchar_t* from,
const wchar_t* from_end, // 0 for null terminated MBCS
std::string & to,
const codecvt_type& cvt);
inline
void convert(const char* from,
std::wstring & to,
const codecvt_type& cvt)
{
BOOST_ASSERT(from);
convert(from, 0, to, cvt);
}
inline
void convert(const wchar_t* from,
std::string & to,
const codecvt_type& cvt)
{
BOOST_ASSERT(from);
convert(from, 0, to, cvt);
}
// value types same -----------------------------------------------------------------//
// char
inline
void convert(const char* from, const char* from_end, std::string & to,
const codecvt_type&)
{
BOOST_ASSERT(from);
BOOST_ASSERT(from_end);
to.append(from, from_end);
}
inline
void convert(const char* from,
std::string & to,
const codecvt_type&)
{
BOOST_ASSERT(from);
to += from;
}
// wchar_t
inline
void convert(const wchar_t* from, const wchar_t* from_end, std::wstring & to,
const codecvt_type&)
{
BOOST_ASSERT(from);
BOOST_ASSERT(from_end);
to.append(from, from_end);
}
inline
void convert(const wchar_t* from,
std::wstring & to,
const codecvt_type&)
{
BOOST_ASSERT(from);
to += from;
}
// Source dispatch
// contiguous containers
template <class U> inline
void dispatch(const std::string& c, U& to, const codecvt_type& cvt)
{
if (c.size())
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
}
template <class U> inline
void dispatch(const std::wstring& c, U& to, const codecvt_type& cvt)
{
if (c.size())
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
}
template <class U> inline
void dispatch(const std::vector<char>& c, U& to, const codecvt_type& cvt)
{
if (c.size())
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
}
template <class U> inline
void dispatch(const std::vector<wchar_t>& c, U& to, const codecvt_type& cvt)
{
if (c.size())
convert(&*c.begin(), &*c.begin() + c.size(), to, cvt);
}
// non-contiguous containers
template <class Container, class U> inline
// disable_if aids broken compilers (IBM, old GCC, etc.) and is harmless for
// conforming compilers. Replace by plain "void" at some future date (2012?)
typename boost::disable_if<boost::is_array<Container>, void>::type
dispatch(const Container & c, U& to, const codecvt_type& cvt)
{
if (c.size())
{
std::basic_string<typename Container::value_type> s(c.begin(), c.end());
convert(s.c_str(), s.c_str()+s.size(), to, cvt);
}
}
// c_str
template <class T, class U> inline
void dispatch(T * const & c_str, U& to, const codecvt_type& cvt)
{
// std::cout << "dispatch() const T *\n";
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(const directory_entry & de,
# ifdef BOOST_WINDOWS_API
std::wstring & to,
# else
std::string & to,
# endif
const codecvt_type&);
}}} // namespace boost::filesystem::path_traits
//----------------------------------------------------------------------------//
namespace boost
{
namespace filesystem
{
using filesystem3::codecvt_error_category;
# ifndef BOOST_FILESYSTEM_NO_DEPRECATED
# endif
}
}
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
#endif // BOOST_FILESYSTEM_PATH_TRAITS_HPP