mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:45:32 -05:00
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: https://github.com/nodejs/node/pull/62788 Refs: https://github.com/nodejs/node/issues/62790 Reviewed-By: Abdirahim Musse <abdirahim.musse@ibm.com> Reviewed-By: Stewart X Addison <sxa@redhat.com>
This commit is contained in:
1 parent
7597d204c1
commit
ad9a2909c2
1 file changed
+8
@@ -1737,7 +1737,15 @@ static void RmSync(const FunctionCallbackInfo<Value>& args) {
|
||||
} else if (error == std::errc::not_a_directory) {
|
||||
std::string message = "Not a directory: " + file_path_str;
|
||||
return env->ThrowErrnoException(ENOTDIR, "rm", message.c_str(), path_c_str);
|
||||
#ifdef _AIX
|
||||
} else if (error == std::errc::permission_denied ||
|
||||
error == std::errc::file_exists) {
|
||||
// Workaround for clang libc++ bug on AIX: std::filesystem::remove_all()
|
||||
// incorrectly returns EEXIST (17) instead of EACCES (13) for permission
|
||||
// errors when trying to remove directories without proper permissions.
|
||||
#else
|
||||
} else if (error == std::errc::permission_denied) {
|
||||
#endif
|
||||
std::string message = "Permission denied: " + file_path_str;
|
||||
return env->ThrowErrnoException(
|
||||
permission_denied_error, "rm", message.c_str(), path_c_str);
|
||||
|
||||
Reference in new issue
Block a user