Contrary to what POSIX says, some directory operations on MacOS can fail
with EPERM instead of EACCES, so we need to handle both.
libstdc++-v3/ChangeLog:
PR libstdc++/99537
* src/c++17/fs_dir.cc (recursive_directory_iterator): Use new
helper function to check for permission denied errors.
* src/filesystem/dir.cc (recursive_directory_iterator):
Likewise.
* src/filesystem/dir-common.h (is_permission_denied_error): New
helper function.
else
{
const int err = errno;
- if (err == EACCES
+ if (fs::is_permission_denied_error(err)
&& is_set(options, fs::directory_options::skip_permission_denied))
{
if (ecptr)
posix::DIR* dirp;
};
+inline bool
+is_permission_denied_error(int e)
+{
+ if (e == EACCES)
+ return true;
+#ifdef __APPLE__
+ if (e == EPERM) // See PR 99533
+ return true;
+#endif
+ return false;
+}
+
} // namespace filesystem
// BEGIN/END macros must be defined before including this file.
else
{
const int err = errno;
- if (err == EACCES
+ if (std::filesystem::is_permission_denied_error(err)
&& is_set(options, fs::directory_options::skip_permission_denied))
{
if (ecptr)