Fix CE
GitOrigin-RevId: 1747b786d930cd2150a9d5eacd75908e3f37a45b
This commit is contained in:
parent
83f99f6193
commit
7831955779
|
@ -549,15 +549,6 @@ Result<std::pair<FileFd, string>> mkstemp(CSlice dir) {
|
||||||
static Result<bool> walk_path_dir(const std::wstring &dir_name,
|
static Result<bool> walk_path_dir(const std::wstring &dir_name,
|
||||||
const std::function<WalkPath::Action(CSlice name, WalkPath::Type type)> &func) {
|
const std::function<WalkPath::Action(CSlice name, WalkPath::Type type)> &func) {
|
||||||
std::wstring name = dir_name + L"\\*";
|
std::wstring name = dir_name + L"\\*";
|
||||||
switch (func(entry_name, WalkPath::Type::EnterDir)) {
|
|
||||||
case WalkPath::Action::Abort:
|
|
||||||
return false;
|
|
||||||
case WalkPath::Action::SkipDir:
|
|
||||||
return true;
|
|
||||||
case WalkPath::Action::Continue:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
WIN32_FIND_DATA file_data;
|
WIN32_FIND_DATA file_data;
|
||||||
auto handle = FindFirstFileExW(name.c_str(), FindExInfoStandard, &file_data, FindExSearchNameMatch, nullptr, 0);
|
auto handle = FindFirstFileExW(name.c_str(), FindExInfoStandard, &file_data, FindExSearchNameMatch, nullptr, 0);
|
||||||
if (handle == INVALID_HANDLE_VALUE) {
|
if (handle == INVALID_HANDLE_VALUE) {
|
||||||
|
@ -567,6 +558,17 @@ static Result<bool> walk_path_dir(const std::wstring &dir_name,
|
||||||
SCOPE_EXIT {
|
SCOPE_EXIT {
|
||||||
FindClose(handle);
|
FindClose(handle);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TRY_RESULT(dir_entry_name, from_wstring(dir_name));
|
||||||
|
switch (func(dir_entry_name, WalkPath::Type::EnterDir)) {
|
||||||
|
case WalkPath::Action::Abort:
|
||||||
|
return false;
|
||||||
|
case WalkPath::Action::SkipDir:
|
||||||
|
return true;
|
||||||
|
case WalkPath::Action::Continue:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
auto full_name = dir_name + L"\\" + file_data.cFileName;
|
auto full_name = dir_name + L"\\" + file_data.cFileName;
|
||||||
TRY_RESULT(entry_name, from_wstring(full_name));
|
TRY_RESULT(entry_name, from_wstring(full_name));
|
||||||
|
@ -595,8 +597,7 @@ static Result<bool> walk_path_dir(const std::wstring &dir_name,
|
||||||
return OS_ERROR("FindNextFileW");
|
return OS_ERROR("FindNextFileW");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRY_RESULT(entry_name, from_wstring(dir_name));
|
switch (func(dir_entry_name, WalkPath::Type::ExitDir)) {
|
||||||
switch (func(entry_name, WalkPath::Type::ExitDir)) {
|
|
||||||
case WalkPath::Action::Abort:
|
case WalkPath::Action::Abort:
|
||||||
return false;
|
return false;
|
||||||
case WalkPath::Action::SkipDir:
|
case WalkPath::Action::SkipDir:
|
||||||
|
|
|
@ -46,7 +46,7 @@ TEST(Port, files) {
|
||||||
bool was_abort = false;
|
bool was_abort = false;
|
||||||
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
|
walk_path(main_dir, [&](CSlice name, WalkPath::Type type) {
|
||||||
CHECK(!was_abort);
|
CHECK(!was_abort);
|
||||||
if (type == WalkPath::Type::EnterDir && ends_with(name, PSLICE() << "/B")) {
|
if (type == WalkPath::Type::EnterDir && ends_with(name, PSLICE() << TD_DIR_SLASH << "B")) {
|
||||||
was_abort = true;
|
was_abort = true;
|
||||||
return WalkPath::Action::Abort;
|
return WalkPath::Action::Abort;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue
Block a user