On 11/03/21 17:54 +0000, Jonathan Wakely wrote:
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
Oh drat, that's the wrong PR number. It should be PR 99533, as the
comment says in the code. I'll fix the ChangeLog tomorrow.
* 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.
--- a/libstdc++-v3/src/filesystem/dir-common.h
+++ b/libstdc++-v3/src/filesystem/dir-common.h
@@ -141,6 +141,18 @@ struct _Dir_base
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.