diff --git a/libstdc++-v3/src/filesystem/dir.cc b/libstdc++-v3/src/filesystem/dir.cc index 016a78d..af42a5a 100644 --- a/libstdc++-v3/src/filesystem/dir.cc +++ b/libstdc++-v3/src/filesystem/dir.cc @@ -69,7 +69,7 @@ struct fs::_Dir { _Dir() : dirp(nullptr) { } - _Dir(DIR* dirp, const fs::path& path) : dirp(dirp), path(path) { } + _Dir(_WDIR* dirp, const fs::path& path) : dirp(dirp), path(path) { } _Dir(_Dir&& d) : dirp(std::exchange(d.dirp, nullptr)), path(std::move(d.path)), @@ -78,11 +78,11 @@ struct fs::_Dir _Dir& operator=(_Dir&&) = delete; - ~_Dir() { if (dirp) ::closedir(dirp); } + ~_Dir() { if (dirp) ::_wclosedir(dirp); } bool advance(ErrorCode); - DIR* dirp; + _WDIR* dirp; fs::path path; directory_entry entry; file_type type = file_type::none; @@ -99,7 +99,7 @@ namespace fs::_Dir opendir(const fs::path& p, fs::directory_options options, ErrorCode ec) { - if (DIR* dirp = ::opendir(p.c_str())) + if (_WDIR* dirp = ::opendir(p.c_str())) return {dirp, p}; const int err = errno; @@ -125,7 +125,7 @@ namespace } inline fs::file_type - get_file_type(const dirent& d __attribute__((__unused__))) + get_file_type(const _wdirent& d __attribute__((__unused__))) { #ifdef _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE switch (d.d_type) @@ -155,11 +155,11 @@ namespace } int - native_readdir(DIR* dirp, ::dirent*& entryp) + native_readdir(_WDIR* dirp, ::_wdirent*& entryp) { #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS errno = 0; - if ((entryp = ::readdir(dirp))) + if ((entryp = ::_wreaddir(dirp))) return 0; return errno; #else @@ -171,8 +171,8 @@ namespace bool fs::_Dir::advance(ErrorCode ec) { - ::dirent ent; - ::dirent* result = &ent; + ::_wdirent ent; + ::_wdirent* result = &ent; if (int err = native_readdir(dirp, result)) { if (!ec) @@ -185,7 +185,7 @@ fs::_Dir::advance(ErrorCode ec) else if (result != nullptr) { // skip past dot and dot-dot - if (!strcmp(ent.d_name, ".") || !strcmp(ent.d_name, "..")) + if (!wcscmp(ent.d_name, L".") || !wcscmp(ent.d_name, L"..")) return advance(std::move(ec)); entry = fs::directory_entry{path / ent.d_name}; type = get_file_type(ent); @@ -260,7 +260,7 @@ recursive_directory_iterator(const path& p, directory_options options, error_code* ec) : _M_options(options), _M_pending(true) { - if (DIR* dirp = ::opendir(p.c_str())) + if (_WDIR* dirp = ::opendir(p.c_str())) { _M_dirs = std::make_shared<_Dir_stack>(); _M_dirs->push(_Dir{ dirp, p });