Hello all,

I have some code which needs to read in data from a large number of files in a directory.

The basic data input code goes something like this:

    foreach(DirEntry e; dirEntries(...))
    {
        auto f = file(e.name, "r");
        // we input data from f.
    }

This runs fine with ldc and dmd. However, if I compile with gdc (4.6.3) I get the following error while running the program:

------------------------------------------------------------------------------
std.exception.ErrnoException@../../../src/libphobos/std/stdio.d(330): Cannot open file in mode `r' (Too many open files)
------------------------------------------------------------------------------

This is trivial to work around by putting an explicit f.close() at the end of the loop, but it looks like a bug to me as f should in any case automatically be closed at the end of the scope -- no?

I don't see a bug report on BitBucket about this, but thought I'd check here first in case this is something that has already been fixed in the latest version.

Thanks & best wishes,

    -- Joe

Reply via email to