| 408 | } |
| 409 | |
| 410 | Status WindowsFileSystem::GetChildren(const string& dir, |
| 411 | std::vector<string>* result) { |
| 412 | string translated_dir = TranslateName(dir); |
| 413 | std::wstring ws_translated_dir = Utf8ToWideChar(translated_dir); |
| 414 | result->clear(); |
| 415 | |
| 416 | std::wstring pattern = ws_translated_dir; |
| 417 | if (!pattern.empty() && pattern.back() != '\\' && pattern.back() != '/') { |
| 418 | pattern += L"\\*"; |
| 419 | } else { |
| 420 | pattern += L'*'; |
| 421 | } |
| 422 | |
| 423 | WIN32_FIND_DATAW find_data; |
| 424 | HANDLE find_handle = ::FindFirstFileW(pattern.c_str(), &find_data); |
| 425 | if (find_handle == INVALID_HANDLE_VALUE) { |
| 426 | string context = "FindFirstFile failed for: " + translated_dir; |
| 427 | return IOErrorFromWindowsError(context, ::GetLastError()); |
| 428 | } |
| 429 | |
| 430 | do { |
| 431 | string file_name = WideCharToUtf8(find_data.cFileName); |
| 432 | const StringPiece basename = file_name; |
| 433 | if (basename != "." && basename != "..") { |
| 434 | result->push_back(file_name); |
| 435 | } |
| 436 | } while (::FindNextFileW(find_handle, &find_data)); |
| 437 | |
| 438 | if (!::FindClose(find_handle)) { |
| 439 | string context = "FindClose failed for: " + translated_dir; |
| 440 | return IOErrorFromWindowsError(context, ::GetLastError()); |
| 441 | } |
| 442 | |
| 443 | return Status::OK(); |
| 444 | } |
| 445 | |
| 446 | Status WindowsFileSystem::DeleteFile(const string& fname) { |
| 447 | Status result; |
nothing calls this directly
no test coverage detected