Boost C++ Libraries: Ticket #699: Changing size of memory-mapped file on Windows https://svn.boost.org/trac10/ticket/699 <pre class="wiki">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_-&gt;handle_, sizelow, &amp;sizehigh, FILE_BEGIN); if (::GetLastError() != NO_ERROR || !::SetEndOfFile(pimpl_-&gt;handle_)) detail::cleanup_and_throw(*pimpl_, "failed setting file size"); Should be: DWORD dwResult = ::SetFilePointer(pimpl_-&gt;handle_, sizelow, &amp;sizehigh, FILE_BEGIN); if (dwResult == INVALID_SET_FILE_POINTER ::GetLastError() != NO_ERROR || !::SetEndOfFile(pimpl_-&gt;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?! </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/699 Trac 1.4.3 Marshall Clow Sun, 19 Aug 2007 15:55:52 GMT component, description changed; severity set https://svn.boost.org/trac10/ticket/699#comment:1 https://svn.boost.org/trac10/ticket/699#comment:1 <ul> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">iostreams</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/699?action=diff&amp;version=1">diff</a>) </li> <li><strong>severity</strong> → <span class="trac-field-new">Problem</span> </li> </ul> Ticket anonymous Tue, 02 Oct 2007 21:38:00 GMT <link>https://svn.boost.org/trac10/ticket/699#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/699#comment:2</guid> <description> <p> Is this a duplicate of Ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/856" title="#856: Bugs: iostreams file_descriptor::write fails under Win32 (closed: fixed)">#856</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jonathan Turkanis</dc:creator> <pubDate>Sat, 29 Dec 2007 20:05:07 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/699#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/699#comment:3</guid> <description> <p> this is not a duplicate of <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/699" title="#699: Bugs: Changing size of memory-mapped file on Windows (closed: fixed)">#699</a>; <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/699" title="#699: Bugs: Changing size of memory-mapped file on Windows (closed: fixed)">#699</a> deals with file_descriptor, not mapped_file </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jonathan Turkanis</dc:creator> <pubDate>Sun, 30 Dec 2007 02:00:32 GMT</pubDate> <title>status, resolution changed https://svn.boost.org/trac10/ticket/699#comment:4 https://svn.boost.org/trac10/ticket/699#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed use of <a class="missing wiki">SetFilePointer</a> in <a class="changeset" href="https://svn.boost.org/trac10/changeset/42353" title="fixed error ching in win32 API (addresses ticket #699); exposed size() ...">[42353]</a> in branches/iostreams_dev, to be merged with trunk shortly. </p> <p> Regarding the ability to resize an existing file, this is anot a supported feature. The new_file_size property of mapped_file_param is just a way to create a new file of a specified size. </p> <p> I realize that this is an old ticket, so you may not be interested in the issue anymore; however, if you would like to submit a feature request, I will consider it for 1.36. My initial feeling is that it should be a general file-resizing function, not limited to memory-mapped files; in that case, it would probably be best o put it in Boost.Filesystem. </p> Ticket