Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56638 - in sandbox/filesystem-v3: boost/filesystem libs/filesystem/src libs/filesystem/test libs/filesystem/test/msvc/convenience_test libs/filesystem/test/msvc/filesystem_dll libs/filesystem/test/msvc/operations_test libs/filesystem/test/msvc/operations_unit_test libs/filesystem/test/msvc/path_test libs/filesystem/test/msvc/path_unit_test
From: bdawes_at_[hidden]
Date: 2009-10-07 15:52:56


Author: bemandawes
Date: 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
New Revision: 56638
URL: http://svn.boost.org/trac/boost/changeset/56638

Log:
Filesystem-v3: prototype class path error_code argument and supporting infrastructure
Added:
   sandbox/filesystem-v3/libs/filesystem/src/codecvt_error_category.cpp (contents, props changed)
Text files modified:
   sandbox/filesystem-v3/boost/filesystem/path.hpp | 49 ++--------------
   sandbox/filesystem-v3/boost/filesystem/path_traits.hpp | 115 ++++++++++++++++-----------------------
   sandbox/filesystem-v3/libs/filesystem/src/operations.cpp | 28 ++++-----
   sandbox/filesystem-v3/libs/filesystem/src/path.cpp | 10 ++-
   sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp | 40 +++++++++----
   sandbox/filesystem-v3/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj | 4 +
   sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj | 4 +
   sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_test/operations_test.vcproj | 4 +
   sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj | 12 ++++
   sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj | 4 +
   sandbox/filesystem-v3/libs/filesystem/test/msvc/path_unit_test/path_unit_test.vcproj | 4 +
   sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp | 71 +++++++++++++++++------
   12 files changed, 185 insertions(+), 160 deletions(-)

Modified: sandbox/filesystem-v3/boost/filesystem/path.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/path.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/path.hpp 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -85,45 +85,6 @@
 {
 
   //------------------------------------------------------------------------------------//
- // class path_error //
- //------------------------------------------------------------------------------------//
-
- // filesystem_error is not used because errors are sometimes thrown during
- // path construction when there isn't a complete path to include.
- // system_error is not used because most uses will be for conversion errors, and
- // thus it is useful to include the source string causing the error. Since
- // processing source string errors is by its nature type dependent, the
- // exception class is templated on the string type.
-
- // path_error can be caught when further type distinctions aren't needed.
-
- class path_error : public std::runtime_error
- {
- public:
- path_error( const char * what_, boost::system::error_code ec_ )
- : std::runtime_error( what_ ), m_ec( ec_ ) {}
-
- boost::system::error_code error_code() const throw() { return m_ec; }
-
- private:
- boost::system::error_code m_ec;
- };
-
- template < class String >
- class basic_path_error : public path_error
- {
- public:
- basic_path_error( const char * what_, boost::system::error_code ec_,
- const String & source_ )
- : path_error( what_, ec_ ), m_source( source_ ) {}
-
- const String & native() const { return m_source; }
-
- private:
- String m_source;
- };
-
- //------------------------------------------------------------------------------------//
   // //
   // class path //
   // //
@@ -228,6 +189,12 @@
       path_traits::dispatch( pathable, m_path, codecvt() );
     }
 
+ template <class PathSource>
+ path( PathSource const & pathable, system::error_code & ec )
+ {
+ path_traits::dispatch( pathable, m_path, codecvt(), ec );
+ }
+
     // ----- assignments -----
 
     path & operator=( const path & p )
@@ -319,7 +286,7 @@
 
 # ifdef BOOST_WINDOWS_API
 
- const std::string native_string() const;
+ const std::string native_string( system::error_code & ec = throws() ) const;
     const std::wstring & native_wstring() const { return m_path; }
 
 # else // BOOST_POSIX_API
@@ -340,7 +307,7 @@
 
 # ifdef BOOST_WINDOWS_API
 
- const std::string string() const;
+ const std::string string( system::error_code & ec = throws() ) const;
     const std::wstring wstring() const;
 
 # else // BOOST_POSIX_API

