Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74327 - sandbox/mmap/boost/mmap/mappble_objects/file
From: dsaritz_at_[hidden]
Date: 2011-09-09 11:53:52


Author: psiha
Date: 2011-09-09 11:53:50 EDT (Fri, 09 Sep 2011)
New Revision: 74327
URL: http://svn.boost.org/trac/boost/changeset/74327

Log:
Added wchar_t overloads for file utility functions under Windows
Text files modified:
   sandbox/mmap/boost/mmap/mappble_objects/file/utility.hpp | 5 +
   sandbox/mmap/boost/mmap/mappble_objects/file/utility.inl | 152 +++++++++++++++++++++++----------------
   2 files changed, 93 insertions(+), 64 deletions(-)

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/utility.hpp
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/utility.hpp (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/utility.hpp 2011-09-09 11:53:50 EDT (Fri, 09 Sep 2011)
@@ -31,6 +31,11 @@
 basic_mapped_view_ref map_file ( char const * file_name, std::size_t desired_size );
 basic_mapped_read_only_view_ref map_read_only_file( char const * file_name );
 
+#ifdef _WIN32
+basic_mapped_view_ref map_file ( wchar_t const * file_name, std::size_t desired_size );
+basic_mapped_read_only_view_ref map_read_only_file( wchar_t const * file_name );
+#endif // _WIN32
+
 //------------------------------------------------------------------------------
 } // namespace mmap
 //------------------------------------------------------------------------------

Modified: sandbox/mmap/boost/mmap/mappble_objects/file/utility.inl
==============================================================================
--- sandbox/mmap/boost/mmap/mappble_objects/file/utility.inl (original)
+++ sandbox/mmap/boost/mmap/mappble_objects/file/utility.inl 2011-09-09 11:53:50 EDT (Fri, 09 Sep 2011)
@@ -27,83 +27,107 @@
 {
 //------------------------------------------------------------------------------
 
-BOOST_IMPL_INLINE
-basic_mapped_view_ref map_file( char const * const file_name, std::size_t desired_size )
+namespace detail
 {
     typedef file_open_flags<BOOST_MMAP_IMPL()> open_flags;
- file_handle<BOOST_MMAP_IMPL()> const file_handle
- (
- create_file
+ typedef file_handle <BOOST_MMAP_IMPL()> default_file_handle;
+
+ BOOST_IMPL_INLINE
+ open_flags create_rw_file_flags()
+ {
+ return open_flags::create
+ (
+ open_flags::handle_access_rights ::read | open_flags::handle_access_rights::write,
+ open_flags::open_policy ::open_or_create,
+ open_flags::system_hints ::sequential_access,
+ open_flags::on_construction_rights::read | open_flags::on_construction_rights::write
+ );
+ }
+
+ BOOST_IMPL_INLINE
+ open_flags create_r_file_flags()
+ {
+ return open_flags::create_for_opening_existing_files
+ (
+ open_flags::handle_access_rights::read,
+ false,
+ open_flags::system_hints ::sequential_access
+ );
+ }
+
+ BOOST_IMPL_INLINE
+ basic_mapped_view_ref map_file( default_file_handle::reference const file_handle, std::size_t desired_size )
+ {
+ if ( desired_size )
+ set_size( file_handle, desired_size );
+ else
+ desired_size = get_size( file_handle );
+
+ typedef file_mapping_flags<BOOST_MMAP_IMPL()> mapping_flags;
+ return basic_mapped_view_ref::map
         (
- file_name,
- open_flags::create
+ create_mapping
             (
- open_flags::handle_access_rights ::read | open_flags::handle_access_rights::write,
- open_flags::open_policy ::open_or_create,
- open_flags::system_hints ::sequential_access,
- open_flags::on_construction_rights::read | open_flags::on_construction_rights::write
- )
- )
- );
-
- if ( desired_size )
- set_size( file_handle.get(), desired_size );
- else
- desired_size = get_size( file_handle.get() );
-
- typedef file_mapping_flags<BOOST_MMAP_IMPL()> mapping_flags;
- return basic_mapped_view_ref::map
- (
- create_mapping
+ file_handle,
+ mapping_flags::create
+ (
+ mapping_flags::handle_access_rights::read | mapping_flags::handle_access_rights::write,
+ mapping_flags::share_mode ::shared
+ )
+ ),
+ 0,
+ desired_size
+ );
+ }
+
+
+ BOOST_IMPL_INLINE
+ basic_mapped_read_only_view_ref map_read_only_file( default_file_handle::reference const file_handle )
+ {
+ typedef file_mapping_flags<BOOST_MMAP_IMPL()> mapping_flags;
+ return basic_mapped_read_only_view_ref::map
         (
- file_handle,
- mapping_flags::create
+ create_mapping
             (
- mapping_flags::handle_access_rights::read | mapping_flags::handle_access_rights::write,
- mapping_flags::share_mode ::shared
- )
- ),
- 0,
- desired_size
- );
-}
+ file_handle,
+ mapping_flags::create
+ (
+ mapping_flags::handle_access_rights::read,
+ mapping_flags::share_mode ::shared
+ )
+ ),
+ 0,
+ get_size( file_handle )
+ );
+ }
+} // namespace detail
 
+BOOST_IMPL_INLINE
+basic_mapped_view_ref map_file( char const * const file_name, std::size_t const desired_size )
+{
+ return detail::map_file( create_file( file_name, detail::create_rw_file_flags() ), desired_size );
+}
 
 BOOST_IMPL_INLINE
 basic_mapped_read_only_view_ref map_read_only_file( char const * const file_name )
 {
- typedef file_open_flags<BOOST_MMAP_IMPL()> open_flags;
- file_handle<BOOST_MMAP_IMPL()> const file_handle
- (
- create_file
- (
- file_name,
- open_flags::create_for_opening_existing_files
- (
- open_flags::handle_access_rights::read,
- false,
- open_flags::system_hints ::sequential_access
- )
- )
- );
-
- typedef file_mapping_flags<BOOST_MMAP_IMPL()> mapping_flags;
- return basic_mapped_read_only_view_ref::map
- (
- create_mapping
- (
- file_handle,
- mapping_flags::create
- (
- mapping_flags::handle_access_rights::read,
- mapping_flags::share_mode ::shared
- )
- ),
- 0,
- get_size( file_handle.get() )
- );
+ return detail::map_read_only_file( create_file( file_name, detail::create_r_file_flags() ) );
 }
 
+#ifdef _WIN32
+ BOOST_IMPL_INLINE
+ basic_mapped_view_ref map_file( wchar_t const * const file_name, std::size_t const desired_size )
+ {
+ return detail::map_file( create_file( file_name, detail::create_rw_file_flags() ), desired_size );
+ }
+
+ BOOST_IMPL_INLINE
+ basic_mapped_read_only_view_ref map_read_only_file( wchar_t const * const file_name )
+ {
+ return detail::map_read_only_file( create_file( file_name, detail::create_r_file_flags() ) );
+ }
+#endif // _WIN32
+
 //------------------------------------------------------------------------------
 } // mmap
 //------------------------------------------------------------------------------


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