zturner added a comment. Doesn't `shutil.rmtree` handle this? I believe it's implemented as `SHFileOperation`. In any case, it's better to not try and re-invent robust directory tree deletion and just use the tools available. https://reviews.llvm.org/D45345