Skip only ESD files in WindowsESD

This commit is contained in:
paravis committed 2026-11-08 23:03:53 +03:00
1 parent 9c1db67b8c
commit a69409e526
2 files changed
+31 -4

No files matched your search

+30 -3
View File
@@ -225,7 +225,8 @@ void App::Apply()
message += L"Затем на разделы будут распакованы файлы из архива Data.pf\r\n";
message += L"(1 -> PARAVIS, 2 -> VTOYEFI, 3 -> DATA).\r\n\r\n";
if (noEsd) {
message += L"Папка WindowsESD на раздел DATA копироваться не будет.\r\n\r\n";
message += L"Файлы *.esd из папки WindowsESD копироваться не будут\r\n";
message += L"(остальные файлы папки будут скопированы).\r\n\r\n";
}
message += L"ВНИМАНИЕ! ВСЕ ДАННЫЕ НА ЭТОМ ДИСКЕ БУДУТ УНИЧТОЖЕНЫ.\r\n";
message += L"Продолжить?";
@@ -458,8 +459,34 @@ int App::ApplyImages(int disk, const std::wstring& wim)
if (i == 2 && noEsd) {
std::wstring esdDir = dir + L"WindowsESD";
std::error_code ec;
std::filesystem::remove_all(esdDir, ec);
DebugLog(L"skip WindowsESD: remove_all %s ec=%d", esdDir.c_str(), ec.value());
if (std::filesystem::exists(esdDir, ec)) {
std::filesystem::recursive_directory_iterator it(
esdDir, std::filesystem::directory_options::skip_permission_denied, ec);
const std::filesystem::recursive_directory_iterator end;
while (it != end) {
if (ec) {
DebugLog(L"skip ESD: scan stopped ec=%d", ec.value());
break;
}
const std::filesystem::directory_entry& entry = *it;
std::error_code fileEc;
if (entry.is_regular_file(fileEc)) {
std::wstring ext = entry.path().extension().wstring();
std::transform(ext.begin(), ext.end(), ext.begin(),
[](wchar_t c) {
return static_cast<wchar_t>(towlower(c));
});
if (ext == L".esd") {
std::error_code removeEc;
std::filesystem::remove(entry.path(), removeEc);
DebugLog(L"skip ESD: %s removed=%d ec=%d",
entry.path().c_str(),
removeEc ? 0 : 1, removeEc.value());
}
}
it.increment(ec);
}
}
}
++applied;