]> granicus.if.org Git - llvm/commit
[Support] Add llvm::sys::fs::remove_directories.
authorZachary Turner <zturner@google.com>
Wed, 8 Mar 2017 22:49:32 +0000 (22:49 +0000)
committerZachary Turner <zturner@google.com>
Wed, 8 Mar 2017 22:49:32 +0000 (22:49 +0000)
commitc036eebbeb6ab205707c42b78276d18aac96e535
treef3749530c354f1d4f96133e5b21c1c9ee4e200ae
parent7b285dee52357ef895fcc8be82bf204188197322
[Support] Add llvm::sys::fs::remove_directories.

We already have a function create_directories() which can create
an entire tree, and remove() which can remove an empty directory,
but we do not have remove_directories() which can remove an entire
tree.  This patch adds such a function.

Because removing a directory tree can have dangerous consequences
when the tree contains a directory symlink, the patch here updates
the existing directory_iterator construct to optionally not follow
symlinks (previously it would always follow symlinks).  The delete
algorithm uses this flag so that for symlinks, only the links are
removed, and not the targets.

On Windows this is implemented with SHFileOperation, which also
does not recurse into symbolic links or junctions.

Differential Revision: https://reviews.llvm.org/D30676

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297314 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/FileSystem.h
lib/Support/Path.cpp
lib/Support/Unix/Path.inc
lib/Support/Windows/Path.inc
unittests/Support/Path.cpp