Menu

#133 FILE_FLAG_NO_BUFFERING read operations don't work correctly

v1.0_(example)
closed-fixed
Matt Wu
None
3
2015-08-06
2015-04-07
Nikola
No

Try to read file with size 524288(0x80000) bytes
by this code

include <windows.h>

include <iostream>

int wmain(int argc, wchar_t ** argv)
{
const DWORD size = 524288;

HANDLE h = ::CreateFileW(L"some-file-with-size-524288", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
if (h == INVALID_HANDLE_VALUE)
{
    std::cerr << "Failed to open file\n";
    return 1;
}

BYTE buf[size];
DWORD read;
BOOL res;

for(int i = 0; i != 3; ++i)
{
    res = ::ReadFile(h, buf, size, &read, NULL);
    std::cout << res << ' ' << read << ' ' << GetLastError() << "\n";
}

}

Program writes
1 524288 0
1 524288 0
1 524288 0
but
1 524288 0
1 0 0
1 0 0
is expected

Discussion

  • Matt Wu

    Matt Wu - 2015-08-06
    • status: open --> closed-fixed
    • assigned_to: Matt Wu
     
  • Matt Wu

    Matt Wu - 2015-08-06

    Internal fileoffset was not updated for noncached i/o. Fixed in 0.60.

     

Log in to post a comment.