Modified: sandbox/filesystem-v3/boost/filesystem/path_traits.hpp
==============================================================================
--- sandbox/filesystem-v3/boost/filesystem/path_traits.hpp (original)
+++ sandbox/filesystem-v3/boost/filesystem/path_traits.hpp 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -7,43 +7,6 @@
 
 // Library home page: http://www.boost.org/libs/filesystem
 
-/*
- FAQ
-
- Why are there no error_code & arguments?
- ----------------------------------------
-
- error_code & arguments add considerably to the surface area of the interface, yet
- appear to be of limited usefulness. They have not been requested by users; the need
- for filesystem error reporting via error_code seems limited to operational failures
- rather than path failures.
-
- error_code & arguments double the number of signatures, since for efficiency the
- use of a default throws() argument is not desirable.
-
- Errors in path conversions only occur if the source and target value types differ AND
- the target encoding can't represent a character present in the source. The only
- commonplace case is when directory iteration on Windows encounters a file name that
- can't be represented in a char encoding.
-
- Workarounds (such as pre-scanning for characters that can't be encoded) appear
- resonable.
-
- Why are there no const codecvt_type & arguments?
- ------------------------------------------------
-
- To hold down the size of the class path interface. Per function codecvt facets
- just aren't needed very often in practice.
-
- An RAII idiom can be used to ensure push/pop behavior as an alternative.
-
- Note that codecvt() is passed to the path_traits::convert functions, since that
- decouples the convert functions from class path.
-
- const codecvt_type & can be added later, but once added, they can never be removed
- since that would break user code.
-*/
-
 #ifndef BOOST_FILESYSTEM_PATH_TRAITS_HPP
 #define BOOST_FILESYSTEM_PATH_TRAITS_HPP
 
@@ -58,6 +21,17 @@
 
 namespace boost { namespace filesystem {
 
+ 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 {
@@ -84,39 +58,40 @@
   // Pathable dispatch
 
   template <class Container, class U> inline
- void dispatch( const Container & c, U & to, const codecvt_type & cvt )
+ void dispatch( const Container & c, U & to, const codecvt_type & cvt,
+ system::error_code & ec = throws() )
   {
 // std::cout << "dispatch() container\n";
     if ( c.size() )
- convert( &*c.begin(), &*c.begin() + c.size(), to, cvt );
+ convert( &*c.begin(), &*c.begin() + c.size(), to, cvt, ec );
+ else if ( &ec != &throws() ) ec.clear();
   }
 
   template <class T, class U> inline
- void dispatch( T * const & c_str, U & to, const codecvt_type & cvt )
+ void dispatch( T * const & c_str, U & to, const codecvt_type & cvt,
+ system::error_code & ec = throws() )
   {
 // std::cout << "dispatch() const T *\n";
     BOOST_ASSERT( c_str );
- convert( c_str, to, cvt );
+ convert( c_str, to, cvt, ec );
   }
   
   template <typename T, size_t N, class U> inline
- void dispatch( T (&array)[N], U & to, const codecvt_type & cvt ) // T, N, U deduced
+ void dispatch( T (&array)[N], U & to, const codecvt_type & cvt,
+ system::error_code & ec = throws() ) // T, N, U deduced
   {
 // std::cout << "dispatch() array, N=" << N << "\n";
- convert( array, array + N - 1, to, cvt );
+ convert( array, array + N - 1, to, cvt, ec );
   }
 
-# ifdef BOOST_WINDOWS_API
-
- BOOST_FILESYSTEM_DECL
- void dispatch( const directory_entry & de, std::wstring & to, const codecvt_type & );
-
-# else
-
   BOOST_FILESYSTEM_DECL
- void dispatch( const directory_entry & de, std::string & to, const codecvt_type & );
-
-# endif
+ void dispatch( const directory_entry & de,
+# ifdef BOOST_WINDOWS_API
+ std::wstring & to,
+# else
+ std::string & to,
+# endif
+ const codecvt_type &, system::error_code & ec = throws() );
 
   // value types differ ---------------------------------------------------------------//
   //
@@ -126,30 +101,34 @@
   void convert( const char * from,
                 const char * from_end, // 0 for null terminated MBCS
                 std::wstring & to,
- const codecvt_type & cvt );
+ const codecvt_type & cvt,
+ system::error_code & ec = throws() );
 
   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 );
+ const codecvt_type & cvt,
+ system::error_code & ec = throws() );
 
   inline
   void convert( const char * from,
                 std::wstring & to,
- const codecvt_type & cvt )
+ const codecvt_type & cvt,
+ system::error_code & ec = throws() )
   {
     BOOST_ASSERT( from );
- convert( from, 0, to, cvt );
+ convert( from, 0, to, cvt, ec );
   }
 
   inline
   void convert( const wchar_t * from,
                 std::string & to,
- const codecvt_type & cvt )
+ const codecvt_type & cvt,
+ system::error_code & ec = throws() )
   {
     BOOST_ASSERT( from );
- convert( from, 0, to, cvt );
+ convert( from, 0, to, cvt, ec );
   }
 
   // value types same -----------------------------------------------------------------//
