digitalmars.D.learn - Simple delete directory tree?
- Nick Sabalausky (2/2) Apr 26 2013 Does phobos have a simple way to delete a directory tree?
- Andrej Mitrovic (2/5) Apr 26 2013 Try rmdirRecurse
- Nick Sabalausky (5/11) Apr 26 2013 I don't know how I managed to overlook that! Thanks :)
- Andrej Mitrovic (4/5) Apr 26 2013 I'd actually prefer if it was an enum or some other default parameter
- Nick Sabalausky (3/11) Apr 26 2013 Yea, that'd be kinda nice.
- Marco Leise (5/12) Apr 28 2013 +1
- Nick Sabalausky (8/23) Apr 26 2013 FWIW, This seems to work fine, at least on windows:
- Jacob Carlborg (4/10) Apr 27 2013 That's cheating.
- Jonathan M Davis (21/35) Apr 27 2013 That's an interesting problem to solve. If you can't legally remove a fi...
Does phobos have a simple way to delete a directory tree? std.file.rmdir(path) and std.file.remove(path) don't seem to do it.
Apr 26 2013
On Friday, 26 April 2013 at 20:54:41 UTC, Nick Sabalausky wrote:Does phobos have a simple way to delete a directory tree? std.file.rmdir(path) and std.file.remove(path) don't seem to do it.Try rmdirRecurse
Apr 26 2013
On Fri, 26 Apr 2013 22:55:36 +0200 "Andrej Mitrovic" <andrej.mitrovich gmail.com> wrote:On Friday, 26 April 2013 at 20:54:41 UTC, Nick Sabalausky wrote:I don't know how I managed to overlook that! Thanks :) Unfortunately, that's still choking with "Access is denied" on something inside a ".git" subdirectory.Does phobos have a simple way to delete a directory tree? std.file.rmdir(path) and std.file.remove(path) don't seem to do it.Try rmdirRecurse
Apr 26 2013
On 4/26/13, Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> wrote:I don't know how I managed to overlook that! Thanks :)I'd actually prefer if it was an enum or some other default parameter in the rmdir function itself: rmdir(string path, bool doRecurse = false);
Apr 26 2013
On Fri, 26 Apr 2013 23:15:20 +0200 Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:On 4/26/13, Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> wrote:Yea, that'd be kinda nice.I don't know how I managed to overlook that! Thanks :)I'd actually prefer if it was an enum or some other default parameter in the rmdir function itself: rmdir(string path, bool doRecurse = false);
Apr 26 2013
Am Fri, 26 Apr 2013 23:15:20 +0200 schrieb Andrej Mitrovic <andrej.mitrovich gmail.com>:On 4/26/13, Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> wrote:+1 -- MarcoI don't know how I managed to overlook that! Thanks :)I'd actually prefer if it was an enum or some other default parameter in the rmdir function itself: rmdir(string path, bool doRecurse = false);
Apr 28 2013
On Fri, 26 Apr 2013 17:01:43 -0400 Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> wrote:On Fri, 26 Apr 2013 22:55:36 +0200 "Andrej Mitrovic" <andrej.mitrovich gmail.com> wrote:FWIW, This seems to work fine, at least on windows: import std.process; version(Windows) system(`rmdir /S /Q "`~path~`"`); else system(`rm -rf '`~path~`'`);On Friday, 26 April 2013 at 20:54:41 UTC, Nick Sabalausky wrote:I don't know how I managed to overlook that! Thanks :) Unfortunately, that's still choking with "Access is denied" on something inside a ".git" subdirectory.Does phobos have a simple way to delete a directory tree? std.file.rmdir(path) and std.file.remove(path) don't seem to do it.Try rmdirRecurse
Apr 26 2013
On 2013-04-26 23:25, Nick Sabalausky wrote:FWIW, This seems to work fine, at least on windows: import std.process; version(Windows) system(`rmdir /S /Q "`~path~`"`); else system(`rm -rf '`~path~`'`);That's cheating. -- /Jacob Carlborg
Apr 27 2013
On Friday, April 26, 2013 17:01:43 Nick Sabalausky wrote:On Fri, 26 Apr 2013 22:55:36 +0200 "Andrej Mitrovic" <andrej.mitrovich gmail.com> wrote:That's an interesting problem to solve. If you can't legally remove a file, then rmdirRecurse either has to throw or ignore it. If it ignores it, the only way to know what went wrong would be to loop through the files that were removed (which could also blow up depending on the file permissions) and see what happens when you try and call remove or rmdir on them directly. On the other hand, if it throws, then you're basically forces to re-implement rmdirRecurse yourself and make it delete every file that you can if you want to at least delete the files that you can delete. Neither approach is exactly ideal. Maybe rmdirRecurse should be changed so that it ignores exceptions and returns whether it succeeded at removing everything or not (since it's void right now). However, if it _did_ fail due to a permissions issue, odds are that it would fail a _lot_ (especially if you're talking about a directory that you don't have permission to write to), and that would be very expensive. So, that might not be a good idea. We _could_ add another argument for telling it which behavior you wanted though. But I'm not sure that providing options like that is a good idea in the general case, particularly when you start considering all of the combinations of behaviors that functions like this could have. Still, it may be merited in this case. I don't know. - Jonathan M DavisOn Friday, 26 April 2013 at 20:54:41 UTC, Nick Sabalausky wrote:I don't know how I managed to overlook that! Thanks :) Unfortunately, that's still choking with "Access is denied" on something inside a ".git" subdirectory.Does phobos have a simple way to delete a directory tree? std.file.rmdir(path) and std.file.remove(path) don't seem to do it.Try rmdirRecurse
Apr 27 2013