On 12/24/2013 04:13 AM, Lemonfiend wrote:
std.file.rmdirRecurse refuses to remove readonly files.

How would I go about deleting them anyway?

Call std.file.setAttributes() first, which has apparently been added just three days ago: :)


https://github.com/D-Programming-Language/phobos/blob/master/std/file.d#L971

If you can't work with git head version of dmd, then do what it does yourself, depending on your platform:

void setAttributes(in char[] name, uint attributes)
{
    version (Windows)
    {
cenforce(SetFileAttributesW(std.utf.toUTF16z(name), attributes), name);
    }
    else version (Posix)
    {
        assert(attributes <= mode_t.max);
        cenforce(!chmod(toStringz(name), cast(mode_t)attributes), name);
    }
}

For example, if you are on Linux:

import core.sys.posix.sys.stat;
import std.conv;

// ...

    chmod("/my/file", cast(mode_t)octal!777)

Ali

Reply via email to