delete-tree ( path -- )
Factor documentation > Factor handbook > Input and output > Directory manipulation > Directory hierarchy manipulation
Prev:with-directory-tree-files ( path quot -- )
Next:copy-tree ( from to -- )


Vocabulary
io.directories.hierarchy

Inputs and outputs
patha pathname string


Word description
Deletes a file or directory, recursing into subdirectories.

Errors
Throws an error if the deletion fails.

Warning
Misuse of this word can lead to catastrophic data loss.


Definition
USING: io.directories io.files.info kernel sequences ;

IN: io.directories.hierarchy

: delete-tree ( path -- )
dup link-info directory? [
[ [ [ delete-tree ] each ] with-directory-files ]
[ delete-directory ] bi
] [ delete-file ] if ;