llvm-project
c31455cd - [libc++] Fix filesystem::remove_all bug with read-only nested directory (#197104)

Commit
13 hours ago
[libc++] Fix filesystem::remove_all bug with read-only nested directory (#197104) Consider a directory `parent/child`, where `parent` has read-only permissions. Calling `remove_all` on `parent` is expected to fail with a permission error, however it fails with a different error depending on the platform (such as "error file exists" on AIX). During the recursive removal, `unlinkat` is first called on the child and fails with a permission error. Rather than returning, the function continues and tries `unlinkat` on the parent and fails with a different error depending on the platform. This error is returned instead of the permission error. This PR makes the first encountered error be returned instead. According to the standard [fs.op.remove.all]: > Effects: Recursively deletes the contents of p if it exists, then > deletes file p itself, as if by POSIX remove. The word "then" implies an ordering where deleting the contents of p should be successful before deleting file p itself. Fixes #197100.
Author
Parents
Loading