Fix GetChildren

This commit is contained in:
Pavel Pimenov 2019-05-04 13:59:24 +03:00
parent abf441b657
commit 85ab8bc050
2 changed files with 8 additions and 1 deletions

View File

@ -571,8 +571,12 @@ class PosixEnv : public Env {
} }
struct ::dirent* entry; struct ::dirent* entry;
while ((entry = ::readdir(dir)) != nullptr) { 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); result->emplace_back(entry->d_name);
} }
}
::closedir(dir); ::closedir(dir);
return Status::OK(); return Status::OK();
} }

View File

@ -467,11 +467,14 @@ class WindowsEnv : public Env {
do { do {
char base_name[_MAX_FNAME]; char base_name[_MAX_FNAME];
char ext[_MAX_EXT]; 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, if (!_splitpath_s(find_data.cFileName, nullptr, 0, nullptr, 0, base_name,
ARRAYSIZE(base_name), ext, ARRAYSIZE(ext))) { ARRAYSIZE(base_name), ext, ARRAYSIZE(ext))) {
result->emplace_back(std::string(base_name) + ext); result->emplace_back(std::string(base_name) + ext);
} }
}
} while (::FindNextFileA(dir_handle, &find_data)); } while (::FindNextFileA(dir_handle, &find_data));
DWORD last_error = ::GetLastError(); DWORD last_error = ::GetLastError();
::FindClose(dir_handle); ::FindClose(dir_handle);