readText for large files on Windows.

Rikki Cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 19 18:41:22 PDT 2015


On 20/04/2015 7:06 a.m., Kenny wrote:
> This function works fine for large text files like 100Mb or 1Gb but
> failed when I tried to read 6Gb file. This happens on Windows x64.
>
> The possible reason that it uses read(in char[], size_t) function and on
> windows it calls GetFileSize. This function returns file size as 32 bit
> value. If you need size for files larger then 4Gb then this function
> provides out parameter where you can pass reference to another 32 bit
> value. But in DMD 2.067 this function is called as
>
> auto size = trustedGetFileSize(h, null);
>
> thus we never get correct size for files larget then 4Gb.
>
> Is it a bug?

It should probably be using GetFileSizeEx instead.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364957(v=vs.85).aspx

So yes, bug.


More information about the Digitalmars-d-learn mailing list