www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - readText for large files on Windows.

reply "Kenny" <artemalive gmail.com> writes:
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?
Apr 19 2015
parent reply Rikki Cattermole <alphaglosined gmail.com> writes:
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.
Apr 19 2015
parent "Kenny" <artemalive gmail.com> writes:
Thanks. The bug is created.
https://issues.dlang.org/show_bug.cgi?id=14469
Apr 19 2015