Thread overview
readText for large files on Windows.
Apr 19, 2015
Kenny
Apr 20, 2015
Rikki Cattermole
Apr 20, 2015
Kenny
April 19, 2015
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?
April 20, 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.
April 20, 2015
Thanks. The bug is created.
https://issues.dlang.org/show_bug.cgi?id=14469