[Issue 7022] New: File.byLine doesn't release file handle

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 27 15:23:00 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=7022

           Summary: File.byLine doesn't release file handle
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrej.mitrovich at gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2011-11-27 15:21:59 PST ---
import std.stdio;
import std.file;
import std.process;

void test()
{
    auto file = File("test.txt", "r");
    foreach (line; file.byLine)  // remove and bug goes away
    {
    }
}

void main()
{
    system("echo blabla > test.txt");  // create file externally
    test();
    std.file.remove("test.txt");
}

std.file.FileException at std\file.d(549): test.txt: The process cannot access the
file because it is being used by another process.

Btw this has nothing to do with that system call, you can remove it if you have
a test.txt file.

As a workaround I can use scope(exit){ file.close(); }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list