@@ -158,40 +137,42 @@
 
   inline
   void convert( const char * from, const char * from_end, std::string & to,
- const codecvt_type & )
+ const codecvt_type &, system::error_code & ec = throws() )
   {
     BOOST_ASSERT( from );
     BOOST_ASSERT( from_end );
     to.append( from, from_end );
+ if ( &ec != &throws() ) ec.clear();
   }
 
   inline
- void convert( const char * from,
- std::string & to,
- const codecvt_type & )
+ void convert( const char * from, std::string & to, const codecvt_type &,
+ system::error_code & ec = throws() )
   {
     BOOST_ASSERT( from );
     to += from;
+ if ( &ec != &throws() ) ec.clear();
   }
 
   // wchar_t
 
   inline
   void convert( const wchar_t * from, const wchar_t * from_end, std::wstring & to,
- const codecvt_type & )
+ const codecvt_type &, system::error_code & ec = throws() )
   {
     BOOST_ASSERT( from );
     BOOST_ASSERT( from_end );
     to.append( from, from_end );
+ if ( &ec != &throws() ) ec.clear();
   }
 
   inline
- void convert( const wchar_t * from,
- std::wstring & to,
- const codecvt_type & )
+ void convert( const wchar_t * from, std::wstring & to, const codecvt_type &,
+ system::error_code & ec = throws() )
   {
     BOOST_ASSERT( from );
     to += from;
+ if ( &ec != &throws() ) ec.clear();
   }
 
 }}} // namespace boost::filesystem::path_traits

Added: sandbox/filesystem-v3/libs/filesystem/src/codecvt_error_category.cpp
==============================================================================
--- (empty file)
+++ sandbox/filesystem-v3/libs/filesystem/src/codecvt_error_category.cpp 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -0,0 +1,79 @@
+// codecvt_error_category implementation file ----------------------------------------//
+
+// 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 at http://www.boost.org/libs/filesystem
+
+//--------------------------------------------------------------------------------------//
+
+#include <boost/config/warning_disable.hpp>
+
+// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_FILESYSTEM_SOURCE
+
+#include <boost/filesystem/config.hpp>
+#include <boost/filesystem/path_traits.hpp>
+#include <boost/system/error_code.hpp>
+#include <vector>
+#include <cstdlib>
+#include <cassert>
+
+//--------------------------------------------------------------------------------------//
+
+namespace
+{
+ class codecvt_error_cat : public boost::system::error_category
+ {
+ public:
+ codecvt_error_cat(){}
+ const char * name() const;
+ std::string message( int ev ) const;
+ };
+
+ const char * codecvt_error_cat::name() const
+ {
+ return "codecvt";
+ }
+
+ std::string codecvt_error_cat::message( int ev ) const
+ {
+ std::string str;
+ switch (ev)
+ {
+ case std::codecvt_base::ok:
+ str = "ok";
+ break;
+ case std::codecvt_base::partial:
+ str = "partial";
+ break;
+ case std::codecvt_base::error:
+ str = "error";
+ break;
+ case std::codecvt_base::noconv:
+ str = "noconv";
+ break;
+ default:
+ str = "unknown error";
+ }
+ return str;
+ }
+
+} // unnamed namespace
+
+namespace boost
+{
+ namespace filesystem
+ {
+
+ BOOST_FILESYSTEM_DECL const boost::system::error_category& codecvt_error_category()
+ {
+ static const codecvt_error_cat codecvt_error_cat_const;
+ return codecvt_error_cat_const;
+ }
+
+ } // namespace system
+} // namespace boost

