Skip to content

Commit 5f02bdb

Browse files
richardlauabmusse
andauthored
src: workaround AIX libc++ std::filesystem bug
On AIX libc++ is returning `EEXIST` instead of `EACCES` when using `std::filesystem::remove_all()` without appropriate permissions to recursively remove the directory. Co-authored-by: Abdirahim Musse <abdirahim.musse@ibm.com> Signed-off-by: Richard Lau <richard.lau@ibm.com> PR-URL: #62788 Refs: #62790 Reviewed-By: Abdirahim Musse <abdirahim.musse@ibm.com> Reviewed-By: Stewart X Addison <sxa@redhat.com>
1 parent 59072b8 commit 5f02bdb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/node_file.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,15 @@ static void RmSync(const FunctionCallbackInfo<Value>& args) {
18331833
} else if (error == std::errc::not_a_directory) {
18341834
std::string message = "Not a directory: " + file_path_str;
18351835
return env->ThrowErrnoException(ENOTDIR, "rm", message.c_str(), path_c_str);
1836+
#ifdef _AIX
1837+
} else if (error == std::errc::permission_denied ||
1838+
error == std::errc::file_exists) {
1839+
// Workaround for clang libc++ bug on AIX: std::filesystem::remove_all()
1840+
// incorrectly returns EEXIST (17) instead of EACCES (13) for permission
1841+
// errors when trying to remove directories without proper permissions.
1842+
#else
18361843
} else if (error == std::errc::permission_denied) {
1844+
#endif
18371845
std::string message = "Permission denied: " + file_path_str;
18381846
return env->ThrowErrnoException(
18391847
permission_denied_error, "rm", message.c_str(), path_c_str);

0 commit comments

Comments
 (0)