https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e27acff64907a6fcabd11…
commit e27acff64907a6fcabd11b80aa2dbf2d9cede258
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Wed Oct 6 02:48:03 2021 +0300
Commit: Stanislav Motylkov <x86corez(a)gmail.com>
CommitDate: Wed Oct 6 14:38:25 2021 +0300
[ZIPFLDR] Improve error reporting
- Restore status text on failure
- Show errors on folder and file creation failures
- Allow to retry extraction attempt
CORE-17796
---
dll/shellext/zipfldr/CZipExtract.cpp | 82 +++++++++++++++++++++++++++++++++++-
dll/shellext/zipfldr/lang/de-DE.rc | 2 +
dll/shellext/zipfldr/lang/en-US.rc | 2 +
dll/shellext/zipfldr/lang/et-EE.rc | 2 +
dll/shellext/zipfldr/lang/fr-FR.rc | 2 +
dll/shellext/zipfldr/lang/hi-IN.rc | 2 +
dll/shellext/zipfldr/lang/it-IT.rc | 2 +
dll/shellext/zipfldr/lang/ja-JP.rc | 2 +
dll/shellext/zipfldr/lang/pl-PL.rc | 2 +
dll/shellext/zipfldr/lang/pt-PT.rc | 2 +
dll/shellext/zipfldr/lang/ro-RO.rc | 2 +
dll/shellext/zipfldr/lang/ru-RU.rc | 2 +
dll/shellext/zipfldr/lang/sv-SE.rc | 2 +
dll/shellext/zipfldr/lang/zh-CN.rc | 2 +
dll/shellext/zipfldr/lang/zh-TW.rc | 2 +
dll/shellext/zipfldr/resource.h | 2 +
16 files changed, 110 insertions(+), 2 deletions(-)
diff --git a/dll/shellext/zipfldr/CZipExtract.cpp b/dll/shellext/zipfldr/CZipExtract.cpp
index 8e2b9fa3bb4..47be6caa5df 100644
--- a/dll/shellext/zipfldr/CZipExtract.cpp
+++ b/dll/shellext/zipfldr/CZipExtract.cpp
@@ -75,6 +75,7 @@ public:
CZipExtract* m_pExtract;
CStringA* m_pPassword;
+ CStringW m_OldStatus;
public:
CExtractSettingsPage(CZipExtract* extract, CStringA* password)
@@ -127,6 +128,8 @@ public:
::EnableWindow(GetDlgItem(IDC_PASSWORD), FALSE);
SetWizardButtons(0);
+ ::GetWindowTextW(GetDlgItem(IDC_STATUSTEXT), m_OldStatus.GetBuffer(MAX_PATH),
MAX_PATH);
+ m_OldStatus.ReleaseBuffer();
CStringW strExtracting(MAKEINTRESOURCEW(IDS_EXTRACTING));
SetDlgItemTextW(IDC_STATUSTEXT, strExtracting);
@@ -156,6 +159,11 @@ public:
return TRUE;
}
+ void WizardReset()
+ {
+ SetDlgItemTextW(IDC_STATUSTEXT, m_OldStatus);
+ }
+
static DWORD WINAPI ExtractEntry(LPVOID lpParam)
{
CExtractSettingsPage* pPage = (CExtractSettingsPage*)lpParam;
@@ -175,6 +183,7 @@ public:
CWindow Progress(pPage->GetDlgItem(IDC_PROGRESS));
Progress.SendMessage(PBM_SETRANGE32, 0, 1);
Progress.SendMessage(PBM_SETPOS, 0, 0);
+ pPage->WizardReset();
}
SendMessageCallback(pPage->GetParent().m_hWnd, PSM_PRESSBUTTON,
PSBTN_NEXT, 0, NULL, NULL);
@@ -571,6 +580,7 @@ public:
PathCombineA(CombinedPath, BaseDirectory, Name);
CStringA FullPath = CombinedPath;
FullPath.Replace('/', '\\'); /* SHPathPrepareForWriteA
does not handle '/' */
+ Retry:
eZipExtractError Result = ExtractSingle(hDlg, FullPath, is_dir, &Info,
Name, Password, &bOverwriteAll, bCancel, &err);
if (Result != eDirectoryError)
CurrentFile++;
@@ -580,12 +590,43 @@ public:
break;
case eExtractAbort:
- case eDirectoryError:
- case eFileError:
case eOpenError:
case eUnpackError:
+ {
+ Close();
+ return false;
+ }
+
+ case eDirectoryError:
+ {
+ char StrippedPath[MAX_PATH] = { 0 };
+
+ StrCpyNA(StrippedPath, FullPath, _countof(StrippedPath));
+ if (!is_dir)
+ PathRemoveFileSpecA(StrippedPath);
+ PathStripPathA(StrippedPath);
+ if (ShowExtractError(hDlg, (LPCSTR)&StrippedPath, err,
eDirectoryError) == IDRETRY)
+ goto Retry;
Close();
return false;
+ }
+
+ case eFileError:
+ {
+ int Result = ShowExtractError(hDlg, FullPath, err, eFileError);
+ switch (Result)
+ {
+ case IDABORT:
+ Close();
+ return false;
+ case IDRETRY:
+ CurrentFile--;
+ goto Retry;
+ case IDIGNORE:
+ break;
+ }
+ break;
+ }
}
if (Result == eNoError && is_dir)
continue;
@@ -595,6 +636,43 @@ public:
Close();
return true;
}
+
+ int ShowExtractError(HWND hDlg, LPCSTR path, int Error, eZipExtractError ErrorType)
+ {
+ CStringA strTitle(MAKEINTRESOURCEW(IDS_ERRORTITLE));
+ CStringA strErr, strText;
+ PSTR Win32ErrorString;
+
+ if (ErrorType == eFileError)
+ strText.LoadString(IDS_CANTEXTRACTFILE);
+ else
+ strText.LoadString(GetModuleHandleA("shell32.dll"), 128); //
IDS_CREATEFOLDER_DENIED
+
+ strText.FormatMessage(strText.GetString(), path);
+
+ if (ErrorType == eFileError || HRESULT_FACILITY(Error) == FACILITY_WIN32)
+ {
+ if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, ErrorType == eFileError ? Error :
HRESULT_CODE(Error), 0,
+ (PSTR)&Win32ErrorString, 0, NULL) != 0)
+ {
+ strErr.SetString(Win32ErrorString);
+ LocalFree(Win32ErrorString);
+ }
+ }
+ if (strErr.GetLength() == 0)
+ strErr.Format(IDS_UNKNOWNERROR, Error);
+
+ strText.Append("\r\n\r\n" + strErr);
+
+ UINT mbFlags = MB_ICONWARNING;
+ if (ErrorType == eDirectoryError)
+ mbFlags |= MB_RETRYCANCEL;
+ else if (ErrorType == eFileError)
+ mbFlags |= MB_ABORTRETRYIGNORE;
+
+ return MessageBoxA(hDlg, strText, strTitle, mbFlags);
+ }
};
diff --git a/dll/shellext/zipfldr/lang/de-DE.rc b/dll/shellext/zipfldr/lang/de-DE.rc
index 44587bdc045..ce1f7280e4f 100644
--- a/dll/shellext/zipfldr/lang/de-DE.rc
+++ b/dll/shellext/zipfldr/lang/de-DE.rc
@@ -76,6 +76,8 @@ BEGIN
IDS_CANTCREATEZIP "Fehler beim Erstellen des Archivs '%s' (Fehler Code:
%d)."
IDS_CANTREADFILE "Datei '%s' konnte nicht gelesen werden."
IDS_EXTRACTING "Extrahieren..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "Extrahier-Assistent"
IDS_WIZ_DEST_TITLE "Ziel auswählen"
diff --git a/dll/shellext/zipfldr/lang/en-US.rc b/dll/shellext/zipfldr/lang/en-US.rc
index 18713a6e39e..e885f59a3f3 100644
--- a/dll/shellext/zipfldr/lang/en-US.rc
+++ b/dll/shellext/zipfldr/lang/en-US.rc
@@ -76,6 +76,8 @@ BEGIN
IDS_CANTCREATEZIP "Failed to create a compressed folder '%s' (Error
Code: %d)."
IDS_CANTREADFILE "Cannot read file '%s'."
IDS_EXTRACTING "Extracting..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "Extraction Wizard"
IDS_WIZ_DEST_TITLE "Select a Destination"
diff --git a/dll/shellext/zipfldr/lang/et-EE.rc b/dll/shellext/zipfldr/lang/et-EE.rc
index b828f152c32..61bd7947e67 100644
--- a/dll/shellext/zipfldr/lang/et-EE.rc
+++ b/dll/shellext/zipfldr/lang/et-EE.rc
@@ -76,6 +76,8 @@ BEGIN
IDS_CANTCREATEZIP "Failed to create a compressed folder '%s' (Error
Code: %d)."
IDS_CANTREADFILE "Cannot read file '%s'."
IDS_EXTRACTING "Ekstraktimine..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "Ekstraktimise visard"
IDS_WIZ_DEST_TITLE "Vali sihtkoht"
diff --git a/dll/shellext/zipfldr/lang/fr-FR.rc b/dll/shellext/zipfldr/lang/fr-FR.rc
index 6b69c26a7d8..217dca2d08b 100644
--- a/dll/shellext/zipfldr/lang/fr-FR.rc
+++ b/dll/shellext/zipfldr/lang/fr-FR.rc
@@ -76,6 +76,8 @@ BEGIN
IDS_CANTCREATEZIP "Failed to create a compressed folder '%s' (Error
Code: %d)."
IDS_CANTREADFILE "Cannot read file '%s'."
IDS_EXTRACTING "Extraction..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "Assistant d'extraction"
IDS_WIZ_DEST_TITLE "Choisir une destination"
diff --git a/dll/shellext/zipfldr/lang/hi-IN.rc b/dll/shellext/zipfldr/lang/hi-IN.rc
index ddf53be90a2..9b972305b39 100644
--- a/dll/shellext/zipfldr/lang/hi-IN.rc
+++ b/dll/shellext/zipfldr/lang/hi-IN.rc
@@ -63,6 +63,8 @@ BEGIN
IDS_CANTCREATEZIP "Failed to create a compressed folder '%s' (Error
Code: %d)."
IDS_CANTREADFILE "Cannot read file '%s'."
IDS_EXTRACTING "Extracting..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "निष्कर्षण विज़ार्ड"
IDS_WIZ_DEST_TITLE "एक गंतव्य चुनें"
diff --git a/dll/shellext/zipfldr/lang/it-IT.rc b/dll/shellext/zipfldr/lang/it-IT.rc
index 2067eadde54..6b75ce72126 100644
--- a/dll/shellext/zipfldr/lang/it-IT.rc
+++ b/dll/shellext/zipfldr/lang/it-IT.rc
@@ -76,6 +76,8 @@ BEGIN
IDS_CANTCREATEZIP "Failed to create a compressed folder '%s' (Error
Code: %d)."
IDS_CANTREADFILE "Cannot read file '%s'."
IDS_EXTRACTING "Estrazione..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "Estrazione Guidata"
IDS_WIZ_DEST_TITLE "Seleziona una Destinazione"
diff --git a/dll/shellext/zipfldr/lang/ja-JP.rc b/dll/shellext/zipfldr/lang/ja-JP.rc
index aaa0f3d9bd0..8132f95d611 100644
--- a/dll/shellext/zipfldr/lang/ja-JP.rc
+++ b/dll/shellext/zipfldr/lang/ja-JP.rc
@@ -76,6 +76,8 @@ BEGIN
IDS_CANTCREATEZIP "圧縮フォルダ '%s' を作るのに失敗しました (エラーコード: %d) 。"
IDS_CANTREADFILE "ファイル '%s' が読めません。"
IDS_EXTRACTING "展開中..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "展開ウィザード"
IDS_WIZ_DEST_TITLE "展開先を選んで下さい"
diff --git a/dll/shellext/zipfldr/lang/pl-PL.rc b/dll/shellext/zipfldr/lang/pl-PL.rc
index a9f2ae9d2a6..166312bb90a 100644
--- a/dll/shellext/zipfldr/lang/pl-PL.rc
+++ b/dll/shellext/zipfldr/lang/pl-PL.rc
@@ -77,6 +77,8 @@ BEGIN
IDS_CANTCREATEZIP "Nie można utworzyć folderu skompresowanego '%s' (kod
błędu: %d)."
IDS_CANTREADFILE "Błąd podczas czytania pliku '%s'."
IDS_EXTRACTING "Trwa wyodrębnianie..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "Kreator wyodrębniania"
IDS_WIZ_DEST_TITLE "Wybierz miejsce docelowe"
diff --git a/dll/shellext/zipfldr/lang/pt-PT.rc b/dll/shellext/zipfldr/lang/pt-PT.rc
index 5eb72e4a875..53bd82c5e7e 100644
--- a/dll/shellext/zipfldr/lang/pt-PT.rc
+++ b/dll/shellext/zipfldr/lang/pt-PT.rc
@@ -76,6 +76,8 @@ BEGIN
IDS_CANTCREATEZIP "Falha ao criar a pasta compactada '%s' (Erro:
%d)."
IDS_CANTREADFILE "Não é possível ler o arquivo '%s'."
IDS_EXTRACTING "A extrair..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "Assistente de extração"
IDS_WIZ_DEST_TITLE "Seleccione um destino"
diff --git a/dll/shellext/zipfldr/lang/ro-RO.rc b/dll/shellext/zipfldr/lang/ro-RO.rc
index 18a5bce6577..021bf033732 100644
--- a/dll/shellext/zipfldr/lang/ro-RO.rc
+++ b/dll/shellext/zipfldr/lang/ro-RO.rc
@@ -76,6 +76,8 @@ BEGIN
IDS_CANTCREATEZIP "Failed to create a compressed folder '%s' (Error
Code: %d)."
IDS_CANTREADFILE "Cannot read file '%s'."
IDS_EXTRACTING "Extragere..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "Asistent de extracție"
IDS_WIZ_DEST_TITLE "Selectați o Destinație"
diff --git a/dll/shellext/zipfldr/lang/ru-RU.rc b/dll/shellext/zipfldr/lang/ru-RU.rc
index 1cdd7e70d4d..e8b9c21b046 100644
--- a/dll/shellext/zipfldr/lang/ru-RU.rc
+++ b/dll/shellext/zipfldr/lang/ru-RU.rc
@@ -76,6 +76,8 @@ BEGIN
IDS_CANTCREATEZIP "Не удалось создать сжатую папку '%s' (код ошибки:
%d)."
IDS_CANTREADFILE "Не удалось прочитать файл '%s'."
IDS_EXTRACTING "Извлечение..."
+ IDS_CANTEXTRACTFILE "Не удалось извлечь файл '%1'."
+ IDS_UNKNOWNERROR "Неизвестная ошибка 0x%08x."
IDS_WIZ_TITLE "Мастер извлечения архивов"
IDS_WIZ_DEST_TITLE "Укажите путь"
diff --git a/dll/shellext/zipfldr/lang/sv-SE.rc b/dll/shellext/zipfldr/lang/sv-SE.rc
index 85fb4ed9006..90d2676e9a5 100644
--- a/dll/shellext/zipfldr/lang/sv-SE.rc
+++ b/dll/shellext/zipfldr/lang/sv-SE.rc
@@ -76,6 +76,8 @@ BEGIN
IDS_CANTCREATEZIP "Failed to create a compressed folder '%s' (Error
Code: %d)."
IDS_CANTREADFILE "Cannot read file '%s'."
IDS_EXTRACTING "Extraherar..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "Extraheringsguiden"
IDS_WIZ_DEST_TITLE "Välj ett mål"
diff --git a/dll/shellext/zipfldr/lang/zh-CN.rc b/dll/shellext/zipfldr/lang/zh-CN.rc
index 8f8d947fd21..f899a8e218b 100644
--- a/dll/shellext/zipfldr/lang/zh-CN.rc
+++ b/dll/shellext/zipfldr/lang/zh-CN.rc
@@ -76,6 +76,8 @@ BEGIN
IDS_CANTCREATEZIP "Failed to create a compressed folder '%s' (Error
Code: %d)."
IDS_CANTREADFILE "Cannot read file '%s'."
IDS_EXTRACTING "正在解压..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "解压向导"
IDS_WIZ_DEST_TITLE "选择一个目标文件夹"
diff --git a/dll/shellext/zipfldr/lang/zh-TW.rc b/dll/shellext/zipfldr/lang/zh-TW.rc
index b6a8d684620..c982d9a64c9 100644
--- a/dll/shellext/zipfldr/lang/zh-TW.rc
+++ b/dll/shellext/zipfldr/lang/zh-TW.rc
@@ -79,6 +79,8 @@ BEGIN
IDS_CANTCREATEZIP "Failed to create a compressed folder '%s' (Error
Code: %d)."
IDS_CANTREADFILE "無法讀取檔案 '%s'."
IDS_EXTRACTING "正在解壓縮..."
+ IDS_CANTEXTRACTFILE "Cannot extract file '%1'."
+ IDS_UNKNOWNERROR "Unknown error 0x%08x."
IDS_WIZ_TITLE "解壓縮精靈"
IDS_WIZ_DEST_TITLE "選擇一個目標資料夾"
diff --git a/dll/shellext/zipfldr/resource.h b/dll/shellext/zipfldr/resource.h
index f2f453afdee..c7e021c63f4 100644
--- a/dll/shellext/zipfldr/resource.h
+++ b/dll/shellext/zipfldr/resource.h
@@ -47,6 +47,8 @@
#define IDS_CANTCREATEZIP 112
#define IDS_CANTREADFILE 113
#define IDS_EXTRACTING 114
+#define IDS_CANTEXTRACTFILE 115
+#define IDS_UNKNOWNERROR 116
/* Wizard titles */
#define IDS_WIZ_TITLE 8000