Opened 16 years ago
Last modified 15 years ago
#699 closed Bugs (fixed)
Changing size of memory-mapped file on Windows — at Version 1
Reported by: | nobody | Owned by: | Jonathan Turkanis |
---|---|---|---|
Milestone: | Component: | iostreams | |
Version: | None | Severity: | Problem |
Keywords: | Cc: |
Description (last modified by )
My email address is barrywhart@yahoo.com. There is a bug in mapped_file_source::open_impl(mapped_file_params p) This function does not correctly check for errors from SetFilePointer, as documented in the MSDN page below. (See "Case Two: calling the function with lpDistanceToMoveHigh != NULL") http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/setfilepointer.asp Current code: ::SetFilePointer(pimpl_->handle_, sizelow, &sizehigh, FILE_BEGIN); if (::GetLastError() != NO_ERROR || !::SetEndOfFile(pimpl_->handle_)) detail::cleanup_and_throw(*pimpl_, "failed setting file size"); Should be: DWORD dwResult = ::SetFilePointer(pimpl_->handle_, sizelow, &sizehigh, FILE_BEGIN); if (dwResult == INVALID_SET_FILE_POINTER ::GetLastError() != NO_ERROR || !::SetEndOfFile(pimpl_->handle_)) detail::cleanup_and_throw(*pimpl_, "failed setting file size"); -- Even after this fix, the ability to resize an existing file is not really useful because the file is apparently recreated rather than resized. I am working around this by resizing the file using system calls, but I wonder if this is how the function is supposed to work?!
Change History (1)
comment:1 by , 15 years ago
Component: | None → iostreams |
---|---|
Description: | modified (diff) |
Severity: | → Problem |
Note:
See TracTickets
for help on using tickets.