Skip to content

Commit

Permalink
Merge branch 'feature-116-better-support-for-systems-without-dirent-d…
Browse files Browse the repository at this point in the history
…_type'
  • Loading branch information
gulrak committed May 24, 2021
2 parents c029736 + 19d0c63 commit a0e5e43
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
#elif defined(__EMSCRIPTEN__)
#define GHC_OS_WEB
#include <wasi/api.h>
#elif defined(__QNX__)
#define GHC_OS_QNX
#define GHC_NO_DIRENT_D_TYPE
#else
#error "Operating system currently not supported!"
#endif
Expand Down Expand Up @@ -5595,8 +5598,13 @@ class directory_iterator::impl
} while (skip || std::strcmp(_entry->d_name, ".") == 0 || std::strcmp(_entry->d_name, "..") == 0);
}
}

void copyToDirEntry()
{
#ifdef GHC_NO_DIRENT_D_TYPE
_dir_entry._symlink_status = file_status();
_dir_entry._status = file_status();
#else
_dir_entry._symlink_status.permissions(perms::unknown);
switch(_entry->d_type) {
case DT_BLK: _dir_entry._symlink_status.type(file_type::block); break;
Expand All @@ -5606,6 +5614,7 @@ class directory_iterator::impl
case DT_LNK: _dir_entry._symlink_status.type(file_type::symlink); break;
case DT_REG: _dir_entry._symlink_status.type(file_type::regular); break;
case DT_SOCK: _dir_entry._symlink_status.type(file_type::socket); break;
case DT_UNKNOWN: _dir_entry._symlink_status.type(file_type::none); break;
default: _dir_entry._symlink_status.type(file_type::unknown); break;
}
if (_entry->d_type != DT_LNK) {
Expand All @@ -5615,6 +5624,7 @@ class directory_iterator::impl
_dir_entry._status.type(file_type::none);
_dir_entry._status.permissions(perms::unknown);
}
#endif
_dir_entry._file_size = static_cast<uintmax_t>(-1);
_dir_entry._hard_link_count = static_cast<uintmax_t>(-1);
_dir_entry._last_write_time = 0;
Expand Down

0 comments on commit a0e5e43

Please sign in to comment.