Skip to content

Commit 69840ee

Browse files
richardlauabmusse
andcommitted
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 <[email protected]> Signed-off-by: Richard Lau <[email protected]>
1 parent 4e612c0 commit 69840ee

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/node_file.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,14 @@ 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+
// Workaround for clang libc++ bug on AIX: std::filesystem::remove_all()
1838+
// incorrectly returns EEXIST (17) instead of EACCES (13) for permission
1839+
// errors when trying to remove directories without proper permissions.
1840+
} else if (error == std::errc::permission_denied || error == std::errc::file_exists) {
1841+
#else
18361842
} else if (error == std::errc::permission_denied) {
1843+
#endif
18371844
std::string message = "Permission denied: " + file_path_str;
18381845
return env->ThrowErrnoException(
18391846
permission_denied_error, "rm", message.c_str(), path_c_str);

0 commit comments

Comments
 (0)