Modified: sandbox/filesystem-v3/libs/filesystem/src/operations.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/operations.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/operations.cpp 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -1441,23 +1441,19 @@
 // <boost/filesystem/path_traits.hpp>, thus avoiding header circularity.
 // test cases are in operations_unit_test.cpp
 
- namespace path_traits
+namespace path_traits
+{
+ void dispatch( const directory_entry & de,
+# ifdef BOOST_WINDOWS_API
+ std::wstring & to,
+# else
+ std::string & to,
+# endif
+ const codecvt_type &, system::error_code & ec )
   {
-# ifdef BOOST_WINDOWS_API
-
- void dispatch( const directory_entry & de, std::wstring & to, const codecvt_type & )
- {
- to = de.path().native();
- }
-
-# else
-
- void dispatch( const directory_entry & de, std::string & to, const codecvt_type & )
- {
- to = de.path().native();
- }
-
-# endif
+ to = de.path().native();
+ if ( &ec != &throws() ) ec.clear();
+ }
 
 } // namespace path_traits
 } // namespace filesystem

Modified: sandbox/filesystem-v3/libs/filesystem/src/path.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/path.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/path.cpp 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -140,12 +140,14 @@
 
 # ifdef BOOST_WINDOWS_PATH
 
- const std::string path::native_string() const
+ const std::string path::native_string( system::error_code & ec ) const
   {
     std::string tmp;
     if ( !m_path.empty() )
       path_traits::convert( &*m_path.begin(), &*m_path.begin()+m_path.size(),
- tmp, codecvt() );
+ tmp, codecvt(), ec );
+ else
+ if ( &ec != &throws() ) ec.clear();
     return tmp;
   }
 
@@ -159,11 +161,11 @@
     }
   }
 
- const std::string path::string() const
+ const std::string path::string( system::error_code & ec ) const
   {
     path tmp( *this );
     tmp.m_portable();
- return tmp.native_string();
+ return tmp.native_string( ec );
   }
 
   const std::wstring path::wstring() const

Modified: sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/src/path_traits.cpp 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -13,12 +13,16 @@
 
 #include <boost/filesystem/path_traits.hpp>
 #include <boost/filesystem/config.hpp>
+#include <boost/system/system_error.hpp>
 #include <boost/scoped_array.hpp>
+#include <boost/throw_exception.hpp>
 #include <locale> // for codecvt_base::result
 #include <cstring> // for strlen
 #include <cwchar> // for wcslen
 
 namespace pt = boost::filesystem::path_traits;
+namespace fs = boost::filesystem;
+namespace bs = boost::system;
 
 //--------------------------------------------------------------------------------------//
 // configuration //
@@ -49,7 +53,8 @@
                    const char * from_end,
                    wchar_t * to, wchar_t * to_end,
                    std::wstring & target,
- const pt::codecvt_type & cvt )
+ const pt::codecvt_type & cvt,
+ bs::error_code & ec )
   {
     //std::cout << std::hex
     // << " from=" << std::size_t(from)
@@ -68,10 +73,14 @@
            to, to_end, to_next )) != std::codecvt_base::ok )
     {
       //std::cout << " result is " << static_cast<int>(res) << std::endl;
- assert( 0 && "append error handling not implemented yet" );
- throw "append error handling not implemented yet";
+ if ( &ec == &boost::throws() )
+ boost::throw_exception( bs::system_error( res, fs::codecvt_error_category(),
+ "boost::filesystem::path codecvt to wstring" ) );
+ else
+ ec.assign( res, fs::codecvt_error_category() );
     }
     target.append( to, to_next );
