REBOL3 tracker
  0.9.12 beta
Ticket #0001545 User: anonymous


Previous Next
TypeWish Statusbuilt Date25-Mar-2010 10:50
Versionalpha 97 CategoryMezzanine Submitted byBrianH
PlatformAll Severityminor Prioritynormal

Summary DELETE-DIR function (from R2)
Description R2 has a DELETE-DIR function which recursively deletes the files from a directory, then the directory itself. Was this left out of R3 on purpose, or just forgotten?
Example code
; The R2 version, which could use a doc string and some tweaking
delete-dir: func [
    dir [file! url!]
    /local files
    if all [
        dir? dir
        dir: dirize dir
        attempt [files: load dir]
    ] [
        foreach file files [delete-dir dir/:file]
    attempt [delete dir]

Assigned ton/a Fixed inr3 master Last Update17-Feb-2014 23:49

27-Apr-2010 06:33

I felt that DELETE should do that as well, eliminating the extra function.
27-Apr-2010 09:01

Well, it doesn't. DELETE doesn't delete a directory that has files in it, at least on Windows. It does delete empty directories though.

I think whether DELETE-DIR should be included (or whether DELETE should delete directories with files in them) is a safety issue. By not including DELETE-DIR by default, perhaps putting it into a filetools module instead, it would make it a little harder to shoot yourself in the foot with a shotgun instead of a pellet gun. I'd use that filetools module, but would be OK with not having it loaded by default. If that is the choice, dismiss this ticket.

Date User Field Action Change
17-Feb-2014 23:49 BrianH Fixedin Modified => r3 master
17-Feb-2014 23:49 BrianH Status Modified reviewed => built
28-Apr-2010 21:07 BrianH Comment : 0002256 Modified -
27-Apr-2010 09:01 BrianH Comment : 0002256 Added -
27-Apr-2010 06:33 carl Comment : 0002254 Added -
27-Apr-2010 06:32 carl Status Modified submitted => reviewed
25-Mar-2010 10:51 BrianH Code Modified -
25-Mar-2010 10:50 BrianH Ticket Added -