On Sunday, 25 September 2016 at 16:07:12 UTC, Matthias Klumpp wrote:
Hello!

I have a class similar to this one:
```
class Dummy
{

private:

    string tmpDir;

public:

    this (string fname)
    {
        tmpDir = buildPath ("/tmp", fname.baseName);
        std.file.mkdirRecurse (tmpDir);
    }

    ~this ()
    {
        close ();
    }

    void close ()
    {
        if (std.file.exists (tmpDir))
                std.file.rmdirRecurse (tmpDir);
    }
}
```

Another problem here is that tmpDir is GC-allocated, but by the time the constructor is called the string can be already collected, you can't read it. A possible solution would be to have a service which you would notify to delete the folder.

Reply via email to