+ if ( &ec != &boost::throws() ) ec.clear();
   }
 
 //--------------------------------------------------------------------------------------//
@@ -83,7 +92,8 @@
                    const wchar_t * from_end,
                    char * to, char * to_end,
                    std::string & target,
- const pt::codecvt_type & cvt )
+ const pt::codecvt_type & cvt,
+ bs::error_code & ec )
   {
     //std::cout << std::hex
     // << " from=" << std::size_t(from)
@@ -102,10 +112,14 @@
            to, to_end, to_next )) != std::codecvt_base::ok )
     {
       //std::cout << " result is " << static_cast<int>(res) << std::endl;
- assert( 0 && "append error handling not implemented yet" );
- throw "append error handling not implemented yet";
+ if ( &ec == &boost::throws() )
+ boost::throw_exception( bs::system_error( res, fs::codecvt_error_category(),
+ "boost::filesystem::path codecvt to string" ) );
+ else
+ ec.assign( res, fs::codecvt_error_category() );
     }
     target.append( to, to_next );
+ if ( &ec != &boost::throws() ) ec.clear();
   }
   
 } // unnamed namespace
@@ -124,7 +138,8 @@
   void convert( const char * from,
                 const char * from_end, // 0 for null terminated MBCS
                 std::wstring & to,
- const codecvt_type & cvt )
+ const codecvt_type & cvt,
+ bs::error_code & ec )
   {
     BOOST_ASSERT( from );
 
@@ -141,12 +156,12 @@
     if ( buf_size > default_codecvt_buf_size )
     {
       boost::scoped_array< wchar_t > buf( new wchar_t [buf_size] );
- convert_aux( from, from_end, buf.get(), buf.get()+buf_size, to, cvt );
+ convert_aux( from, from_end, buf.get(), buf.get()+buf_size, to, cvt, ec );
     }
     else
     {
       wchar_t buf[default_codecvt_buf_size];
- convert_aux( from, from_end, buf, buf+default_codecvt_buf_size, to, cvt );
+ convert_aux( from, from_end, buf, buf+default_codecvt_buf_size, to, cvt, ec );
     }
   }
 
@@ -158,7 +173,8 @@
   void convert( const wchar_t * from,
                 const wchar_t * from_end, // 0 for null terminated MBCS
                 std::string & to,
- const codecvt_type & cvt )
+ const codecvt_type & cvt,
+ bs::error_code & ec )
   {
     BOOST_ASSERT( from );
 
@@ -180,12 +196,12 @@
     if ( buf_size > default_codecvt_buf_size )
     {
       boost::scoped_array< char > buf( new char [buf_size] );
- convert_aux( from, from_end, buf.get(), buf.get()+buf_size, to, cvt );
+ convert_aux( from, from_end, buf.get(), buf.get()+buf_size, to, cvt, ec );
     }
     else
     {
       char buf[default_codecvt_buf_size];
- convert_aux( from, from_end, buf, buf+default_codecvt_buf_size, to, cvt );
+ convert_aux( from, from_end, buf, buf+default_codecvt_buf_size, to, cvt, ec );
     }
   }
 }}} // namespace boost::filesystem::path_traits

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/convenience_test/convenience_test.vcproj 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -173,6 +173,10 @@
                         UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
                         <File
+ RelativePath="..\..\..\src\codecvt_error_category.cpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\convenience_test.cpp"
>
                         </File>

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/filesystem_dll/filesystem_dll.vcproj 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -175,6 +175,10 @@
                         UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
                         <File
+ RelativePath="..\..\..\src\codecvt_error_category.cpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\src\operations.cpp"
>
                         </File>

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_test/operations_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_test/operations_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_test/operations_test.vcproj 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -172,6 +172,10 @@
                         UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
                         <File
+ RelativePath="..\..\..\src\codecvt_error_category.cpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\..\system\src\error_code.cpp"
>
                         </File>

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/operations_unit_test/operations_unit_test.vcproj 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -175,6 +175,10 @@
                         UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
                         <File
