Boost logo

Boost :

From: SourceForge.net (noreply_at_[hidden])
Date: 2006-08-01 16:10:14


Bugs item #1532684, was opened at 2006-08-01 13:10
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1532684&group_id=7586

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Changing size of memory-mapped file on Windows

Initial Comment:
My email address is barrywhart_at_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?!
----------------------------------------------------------------------
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1532684&group_id=7586
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk