Ticket #3505: mapped_file.cpp.2.patch

File mapped_file.cpp.2.patch, 1015 bytes (added by yrs90@…, 13 years ago)

mapped_file, Windows build, invalid handle check patch (omits diff against unrelated file mistakenly included in previous patch)

  • libs/iostreams/src/mapped_file.cpp

    diff -r 23a892ae0220 libs/iostreams/src/mapped_file.cpp
    a b  
    169169    #ifndef NDEBUG
    170170        msg += std::string(" (\"") + impl.path_ + "\")";
    171171    #endif
    172     if (impl.mapped_handle_ != INVALID_HANDLE_VALUE)
     172    if (impl.mapped_handle_ != NULL)
    173173        ::CloseHandle(impl.mapped_handle_);
    174     if (impl.handle_ != NULL)
     174    if (impl.handle_ != INVALID_HANDLE_VALUE)
    175175        ::CloseHandle(impl.handle_);
    176176    impl.clear(true);
    177177    throw_system_failure(msg);
     
    399399    return;
    400400}
    401401
     402#ifdef BOOST_IOSTREAMS_WINDOWS
     403bool mapped_file_source::is_open() const
     404{ return !!pimpl_ && pimpl_->handle_ != INVALID_HANDLE_VALUE; }
     405#else
    402406bool mapped_file_source::is_open() const
    403407{ return !!pimpl_ && pimpl_->handle_ != 0; }
     408#endif
    404409
    405410int mapped_file_source::alignment()
    406411{ return static_cast<int>(sysconf(_SC_PAGESIZE)); }