+ RelativePath="..\..\..\src\codecvt_error_category.cpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\..\system\src\error_code.cpp"
>
                         </File>
@@ -195,6 +199,14 @@
>
                         </File>
                         <File
+ RelativePath="..\..\..\src\portability.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\src\utf8_codecvt_facet.cpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\src\windows_file_codecvt.cpp"
>
                         </File>

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/path_test/path_test.vcproj 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -173,6 +173,10 @@
                         UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
                         <File
+ RelativePath="..\..\..\src\codecvt_error_category.cpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\..\system\src\error_code.cpp"
>
                         </File>

Modified: sandbox/filesystem-v3/libs/filesystem/test/msvc/path_unit_test/path_unit_test.vcproj
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/msvc/path_unit_test/path_unit_test.vcproj (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/msvc/path_unit_test/path_unit_test.vcproj 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -173,6 +173,10 @@
                         UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
                         <File
+ RelativePath="..\..\..\src\codecvt_error_category.cpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\..\system\src\error_code.cpp"
>
                         </File>

Modified: sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/path_unit_test.cpp 2009-10-07 15:52:54 EDT (Wed, 07 Oct 2009)
@@ -26,6 +26,7 @@
 #include <iostream>
 #include <sstream>
 #include <string>
+#include <locale>
 
 namespace fs = boost::filesystem;
 using boost::filesystem::path;
@@ -554,6 +555,55 @@
     std::cout << " locale testing complete" << std::endl;
   }
 
+ // test_overloads ------------------------------------------------------------------//
+
+ void test_overloads()
+ {
+ std::cout << "testing overloads..." << std::endl;
+ std::string s("hello");
+ const char a[] = "goodbye";
+ path p1( s );
+ path p2( s.c_str() );
+ path p3( a );
+ path p4( "foo" );
+
+ std::wstring ws(L"hello");
+ const wchar_t wa[] = L"goodbye";
+ path wp1( ws );
+ path wp2( ws.c_str() );
+ path wp3( wa );
+ path wp4( L"foo" );
+ }
+
+ // test_error_handling -------------------------------------------------------------//
+
+ void test_error_handling()
+ {
+ std::cout << "testing error handling..." << std::endl;
+
+ boost::system::error_code ec ( -1, fs::codecvt_error_category() );
+
+ BOOST_TEST( ec );
+ path p1( "foo", ec );
+ BOOST_TEST( !ec );
+
+# ifdef BOOST_WINDOWS_PATH
+
+ ec.assign( -1, fs::codecvt_error_category() );
+ BOOST_TEST( ec );
+ path p2( L"\u2780", ec ); // \u2780 is circled 1, white background == e2 9e 80 in UTF-8
+ BOOST_TEST( !ec );
+
+ ec.clear();
+ std::string s2 ( p2.string( ec ) );
+ BOOST_TEST( ec );
+ BOOST_TEST_EQ( ec, boost::system::error_code( std::codecvt_base::error,
+ fs::codecvt_error_category() ) );
+
+# endif
+
+ }
+
 # if 0
 
 // // test_locales --------------------------------------------------------------------//
@@ -635,26 +685,6 @@
 
 # endif
 
- // test_overloads ------------------------------------------------------------------//
-
- void test_overloads()
- {
- std::cout << "testing overloads..." << std::endl;
- std::string s("hello");
- const char a[] = "goodbye";
- path p1( s );
- path p2( s.c_str() );
- path p3( a );
- path p4( "foo" );
-
- std::wstring ws(L"hello");
- const wchar_t wa[] = L"goodbye";
- path wp1( ws );
- path wp2( ws.c_str() );
- path wp3( wa );
- path wp4( L"foo" );
- }
-
 } // unnamed namespace
 
 //--------------------------------------------------------------------------------------//
@@ -678,6 +708,7 @@
   test_decompositions();
   test_queries();
   test_imbue_locale();
+ test_error_handling();
 
 # if 0
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk