Boost logo

Boost :

Subject: Re: [boost] [iostreams]mapped_file bug on Win32?
From: eg (egoots_at_[hidden])
Date: 2010-02-22 13:17:02


On 2/21/2010 11:05 PM, eg wrote:

>
>> Shortly thereafter is a call to SetFilePointer. The docs say that the
>> proper way to check for an error from SetFilePointer is to compare its
>> return value to INVALID_SET_VALUE_POINTER.
>>
>> http://msdn.microsoft.com/en-us/library/aa365541%28VS.85%29.aspx
>>
>
> According to the docs... that seems to only be true if the 3rd parameter
> is NULL.
>
> Otherwise:
> "If function succeeds and lpDistanceToMoveHigh is not NULL, the return
> value is the low-order DWORD of the new file pointer and
> lpDistanceToMoveHigh contains the high order DWORD of the new file
> pointer."
>

Oops... I forgot to add the next line in the quote, which makes my point
more understandable:

"If the function fails, the return value is INVALID_SET_FILE_POINTER. To
get extended error information, call GetLastError."

I was just trying to point out there is a case in which GetLastError()
should be called.

The remarks section shows sample code such as the following:

// Try to move hFile file pointer a huge distance
        DWORD dwPtrLow = SetFilePointer( hFile,
                                      lDistLow,
                                      &lDistHigh,
                                      FILE_BEGIN );
        
        // Test for failure
        if ( dwPtrLow == INVALID_SET_FILE_POINTER &&
             GetLastError() != NO_ERROR )
        {
                // Deal with failure
                // . . .

        } // End of error handler


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