$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: technews_at_[hidden]
Date: 2007-12-29 20:56:17
Author: turkanis
Date: 2007-12-29 20:56:16 EST (Sat, 29 Dec 2007)
New Revision: 42353
URL: http://svn.boost.org/trac/boost/changeset/42353
Log:
fixed error ching in win32 API (addresses ticket #699); exposed size() in mapped_file_sink
Text files modified: 
   branches/iostreams_dev/boost/iostreams/device/mapped_file.hpp |     1 +                                       
   branches/iostreams_dev/libs/iostreams/src/mapped_file.cpp     |    12 ++++++++++--                            
   2 files changed, 11 insertions(+), 2 deletions(-)
Modified: branches/iostreams_dev/boost/iostreams/device/mapped_file.hpp
==============================================================================
--- branches/iostreams_dev/boost/iostreams/device/mapped_file.hpp	(original)
+++ branches/iostreams_dev/boost/iostreams/device/mapped_file.hpp	2007-12-29 20:56:16 EST (Sat, 29 Dec 2007)
@@ -221,6 +221,7 @@
           public closable_tag
         { };
     using mapped_file::close;
+    using mapped_file::size;
     explicit mapped_file_sink(mapped_file_params p);
     explicit mapped_file_sink( const std::string& path,
                                size_type length = max_length,
Modified: branches/iostreams_dev/libs/iostreams/src/mapped_file.cpp
==============================================================================
--- branches/iostreams_dev/libs/iostreams/src/mapped_file.cpp	(original)
+++ branches/iostreams_dev/libs/iostreams/src/mapped_file.cpp	2007-12-29 20:56:16 EST (Sat, 29 Dec 2007)
@@ -22,6 +22,9 @@
 #ifdef BOOST_IOSTREAMS_WINDOWS
 # define WIN32_LEAN_AND_MEAN  // Exclude rarely-used stuff from Windows headers
 # include <windows.h>
+# ifndef INVALID_SET_FILE_POINTER
+#  define INVALID_SET_FILE_POINTER ((DWORD)-1)
+# endif
 #else
 # include <errno.h>
 # include <fcntl.h>
@@ -194,9 +197,14 @@
     if (p.new_file_size != 0 && !readonly) {
         LONG sizehigh = (p.new_file_size >> (sizeof(LONG) * 8));
         LONG sizelow = (p.new_file_size & 0xffffffff);
-        ::SetFilePointer(pimpl_->handle_, sizelow, &sizehigh, FILE_BEGIN);
-        if (::GetLastError() != NO_ERROR || !::SetEndOfFile(pimpl_->handle_))
+        DWORD result =
+            ::SetFilePointer(pimpl_->handle_, sizelow, &sizehigh, FILE_BEGIN);
+        if ( result == INVALID_SET_FILE_POINTER && 
+                 ::GetLastError() != NO_ERROR || 
+             !::SetEndOfFile(pimpl_->handle_) )
+        {
             detail::cleanup_and_throw(*pimpl_, "failed setting file size");
+        }
     }
 
     //--------------Create mapping--------------------------------------------//