forked from pool/doxygen
71 lines
2.4 KiB
Diff
71 lines
2.4 KiB
Diff
Index: doxygen-1.9.4/filesystem/filesystem.hpp
|
|
===================================================================
|
|
--- doxygen-1.9.4.orig/filesystem/filesystem.hpp
|
|
+++ doxygen-1.9.4/filesystem/filesystem.hpp
|
|
@@ -5548,12 +5548,13 @@ public:
|
|
impl(const path& path, directory_options options)
|
|
: _base(path)
|
|
, _options(options)
|
|
- , _dir(nullptr)
|
|
+ , _n(-1)
|
|
+ , _name_list(nullptr)
|
|
, _entry(nullptr)
|
|
{
|
|
if (!path.empty()) {
|
|
- _dir = ::opendir(path.native().c_str());
|
|
- if (!_dir) {
|
|
+ _n = ::scandir(path.native().c_str(), &_name_list, NULL, alphasort);
|
|
+ if (_n == -1) {
|
|
auto error = errno;
|
|
_base = filesystem::path();
|
|
if ((error != EACCES && error != EPERM) || (options & directory_options::skip_permission_denied) == directory_options::none) {
|
|
@@ -5568,30 +5569,31 @@ public:
|
|
impl(const impl& other) = delete;
|
|
~impl()
|
|
{
|
|
- if (_dir) {
|
|
- ::closedir(_dir);
|
|
+ if (_name_list) {
|
|
+ ::free(_name_list);
|
|
}
|
|
}
|
|
void increment(std::error_code& ec)
|
|
{
|
|
- if (_dir) {
|
|
+ if (_name_list) {
|
|
bool skip;
|
|
do {
|
|
skip = false;
|
|
errno = 0;
|
|
- _entry = ::readdir(_dir);
|
|
- if (_entry) {
|
|
+ if (_n >= 0) {
|
|
+ _entry = _name_list[_n--];
|
|
_dir_entry._path = _base;
|
|
_dir_entry._path.append_name(_entry->d_name);
|
|
copyToDirEntry();
|
|
+ ::free(_entry);
|
|
if (ec && (ec.value() == EACCES || ec.value() == EPERM) && (_options & directory_options::skip_permission_denied) == directory_options::skip_permission_denied) {
|
|
ec.clear();
|
|
skip = true;
|
|
}
|
|
}
|
|
else {
|
|
- ::closedir(_dir);
|
|
- _dir = nullptr;
|
|
+ ::free(_name_list);
|
|
+ _name_list = nullptr;
|
|
_dir_entry._path.clear();
|
|
if (errno) {
|
|
ec = detail::make_system_error();
|
|
@@ -5634,7 +5636,8 @@ public:
|
|
}
|
|
path _base;
|
|
directory_options _options;
|
|
- DIR* _dir;
|
|
+ int _n;
|
|
+ struct ::dirent** _name_list;
|
|
struct ::dirent* _entry;
|
|
directory_entry _dir_entry;
|
|
std::error_code _ec;
|