1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
|
// ExtractGUI.cpp
#include "StdAfx.h"
#include "../../../Common/IntToString.h"
#include "../../../Common/StringConvert.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/FileFind.h"
#include "../../../Windows/FileName.h"
#include "../../../Windows/Thread.h"
#include "../FileManager/ExtractCallback.h"
#include "../FileManager/FormatUtils.h"
#include "../FileManager/LangUtils.h"
#include "../FileManager/resourceGui.h"
#include "../FileManager/OverwriteDialogRes.h"
#include "../Common/ArchiveExtractCallback.h"
#include "../Common/PropIDUtils.h"
#include "../Explorer/MyMessages.h"
#include "resource2.h"
#include "ExtractRes.h"
#include "ExtractDialog.h"
#include "ExtractGUI.h"
#include "HashGUI.h"
#include "../FileManager/PropertyNameRes.h"
using namespace NWindows;
using namespace NFile;
using namespace NDir;
static const wchar_t * const kIncorrectOutDir = L"Incorrect output directory path";
#ifndef Z7_SFX
static void AddValuePair(UString &s, UINT resourceID, UInt64 value, bool addColon = true)
{
AddLangString(s, resourceID);
if (addColon)
s.Add_Colon();
s.Add_Space();
s.Add_UInt64(value);
s.Add_LF();
}
static void AddSizePair(UString &s, UINT resourceID, UInt64 value)
{
AddLangString(s, resourceID);
s += ": ";
AddSizeValue(s, value);
s.Add_LF();
}
#endif
class CThreadExtracting: public CProgressThreadVirt
{
HRESULT ProcessVirt() Z7_override;
public:
/*
#ifdef Z7_EXTERNAL_CODECS
const CExternalCodecs *externalCodecs;
#endif
*/
CCodecs *codecs;
CExtractCallbackImp *ExtractCallbackSpec;
const CObjectVector<COpenType> *FormatIndices;
const CIntVector *ExcludedFormatIndices;
UStringVector *ArchivePaths;
UStringVector *ArchivePathsFull;
const NWildcard::CCensorNode *WildcardCensor;
const CExtractOptions *Options;
#ifndef Z7_SFX
CHashBundle *HashBundle;
virtual void ProcessWasFinished_GuiVirt() Z7_override;
#endif
CMyComPtr<IFolderArchiveExtractCallback> FolderArchiveExtractCallback;
UString Title;
CPropNameValPairs Pairs;
};
#ifndef Z7_SFX
void CThreadExtracting::ProcessWasFinished_GuiVirt()
{
if (HashBundle && !Pairs.IsEmpty())
ShowHashResults(Pairs, *this);
}
#endif
HRESULT CThreadExtracting::ProcessVirt()
{
CDecompressStat Stat;
#ifndef Z7_SFX
/*
if (HashBundle)
HashBundle->Init();
*/
#endif
HRESULT res = Extract(
/*
#ifdef Z7_EXTERNAL_CODECS
externalCodecs,
#endif
*/
codecs,
*FormatIndices, *ExcludedFormatIndices,
*ArchivePaths, *ArchivePathsFull,
*WildcardCensor, *Options,
ExtractCallbackSpec, ExtractCallbackSpec, FolderArchiveExtractCallback,
#ifndef Z7_SFX
HashBundle,
#endif
FinalMessage.ErrorMessage.Message, Stat);
#ifndef Z7_SFX
if (res == S_OK && ExtractCallbackSpec->IsOK())
{
if (HashBundle)
{
AddValuePair(Pairs, IDS_ARCHIVES_COLON, Stat.NumArchives);
AddSizeValuePair(Pairs, IDS_PROP_PACKED_SIZE, Stat.PackSize);
AddHashBundleRes(Pairs, *HashBundle);
}
else if (Options->TestMode)
{
UString s;
AddValuePair(s, IDS_ARCHIVES_COLON, Stat.NumArchives, false);
AddSizePair(s, IDS_PROP_PACKED_SIZE, Stat.PackSize);
if (Stat.NumFolders != 0)
AddValuePair(s, IDS_PROP_FOLDERS, Stat.NumFolders);
AddValuePair(s, IDS_PROP_FILES, Stat.NumFiles);
AddSizePair(s, IDS_PROP_SIZE, Stat.UnpackSize);
if (Stat.NumAltStreams != 0)
{
s.Add_LF();
AddValuePair(s, IDS_PROP_NUM_ALT_STREAMS, Stat.NumAltStreams);
AddSizePair(s, IDS_PROP_ALT_STREAMS_SIZE, Stat.AltStreams_UnpackSize);
}
s.Add_LF();
AddLangString(s, IDS_MESSAGE_NO_ERRORS);
FinalMessage.OkMessage.Title = Title;
FinalMessage.OkMessage.Message = s;
}
}
#endif
return res;
}
HRESULT ExtractGUI(
// DECL_EXTERNAL_CODECS_LOC_VARS
CCodecs *codecs,
const CObjectVector<COpenType> &formatIndices,
const CIntVector &excludedFormatIndices,
UStringVector &archivePaths,
UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
CExtractOptions &options,
#ifndef Z7_SFX
CHashBundle *hb,
#endif
bool showDialog,
bool &messageWasDisplayed,
CExtractCallbackImp *extractCallback,
HWND hwndParent)
{
messageWasDisplayed = false;
CThreadExtracting extracter;
/*
#ifdef Z7_EXTERNAL_CODECS
extracter.externalCodecs = _externalCodecs;
#endif
*/
extracter.codecs = codecs;
extracter.FormatIndices = &formatIndices;
extracter.ExcludedFormatIndices = &excludedFormatIndices;
if (!options.TestMode)
{
FString outputDir = options.OutputDir;
#ifndef UNDER_CE
if (outputDir.IsEmpty())
GetCurrentDir(outputDir);
#endif
if (showDialog)
{
CExtractDialog dialog;
FString outputDirFull;
if (!MyGetFullPathName(outputDir, outputDirFull))
{
ShowErrorMessage(kIncorrectOutDir);
messageWasDisplayed = true;
return E_FAIL;
}
NName::NormalizeDirPathPrefix(outputDirFull);
dialog.DirPath = fs2us(outputDirFull);
dialog.OverwriteMode = options.OverwriteMode;
dialog.OverwriteMode_Force = options.OverwriteMode_Force;
dialog.PathMode = options.PathMode;
dialog.PathMode_Force = options.PathMode_Force;
dialog.ElimDup = options.ElimDup;
if (archivePathsFull.Size() == 1)
dialog.ArcPath = archivePathsFull[0];
#ifndef Z7_SFX
// dialog.AltStreams = options.NtOptions.AltStreams;
dialog.NtSecurity = options.NtOptions.NtSecurity;
if (extractCallback->PasswordIsDefined)
dialog.Password = extractCallback->Password;
#endif
if (dialog.Create(hwndParent) != IDOK)
return E_ABORT;
outputDir = us2fs(dialog.DirPath);
options.OverwriteMode = dialog.OverwriteMode;
options.PathMode = dialog.PathMode;
options.ElimDup = dialog.ElimDup;
#ifndef Z7_SFX
// options.NtOptions.AltStreams = dialog.AltStreams;
options.NtOptions.NtSecurity = dialog.NtSecurity;
extractCallback->Password = dialog.Password;
extractCallback->PasswordIsDefined = !dialog.Password.IsEmpty();
#endif
}
if (!MyGetFullPathName(outputDir, options.OutputDir))
{
ShowErrorMessage(kIncorrectOutDir);
messageWasDisplayed = true;
return E_FAIL;
}
NName::NormalizeDirPathPrefix(options.OutputDir);
/*
if (!CreateComplexDirectory(options.OutputDir))
{
UString s = GetUnicodeString(NError::MyFormatMessage(GetLastError()));
UString s2 = MyFormatNew(IDS_CANNOT_CREATE_FOLDER,
#ifdef Z7_LANG
0x02000603,
#endif
options.OutputDir);
s2.Add_LF();
s2 += s;
MyMessageBox(s2);
return E_FAIL;
}
*/
}
UString title = LangString(options.TestMode ? IDS_PROGRESS_TESTING : IDS_PROGRESS_EXTRACTING);
extracter.Title = title;
extracter.ExtractCallbackSpec = extractCallback;
extracter.ExtractCallbackSpec->ProgressDialog = &extracter;
extracter.FolderArchiveExtractCallback = extractCallback;
extracter.ExtractCallbackSpec->Init();
extracter.CompressingMode = false;
extracter.ArchivePaths = &archivePaths;
extracter.ArchivePathsFull = &archivePathsFull;
extracter.WildcardCensor = &wildcardCensor;
extracter.Options = &options;
#ifndef Z7_SFX
extracter.HashBundle = hb;
#endif
extracter.IconID = IDI_ICON;
RINOK(extracter.Create(title, hwndParent))
messageWasDisplayed = extracter.ThreadFinishedOK && extracter.MessagesDisplayed;
return extracter.Result;
}
|