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: nob...@puremagic.com
        ReportedBy: andrej.mitrov...@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrov...@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@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: -------

Reply via email to