System.Directory.removeDirectoryRecursive and symlinks

Gracjan Polak gracjanpolak at gmail.com
Tue Jun 10 19:19:30 UTC 2014


Isaac Dupree <ml <at> isaac.cedarswampstudios.org> writes:

> Should removeDirectoryRecursive also remove regular files when called on 
> a file?  That's what `rm -r` does, but it might not be what we want 
> `removeDirectoryRecursive` to do.

Easiest would be to removeLink, if that fails due to directory then empty
directory and then removeDirectory, but unlink man page says:

[EPERM] The named file is a directory and the effective user ID of the
process is not the super-user.

So unlink seems to sometimes be able to unlink directories. What happens to
such directories is not know to me. I also wasn't able to sucessfully unlink
directory, so hard to say what is going on. (Note that this bug is also
present in current implementation that recurses, tries removeFile, then
getDirectoryContents, then removeDirectory).

Who would have thought that removing directory would be that hard?

-- 
Gracjan




More information about the Libraries mailing list