From 85ab8bc0509b700b0884ede20174e9f7525e694d Mon Sep 17 00:00:00 2001 From: Pavel Pimenov Date: Sat, 4 May 2019 13:59:24 +0300 Subject: [PATCH] Fix GetChildren --- util/env_posix.cc | 4 ++++ util/env_windows.cc | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/util/env_posix.cc b/util/env_posix.cc index 8c74f5a..9aeddcc 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -571,8 +571,12 @@ class PosixEnv : public Env { } struct ::dirent* entry; while ((entry = ::readdir(dir)) != nullptr) { + if (!(entry->d_name[0] == '.' && entry->d_name[1] == '\0' || + entry->d_name[0] == '.' && entry->d_name[1] == '.' && + entry->d_name[2] == '\0')) { result->emplace_back(entry->d_name); } + } ::closedir(dir); return Status::OK(); } diff --git a/util/env_windows.cc b/util/env_windows.cc index 09e3df6..e2c7291 100644 --- a/util/env_windows.cc +++ b/util/env_windows.cc @@ -467,11 +467,14 @@ class WindowsEnv : public Env { do { char base_name[_MAX_FNAME]; char ext[_MAX_EXT]; - + if(!(find_data.cFileName[0] == '.' && find_data.cFileName[1] == '\0' || + find_data.cFileName[0] == '.' && find_data.cFileName[1] == '.' && + find_data.cFileName[2] == '\0')) { if (!_splitpath_s(find_data.cFileName, nullptr, 0, nullptr, 0, base_name, ARRAYSIZE(base_name), ext, ARRAYSIZE(ext))) { result->emplace_back(std::string(base_name) + ext); } + } } while (::FindNextFileA(dir_handle, &find_data)); DWORD last_error = ::GetLastError(); ::FindClose(dir_handle);