Boost logo

Boost-Commit :

From: technews_at_[hidden]
Date: 2007-12-22 20:00:55


Author: turkanis
Date: 2007-12-22 20:00:55 EST (Sat, 22 Dec 2007)
New Revision: 42252
URL: http://svn.boost.org/trac/boost/changeset/42252

Log:
Changed error checking on Windows API function. Adresses #856 (ported from sandbox-branches/birbacher/fix_iostreams); moved #define for INVALID_SET_FILE_POINTER to common location for use in write() and seek()
Text files modified:
   branches/iostreams_dev/libs/iostreams/src/file_descriptor.cpp | 10 ++++++----
   1 files changed, 6 insertions(+), 4 deletions(-)

Modified: branches/iostreams_dev/libs/iostreams/src/file_descriptor.cpp
==============================================================================
--- branches/iostreams_dev/libs/iostreams/src/file_descriptor.cpp (original)
+++ branches/iostreams_dev/libs/iostreams/src/file_descriptor.cpp 2007-12-22 20:00:55 EST (Sat, 22 Dec 2007)
@@ -31,6 +31,9 @@
 # include <io.h> // low-level file i/o.
 # define WINDOWS_LEAN_AND_MEAN
 # include <windows.h>
+# ifndef INVALID_SET_FILE_POINTER
+# define INVALID_SET_FILE_POINTER ((DWORD)-1)
+# endif
 #else
 # include <sys/types.h> // mode_t.
 # include <unistd.h> // low-level file i/o.
@@ -157,9 +160,6 @@
 std::streamsize file_descriptor::write(const char_type* s, std::streamsize n)
 {
 #ifdef BOOST_IOSTREAMS_WINDOWS
-# ifndef INVALID_SET_FILE_POINTER
-# define INVALID_SET_FILE_POINTER ((DWORD)-1)
-# endif
     if (pimpl_->flags_ & impl::has_handle) {
         if (pimpl_->flags_ & impl::append) {
             DWORD const dwResult =
@@ -199,7 +199,9 @@
                                   way == BOOST_IOS::cur ?
                                     FILE_CURRENT :
                                     FILE_END );
- if (::GetLastError() != NO_ERROR) {
+ if ( dwResultLow == INVALID_SET_FILE_POINTER &&
+ ::GetLastError() != NO_ERROR )
+ {
             throw detail::bad_seek();
         } else {
            return offset_to_position(


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