chore: initial commit (extracted from Launchers monorepo)

Plugin: ns7zip v2.0.0
Architectures: x86-ansi, x86-unicode, amd64-unicode
License: LGPL-2.1-or-later
This commit is contained in:
Simone
2026-04-29 14:07:51 +02:00
commit d074cc7c07
3848 changed files with 1076682 additions and 0 deletions
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="7-Zip.7-Zip.7zG" type="win32"/>
<description>7-Zip GUI.</description>
<dependency>
<dependentAssembly><assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/></dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"><application>
<!-- Vista --> <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Win 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Win 8 --> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Win 8.1 --> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Win 10 --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application></compatibility>
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware></windowsSettings></application>
</assembly>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
// BenchmarkDialog.h
#ifndef ZIP7_INC_BENCHMARK_DIALOG_H
#define ZIP7_INC_BENCHMARK_DIALOG_H
#include "../../Common/CreateCoder.h"
#include "../../UI/Common/Property.h"
const UInt32 k_NumBenchIterations_Default = 10;
HRESULT Benchmark(
DECL_EXTERNAL_CODECS_LOC_VARS
const CObjectVector<CProperty> &props, UInt32 numIterations, HWND hwndParent = NULL);
#endif
@@ -0,0 +1,288 @@
#include "BenchmarkDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 332
#define yc 248
#undef g0xs
#undef g1x
#undef g1xs
#undef g2xs
#undef g3x
#undef g3xs
#undef g4x
#define gs 160
#define gSpace 24
#define g0xs 90
#define g1xs 48
#define g1x (m + g0xs)
#define gc2x (g1x + g1xs + m)
#define gc2xs 80
#define g4x (m + m)
#define sRating 58
#define sSpeed 60
#define sUsage 46
#define sRpu 58
#define sSize 52
// #define sFreq 34
#define xRating (xs - m - m - sRating)
#define xRpu (xRating - sRpu)
#define xUsage (xRpu - sUsage)
#define xSpeed (xUsage - sSpeed)
#define xSize (xSpeed - sSize)
// #define xFreq (xUsage - sFreq)
#define sLabel (xSize - g4x)
#define sTotalRating (sUsage + sRpu + sRating + m + m)
#define xTotalRating (xs - m - sTotalRating)
#define sPasses 60
#define g2xs 60
#define g3xs 64
#define g3x (m + g2xs)
#undef GROUP_Y_SIZE
#undef GROUP_Y2_SIZE
#ifdef UNDER_CE
#define GROUP_Y_SIZE 8
#define GROUP_Y2_SIZE 8
#else
#define GROUP_Y_SIZE 40
#define GROUP_Y2_SIZE 32
#endif
#define g7xs bx1 - m - g0xs - g1xs - m
#define sLog 140 + 0
// MY_MODAL_DIALOG_STYLE
IDD_BENCH DIALOG 0, 0, xs + sLog, ys MY_MODAL_RESIZE_DIALOG_STYLE | WS_MINIMIZEBOX
CAPTION "Benchmark"
MY_FONT
BEGIN
PUSHBUTTON "&Restart", IDB_RESTART, bx1, m, bxs, bys
PUSHBUTTON "&Stop", IDB_STOP, bx1, m + bys + 6, bxs, bys
PUSHBUTTON "&Help", IDHELP, bx2, by, bxs, bys
PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys
LTEXT "&Dictionary size:", IDT_BENCH_DICTIONARY, m, m + 1, g0xs, 8
COMBOBOX IDC_BENCH_DICTIONARY, g1x, m, g1xs, 140, MY_COMBO
LTEXT "Memory usage:", IDT_BENCH_MEMORY, gc2x, m - 2, g7xs, 8
LTEXT "", IDT_BENCH_MEMORY_VAL, gc2x, m + 8, g7xs, MY_TEXT_NOPREFIX
LTEXT "&Number of CPU threads:", IDT_BENCH_NUM_THREADS, m, 30, g0xs, 8
COMBOBOX IDC_BENCH_NUM_THREADS, g1x, 29, g1xs, 140, MY_COMBO
LTEXT "", IDT_BENCH_HARDWARE_THREADS, gc2x, 30, g7xs, 24, SS_NOPREFIX
RTEXT "Size", IDT_BENCH_SIZE, xSize, 54, sSize, MY_TEXT_NOPREFIX
RTEXT "CPU Usage", IDT_BENCH_USAGE_LABEL, xUsage, 54, sUsage, MY_TEXT_NOPREFIX
RTEXT "Speed", IDT_BENCH_SPEED, xSpeed, 54, sSpeed, MY_TEXT_NOPREFIX
RTEXT "Rating / Usage", IDT_BENCH_RPU_LABEL, xRpu, 54, sRpu, MY_TEXT_NOPREFIX
RTEXT "Rating", IDT_BENCH_RATING_LABEL, xRating, 54, sRating, MY_TEXT_NOPREFIX
GROUPBOX "Compressing", IDG_BENCH_COMPRESSING, m, 64, xc, GROUP_Y_SIZE
LTEXT "Current", IDT_BENCH_CURRENT, g4x, 76, sLabel, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_SIZE1, xSize, 76, sSize, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_USAGE1, xUsage, 76, sUsage, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_SPEED1, xSpeed, 76, sSpeed, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_RPU1, xRpu, 76, sRpu, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_RATING1, xRating, 76, sRating, MY_TEXT_NOPREFIX
LTEXT "Resulting", IDT_BENCH_RESULTING, g4x, 89, sLabel, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_SIZE2, xSize, 89, sSize, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_USAGE2, xUsage, 89, sUsage, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_SPEED2, xSpeed, 89, sSpeed, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_RPU2, xRpu, 89, sRpu, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_COMPRESS_RATING2, xRating, 89, sRating, MY_TEXT_NOPREFIX
GROUPBOX "Decompressing", IDG_BENCH_DECOMPRESSING, m, 111, xc, GROUP_Y_SIZE
LTEXT "Current", IDT_BENCH_CURRENT2, g4x, 123, sLabel, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_SIZE1, xSize, 123, sSize, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_USAGE1, xUsage, 123, sUsage, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_SPEED1, xSpeed, 123, sSpeed, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_RPU1, xRpu, 123, sRpu, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_RATING1, xRating, 123, sRating, MY_TEXT_NOPREFIX
LTEXT "Resulting", IDT_BENCH_RESULTING2, g4x, 136, sLabel, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_SIZE2, xSize, 136, sSize, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_USAGE2, xUsage, 136, sUsage, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_SPEED2, xSpeed, 136, sSpeed, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_RPU2, xRpu, 136, sRpu, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_DECOMPR_RATING2, xRating, 136, sRating, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_ERROR_MESSAGE, m, 155, xc, MY_TEXT_NOPREFIX
GROUPBOX "Total Rating", IDG_BENCH_TOTAL_RATING, xTotalRating, 163, sTotalRating, GROUP_Y2_SIZE
RTEXT "", IDT_BENCH_TOTAL_USAGE_VAL, xUsage, 176, sUsage, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_TOTAL_RPU_VAL, xRpu, 176, sRpu, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_TOTAL_RATING_VAL, xRating, 176, sRating, MY_TEXT_NOPREFIX
// RTEXT "", IDT_BENCH_CPU, m + sPasses, 202, xc - sPasses, 16, SS_NOPREFIX
RTEXT "", IDT_BENCH_CPU, m + 0, 202, xc - 0, 16, SS_NOPREFIX
RTEXT "", IDT_BENCH_VER, m + xc - 100, 222, 100, MY_TEXT_NOPREFIX
LTEXT "", IDT_BENCH_CPU_FEATURE, m, 222, xc - 100, 16, SS_NOPREFIX // - 100
LTEXT "", IDT_BENCH_SYS1, m, 238, xc - 140, MY_TEXT_NOPREFIX
LTEXT "", IDT_BENCH_SYS2, m, 248, xc - 140, MY_TEXT_NOPREFIX
LTEXT "", IDT_BENCH_LOG, m + xc + m, m, sLog - m, yc, SS_LEFTNOWORDWRAP | SS_NOPREFIX
LTEXT "Elapsed time:", IDT_BENCH_ELAPSED, m, 163, g2xs, 8
// LTEXT "Size:", IDT_BENCH_SIZE, m, 176, g2xs, 8
LTEXT "Passes:", IDT_BENCH_PASSES, m, 176, g2xs, 8
COMBOBOX IDC_BENCH_NUM_PASSES, m, 187, sPasses, 140, MY_COMBO
RTEXT "", IDT_BENCH_ELAPSED_VAL, g3x, 163, g3xs, MY_TEXT_NOPREFIX
// RTEXT "", IDT_BENCH_SIZE_VAL, g3x, 176, g3xs, MY_TEXT_NOPREFIX
RTEXT "", IDT_BENCH_PASSES_VAL, g3x, 176, g3xs, MY_TEXT_NOPREFIX
END
#ifdef UNDER_CE
#undef m
#define m 4
#undef xc
#undef yc
#define xc 154
#define yc 160
#undef g0xs
#undef g1x
#undef g1xs
#undef g2xs
#undef g3x
#undef g3xs
#undef bxs
#undef bys
#define bxs 60
#define bys 14
#undef gs
#undef gSpace
#define gs 160
#define gSpace 24
#define g0xs (xc - bxs)
#define g1xs 44
#undef g4x
#define g4x (m)
#undef xRpu
#undef xUsage
#undef xRating
#undef xTotalRating
#undef sRpu
#undef sRating
#undef sUsage
#undef sLabel
#undef sTotalRating
#define sRating 40
#define sUsage 24
#define sRpu 40
#define xRating (xs - m - sRating)
#define xRpu (xRating - sRpu)
#define xUsage (xRpu - sUsage)
#define sLabel (xUsage - g4x)
#define sTotalRating (sRpu + sRating)
#define xTotalRating (xs - m - sTotalRating)
#define g3xs 32
#define g3x (xRpu - g3xs)
#define g2xs (g3x - m)
IDD_BENCH_2 DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
CAPTION "Benchmark"
MY_FONT
BEGIN
PUSHBUTTON "&Restart", IDB_RESTART, bx1, m, bxs, bys
PUSHBUTTON "&Stop", IDB_STOP, bx1, m + bys + m, bxs, bys
PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys
LTEXT "&Dictionary size:", IDT_BENCH_DICTIONARY, m, m, g0xs, 8
COMBOBOX IDC_BENCH_DICTIONARY, m, m + 11, g1xs, 140, MY_COMBO
LTEXT "&Number of CPU threads:", IDT_BENCH_NUM_THREADS, m, 31, g0xs, 8
COMBOBOX IDC_BENCH_NUM_THREADS, m, 42, g1xs, 140, MY_COMBO
LTEXT "", IDT_BENCH_MEMORY_VAL, m + g1xs + 8, m + 13, xc - bxs - g1xs - 8, 8
LTEXT "", IDT_BENCH_HARDWARE_THREADS, m + g1xs + 8, 44, xc - bxs - g1xs - 8, 8
LTEXT "Current", IDT_BENCH_CURRENT, g4x, 70, sLabel, 8
RTEXT "", IDT_BENCH_COMPRESS_USAGE1, xUsage, 70, sUsage, 8
RTEXT "", IDT_BENCH_COMPRESS_RPU1, xRpu, 70, sRpu, 8
RTEXT "", IDT_BENCH_COMPRESS_RATING1, xRating, 70, sRating, 8
LTEXT "Resulting", IDT_BENCH_RESULTING, g4x, 80, sLabel, 8
RTEXT "", IDT_BENCH_COMPRESS_USAGE2, xUsage, 80, sUsage, 8
RTEXT "", IDT_BENCH_COMPRESS_RPU2, xRpu, 80, sRpu, 8
RTEXT "", IDT_BENCH_COMPRESS_RATING2, xRating, 80, sRating, 8
LTEXT "Compressing", IDG_BENCH_COMPRESSING, m, 60, xc - bxs, 8
LTEXT "Current", IDT_BENCH_CURRENT2, g4x, 104, sLabel, 8
RTEXT "", IDT_BENCH_DECOMPR_USAGE1, xUsage, 104, sUsage, 8
RTEXT "", IDT_BENCH_DECOMPR_RPU1, xRpu, 104, sRpu, 8
RTEXT "", IDT_BENCH_DECOMPR_RATING1, xRating, 104, sRating, 8
LTEXT "Resulting", IDT_BENCH_RESULTING2, g4x, 114, sLabel, 8
RTEXT "", IDT_BENCH_DECOMPR_USAGE2, xUsage, 114, sUsage, 8
RTEXT "", IDT_BENCH_DECOMPR_RPU2, xRpu, 114, sRpu, 8
RTEXT "", IDT_BENCH_DECOMPR_RATING2, xRating, 114, sRating, 8
LTEXT "Decompressing", IDG_BENCH_DECOMPRESSING, m, 94, xc, 8
RTEXT "", IDT_BENCH_TOTAL_RPU_VAL, xRpu, 140, sRpu, 8
RTEXT "", IDT_BENCH_TOTAL_RATING_VAL, xRating, 140, sRating, 8
LTEXT "Elapsed time:", IDT_BENCH_ELAPSED, m, 130, g2xs, 8
LTEXT "Size:", IDT_BENCH_SIZE, m, 140, g2xs, 8
LTEXT "Passes:", IDT_BENCH_PASSES, m, 150, g2xs, 8
RTEXT "", IDT_BENCH_ELAPSED_VAL, g3x, 130, g3xs, 8
RTEXT "", IDT_BENCH_SIZE_VAL, g3x, 140, g3xs, 8
RTEXT "", IDT_BENCH_PASSES_VAL, g3x, 150, g3xs, 8
END
#endif
#include "../../GuiCommon.rc"
#define xc 360
#define yc 260
IDD_BENCH_TOTAL DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT
CAPTION "Benchmark"
{
LTEXT "Elapsed time:", IDT_BENCH_ELAPSED, m, m, 58, 8
RTEXT "", IDT_BENCH_ELAPSED_VAL, m + 58, m, 38, 8
EDITTEXT IDE_BENCH2_EDIT, m, m + 14, xc, yc - bys - m - 14, ES_MULTILINE | ES_READONLY | ES_AUTOVSCROLL | WS_VSCROLL | WS_HSCROLL
PUSHBUTTON "&Help", IDHELP, bx2, by, bxs, bys
PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys
}
@@ -0,0 +1,79 @@
#define IDD_BENCH 7600
#define IDD_BENCH_2 17600
#define IDD_BENCH_TOTAL 7699
#define IDE_BENCH2_EDIT 100
#define IDC_BENCH_DICTIONARY 101
#define IDT_BENCH_MEMORY_VAL 102
#define IDC_BENCH_NUM_THREADS 103
#define IDT_BENCH_HARDWARE_THREADS 104
#define IDT_BENCH_VER 105
#define IDT_BENCH_CPU 106
#define IDT_BENCH_SYS1 107
#define IDT_BENCH_SYS2 108
#define IDT_BENCH_CPU_FEATURE 109
#define IDT_BENCH_COMPRESS_SPEED1 110
#define IDT_BENCH_COMPRESS_SPEED2 111
#define IDT_BENCH_COMPRESS_RATING1 112
#define IDT_BENCH_COMPRESS_RATING2 113
#define IDT_BENCH_COMPRESS_USAGE1 114
#define IDT_BENCH_COMPRESS_USAGE2 115
#define IDT_BENCH_COMPRESS_RPU1 116
#define IDT_BENCH_COMPRESS_RPU2 117
#define IDT_BENCH_DECOMPR_SPEED1 118
#define IDT_BENCH_DECOMPR_SPEED2 119
#define IDT_BENCH_DECOMPR_RATING1 120
#define IDT_BENCH_DECOMPR_RATING2 121
#define IDT_BENCH_DECOMPR_USAGE1 122
#define IDT_BENCH_DECOMPR_USAGE2 123
#define IDT_BENCH_DECOMPR_RPU1 124
#define IDT_BENCH_DECOMPR_RPU2 125
#define IDT_BENCH_TOTAL_RATING_VAL 130
#define IDT_BENCH_TOTAL_RPU_VAL 131
#define IDT_BENCH_TOTAL_USAGE_VAL 133
#define IDT_BENCH_ELAPSED_VAL 140
// #define IDT_BENCH_SIZE_VAL 141
#define IDT_BENCH_PASSES_VAL 142
#define IDC_BENCH_NUM_PASSES 143
#define IDT_BENCH_LOG 160
#define IDT_BENCH_ERROR_MESSAGE 161
#define IDT_BENCH_COMPRESS_SIZE1 170
#define IDT_BENCH_COMPRESS_SIZE2 171
#define IDT_BENCH_DECOMPR_SIZE1 172
#define IDT_BENCH_DECOMPR_SIZE2 173
// #define IDT_BENCH_FREQ_CUR 150
// #define IDT_BENCH_FREQ_RES 151
#define IDB_STOP 442
#define IDB_RESTART 443
#define IDT_BENCH_DICTIONARY 4006
#define IDT_BENCH_NUM_THREADS 4009
#define IDT_BENCH_SIZE 1007
#define IDT_BENCH_ELAPSED 3900
#define IDT_BENCH_SPEED 3903
#define IDT_BENCH_MEMORY 7601
#define IDG_BENCH_COMPRESSING 7602
#define IDG_BENCH_DECOMPRESSING 7603
#define IDG_BENCH_TOTAL_RATING 7605
#define IDT_BENCH_RATING_LABEL 7604
#define IDT_BENCH_CURRENT 7606
#define IDT_BENCH_RESULTING 7607
#define IDT_BENCH_USAGE_LABEL 7608
#define IDT_BENCH_RPU_LABEL 7609
#define IDT_BENCH_PASSES 7610
#define IDT_BENCH_CURRENT2 (7606+50)
#define IDT_BENCH_RESULTING2 (7607+50)
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,483 @@
// CompressDialog.h
#ifndef ZIP7_INC_COMPRESS_DIALOG_H
#define ZIP7_INC_COMPRESS_DIALOG_H
#include "../../../Common/Wildcard.h"
#include "../../../Windows/Control/ComboBox.h"
#include "../../../Windows/Control/Edit.h"
#include "../Common/LoadCodecs.h"
#include "../Common/ZipRegistry.h"
#include "../FileManager/DialogSize.h"
#include "CompressDialogRes.h"
namespace NCompressDialog
{
namespace NUpdateMode
{
enum EEnum
{
kAdd,
kUpdate,
kFresh,
kSync
};
}
struct CInfo
{
NUpdateMode::EEnum UpdateMode;
NWildcard::ECensorPathMode PathMode;
bool SolidIsSpecified;
// bool MultiThreadIsAllowed;
UInt64 SolidBlockSize;
UInt32 NumThreads;
NCompression::CMemUse MemUsage;
CRecordVector<UInt64> VolumeSizes;
UInt32 Level;
UString Method;
UInt64 Dict64;
// UInt64 Dict64_Chain;
bool OrderMode;
UInt32 Order;
UString Options;
UString EncryptionMethod;
bool SFXMode;
bool OpenShareForWrite;
bool DeleteAfterCompressing;
CBoolPair SymLinks;
CBoolPair HardLinks;
CBoolPair AltStreams;
CBoolPair NtSecurity;
CBoolPair PreserveATime;
UInt32 TimePrec;
CBoolPair MTime;
CBoolPair CTime;
CBoolPair ATime;
CBoolPair SetArcMTime;
UString ArcPath; // in: Relative or abs ; out: Relative or abs
// FString CurrentDirPrefix;
bool KeepName;
bool GetFullPathName(UString &result) const;
int FormatIndex;
UString Password;
bool EncryptHeadersIsAllowed;
bool EncryptHeaders;
CInfo():
UpdateMode(NCompressDialog::NUpdateMode::kAdd),
PathMode(NWildcard::k_RelatPath),
SFXMode(false),
OpenShareForWrite(false),
DeleteAfterCompressing(false),
FormatIndex(-1)
{
Level = Order = (UInt32)(Int32)-1;
NumThreads = (UInt32)(Int32)-1;
SolidIsSpecified = false;
Dict64 = (UInt64)(Int64)(-1);
// Dict64_Chain = (UInt64)(Int64)(-1);
OrderMode = false;
Method.Empty();
Options.Empty();
EncryptionMethod.Empty();
TimePrec = (UInt32)(Int32)(-1);
}
};
}
struct CBool1
{
bool Val;
bool Supported;
CBool1(): Val(false), Supported(false) {}
void Init()
{
Val = false;
Supported = false;
}
void SetTrueTrue()
{
Val = true;
Supported = true;
}
void SetVal_as_Supported(bool val)
{
Val = val;
Supported = true;
}
/*
bool IsVal_True_and_Defined() const
{
return Def && Val;
}
*/
};
class CCompressDialog: public NWindows::NControl::CModalDialog
{
public:
CBool1 SymLinks;
CBool1 HardLinks;
CBool1 AltStreams;
CBool1 NtSecurity;
CBool1 PreserveATime;
private:
bool _ramSize_Defined;
NWindows::NControl::CComboBox m_ArchivePath;
NWindows::NControl::CComboBox m_Format;
NWindows::NControl::CComboBox m_Level;
NWindows::NControl::CComboBox m_Method;
NWindows::NControl::CComboBox m_Dictionary;
// NWindows::NControl::CComboBox m_Dictionary_Chain;
NWindows::NControl::CComboBox m_Order;
NWindows::NControl::CComboBox m_Solid;
NWindows::NControl::CComboBox m_NumThreads;
NWindows::NControl::CComboBox m_MemUse;
NWindows::NControl::CComboBox m_Volume;
int _dictionaryCombo_left;
UStringVector _memUse_Strings;
NWindows::NControl::CDialogChildControl m_Params;
NWindows::NControl::CComboBox m_UpdateMode;
NWindows::NControl::CComboBox m_PathMode;
NWindows::NControl::CEdit _password1Control;
NWindows::NControl::CEdit _password2Control;
NWindows::NControl::CComboBox _encryptionMethod;
int _auto_MethodId;
UInt32 _auto_Dict; // (UInt32)(Int32)-1 means unknown
UInt32 _auto_Dict_Chain; // (UInt32)(Int32)-1 means unknown
UInt32 _auto_Order;
UInt64 _auto_Solid;
UInt32 _auto_NumThreads;
int _default_encryptionMethod_Index;
int m_PrevFormat;
UString DirPrefix;
UString StartDirPrefix;
size_t _ramSize; // full RAM size avail
size_t _ramSize_Reduced; // full for 64-bit and reduced for 32-bit
UInt64 _ramUsage_Auto;
public:
NCompression::CInfo m_RegistryInfo;
void SetArchiveName(const UString &name);
int FindRegistryFormat(const UString &name);
unsigned FindRegistryFormat_Always(const UString &name);
const CArcInfoEx &Get_ArcInfoEx()
{
return (*ArcFormats)[GetFormatIndex()];
}
NCompression::CFormatOptions &Get_FormatOptions();
void CheckSFXNameChange();
void SetArchiveName2(bool prevWasSFX);
unsigned GetStaticFormatIndex();
void SetNearestSelectComboBox(NWindows::NControl::CComboBox &comboBox, UInt32 value);
void SetLevel2();
void SetLevel()
{
SetLevel2();
EnableMultiCombo(IDC_COMPRESS_LEVEL);
SetMethod();
}
void SetMethod2(int keepMethodId);
void SetMethod(int keepMethodId = -1)
{
SetMethod2(keepMethodId);
EnableMultiCombo(IDC_COMPRESS_METHOD);
}
void MethodChanged()
{
SetDictionary2();
EnableMultiCombo(IDC_COMPRESS_DICTIONARY);
// EnableMultiCombo(IDC_COMPRESS_DICTIONARY2);
SetOrder2();
EnableMultiCombo(IDC_COMPRESS_ORDER);
}
int GetMethodID_RAW();
int GetMethodID();
UString GetMethodSpec(UString &estimatedName);
UString GetMethodSpec();
bool IsMethodEqualTo(const UString &s);
UString GetEncryptionMethodSpec();
bool IsZipFormat();
bool IsXzFormat();
void SetEncryptionMethod();
int AddDict2(size_t sizeReal, size_t sizeShow);
int AddDict(size_t size);
// int AddDict_Chain(size_t size);
void SetDictionary2();
UInt32 GetComboValue(NWindows::NControl::CComboBox &c, int defMax = 0);
UInt64 GetComboValue_64(NWindows::NControl::CComboBox &c, int defMax = 0);
UInt32 GetLevel() { return GetComboValue(m_Level); }
UInt32 GetLevelSpec() { return GetComboValue(m_Level, 1); }
UInt32 GetLevel2();
UInt64 GetDictSpec() { return GetComboValue_64(m_Dictionary, 1); }
// UInt64 GetDictChainSpec() { return GetComboValue_64(m_Dictionary_Chain, 1); }
UInt64 GetDict2()
{
UInt64 num = GetDictSpec();
if (num == (UInt64)(Int64)-1)
{
if (_auto_Dict == (UInt32)(Int32)-1)
return (UInt64)(Int64)-1; // unknown
num = _auto_Dict;
}
return num;
}
// UInt32 GetOrder() { return GetComboValue(m_Order); }
UInt32 GetOrderSpec() { return GetComboValue(m_Order, 1); }
UInt32 GetNumThreadsSpec() { return GetComboValue(m_NumThreads, 1); }
UInt32 GetNumThreads2()
{
UInt32 num = GetNumThreadsSpec();
if (num == (UInt32)(Int32)-1)
num = _auto_NumThreads;
return num;
}
UInt32 GetBlockSizeSpec() { return GetComboValue(m_Solid, 1); }
/*
UInt32 GetPrecSpec() { return GetComboValue(m_Prec, 1); }
UInt32 GetPrec() { return GetComboValue(m_Prec, 0); }
*/
int AddOrder(UInt32 size);
int AddOrder_Auto();
void SetOrder2();
bool GetOrderMode();
void SetSolidBlockSize2();
void SetSolidBlockSize(/* bool useDictionary = false */)
{
SetSolidBlockSize2();
EnableMultiCombo(IDC_COMPRESS_SOLID);
}
void SetNumThreads2();
void SetNumThreads()
{
SetNumThreads2();
EnableMultiCombo(IDC_COMPRESS_THREADS);
}
int AddMemComboItem(UInt64 val, bool isPercent = false, bool isDefault = false);
void SetMemUseCombo();
UString Get_MemUse_Spec();
UInt64 Get_MemUse_Bytes();
UInt64 GetMemoryUsage_Dict_DecompMem(UInt64 dict, UInt64 &decompressMemory);
UInt64 GetMemoryUsage_Threads_Dict_DecompMem(UInt32 numThreads, UInt64 dict, UInt64 &decompressMemory);
UInt64 GetMemoryUsage_DecompMem(UInt64 &decompressMemory);
UInt64 GetMemoryUsageComp_Threads_Dict(UInt32 numThreads, UInt64 dict64);
void PrintMemUsage(UINT res, UInt64 value);
void SetMemoryUsage();
void Print_Params();
void SetParams();
void SaveOptionsInMem();
void UpdatePasswordControl();
bool IsShowPasswordChecked() const { return IsButtonCheckedBool(IDX_PASSWORD_SHOW); }
unsigned GetFormatIndex();
bool SetArcPathFields(const UString &path, UString &name, bool always);
bool SetArcPathFields(const UString &path);
bool GetFinalPath_Smart(UString &resPath) const;
void ArcPath_WasChanged(const UString &newPath);
void CheckSFXControlsEnable();
// void CheckVolumeEnable();
void EnableMultiCombo(unsigned id);
void FormatChanged(bool isChanged);
void OnButtonSetArchive();
bool IsSFX();
void OnButtonSFX();
virtual bool OnInit() Z7_override;
virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam) Z7_override;
virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM lParam) Z7_override;
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
virtual void OnOK() Z7_override;
virtual void OnHelp() Z7_override;
void MessageBoxError(LPCWSTR message)
{
MessageBoxW(*this, message, L"7-Zip", MB_ICONERROR);
}
void ShowOptionsString();
public:
const CObjectVector<CArcInfoEx> *ArcFormats;
CUIntVector ArcIndices; // can not be empty, must contain Info.FormatIndex, if Info.FormatIndex >= 0
AStringVector ExternalMethods;
void SetMethods(const CObjectVector<CCodecInfoUser> &userCodecs);
NCompressDialog::CInfo Info;
UString OriginalFileName; // for bzip2, gzip2
INT_PTR Create(HWND wndParent = NULL)
{
BIG_DIALOG_SIZE(400, 320);
return CModalDialog::Create(SIZED_DIALOG(IDD_COMPRESS), wndParent);
}
CCompressDialog() {}
};
class COptionsDialog: public NWindows::NControl::CModalDialog
{
struct CBoolBox
{
bool IsSupported;
bool DefaultVal;
CBoolPair BoolPair;
unsigned Id;
unsigned Set_Id;
void SetIDs(unsigned id, unsigned set_Id)
{
Id = id;
Set_Id = set_Id;
}
CBoolBox():
IsSupported(false),
DefaultVal(false)
{}
};
CCompressDialog *cd;
NWindows::NControl::CComboBox m_Prec;
UInt32 _auto_Prec;
UInt32 TimePrec;
void Reset_TimePrec() { TimePrec = (UInt32)(Int32)-1; }
bool IsSet_TimePrec() const { return TimePrec != (UInt32)(Int32)-1; }
CBoolBox MTime;
CBoolBox CTime;
CBoolBox ATime;
CBoolBox ZTime;
UString SecString;
UString NsString;
void CheckButton_Bool1(UINT id, const CBool1 &b1);
void GetButton_Bool1(UINT id, CBool1 &b1);
void CheckButton_BoolBox(bool supported, const CBoolPair &b2, CBoolBox &bb);
void GetButton_BoolBox(CBoolBox &bb);
void Store_TimeBoxes();
UInt32 GetComboValue(NWindows::NControl::CComboBox &c, int defMax = 0);
UInt32 GetPrecSpec()
{
UInt32 prec = GetComboValue(m_Prec, 1);
if (prec == _auto_Prec)
prec = (UInt32)(Int32)-1;
return prec;
}
UInt32 GetPrec() { return GetComboValue(m_Prec, 0); }
// void OnButton_TimeDefault();
int AddPrec(unsigned prec, bool isDefault);
void SetPrec();
void SetTimeMAC();
void On_CheckBoxSet_Prec_Clicked();
void On_CheckBoxSet_Clicked(const CBoolBox &bb);
virtual bool OnInit() Z7_override;
virtual bool OnCommand(unsigned code, unsigned itemID, LPARAM lParam) Z7_override;
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
virtual void OnOK() Z7_override;
virtual void OnHelp() Z7_override;
public:
INT_PTR Create(HWND wndParent = NULL)
{
BIG_DIALOG_SIZE(240, 232);
return CModalDialog::Create(SIZED_DIALOG(IDD_COMPRESS_OPTIONS), wndParent);
}
COptionsDialog(CCompressDialog *cdLoc):
cd(cdLoc)
// , TimePrec(0)
{
Reset_TimePrec();
}
};
#endif
@@ -0,0 +1,233 @@
#include "CompressDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 400
#define yc 320
#undef gSize
#undef gSpace
#undef g0xs
#undef g1x
#undef g1xs
#undef g2xs
#undef g3x
#undef g3xs
#undef g4x
#undef g4x2
#undef g4xs
#undef g4xs2
#define gSize 192
#define gSpace 24
#define g1xs 88
#define g0xs (gSize - g1xs)
#define g1x (m + g0xs)
#define g3xs 52
#define g2xs (gSize - g3xs)
#define g3x (m + g2xs)
#define g4x (m + gSize + gSpace)
#define g4x2 (g4x + m)
#define g4xs (xc - gSize - gSpace)
#define g4xs2 (g4xs - m - m)
#define yOpt 80
#define xArcFolderOffs 40
#undef GROUP_Y_SIZE
#undef GROUP_Y_SIZE_ENCRYPT
#ifdef UNDER_CE
#define GROUP_Y_SIZE 8
#define GROUP_Y_SIZE_ENCRYPT 8
#else
#define GROUP_Y_SIZE 64
#define GROUP_Y_SIZE_ENCRYPT 128
#endif
// #define DICT_SIZE_SPACE 8
// #define DICT_SIZE 54
// #define DICT_x (g1x + g1xs - DICT_SIZE)
// #define DICT2_x (DICT_x - DICT_SIZE_SPACE - DICT_SIZE)
#define yPsw (yOpt + GROUP_Y_SIZE + 8)
IDD_COMPRESS DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT
CAPTION "Add to Archive"
BEGIN
LTEXT "", IDT_COMPRESS_ARCHIVE_FOLDER, m + xArcFolderOffs, m, xc - xArcFolderOffs, 8
LTEXT "&Archive:", IDT_COMPRESS_ARCHIVE, m, 12, xArcFolderOffs, 8
COMBOBOX IDC_COMPRESS_ARCHIVE, m + xArcFolderOffs, 18, xc - bxsDots - 12 - xArcFolderOffs, 126, MY_COMBO_WITH_EDIT
PUSHBUTTON "...", IDB_COMPRESS_SET_ARCHIVE, xs - m - bxsDots, 16, bxsDots, bys, WS_GROUP
LTEXT "Archive &format:", IDT_COMPRESS_FORMAT, m, 41, g0xs, 8
COMBOBOX IDC_COMPRESS_FORMAT, g1x, 39, g1xs, 80, MY_COMBO | CBS_SORT
LTEXT "Compression &level:", IDT_COMPRESS_LEVEL, m, 62, g0xs, 8
COMBOBOX IDC_COMPRESS_LEVEL, g1x, 60, g1xs, 80, MY_COMBO
LTEXT "Compression &method:", IDT_COMPRESS_METHOD, m, 83, g0xs, 8
COMBOBOX IDC_COMPRESS_METHOD, g1x, 81, g1xs, 80, MY_COMBO
LTEXT "&Dictionary size:", IDT_COMPRESS_DICTIONARY, m, 104, g0xs, 8
COMBOBOX IDC_COMPRESS_DICTIONARY, g1x, 102, g1xs, 167, MY_COMBO
// LTEXT "&Dictionary size:", IDT_COMPRESS_DICTIONARY, m, 104, DICT_x - m, 16 // 8, SS_LEFTNOWORDWRAP
// LTEXT "", IDT_COMPRESS_PARAMS_INFO, m, 283, xs, MY_TEXT_NOPREFIX
// CTEXT "-", 0, DICT_x - DICT_SIZE_SPACE, 104, DICT_SIZE_SPACE, 8
// COMBOBOX IDC_COMPRESS_DICTIONARY2, DICT2_x, 102, DICT_SIZE, 140, MY_COMBO
// COMBOBOX IDC_COMPRESS_DICTIONARY, DICT_x, 102, DICT_SIZE, 140, MY_COMBO
LTEXT "&Word size:", IDT_COMPRESS_ORDER, m, 125, g0xs, 8
COMBOBOX IDC_COMPRESS_ORDER, g1x, 123, g1xs, 140, MY_COMBO
LTEXT "&Solid Block size:", IDT_COMPRESS_SOLID, m, 146, g0xs, 8
COMBOBOX IDC_COMPRESS_SOLID, g1x, 144, g1xs, 140, MY_COMBO
LTEXT "Number of CPU &threads:", IDT_COMPRESS_THREADS, m, 167, g0xs, 8
COMBOBOX IDC_COMPRESS_THREADS, g1x, 165, g1xs - 35, 140, MY_COMBO
RTEXT "", IDT_COMPRESS_HARDWARE_THREADS, g1x + g1xs - 35 + 10, 167, 25, MY_TEXT_NOPREFIX
LTEXT "Memory usage for Compressing:", IDT_COMPRESS_MEMORY, m, 184, g2xs, 8
COMBOBOX IDC_COMPRESS_MEM_USE, g3x, 188, g3xs, 140, MY_COMBO
LTEXT "", IDT_COMPRESS_MEMORY_VALUE, m, 194, g2xs, MY_TEXT_NOPREFIX
LTEXT "Memory usage for Decompressing:", IDT_COMPRESS_MEMORY_DE, m, 208, g2xs, 8
RTEXT "", IDT_COMPRESS_MEMORY_DE_VALUE, g3x, 208, g3xs, MY_TEXT_NOPREFIX
LTEXT "Split to &volumes, bytes:", IDT_SPLIT_TO_VOLUMES, m, 225, gSize, 8
COMBOBOX IDC_COMPRESS_VOLUME, m, 237, gSize, 73, MY_COMBO_WITH_EDIT
LTEXT "Parameters:", IDT_COMPRESS_PARAMETERS, m, 256, gSize, 8
EDITTEXT IDE_COMPRESS_PARAMETERS, m, 268, gSize, 14, ES_AUTOHSCROLL
PUSHBUTTON "Options", IDB_COMPRESS_OPTIONS, m, 292, bxs, bys
LTEXT "", IDT_COMPRESS_OPTIONS, m + bxs + m, 294, gSize - bxs - m, 16, SS_NOPREFIX
LTEXT "&Update mode:", IDT_COMPRESS_UPDATE_MODE, g4x, 41, 80, 8
COMBOBOX IDC_COMPRESS_UPDATE_MODE, g4x + 84, 39, g4xs - 84, 80, MY_COMBO
LTEXT "Path mode:", IDT_COMPRESS_PATH_MODE, g4x, 61, 80, 8
COMBOBOX IDC_COMPRESS_PATH_MODE, g4x + 84, 59, g4xs - 84, 80, MY_COMBO
GROUPBOX "Options", IDG_COMPRESS_OPTIONS, g4x, yOpt, g4xs, GROUP_Y_SIZE
CONTROL "Create SF&X archive", IDX_COMPRESS_SFX, MY_CHECKBOX,
g4x2, yOpt + 14, g4xs2, 10
CONTROL "Compress shared files", IDX_COMPRESS_SHARED, MY_CHECKBOX,
g4x2, yOpt + 30, g4xs2, 10
CONTROL "Delete files after compression", IDX_COMPRESS_DEL, MY_CHECKBOX,
g4x2, yOpt + 46, g4xs2, 10
GROUPBOX "Encryption", IDG_COMPRESS_ENCRYPTION, g4x, yPsw, g4xs, GROUP_Y_SIZE_ENCRYPT
LTEXT "Enter &password:", IDT_PASSWORD_ENTER, g4x2, yPsw + 14, g4xs2, 8
EDITTEXT IDE_COMPRESS_PASSWORD1, g4x2, yPsw + 26, g4xs2, 14, ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Reenter password:", IDT_PASSWORD_REENTER, g4x2, yPsw + 46, g4xs2, 8
EDITTEXT IDE_COMPRESS_PASSWORD2, g4x2, yPsw + 58, g4xs2, 14, ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Show Password", IDX_PASSWORD_SHOW, MY_CHECKBOX,
g4x2, yPsw + 79, g4xs2, 10
LTEXT "&Encryption method:", IDT_COMPRESS_ENCRYPTION_METHOD, g4x2, yPsw + 95, 100, 8
COMBOBOX IDC_COMPRESS_ENCRYPTION_METHOD, g4x2 + 100, yPsw + 93, g4xs2 - 100, 198, MY_COMBO
CONTROL "Encrypt file &names", IDX_COMPRESS_ENCRYPT_FILE_NAMES, MY_CHECKBOX,
g4x2, yPsw + 111, g4xs2, 10
DEFPUSHBUTTON "OK", IDOK, bx3, by, bxs, bys, WS_GROUP
PUSHBUTTON "Cancel", IDCANCEL, bx2, by, bxs, bys
PUSHBUTTON "Help", IDHELP, bx1, by, bxs, bys
END
#ifdef UNDER_CE
#undef m
#undef xc
#undef yc
#define m 4
#define xc 152
#define yc 160
IDD_COMPRESS_2 DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT
CAPTION "Add to Archive"
MY_FONT
BEGIN
COMBOBOX IDC_COMPRESS_ARCHIVE, m, m, xc - bxsDots - m, 126, MY_COMBO_WITH_EDIT
PUSHBUTTON "...", IDB_COMPRESS_SET_ARCHIVE, xs - m - bxsDots, m, bxsDots, 12, WS_GROUP
COMBOBOX IDC_COMPRESS_FORMAT, m , 22, 32, 80, MY_COMBO | CBS_SORT
COMBOBOX IDC_COMPRESS_LEVEL, m + 36, 22, 68, 80, MY_COMBO
COMBOBOX IDC_COMPRESS_METHOD, m + 108, 22, 44, 80, MY_COMBO
COMBOBOX IDC_COMPRESS_DICTIONARY, m, 40, 40, 80, MY_COMBO
COMBOBOX IDC_COMPRESS_ORDER, m + 44, 40, 32, 80, MY_COMBO
COMBOBOX IDC_COMPRESS_SOLID, m + 80, 40, 40, 80, MY_COMBO
COMBOBOX IDC_COMPRESS_THREADS, m + 124, 40, 28, 80, MY_COMBO
LTEXT "Split to &volumes, bytes:", IDT_SPLIT_TO_VOLUMES, m, 60, 32, 8
COMBOBOX IDC_COMPRESS_VOLUME, m + 32, 58, 44, 73, MY_COMBO_WITH_EDIT
LTEXT "Parameters:", IDT_COMPRESS_PARAMETERS, m + 80, 60, 48, 8
EDITTEXT IDE_COMPRESS_PARAMETERS, m + 128, 58, 24, 13, ES_AUTOHSCROLL
COMBOBOX IDC_COMPRESS_UPDATE_MODE, m, 76, 88, 80, MY_COMBO
CONTROL "SF&X", IDX_COMPRESS_SFX, MY_CHECKBOX, m + 92, 77, 60, 10
CONTROL "Compress shared files", IDX_COMPRESS_SHARED, MY_CHECKBOX, m, 94, xc, 10
LTEXT "Enter &password:", IDT_PASSWORD_ENTER, m, 112, 60, 8
EDITTEXT IDE_COMPRESS_PASSWORD1, m + 60, 110, 44, 13, ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Show Password", IDX_PASSWORD_SHOW, MY_CHECKBOX, m + 108, 112, 44, 10
COMBOBOX IDC_COMPRESS_ENCRYPTION_METHOD, m, 128, 48, 198, MY_COMBO
CONTROL "Encrypt file &names", IDX_COMPRESS_ENCRYPT_FILE_NAMES, MY_CHECKBOX, m + 52, 130, 100, 10
OK_CANCEL
END
#endif
STRINGTABLE
BEGIN
IDS_PASSWORD_NOT_MATCH "Passwords do not match"
IDS_PASSWORD_USE_ASCII "Use only English letters, numbers and special characters (!, #, $, ...) for password."
IDS_PASSWORD_TOO_LONG "Password is too long"
IDS_METHOD_STORE "Store"
IDS_METHOD_FASTEST "Fastest"
IDS_METHOD_FAST "Fast"
IDS_METHOD_NORMAL "Normal"
IDS_METHOD_MAXIMUM "Maximum"
IDS_METHOD_ULTRA "Ultra"
IDS_COMPRESS_UPDATE_MODE_ADD "Add and replace files"
IDS_COMPRESS_UPDATE_MODE_UPDATE "Update and add files"
IDS_COMPRESS_UPDATE_MODE_FRESH "Freshen existing files"
IDS_COMPRESS_UPDATE_MODE_SYNC "Synchronize files"
IDS_OPEN_TYPE_ALL_FILES "All Files"
IDS_COMPRESS_SET_ARCHIVE_BROWSE "Browse"
IDS_COMPRESS_NON_SOLID "Non-solid"
IDS_COMPRESS_SOLID "Solid"
IDS_SPLIT_CONFIRM "Specified volume size: {0} bytes.\nAre you sure you want to split archive into such volumes?"
IDS_COMPRESS_SEC "sec"
IDS_COMPRESS_NS "ns"
IDS_MEM_OPERATION_BLOCKED "The operation was blocked by 7-Zip."
END
#include "CompressOptionsDialog.rc"
@@ -0,0 +1,125 @@
#define IDD_COMPRESS 4000
#define IDD_COMPRESS_2 14000
#define IDD_COMPRESS_OPTIONS 14001
#define IDC_COMPRESS_ARCHIVE 100
#define IDB_COMPRESS_SET_ARCHIVE 101
#define IDC_COMPRESS_LEVEL 102
#define IDC_COMPRESS_UPDATE_MODE 103
#define IDC_COMPRESS_FORMAT 104
#define IDC_COMPRESS_VOLUME 105
#define IDC_COMPRESS_METHOD 106
#define IDC_COMPRESS_DICTIONARY 107
#define IDC_COMPRESS_ORDER 108
#define IDC_COMPRESS_SOLID 109
#define IDC_COMPRESS_THREADS 110
#define IDE_COMPRESS_PARAMETERS 111
#define IDT_COMPRESS_HARDWARE_THREADS 112
#define IDT_COMPRESS_MEMORY_VALUE 113
#define IDT_COMPRESS_MEMORY_DE_VALUE 114
#define IDG_COMPRESS_NTFS 115
#define IDC_COMPRESS_PATH_MODE 116
#define IDC_COMPRESS_MEM_USE 117
// #define IDC_COMPRESS_DICTIONARY2 118
#define IDE_COMPRESS_PASSWORD1 120
#define IDE_COMPRESS_PASSWORD2 121
#define IDC_COMPRESS_ENCRYPTION_METHOD 122
#define IDT_COMPRESS_ARCHIVE_FOLDER 130
// #define IDB_COMPRESS_OPTIONS 140
#define IDB_COMPRESS_OPTIONS 2100
#define IDT_COMPRESS_OPTIONS 141
// #define IDT_COMPRESS_PARAMS_INFO 142
#define IDT_COMPRESS_PATH_MODE 3410
#define IDT_PASSWORD_ENTER 3801
#define IDT_PASSWORD_REENTER 3802
#define IDX_PASSWORD_SHOW 3803
#define IDS_PASSWORD_NOT_MATCH 3804
#define IDS_PASSWORD_USE_ASCII 3805
#define IDS_PASSWORD_TOO_LONG 3806
#define IDT_COMPRESS_ARCHIVE 4001
#define IDT_COMPRESS_UPDATE_MODE 4002
#define IDT_COMPRESS_FORMAT 4003
#define IDT_COMPRESS_LEVEL 4004
#define IDT_COMPRESS_METHOD 4005
#define IDT_COMPRESS_DICTIONARY 4006
#define IDT_COMPRESS_ORDER 4007
#define IDT_COMPRESS_SOLID 4008
#define IDT_COMPRESS_THREADS 4009
#define IDT_COMPRESS_PARAMETERS 4010
#define IDG_COMPRESS_OPTIONS 4011
#define IDX_COMPRESS_SFX 4012
#define IDX_COMPRESS_SHARED 4013
#define IDG_COMPRESS_ENCRYPTION 4014
#define IDT_COMPRESS_ENCRYPTION_METHOD 4015
#define IDX_COMPRESS_ENCRYPT_FILE_NAMES 4016
#define IDT_COMPRESS_MEMORY 4017
#define IDT_COMPRESS_MEMORY_DE 4018
#define IDX_COMPRESS_DEL 4019
#define IDX_COMPRESS_NT_SYM_LINKS 4040
#define IDX_COMPRESS_NT_HARD_LINKS 4041
#define IDX_COMPRESS_NT_ALT_STREAMS 4042
#define IDX_COMPRESS_NT_SECUR 4043
#define IDS_METHOD_STORE 4050
#define IDS_METHOD_FASTEST 4051
#define IDS_METHOD_FAST 4052
#define IDS_METHOD_NORMAL 4053
#define IDS_METHOD_MAXIMUM 4054
#define IDS_METHOD_ULTRA 4055
#define IDS_COMPRESS_UPDATE_MODE_ADD 4060
#define IDS_COMPRESS_UPDATE_MODE_UPDATE 4061
#define IDS_COMPRESS_UPDATE_MODE_FRESH 4062
#define IDS_COMPRESS_UPDATE_MODE_SYNC 4063
#define IDS_COMPRESS_SET_ARCHIVE_BROWSE 4070
#define IDS_OPEN_TYPE_ALL_FILES 4071
#define IDS_COMPRESS_NON_SOLID 4072
#define IDS_COMPRESS_SOLID 4073
#define IDT_SPLIT_TO_VOLUMES 7302
#define IDS_INCORRECT_VOLUME_SIZE 7307
#define IDS_SPLIT_CONFIRM 7308
// Options Dialog
#define IDG_COMPRESS_TIME 4080
#define IDT_COMPRESS_TIME_PREC 4081
#define IDX_COMPRESS_MTIME 4082
#define IDX_COMPRESS_CTIME 4083
#define IDX_COMPRESS_ATIME 4084
#define IDX_COMPRESS_ZTIME 4085
#define IDX_COMPRESS_PRESERVE_ATIME 4086
#define IDS_COMPRESS_SEC 4090
#define IDS_COMPRESS_NS 4091
#define IDC_COMPRESS_TIME_PREC 190
#define IDT_COMPRESS_TIME_INFO 191
#define IDX_COMPRESS_PREC_SET 201
#define IDX_COMPRESS_MTIME_SET 202
#define IDX_COMPRESS_CTIME_SET 203
#define IDX_COMPRESS_ATIME_SET 204
#define IDX_COMPRESS_ZTIME_SET 205
// #define IDX_COMPRESS_NT_SYM_LINKS_SET 210
// #define IDX_COMPRESS_NT_HARD_LINKS_SET 211
// #define IDX_COMPRESS_NT_ALT_STREAMS_SET 212
// #define IDX_COMPRESS_NT_SECUR_SET 213
#define IDS_MEM_OPERATION_BLOCKED 7810
@@ -0,0 +1,79 @@
#include "CompressDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 240
#define yc 232
#define g5x m
#define g5x2 (g5x + m)
#define g5xs (xc)
#define g5xs2 (g5xs - m - m)
#define ntPosX g5x2
#define ntPosY m
#define ntSizeX g5xs2
#define precSizeX 76
#define ntSizeY 72
#define timePosY (ntPosY + ntSizeY + 20)
IDD_COMPRESS_OPTIONS DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT
CAPTION "Options"
BEGIN
GROUPBOX "NTFS", IDG_COMPRESS_NTFS, g5x, ntPosY, g5xs, ntSizeY
MY_CONTROL_CHECKBOX ("Store symbolic links", IDX_COMPRESS_NT_SYM_LINKS,
ntPosX, ntPosY + 12, ntSizeX)
MY_CONTROL_CHECKBOX ("Store hard links", IDX_COMPRESS_NT_HARD_LINKS,
ntPosX, ntPosY + 26, ntSizeX)
MY_CONTROL_CHECKBOX ("Store alternate data streams", IDX_COMPRESS_NT_ALT_STREAMS,
ntPosX, ntPosY + 40, ntSizeX)
MY_CONTROL_CHECKBOX ("Store file security", IDX_COMPRESS_NT_SECUR,
ntPosX, ntPosY + 54, ntSizeX)
LTEXT "", IDT_COMPRESS_TIME_INFO, g5x, timePosY - 14, g5xs, 8
GROUPBOX "Time", IDG_COMPRESS_TIME, g5x, timePosY, g5xs, 112
// MY_CONTROL_CHECKBOX ("Default", IDX_COMPRESS_TIME_DEFAULT,
// ntPosX, timePosY + 10, ntSizeX)
MY_CONTROL_CHECKBOX_COLON (IDX_COMPRESS_PREC_SET, ntPosX, timePosY + 14)
LTEXT "Timestamp precision:", IDT_COMPRESS_TIME_PREC,
ntPosX + cboxColonSize, timePosY + 14, ntSizeX - precSizeX - cboxColonSize, 8
COMBOBOX IDC_COMPRESS_TIME_PREC, ntPosX + ntSizeX - precSizeX, timePosY + 12, precSizeX, 70, MY_COMBO
// PUSHBUTTON "Default", IDB_COMPRESS_TIME_DEFAULT, ntPosX + ntSizeX - bxs, timePosY + 22, bxs, bys, WS_GROUP
MY_CONTROL_CHECKBOX_COLON (IDX_COMPRESS_MTIME_SET, ntPosX, timePosY + 28)
MY_CONTROL_CHECKBOX ("Store modification time", IDX_COMPRESS_MTIME,
ntPosX + cboxColonSize, timePosY + 28, ntSizeX - cboxColonSize)
MY_CONTROL_CHECKBOX_COLON (IDX_COMPRESS_CTIME_SET, ntPosX, timePosY + 42)
MY_CONTROL_CHECKBOX ("Store creation time", IDX_COMPRESS_CTIME,
ntPosX + cboxColonSize, timePosY + 42, ntSizeX - cboxColonSize)
MY_CONTROL_CHECKBOX_COLON (IDX_COMPRESS_ATIME_SET, ntPosX, timePosY + 56)
MY_CONTROL_CHECKBOX ("Store last access time", IDX_COMPRESS_ATIME,
ntPosX + cboxColonSize, timePosY + 56, ntSizeX - cboxColonSize)
MY_CONTROL_CHECKBOX_2LINES(colonString,
IDX_COMPRESS_ZTIME_SET,
ntPosX, timePosY + 72, cboxColonSize)
MY_CONTROL_CHECKBOX_2LINES(
"Set archive time to latest file time",
IDX_COMPRESS_ZTIME,
ntPosX + cboxColonSize, timePosY + 72, ntSizeX - cboxColonSize)
MY_CONTROL_CHECKBOX_2LINES(
"Do not change source files last access time",
IDX_COMPRESS_PRESERVE_ATIME,
ntPosX, timePosY + 92, ntSizeX)
DEFPUSHBUTTON "OK", IDOK, bx3, by, bxs, bys, WS_GROUP
PUSHBUTTON "Cancel", IDCANCEL, bx2, by, bxs, bys
PUSHBUTTON "Help", IDHELP, bx1, by, bxs, bys
END
+59
View File
@@ -0,0 +1,59 @@
#include "ExtractRes.h"
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
STRINGTABLE DISCARDABLE
BEGIN
IDS_MEM_ERROR "The system cannot allocate the required amount of memory"
IDS_CANNOT_CREATE_FOLDER "Cannot create folder '{0}'"
IDS_UPDATE_NOT_SUPPORTED "Update operations are not supported for this archive."
IDS_CANT_OPEN_ARCHIVE "Cannot open file '{0}' as archive"
IDS_CANT_OPEN_ENCRYPTED_ARCHIVE "Cannot open encrypted archive '{0}'. Wrong password?"
IDS_UNSUPPORTED_ARCHIVE_TYPE "Unsupported archive type"
IDS_CANT_OPEN_AS_TYPE "Cannot open the file as {0} archive"
IDS_IS_OPEN_AS_TYPE "The file is open as {0} archive"
IDS_IS_OPEN_WITH_OFFSET "The archive is open with offset"
IDS_PROGRESS_EXTRACTING "Extracting"
IDS_PROGRESS_SKIPPING "Skipping"
IDS_EXTRACT_SET_FOLDER "Specify a location for extracted files."
IDS_EXTRACT_PATHS_FULL "Full pathnames"
IDS_EXTRACT_PATHS_NO "No pathnames"
IDS_EXTRACT_PATHS_ABS "Absolute pathnames"
IDS_PATH_MODE_RELAT "Relative pathnames"
IDS_EXTRACT_OVERWRITE_ASK "Ask before overwrite"
IDS_EXTRACT_OVERWRITE_WITHOUT_PROMPT "Overwrite without prompt"
IDS_EXTRACT_OVERWRITE_SKIP_EXISTING "Skip existing files"
IDS_EXTRACT_OVERWRITE_RENAME "Auto rename"
IDS_EXTRACT_OVERWRITE_RENAME_EXISTING "Auto rename existing files"
IDS_EXTRACT_MESSAGE_UNSUPPORTED_METHOD "Unsupported compression method for '{0}'."
IDS_EXTRACT_MESSAGE_DATA_ERROR "Data error in '{0}'. File is broken"
IDS_EXTRACT_MESSAGE_CRC_ERROR "CRC failed in '{0}'. File is broken."
IDS_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED "Data error in encrypted file '{0}'. Wrong password?"
IDS_EXTRACT_MESSAGE_CRC_ERROR_ENCRYPTED "CRC failed in encrypted file '{0}'. Wrong password?"
IDS_EXTRACT_MSG_WRONG_PSW_GUESS "Wrong password?"
// IDS_EXTRACT_MSG_ENCRYPTED "Encrypted file"
IDS_EXTRACT_MSG_UNSUPPORTED_METHOD "Unsupported compression method"
IDS_EXTRACT_MSG_DATA_ERROR "Data error"
IDS_EXTRACT_MSG_CRC_ERROR "CRC failed"
IDS_EXTRACT_MSG_UNAVAILABLE_DATA "Unavailable data"
IDS_EXTRACT_MSG_UEXPECTED_END "Unexpected end of data"
IDS_EXTRACT_MSG_DATA_AFTER_END "There are some data after the end of the payload data"
IDS_EXTRACT_MSG_IS_NOT_ARC "Is not archive"
IDS_EXTRACT_MSG_HEADERS_ERROR "Headers Error"
IDS_EXTRACT_MSG_WRONG_PSW_CLAIM "Wrong password"
IDS_OPEN_MSG_UNAVAILABLE_START "Unavailable start of archive"
IDS_OPEN_MSG_UNCONFIRMED_START "Unconfirmed start of archive"
// IDS_OPEN_MSG_ERROR_FLAGS + 5 "Unexpected end of archive"
// IDS_OPEN_MSG_ERROR_FLAGS + 6 "There are data after the end of archive"
IDS_OPEN_MSG_UNSUPPORTED_FEATURE "Unsupported feature"
END
@@ -0,0 +1,421 @@
// ExtractDialog.cpp
#include "StdAfx.h"
#include "../../../Common/StringConvert.h"
#include "../../../Common/Wildcard.h"
#include "../../../Windows/FileName.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/ResourceString.h"
#ifndef Z7_NO_REGISTRY
#include "../FileManager/HelpUtils.h"
#endif
#include "../FileManager/BrowseDialog.h"
#include "../FileManager/LangUtils.h"
#include "../FileManager/resourceGui.h"
#include "ExtractDialog.h"
#include "ExtractDialogRes.h"
#include "ExtractRes.h"
using namespace NWindows;
using namespace NFile;
using namespace NName;
extern HINSTANCE g_hInstance;
#ifndef Z7_SFX
static const UInt32 kPathMode_IDs[] =
{
IDS_EXTRACT_PATHS_FULL,
IDS_EXTRACT_PATHS_NO,
IDS_EXTRACT_PATHS_ABS
};
static const UInt32 kOverwriteMode_IDs[] =
{
IDS_EXTRACT_OVERWRITE_ASK,
IDS_EXTRACT_OVERWRITE_WITHOUT_PROMPT,
IDS_EXTRACT_OVERWRITE_SKIP_EXISTING,
IDS_EXTRACT_OVERWRITE_RENAME,
IDS_EXTRACT_OVERWRITE_RENAME_EXISTING
};
static const
// NExtract::NPathMode::EEnum
int
kPathModeButtonsVals[] =
{
NExtract::NPathMode::kFullPaths,
NExtract::NPathMode::kNoPaths,
NExtract::NPathMode::kAbsPaths
};
static const
int
// NExtract::NOverwriteMode::EEnum
kOverwriteButtonsVals[] =
{
NExtract::NOverwriteMode::kAsk,
NExtract::NOverwriteMode::kOverwrite,
NExtract::NOverwriteMode::kSkip,
NExtract::NOverwriteMode::kRename,
NExtract::NOverwriteMode::kRenameExisting
};
#endif
#ifdef Z7_LANG
static const UInt32 kLangIDs[] =
{
IDT_EXTRACT_EXTRACT_TO,
IDT_EXTRACT_PATH_MODE,
IDT_EXTRACT_OVERWRITE_MODE,
// IDX_EXTRACT_ALT_STREAMS,
IDX_EXTRACT_NT_SECUR,
IDX_EXTRACT_ELIM_DUP,
IDG_PASSWORD,
IDX_PASSWORD_SHOW
};
#endif
// static const int kWildcardsButtonIndex = 2;
#ifndef Z7_NO_REGISTRY
static const unsigned kHistorySize = 16;
#endif
#ifndef Z7_SFX
// it's used in CompressDialog also
void AddComboItems(NControl::CComboBox &combo, const UInt32 *langIDs, unsigned numItems, const int *values, int curVal);
void AddComboItems(NControl::CComboBox &combo, const UInt32 *langIDs, unsigned numItems, const int *values, int curVal)
{
unsigned curSel = 0;
for (unsigned i = 0; i < numItems; i++)
{
UString s = LangString(langIDs[i]);
s.RemoveChar(L'&');
const int index = (int)combo.AddString(s);
combo.SetItemData(index, (LPARAM)i);
if (values[i] == curVal)
curSel = i;
}
combo.SetCurSel(curSel);
}
// it's used in CompressDialog also
bool GetBoolsVal(const CBoolPair &b1, const CBoolPair &b2);
bool GetBoolsVal(const CBoolPair &b1, const CBoolPair &b2)
{
if (b1.Def) return b1.Val;
if (b2.Def) return b2.Val;
return b1.Val;
}
void CExtractDialog::CheckButton_TwoBools(UINT id, const CBoolPair &b1, const CBoolPair &b2)
{
CheckButton(id, GetBoolsVal(b1, b2));
}
void CExtractDialog::GetButton_Bools(UINT id, CBoolPair &b1, CBoolPair &b2)
{
const bool val = IsButtonCheckedBool(id);
const bool oldVal = GetBoolsVal(b1, b2);
if (val != oldVal)
b1.Def = b2.Def = true;
b1.Val = b2.Val = val;
}
#endif
bool CExtractDialog::OnInit()
{
#ifdef Z7_LANG
{
UString s;
LangString_OnlyFromLangFile(IDD_EXTRACT, s);
if (s.IsEmpty())
GetText(s);
if (!ArcPath.IsEmpty())
{
s += " : ";
s += ArcPath;
}
SetText(s);
// LangSetWindowText(*this, IDD_EXTRACT);
LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
}
#endif
#ifndef Z7_SFX
_passwordControl.Attach(GetItem(IDE_EXTRACT_PASSWORD));
_passwordControl.SetText(Password);
_passwordControl.SetPasswordChar(TEXT('*'));
_pathName.Attach(GetItem(IDE_EXTRACT_NAME));
#endif
#ifdef Z7_NO_REGISTRY
PathMode = NExtract::NPathMode::kFullPaths;
OverwriteMode = NExtract::NOverwriteMode::kAsk;
#else
_info.Load();
if (_info.PathMode == NExtract::NPathMode::kCurPaths)
_info.PathMode = NExtract::NPathMode::kFullPaths;
if (!PathMode_Force && _info.PathMode_Force)
PathMode = _info.PathMode;
if (!OverwriteMode_Force && _info.OverwriteMode_Force)
OverwriteMode = _info.OverwriteMode;
// CheckButton_TwoBools(IDX_EXTRACT_ALT_STREAMS, AltStreams, _info.AltStreams);
CheckButton_TwoBools(IDX_EXTRACT_NT_SECUR, NtSecurity, _info.NtSecurity);
CheckButton_TwoBools(IDX_EXTRACT_ELIM_DUP, ElimDup, _info.ElimDup);
CheckButton(IDX_PASSWORD_SHOW, _info.ShowPassword.Val);
UpdatePasswordControl();
#endif
_path.Attach(GetItem(IDC_EXTRACT_PATH));
UString pathPrefix = DirPath;
#ifndef Z7_SFX
if (_info.SplitDest.Val)
{
CheckButton(IDX_EXTRACT_NAME_ENABLE, true);
UString pathName;
SplitPathToParts_Smart(DirPath, pathPrefix, pathName);
if (pathPrefix.IsEmpty())
pathPrefix = pathName;
else
_pathName.SetText(pathName);
}
else
ShowItem_Bool(IDE_EXTRACT_NAME, false);
#endif
_path.SetText(pathPrefix);
#ifndef Z7_NO_REGISTRY
for (unsigned i = 0; i < _info.Paths.Size() && i < kHistorySize; i++)
_path.AddString(_info.Paths[i]);
#endif
/*
if (_info.Paths.Size() > 0)
_path.SetCurSel(0);
else
_path.SetCurSel(-1);
*/
#ifndef Z7_SFX
_pathMode.Attach(GetItem(IDC_EXTRACT_PATH_MODE));
_overwriteMode.Attach(GetItem(IDC_EXTRACT_OVERWRITE_MODE));
AddComboItems(_pathMode, kPathMode_IDs, Z7_ARRAY_SIZE(kPathMode_IDs), kPathModeButtonsVals, PathMode);
AddComboItems(_overwriteMode, kOverwriteMode_IDs, Z7_ARRAY_SIZE(kOverwriteMode_IDs), kOverwriteButtonsVals, OverwriteMode);
#endif
HICON icon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON));
SetIcon(ICON_BIG, icon);
// CWindow filesWindow = GetItem(IDC_EXTRACT_RADIO_FILES);
// filesWindow.Enable(_enableFilesButton);
NormalizePosition();
return CModalDialog::OnInit();
}
#ifndef Z7_SFX
void CExtractDialog::UpdatePasswordControl()
{
_passwordControl.SetPasswordChar(IsShowPasswordChecked() ? 0 : TEXT('*'));
UString password;
_passwordControl.GetText(password);
_passwordControl.SetText(password);
}
#endif
bool CExtractDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
{
switch (buttonID)
{
case IDB_EXTRACT_SET_PATH:
OnButtonSetPath();
return true;
#ifndef Z7_SFX
case IDX_EXTRACT_NAME_ENABLE:
ShowItem_Bool(IDE_EXTRACT_NAME, IsButtonCheckedBool(IDX_EXTRACT_NAME_ENABLE));
return true;
case IDX_PASSWORD_SHOW:
{
UpdatePasswordControl();
return true;
}
#endif
}
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
void CExtractDialog::OnButtonSetPath()
{
UString currentPath;
_path.GetText(currentPath);
UString title = LangString(IDS_EXTRACT_SET_FOLDER);
UString resultPath;
if (!MyBrowseForFolder(*this, title, currentPath, resultPath))
return;
#ifndef Z7_NO_REGISTRY
_path.SetCurSel(-1);
#endif
_path.SetText(resultPath);
}
void AddUniqueString(UStringVector &list, const UString &s);
void AddUniqueString(UStringVector &list, const UString &s)
{
FOR_VECTOR (i, list)
if (s.IsEqualTo_NoCase(list[i]))
return;
list.Add(s);
}
void CExtractDialog::OnOK()
{
#ifndef Z7_SFX
int pathMode2 = kPathModeButtonsVals[_pathMode.GetCurSel()];
if (PathMode != NExtract::NPathMode::kCurPaths ||
pathMode2 != NExtract::NPathMode::kFullPaths)
PathMode = (NExtract::NPathMode::EEnum)pathMode2;
OverwriteMode = (NExtract::NOverwriteMode::EEnum)kOverwriteButtonsVals[_overwriteMode.GetCurSel()];
// _filesMode = (NExtractionDialog::NFilesMode::EEnum)GetFilesMode();
_passwordControl.GetText(Password);
#endif
#ifndef Z7_NO_REGISTRY
// GetButton_Bools(IDX_EXTRACT_ALT_STREAMS, AltStreams, _info.AltStreams);
GetButton_Bools(IDX_EXTRACT_NT_SECUR, NtSecurity, _info.NtSecurity);
GetButton_Bools(IDX_EXTRACT_ELIM_DUP, ElimDup, _info.ElimDup);
bool showPassword = IsShowPasswordChecked();
if (showPassword != _info.ShowPassword.Val)
{
_info.ShowPassword.Def = true;
_info.ShowPassword.Val = showPassword;
}
if (_info.PathMode != pathMode2)
{
_info.PathMode_Force = true;
_info.PathMode = (NExtract::NPathMode::EEnum)pathMode2;
/*
// we allow kAbsPaths in registry.
if (_info.PathMode == NExtract::NPathMode::kAbsPaths)
_info.PathMode = NExtract::NPathMode::kFullPaths;
*/
}
if (!OverwriteMode_Force && _info.OverwriteMode != OverwriteMode)
_info.OverwriteMode_Force = true;
_info.OverwriteMode = OverwriteMode;
#else
ElimDup.Val = IsButtonCheckedBool(IDX_EXTRACT_ELIM_DUP);
#endif
UString s;
#ifdef Z7_NO_REGISTRY
_path.GetText(s);
#else
int currentItem = _path.GetCurSel();
if (currentItem == CB_ERR)
{
_path.GetText(s);
if (_path.GetCount() >= (int)kHistorySize)
currentItem = _path.GetCount() - 1;
}
else
_path.GetLBText(currentItem, s);
#endif
s.Trim();
NName::NormalizeDirPathPrefix(s);
#ifndef Z7_SFX
const bool splitDest = IsButtonCheckedBool(IDX_EXTRACT_NAME_ENABLE);
if (splitDest)
{
UString pathName;
_pathName.GetText(pathName);
pathName.Trim();
s += pathName;
NName::NormalizeDirPathPrefix(s);
}
if (splitDest != _info.SplitDest.Val)
{
_info.SplitDest.Def = true;
_info.SplitDest.Val = splitDest;
}
#endif
DirPath = s;
#ifndef Z7_NO_REGISTRY
_info.Paths.Clear();
#ifndef Z7_SFX
AddUniqueString(_info.Paths, s);
#endif
for (int i = 0; i < _path.GetCount(); i++)
if (i != currentItem)
{
UString sTemp;
_path.GetLBText(i, sTemp);
sTemp.Trim();
AddUniqueString(_info.Paths, sTemp);
}
_info.Save();
#endif
CModalDialog::OnOK();
}
#ifndef Z7_NO_REGISTRY
#define kHelpTopic "fm/plugins/7-zip/extract.htm"
void CExtractDialog::OnHelp()
{
ShowHelpWindow(kHelpTopic);
CModalDialog::OnHelp();
}
#endif
@@ -0,0 +1,113 @@
// ExtractDialog.h
#ifndef ZIP7_INC_EXTRACT_DIALOG_H
#define ZIP7_INC_EXTRACT_DIALOG_H
#include "ExtractDialogRes.h"
#include "../../../Windows/Control/ComboBox.h"
#include "../../../Windows/Control/Edit.h"
#include "../Common/ExtractMode.h"
#include "../FileManager/DialogSize.h"
#ifndef Z7_NO_REGISTRY
#include "../Common/ZipRegistry.h"
#endif
namespace NExtractionDialog
{
/*
namespace NFilesMode
{
enum EEnum
{
kSelected,
kAll,
kSpecified
};
}
*/
}
class CExtractDialog: public NWindows::NControl::CModalDialog
{
#ifdef Z7_NO_REGISTRY
NWindows::NControl::CDialogChildControl _path;
#else
NWindows::NControl::CComboBox _path;
#endif
#ifndef Z7_SFX
NWindows::NControl::CEdit _pathName;
NWindows::NControl::CEdit _passwordControl;
NWindows::NControl::CComboBox _pathMode;
NWindows::NControl::CComboBox _overwriteMode;
#endif
#ifndef Z7_SFX
// int GetFilesMode() const;
void UpdatePasswordControl();
#endif
void OnButtonSetPath();
void CheckButton_TwoBools(UINT id, const CBoolPair &b1, const CBoolPair &b2);
void GetButton_Bools(UINT id, CBoolPair &b1, CBoolPair &b2);
virtual bool OnInit() Z7_override;
virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
virtual void OnOK() Z7_override;
#ifndef Z7_NO_REGISTRY
virtual void OnHelp() Z7_override;
NExtract::CInfo _info;
#endif
bool IsShowPasswordChecked() const { return IsButtonCheckedBool(IDX_PASSWORD_SHOW); }
public:
// bool _enableSelectedFilesButton;
// bool _enableFilesButton;
// NExtractionDialog::NFilesMode::EEnum FilesMode;
UString DirPath;
UString ArcPath;
#ifndef Z7_SFX
UString Password;
#endif
bool PathMode_Force;
bool OverwriteMode_Force;
NExtract::NPathMode::EEnum PathMode;
NExtract::NOverwriteMode::EEnum OverwriteMode;
#ifndef Z7_SFX
// CBoolPair AltStreams;
CBoolPair NtSecurity;
#endif
CBoolPair ElimDup;
INT_PTR Create(HWND aWndParent = NULL)
{
#ifdef Z7_SFX
BIG_DIALOG_SIZE(240, 64);
#else
BIG_DIALOG_SIZE(300, 160);
#endif
return CModalDialog::Create(SIZED_DIALOG(IDD_EXTRACT), aWndParent);
}
CExtractDialog():
PathMode_Force(false),
OverwriteMode_Force(false)
{
ElimDup.Val = true;
}
};
#endif
@@ -0,0 +1,98 @@
#include "ExtractDialogRes.h"
#include "../../GuiCommon.rc"
#define xc 336
#define yc 168
#undef g1xs
#undef g2x
#undef g2x2
#undef g2xs
#undef g2xs2
#define g1xs 160
#define gSpace 20
#define g2x (m + g1xs + gSpace)
#define g2x2 (g2x + m)
#define g2xs (xc - g1xs - gSpace)
#define g2xs2 (g2xs - m - m)
#undef GROUP_Y_SIZE
#ifdef UNDER_CE
#define GROUP_Y_SIZE 8
#else
#define GROUP_Y_SIZE 56
#endif
IDD_EXTRACT DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT
CAPTION "Extract"
BEGIN
LTEXT "E&xtract to:", IDT_EXTRACT_EXTRACT_TO, m, m, xc, 8
COMBOBOX IDC_EXTRACT_PATH, m, m + 12, xc - bxsDots - 12, 100, MY_COMBO_WITH_EDIT
PUSHBUTTON "...", IDB_EXTRACT_SET_PATH, xs - m - bxsDots, m + 12 - 2, bxsDots, bys, WS_GROUP
CONTROL "", IDX_EXTRACT_NAME_ENABLE, MY_CHECKBOX, m, m + 34, 12, 10
EDITTEXT IDE_EXTRACT_NAME, m + 12 + 2, m + 32, g1xs - 12 - 2, 14, ES_AUTOHSCROLL
LTEXT "Path mode:", IDT_EXTRACT_PATH_MODE, m, m + 52, g1xs, 8
COMBOBOX IDC_EXTRACT_PATH_MODE, m, m + 64, g1xs, 140, MY_COMBO
CONTROL "Eliminate duplication of root folder", IDX_EXTRACT_ELIM_DUP, MY_CHECKBOX,
m, m + 84, g1xs, 10
LTEXT "Overwrite mode:", IDT_EXTRACT_OVERWRITE_MODE, m, m + 104, g1xs, 8
COMBOBOX IDC_EXTRACT_OVERWRITE_MODE, m, m + 116, g1xs, 140, MY_COMBO
GROUPBOX "Password", IDG_PASSWORD, g2x, m + 36, g2xs, GROUP_Y_SIZE
EDITTEXT IDE_EXTRACT_PASSWORD, g2x2, m + 50, g2xs2, 14, ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Show Password", IDX_PASSWORD_SHOW, MY_CHECKBOX, g2x2, m + 72, g2xs2, 10
// CONTROL "Restore alternate data streams", IDX_EXTRACT_ALT_STREAMS, MY_CHECKBOX,
// g2x, m + 104, g2xs, 10
CONTROL "Restore file security", IDX_EXTRACT_NT_SECUR, MY_CHECKBOX,
g2x, m + 104, g2xs, 10
DEFPUSHBUTTON "OK", IDOK, bx3, by, bxs, bys, WS_GROUP
PUSHBUTTON "Cancel", IDCANCEL, bx2, by, bxs, bys
PUSHBUTTON "Help", IDHELP, bx1, by, bxs, bys
END
#ifdef UNDER_CE
#undef m
#define m 4
#undef xc
#undef yc
#define xc 152
#define yc 128
#undef g1xs
#define g1xs 64
IDD_EXTRACT_2 DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT
CAPTION "Extract"
BEGIN
LTEXT "E&xtract to:", IDT_EXTRACT_EXTRACT_TO, m, m, xc - bxsDots - 8, 8
COMBOBOX IDC_EXTRACT_PATH, m, m + 12, xc - bxsDots - 8, 100, MY_COMBO_WITH_EDIT
PUSHBUTTON "...", IDB_EXTRACT_SET_PATH, xs - m - bxsDots, m + 12 - 3, bxsDots, bys, WS_GROUP
LTEXT "Path mode:", IDT_EXTRACT_PATH_MODE, m, m + 36, g1xs, 8
COMBOBOX IDC_EXTRACT_PATH_MODE, m + g1xs, m + 36, xc - g1xs, 100, MY_COMBO
LTEXT "Overwrite mode:", IDT_EXTRACT_OVERWRITE_MODE, m, m + 56, g1xs, 8
COMBOBOX IDC_EXTRACT_OVERWRITE_MODE, m + g1xs, m + 56, xc - g1xs, 100, MY_COMBO
LTEXT "Password", IDG_PASSWORD, m, m + 76, g1xs, 8
EDITTEXT IDE_EXTRACT_PASSWORD, m + g1xs, m + 76, xc - g1xs, 14, ES_PASSWORD | ES_AUTOHSCROLL
CONTROL "Show Password", IDX_PASSWORD_SHOW, MY_CHECKBOX, m, m + 92, xc, 10
OK_CANCEL
END
#endif
@@ -0,0 +1,24 @@
#define IDD_EXTRACT 3400
#define IDD_EXTRACT_2 13400
#define IDC_EXTRACT_PATH 100
#define IDB_EXTRACT_SET_PATH 101
#define IDC_EXTRACT_PATH_MODE 102
#define IDC_EXTRACT_OVERWRITE_MODE 103
#define IDE_EXTRACT_PASSWORD 120
#define IDE_EXTRACT_NAME 130
#define IDX_EXTRACT_NAME_ENABLE 131
#define IDT_EXTRACT_EXTRACT_TO 3401
#define IDT_EXTRACT_PATH_MODE 3410
#define IDT_EXTRACT_OVERWRITE_MODE 3420
#define IDX_EXTRACT_ELIM_DUP 3430
#define IDX_EXTRACT_NT_SECUR 3431
// #define IDX_EXTRACT_ALT_STREAMS 3432
#define IDX_PASSWORD_SHOW 3803
#define IDG_PASSWORD 3807
@@ -0,0 +1,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;
}
@@ -0,0 +1,39 @@
// GUI/ExtractGUI.h
#ifndef ZIP7_INC_EXTRACT_GUI_H
#define ZIP7_INC_EXTRACT_GUI_H
#include "../Common/Extract.h"
#include "../FileManager/ExtractCallback.h"
/*
RESULT can be S_OK, even if there are errors!!!
if RESULT == S_OK, check extractCallback->IsOK() after ExtractGUI().
RESULT = E_ABORT - user break.
RESULT != E_ABORT:
{
messageWasDisplayed = true - message was displayed already.
messageWasDisplayed = false - there was some internal error, so you must show error message.
}
*/
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 = NULL);
#endif
@@ -0,0 +1,51 @@
#define IDS_MEM_ERROR 3000
#define IDS_CANNOT_CREATE_FOLDER 3003
#define IDS_UPDATE_NOT_SUPPORTED 3004
#define IDS_CANT_OPEN_ARCHIVE 3005
#define IDS_CANT_OPEN_ENCRYPTED_ARCHIVE 3006
#define IDS_UNSUPPORTED_ARCHIVE_TYPE 3007
#define IDS_CANT_OPEN_AS_TYPE 3017
#define IDS_IS_OPEN_AS_TYPE 3018
#define IDS_IS_OPEN_WITH_OFFSET 3019
#define IDS_PROGRESS_EXTRACTING 3300
#define IDS_PROGRESS_SKIPPING 3325
#define IDS_EXTRACT_SET_FOLDER 3402
#define IDS_EXTRACT_PATHS_FULL 3411
#define IDS_EXTRACT_PATHS_NO 3412
#define IDS_EXTRACT_PATHS_ABS 3413
#define IDS_PATH_MODE_RELAT 3414
#define IDS_EXTRACT_OVERWRITE_ASK 3421
#define IDS_EXTRACT_OVERWRITE_WITHOUT_PROMPT 3422
#define IDS_EXTRACT_OVERWRITE_SKIP_EXISTING 3423
#define IDS_EXTRACT_OVERWRITE_RENAME 3424
#define IDS_EXTRACT_OVERWRITE_RENAME_EXISTING 3425
#define IDS_EXTRACT_MESSAGE_UNSUPPORTED_METHOD 3700
#define IDS_EXTRACT_MESSAGE_DATA_ERROR 3701
#define IDS_EXTRACT_MESSAGE_CRC_ERROR 3702
#define IDS_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED 3703
#define IDS_EXTRACT_MESSAGE_CRC_ERROR_ENCRYPTED 3704
#define IDS_EXTRACT_MSG_WRONG_PSW_GUESS 3710
// #define IDS_EXTRACT_MSG_ENCRYPTED 3711
#define IDS_EXTRACT_MSG_UNSUPPORTED_METHOD 3721
#define IDS_EXTRACT_MSG_DATA_ERROR 3722
#define IDS_EXTRACT_MSG_CRC_ERROR 3723
#define IDS_EXTRACT_MSG_UNAVAILABLE_DATA 3724
#define IDS_EXTRACT_MSG_UEXPECTED_END 3725
#define IDS_EXTRACT_MSG_DATA_AFTER_END 3726
#define IDS_EXTRACT_MSG_IS_NOT_ARC 3727
#define IDS_EXTRACT_MSG_HEADERS_ERROR 3728
#define IDS_EXTRACT_MSG_WRONG_PSW_CLAIM 3729
#define IDS_OPEN_MSG_UNAVAILABLE_START 3763
#define IDS_OPEN_MSG_UNCONFIRMED_START 3764
#define IDS_OPEN_MSG_UNSUPPORTED_FEATURE 3768
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

+494
View File
@@ -0,0 +1,494 @@
// GUI.cpp
#include "StdAfx.h"
#ifdef _WIN32
#include "../../../../C/DllSecur.h"
#endif
#include "../../../Common/MyWindows.h"
#if defined(__MINGW32__) || defined(__MINGW64__)
#include <shlwapi.h>
#else
#include <Shlwapi.h>
#endif
#include "../../../Common/MyInitGuid.h"
#include "../../../Common/CommandLineParser.h"
#include "../../../Common/MyException.h"
#include "../../../Common/StringConvert.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/NtCheck.h"
#include "../Common/ArchiveCommandLine.h"
#include "../Common/ExitCode.h"
#include "../FileManager/StringUtils.h"
#include "../FileManager/LangUtils.h"
#include "BenchmarkDialog.h"
#include "ExtractGUI.h"
#include "HashGUI.h"
#include "UpdateGUI.h"
#include "ExtractRes.h"
using namespace NWindows;
#ifdef Z7_EXTERNAL_CODECS
extern
const CExternalCodecs *g_ExternalCodecs_Ptr;
const CExternalCodecs *g_ExternalCodecs_Ptr;
#endif
extern
HINSTANCE g_hInstance;
HINSTANCE g_hInstance;
extern
bool g_DisableUserQuestions;
bool g_DisableUserQuestions;
#ifndef UNDER_CE
#if !defined(Z7_WIN32_WINNT_MIN) || Z7_WIN32_WINNT_MIN < 0x0500 // win2000
#define Z7_USE_DYN_ComCtl32Version
#endif
#ifdef Z7_USE_DYN_ComCtl32Version
Z7_DIAGNOSTIC_IGNORE_CAST_FUNCTION
extern
DWORD g_ComCtl32Version;
DWORD g_ComCtl32Version;
static DWORD GetDllVersion(LPCTSTR dllName)
{
DWORD dwVersion = 0;
const HMODULE hmodule = LoadLibrary(dllName);
if (hmodule)
{
const
DLLGETVERSIONPROC f_DllGetVersion = Z7_GET_PROC_ADDRESS(
DLLGETVERSIONPROC, hmodule,
"DllGetVersion");
if (f_DllGetVersion)
{
DLLVERSIONINFO dvi;
ZeroMemory(&dvi, sizeof(dvi));
dvi.cbSize = sizeof(dvi);
const HRESULT hr = (*f_DllGetVersion)(&dvi);
if (SUCCEEDED(hr))
dwVersion = (DWORD)MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
}
FreeLibrary(hmodule);
}
return dwVersion;
}
#endif
#endif
extern
bool g_LVN_ITEMACTIVATE_Support;
bool g_LVN_ITEMACTIVATE_Support = true;
DECLARE_AND_SET_CLIENT_VERSION_VAR
static void ErrorMessage(LPCWSTR message)
{
if (!g_DisableUserQuestions)
MessageBoxW(NULL, message, L"7-Zip", MB_ICONERROR | MB_OK);
}
static void ErrorMessage(const char *s)
{
ErrorMessage(GetUnicodeString(s));
}
static void ErrorLangMessage(UINT resourceID)
{
ErrorMessage(LangString(resourceID));
}
static const char * const kNoFormats = "7-Zip cannot find the code that works with archives.";
static int ShowMemErrorMessage()
{
ErrorLangMessage(IDS_MEM_ERROR);
return NExitCode::kMemoryError;
}
static int ShowSysErrorMessage(HRESULT errorCode)
{
if (errorCode == E_OUTOFMEMORY)
return ShowMemErrorMessage();
ErrorMessage(HResultToMessage(errorCode));
return NExitCode::kFatalError;
}
static void ThrowException_if_Error(HRESULT res)
{
if (res != S_OK)
throw CSystemException(res);
}
static int Main2()
{
UStringVector commandStrings;
NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
#ifndef UNDER_CE
if (commandStrings.Size() > 0)
commandStrings.Delete(0);
#endif
if (commandStrings.Size() == 0)
{
MessageBoxW(NULL, L"Specify command", L"7-Zip", 0);
return 0;
}
CArcCmdLineOptions options;
CArcCmdLineParser parser;
parser.Parse1(commandStrings, options);
g_DisableUserQuestions = options.YesToAll;
parser.Parse2(options);
CREATE_CODECS_OBJECT
codecs->CaseSensitive_Change = options.CaseSensitive_Change;
codecs->CaseSensitive = options.CaseSensitive;
ThrowException_if_Error(codecs->Load());
Codecs_AddHashArcHandler(codecs);
#ifdef Z7_EXTERNAL_CODECS
{
g_ExternalCodecs_Ptr = &_externalCodecs;
UString s;
codecs->GetCodecsErrorMessage(s);
if (!s.IsEmpty())
{
if (!g_DisableUserQuestions)
MessageBoxW(NULL, s, L"7-Zip", MB_ICONERROR);
}
}
#endif
const bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
if (codecs->Formats.Size() == 0 &&
(isExtractGroupCommand
|| options.Command.IsFromUpdateGroup()))
{
#ifdef Z7_EXTERNAL_CODECS
if (!codecs->MainDll_ErrorPath.IsEmpty())
{
UString s ("7-Zip cannot load module: ");
s += fs2us(codecs->MainDll_ErrorPath);
throw s;
}
#endif
throw kNoFormats;
}
CObjectVector<COpenType> formatIndices;
if (!ParseOpenTypes(*codecs, options.ArcType, formatIndices))
{
ErrorLangMessage(IDS_UNSUPPORTED_ARCHIVE_TYPE);
return NExitCode::kFatalError;
}
CIntVector excludedFormats;
FOR_VECTOR (k, options.ExcludedArcTypes)
{
CIntVector tempIndices;
if (!codecs->FindFormatForArchiveType(options.ExcludedArcTypes[k], tempIndices)
|| tempIndices.Size() != 1)
{
ErrorLangMessage(IDS_UNSUPPORTED_ARCHIVE_TYPE);
return NExitCode::kFatalError;
}
excludedFormats.AddToUniqueSorted(tempIndices[0]);
// excludedFormats.Sort();
}
#ifdef Z7_EXTERNAL_CODECS
if (isExtractGroupCommand
|| options.Command.IsFromUpdateGroup()
|| options.Command.CommandType == NCommandType::kHash
|| options.Command.CommandType == NCommandType::kBenchmark)
ThrowException_if_Error(_externalCodecs.Load());
#endif
if (options.Command.CommandType == NCommandType::kBenchmark)
{
HRESULT res = Benchmark(
EXTERNAL_CODECS_VARS_L
options.Properties,
options.NumIterations_Defined ?
options.NumIterations :
k_NumBenchIterations_Default);
/*
if (res == S_FALSE)
{
stdStream << "\nDecoding Error\n";
return NExitCode::kFatalError;
}
*/
ThrowException_if_Error(res);
}
else if (isExtractGroupCommand)
{
UStringVector ArchivePathsSorted;
UStringVector ArchivePathsFullSorted;
CExtractCallbackImp *ecs = new CExtractCallbackImp;
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
#ifndef Z7_NO_CRYPTO
ecs->PasswordIsDefined = options.PasswordEnabled;
ecs->Password = options.Password;
#endif
ecs->Init();
CExtractOptions eo;
(CExtractOptionsBase &)eo = options.ExtractOptions;
eo.StdInMode = options.StdInMode;
eo.StdOutMode = options.StdOutMode;
eo.YesToAll = options.YesToAll;
ecs->YesToAll = options.YesToAll;
eo.TestMode = options.Command.IsTestCommand();
ecs->TestMode = eo.TestMode;
#ifndef Z7_SFX
eo.Properties = options.Properties;
#endif
bool messageWasDisplayed = false;
#ifndef Z7_SFX
CHashBundle hb;
CHashBundle *hb_ptr = NULL;
if (!options.HashMethods.IsEmpty())
{
hb_ptr = &hb;
ThrowException_if_Error(hb.SetMethods(EXTERNAL_CODECS_VARS_L options.HashMethods));
}
#endif
{
CDirItemsStat st;
HRESULT hresultMain = EnumerateDirItemsAndSort(
options.arcCensor,
NWildcard::k_RelatPath,
UString(), // addPathPrefix
ArchivePathsSorted,
ArchivePathsFullSorted,
st,
NULL // &scan: change it!!!!
);
if (hresultMain != S_OK)
{
/*
if (hresultMain != E_ABORT && messageWasDisplayed)
return NExitCode::kFatalError;
*/
throw CSystemException(hresultMain);
}
}
ecs->MultiArcMode = (ArchivePathsSorted.Size() > 1);
HRESULT result = ExtractGUI(
// EXTERNAL_CODECS_VARS_L
codecs,
formatIndices, excludedFormats,
ArchivePathsSorted,
ArchivePathsFullSorted,
options.Censor.Pairs.Front().Head,
eo,
#ifndef Z7_SFX
hb_ptr,
#endif
options.ShowDialog, messageWasDisplayed, ecs);
if (result != S_OK)
{
if (result != E_ABORT && messageWasDisplayed)
return NExitCode::kFatalError;
throw CSystemException(result);
}
if (!ecs->IsOK())
return NExitCode::kFatalError;
}
else if (options.Command.IsFromUpdateGroup())
{
#ifndef Z7_NO_CRYPTO
bool passwordIsDefined = options.PasswordEnabled && !options.Password.IsEmpty();
#endif
CUpdateCallbackGUI callback;
// callback.EnablePercents = options.EnablePercents;
#ifndef Z7_NO_CRYPTO
callback.PasswordIsDefined = passwordIsDefined;
callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty();
callback.Password = options.Password;
#endif
// callback.StdOutMode = options.UpdateOptions.StdOutMode;
callback.Init();
if (!options.UpdateOptions.InitFormatIndex(codecs, formatIndices, options.ArchiveName) ||
!options.UpdateOptions.SetArcPath(codecs, options.ArchiveName))
{
ErrorLangMessage(IDS_UPDATE_NOT_SUPPORTED);
return NExitCode::kFatalError;
}
bool messageWasDisplayed = false;
HRESULT result = UpdateGUI(
codecs, formatIndices,
options.ArchiveName,
options.Censor,
options.UpdateOptions,
options.ShowDialog,
messageWasDisplayed,
&callback);
if (result != S_OK)
{
if (result != E_ABORT && messageWasDisplayed)
return NExitCode::kFatalError;
throw CSystemException(result);
}
if (callback.FailedFiles.Size() > 0)
{
if (!messageWasDisplayed)
throw CSystemException(E_FAIL);
return NExitCode::kWarning;
}
}
else if (options.Command.CommandType == NCommandType::kHash)
{
bool messageWasDisplayed = false;
HRESULT result = HashCalcGUI(EXTERNAL_CODECS_VARS_L
options.Censor, options.HashOptions, messageWasDisplayed);
if (result != S_OK)
{
if (result != E_ABORT && messageWasDisplayed)
return NExitCode::kFatalError;
throw CSystemException(result);
}
/*
if (callback.FailedFiles.Size() > 0)
{
if (!messageWasDisplayed)
throw CSystemException(E_FAIL);
return NExitCode::kWarning;
}
*/
}
else
{
throw "Unsupported command";
}
return 0;
}
#if defined(_UNICODE) && !defined(_WIN64) && !defined(UNDER_CE)
#define NT_CHECK_FAIL_ACTION ErrorMessage("Unsupported Windows version"); return NExitCode::kFatalError;
#endif
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
#ifdef UNDER_CE
LPWSTR
#else
LPSTR
#endif
/* lpCmdLine */, int /* nCmdShow */)
{
g_hInstance = hInstance;
#ifdef _WIN32
NT_CHECK
#endif
InitCommonControls();
#ifdef Z7_USE_DYN_ComCtl32Version
g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll"));
g_LVN_ITEMACTIVATE_Support = (g_ComCtl32Version >= MAKELONG(71, 4));
#endif
// OleInitialize is required for ProgressBar in TaskBar.
#ifndef UNDER_CE
OleInitialize(NULL);
#endif
#ifdef Z7_LANG
LoadLangOneTime();
#endif
// setlocale(LC_COLLATE, ".ACP");
try
{
#ifdef _WIN32
My_SetDefaultDllDirectories();
#endif
return Main2();
}
catch(const CNewException &)
{
return ShowMemErrorMessage();
}
catch(const CMessagePathException &e)
{
ErrorMessage(e);
return NExitCode::kUserError;
}
catch(const CSystemException &systemError)
{
if (systemError.ErrorCode == E_ABORT)
return NExitCode::kUserBreak;
return ShowSysErrorMessage(systemError.ErrorCode);
}
catch(const UString &s)
{
ErrorMessage(s);
return NExitCode::kFatalError;
}
catch(const AString &s)
{
ErrorMessage(s);
return NExitCode::kFatalError;
}
catch(const wchar_t *s)
{
ErrorMessage(s);
return NExitCode::kFatalError;
}
catch(const char *s)
{
ErrorMessage(s);
return NExitCode::kFatalError;
}
catch(int v)
{
AString e ("Error: ");
e.Add_UInt32((unsigned)v);
ErrorMessage(e);
return NExitCode::kFatalError;
}
catch(...)
{
ErrorMessage("Unknown error");
return NExitCode::kFatalError;
}
}
File diff suppressed because it is too large Load Diff
+29
View File
@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "GUI"=.\GUI.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
+341
View File
@@ -0,0 +1,341 @@
// HashGUI.cpp
#include "StdAfx.h"
#include "../../../Common/IntToString.h"
#include "../../../Common/StringConvert.h"
#include "../../../Windows/ErrorMsg.h"
#include "../FileManager/FormatUtils.h"
#include "../FileManager/LangUtils.h"
#include "../FileManager/ListViewDialog.h"
#include "../FileManager/OverwriteDialogRes.h"
#include "../FileManager/ProgressDialog2.h"
#include "../FileManager/ProgressDialog2Res.h"
#include "../FileManager/PropertyNameRes.h"
#include "../FileManager/resourceGui.h"
#include "HashGUI.h"
using namespace NWindows;
class CHashCallbackGUI Z7_final: public CProgressThreadVirt, public IHashCallbackUI
{
UInt64 NumFiles;
bool _curIsFolder;
UString FirstFileName;
// UString MainPath;
CPropNameValPairs PropNameValPairs;
HRESULT ProcessVirt() Z7_override;
virtual void ProcessWasFinished_GuiVirt() Z7_override;
public:
const NWildcard::CCensor *censor;
const CHashOptions *options;
DECL_EXTERNAL_CODECS_LOC_VARS_DECL
Z7_IFACE_IMP(IDirItemsCallback)
Z7_IFACE_IMP(IHashCallbackUI)
/*
void AddErrorMessage(DWORD systemError, const wchar_t *name)
{
Sync.AddError_Code_Name(systemError, name);
}
*/
void AddErrorMessage(HRESULT systemError, const wchar_t *name)
{
Sync.AddError_Code_Name(systemError, name);
}
};
void AddValuePair(CPropNameValPairs &pairs, UINT resourceID, UInt64 value)
{
CProperty &pair = pairs.AddNew();
AddLangString(pair.Name, resourceID);
char sz[32];
ConvertUInt64ToString(value, sz);
pair.Value = sz;
}
void AddSizeValuePair(CPropNameValPairs &pairs, UINT resourceID, UInt64 value)
{
CProperty &pair = pairs.AddNew();
LangString(resourceID, pair.Name);
AddSizeValue(pair.Value, value);
}
HRESULT CHashCallbackGUI::StartScanning()
{
CProgressSync &sync = Sync;
sync.Set_Status(LangString(IDS_SCANNING));
return CheckBreak();
}
HRESULT CHashCallbackGUI::ScanProgress(const CDirItemsStat &st, const FString &path, bool isDir)
{
return Sync.ScanProgress(st.NumFiles, st.GetTotalBytes(), path, isDir);
}
HRESULT CHashCallbackGUI::ScanError(const FString &path, DWORD systemError)
{
AddErrorMessage(HRESULT_FROM_WIN32(systemError), fs2us(path));
return CheckBreak();
}
HRESULT CHashCallbackGUI::FinishScanning(const CDirItemsStat &st)
{
return ScanProgress(st, FString(), false); // isDir
}
HRESULT CHashCallbackGUI::CheckBreak()
{
return Sync.CheckStop();
}
HRESULT CHashCallbackGUI::SetNumFiles(UInt64 numFiles)
{
CProgressSync &sync = Sync;
sync.Set_NumFilesTotal(numFiles);
return CheckBreak();
}
HRESULT CHashCallbackGUI::SetTotal(UInt64 size)
{
CProgressSync &sync = Sync;
sync.Set_NumBytesTotal(size);
return CheckBreak();
}
HRESULT CHashCallbackGUI::SetCompleted(const UInt64 *completed)
{
return Sync.Set_NumBytesCur(completed);
}
HRESULT CHashCallbackGUI::BeforeFirstFile(const CHashBundle & /* hb */)
{
return S_OK;
}
HRESULT CHashCallbackGUI::GetStream(const wchar_t *name, bool isFolder)
{
if (NumFiles == 0)
FirstFileName = name;
_curIsFolder = isFolder;
CProgressSync &sync = Sync;
sync.Set_FilePath(name, isFolder);
return CheckBreak();
}
HRESULT CHashCallbackGUI::OpenFileError(const FString &path, DWORD systemError)
{
// if (systemError == ERROR_SHARING_VIOLATION)
{
AddErrorMessage(HRESULT_FROM_WIN32(systemError), fs2us(path));
return S_FALSE;
}
// return systemError;
}
HRESULT CHashCallbackGUI::SetOperationResult(UInt64 /* fileSize */, const CHashBundle & /* hb */, bool /* showHash */)
{
CProgressSync &sync = Sync;
if (!_curIsFolder)
NumFiles++;
sync.Set_NumFilesCur(NumFiles);
return CheckBreak();
}
static const unsigned k_DigestStringSize = k_HashCalc_DigestSize_Max * 2 + k_HashCalc_ExtraSize * 2 + 16;
static void AddHashString(CProperty &s, const CHasherState &h, unsigned digestIndex)
{
char temp[k_DigestStringSize];
h.WriteToString(digestIndex, temp);
s.Value = temp;
}
static void AddHashResString(CPropNameValPairs &s, const CHasherState &h, unsigned digestIndex, UInt32 resID)
{
CProperty &pair = s.AddNew();
UString &s2 = pair.Name;
LangString(resID, s2);
UString name (h.Name);
s2.Replace(L"CRC", name);
s2.Replace(L":", L"");
AddHashString(pair, h, digestIndex);
}
void AddHashBundleRes(CPropNameValPairs &s, const CHashBundle &hb)
{
if (hb.NumErrors != 0)
AddValuePair(s, IDS_PROP_NUM_ERRORS, hb.NumErrors);
if (hb.NumFiles == 1 && hb.NumDirs == 0 && !hb.FirstFileName.IsEmpty())
{
CProperty &pair = s.AddNew();
LangString(IDS_PROP_NAME, pair.Name);
pair.Value = hb.FirstFileName;
}
else
{
if (!hb.MainName.IsEmpty())
{
CProperty &pair = s.AddNew();
LangString(IDS_PROP_NAME, pair.Name);
pair.Value = hb.MainName;
}
if (hb.NumDirs != 0)
AddValuePair(s, IDS_PROP_FOLDERS, hb.NumDirs);
AddValuePair(s, IDS_PROP_FILES, hb.NumFiles);
}
AddSizeValuePair(s, IDS_PROP_SIZE, hb.FilesSize);
if (hb.NumAltStreams != 0)
{
AddValuePair(s, IDS_PROP_NUM_ALT_STREAMS, hb.NumAltStreams);
AddSizeValuePair(s, IDS_PROP_ALT_STREAMS_SIZE, hb.AltStreamsSize);
}
FOR_VECTOR (i, hb.Hashers)
{
const CHasherState &h = hb.Hashers[i];
if (hb.NumFiles == 1 && hb.NumDirs == 0)
{
CProperty &pair = s.AddNew();
pair.Name += h.Name;
AddHashString(pair, h, k_HashCalc_Index_DataSum);
}
else
{
AddHashResString(s, h, k_HashCalc_Index_DataSum, IDS_CHECKSUM_CRC_DATA);
AddHashResString(s, h, k_HashCalc_Index_NamesSum, IDS_CHECKSUM_CRC_DATA_NAMES);
}
if (hb.NumAltStreams != 0)
{
AddHashResString(s, h, k_HashCalc_Index_StreamsSum, IDS_CHECKSUM_CRC_STREAMS_NAMES);
}
}
}
void AddHashBundleRes(UString &s, const CHashBundle &hb)
{
CPropNameValPairs pairs;
AddHashBundleRes(pairs, hb);
FOR_VECTOR (i, pairs)
{
const CProperty &pair = pairs[i];
s += pair.Name;
s += ": ";
s += pair.Value;
s.Add_LF();
}
if (hb.NumErrors == 0 && hb.Hashers.IsEmpty())
{
s.Add_LF();
AddLangString(s, IDS_MESSAGE_NO_ERRORS);
s.Add_LF();
}
}
HRESULT CHashCallbackGUI::AfterLastFile(CHashBundle &hb)
{
hb.FirstFileName = FirstFileName;
// MainPath
AddHashBundleRes(PropNameValPairs, hb);
CProgressSync &sync = Sync;
sync.Set_NumFilesCur(hb.NumFiles);
// CProgressMessageBoxPair &pair = GetMessagePair(hb.NumErrors != 0);
// pair.Message = s;
// LangString(IDS_CHECKSUM_INFORMATION, pair.Title);
return S_OK;
}
HRESULT CHashCallbackGUI::ProcessVirt()
{
NumFiles = 0;
AString errorInfo;
HRESULT res = HashCalc(EXTERNAL_CODECS_LOC_VARS
*censor, *options, errorInfo, this);
return res;
}
HRESULT HashCalcGUI(
DECL_EXTERNAL_CODECS_LOC_VARS
const NWildcard::CCensor &censor,
const CHashOptions &options,
bool &messageWasDisplayed)
{
CHashCallbackGUI t;
#ifdef Z7_EXTERNAL_CODECS
t._externalCodecs = _externalCodecs;
#endif
t.censor = &censor;
t.options = &options;
t.ShowCompressionInfo = false;
const UString title = LangString(IDS_CHECKSUM_CALCULATING);
t.MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
t.MainAddTitle = title;
t.MainAddTitle.Add_Space();
RINOK(t.Create(title))
messageWasDisplayed = t.ThreadFinishedOK && t.MessagesDisplayed;
return S_OK;
}
void ShowHashResults(const CPropNameValPairs &propPairs, HWND hwnd)
{
CListViewDialog lv;
FOR_VECTOR (i, propPairs)
{
const CProperty &pair = propPairs[i];
lv.Strings.Add(pair.Name);
lv.Values.Add(pair.Value);
}
lv.Title = LangString(IDS_CHECKSUM_INFORMATION);
lv.DeleteIsAllowed = true;
lv.SelectFirst = false;
lv.NumColumns = 2;
lv.Create(hwnd);
}
void ShowHashResults(const CHashBundle &hb, HWND hwnd)
{
CPropNameValPairs propPairs;
AddHashBundleRes(propPairs, hb);
ShowHashResults(propPairs, hwnd);
}
void CHashCallbackGUI::ProcessWasFinished_GuiVirt()
{
if (Result != E_ABORT)
ShowHashResults(PropNameValPairs, *this);
}
+27
View File
@@ -0,0 +1,27 @@
// HashGUI.h
#ifndef ZIP7_INC_HASH_GUI_H
#define ZIP7_INC_HASH_GUI_H
#include "../Common/HashCalc.h"
#include "../Common/Property.h"
HRESULT HashCalcGUI(
DECL_EXTERNAL_CODECS_LOC_VARS
const NWildcard::CCensor &censor,
const CHashOptions &options,
bool &messageWasDisplayed);
typedef CObjectVector<CProperty> CPropNameValPairs;
void AddValuePair(CPropNameValPairs &pairs, UINT resourceID, UInt64 value);
void AddSizeValue(UString &s, UInt64 value);
void AddSizeValuePair(CPropNameValPairs &pairs, UINT resourceID, UInt64 value);
void AddHashBundleRes(CPropNameValPairs &s, const CHashBundle &hb);
void AddHashBundleRes(UString &s, const CHashBundle &hb);
void ShowHashResults(const CPropNameValPairs &propPairs, HWND hwnd);
void ShowHashResults(const CHashBundle &hb, HWND hwnd);
#endif
@@ -0,0 +1,3 @@
// StdAfx.cpp
#include "StdAfx.h"
+6
View File
@@ -0,0 +1,6 @@
// StdAfx.h
#if _MSC_VER >= 1800
#pragma warning(disable : 4464) // relative include path contains '..'
#endif
#include "../FileManager/StdAfx.h"
@@ -0,0 +1,295 @@
// UpdateCallbackGUI.cpp
#include "StdAfx.h"
#include "../../../Common/IntToString.h"
#include "../../../Common/StringConvert.h"
#include "../../../Windows/PropVariant.h"
#include "../FileManager/FormatUtils.h"
#include "../FileManager/LangUtils.h"
#include "../FileManager/resourceGui.h"
#include "resource2.h"
#include "UpdateCallbackGUI.h"
using namespace NWindows;
// CUpdateCallbackGUI::~CUpdateCallbackGUI() {}
void CUpdateCallbackGUI::Init()
{
CUpdateCallbackGUI2::Init();
FailedFiles.Clear();
}
void OpenResult_GUI(UString &s, const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result);
HRESULT CUpdateCallbackGUI::OpenResult(
const CCodecs *codecs, const CArchiveLink &arcLink, const wchar_t *name, HRESULT result)
{
UString s;
OpenResult_GUI(s, codecs, arcLink, name, result);
if (!s.IsEmpty())
{
ProgressDialog->Sync.AddError_Message(s);
}
return S_OK;
}
HRESULT CUpdateCallbackGUI::StartScanning()
{
CProgressSync &sync = ProgressDialog->Sync;
sync.Set_Status(LangString(IDS_SCANNING));
return S_OK;
}
HRESULT CUpdateCallbackGUI::ScanError(const FString &path, DWORD systemError)
{
FailedFiles.Add(path);
ProgressDialog->Sync.AddError_Code_Name(HRESULT_FROM_WIN32(systemError), fs2us(path));
return S_OK;
}
HRESULT CUpdateCallbackGUI::FinishScanning(const CDirItemsStat &st)
{
CProgressSync &sync = ProgressDialog->Sync;
RINOK(ProgressDialog->Sync.ScanProgress(st.NumFiles + st.NumAltStreams,
st.GetTotalBytes(), FString(), true))
sync.Set_Status(L"");
return S_OK;
}
HRESULT CUpdateCallbackGUI::StartArchive(const wchar_t *name, bool /* updating */)
{
CProgressSync &sync = ProgressDialog->Sync;
sync.Set_Status(LangString(IDS_PROGRESS_COMPRESSING));
sync.Set_TitleFileName(name);
return S_OK;
}
HRESULT CUpdateCallbackGUI::FinishArchive(const CFinishArchiveStat & /* st */)
{
CProgressSync &sync = ProgressDialog->Sync;
sync.Set_Status(L"");
return S_OK;
}
HRESULT CUpdateCallbackGUI::CheckBreak()
{
return ProgressDialog->Sync.CheckStop();
}
HRESULT CUpdateCallbackGUI::ScanProgress(const CDirItemsStat &st, const FString &path, bool isDir)
{
return ProgressDialog->Sync.ScanProgress(st.NumFiles + st.NumAltStreams,
st.GetTotalBytes(), path, isDir);
}
/*
HRESULT CUpdateCallbackGUI::Finalize()
{
return S_OK;
}
*/
HRESULT CUpdateCallbackGUI::SetNumItems(const CArcToDoStat &stat)
{
ProgressDialog->Sync.Set_NumFilesTotal(stat.Get_NumDataItems_Total());
return S_OK;
}
HRESULT CUpdateCallbackGUI::SetTotal(UInt64 total)
{
ProgressDialog->Sync.Set_NumBytesTotal(total);
return S_OK;
}
HRESULT CUpdateCallbackGUI::SetCompleted(const UInt64 *completed)
{
return ProgressDialog->Sync.Set_NumBytesCur(completed);
}
HRESULT CUpdateCallbackGUI::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
{
ProgressDialog->Sync.Set_Ratio(inSize, outSize);
return CheckBreak();
}
HRESULT CUpdateCallbackGUI::GetStream(const wchar_t *name, bool isDir, bool /* isAnti */, UInt32 mode)
{
return SetOperation_Base(mode, name, isDir);
}
HRESULT CUpdateCallbackGUI::OpenFileError(const FString &path, DWORD systemError)
{
FailedFiles.Add(path);
// if (systemError == ERROR_SHARING_VIOLATION)
{
ProgressDialog->Sync.AddError_Code_Name(HRESULT_FROM_WIN32(systemError), fs2us(path));
return S_FALSE;
}
// return systemError;
}
HRESULT CUpdateCallbackGUI::SetOperationResult(Int32 /* operationResult */)
{
NumFiles++;
ProgressDialog->Sync.Set_NumFilesCur(NumFiles);
return S_OK;
}
void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileName, UString &s);
HRESULT CUpdateCallbackGUI::ReportExtractResult(Int32 opRes, Int32 isEncrypted, const wchar_t *name)
{
if (opRes != NArchive::NExtract::NOperationResult::kOK)
{
UString s;
SetExtractErrorMessage(opRes, isEncrypted, name, s);
ProgressDialog->Sync.AddError_Message(s);
}
return S_OK;
}
HRESULT CUpdateCallbackGUI::ReportUpdateOperation(UInt32 op, const wchar_t *name, bool isDir)
{
return SetOperation_Base(op, name, isDir);
}
HRESULT CUpdateCallbackGUI::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
{
*password = NULL;
if (passwordIsDefined)
*passwordIsDefined = BoolToInt(PasswordIsDefined);
if (!PasswordIsDefined)
{
if (AskPassword)
{
RINOK(ShowAskPasswordDialog())
}
}
if (passwordIsDefined)
*passwordIsDefined = BoolToInt(PasswordIsDefined);
return StringToBstr(Password, password);
}
HRESULT CUpdateCallbackGUI::CryptoGetTextPassword(BSTR *password)
{
return CryptoGetTextPassword2(NULL, password);
}
/*
It doesn't work, since main stream waits Dialog
HRESULT CUpdateCallbackGUI::CloseProgress()
{
ProgressDialog->MyClose();
return S_OK;
}
*/
HRESULT CUpdateCallbackGUI::Open_CheckBreak()
{
return ProgressDialog->Sync.CheckStop();
}
HRESULT CUpdateCallbackGUI::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
{
// if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesTotal(*numFiles);
return S_OK;
}
HRESULT CUpdateCallbackGUI::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
{
return ProgressDialog->Sync.CheckStop();
}
#ifndef Z7_NO_CRYPTO
HRESULT CUpdateCallbackGUI::Open_CryptoGetTextPassword(BSTR *password)
{
PasswordWasAsked = true;
return CryptoGetTextPassword2(NULL, password);
}
/*
HRESULT CUpdateCallbackGUI::Open_GetPasswordIfAny(bool &passwordIsDefined, UString &password)
{
passwordIsDefined = PasswordIsDefined;
password = Password;
return S_OK;
}
bool CUpdateCallbackGUI::Open_WasPasswordAsked()
{
return PasswordWasAsked;
}
void CUpdateCallbackGUI::Open_Clear_PasswordWasAsked_Flag()
{
PasswordWasAsked = false;
}
*/
HRESULT CUpdateCallbackGUI::ShowDeleteFile(const wchar_t *name, bool isDir)
{
return SetOperation_Base(NUpdateNotifyOp::kDelete, name, isDir);
}
HRESULT CUpdateCallbackGUI::FinishDeletingAfterArchiving()
{
// ClosePercents2();
return S_OK;
}
HRESULT CUpdateCallbackGUI::DeletingAfterArchiving(const FString &path, bool isDir)
{
return ProgressDialog->Sync.Set_Status2(_lang_Removing, fs2us(path), isDir);
}
HRESULT CUpdateCallbackGUI::MoveArc_Start(const wchar_t *srcTempPath, const wchar_t *destFinalPath, UInt64 totalSize, Int32 updateMode)
{
return MoveArc_Start_Base(srcTempPath, destFinalPath, totalSize, updateMode);
}
HRESULT CUpdateCallbackGUI::MoveArc_Progress(UInt64 totalSize, UInt64 currentSize)
{
return MoveArc_Progress_Base(totalSize, currentSize);
}
HRESULT CUpdateCallbackGUI::MoveArc_Finish()
{
return MoveArc_Finish_Base();
}
HRESULT CUpdateCallbackGUI::StartOpenArchive(const wchar_t * /* name */)
{
return S_OK;
}
HRESULT CUpdateCallbackGUI::ReadingFileError(const FString &path, DWORD systemError)
{
FailedFiles.Add(path);
ProgressDialog->Sync.AddError_Code_Name(HRESULT_FROM_WIN32(systemError), fs2us(path));
return S_OK;
}
HRESULT CUpdateCallbackGUI::WriteSfx(const wchar_t * /* name */, UInt64 /* size */)
{
CProgressSync &sync = ProgressDialog->Sync;
sync.Set_Status(L"WriteSfx");
return S_OK;
}
HRESULT CUpdateCallbackGUI::Open_Finished()
{
// ClosePercents();
return S_OK;
}
#endif
@@ -0,0 +1,31 @@
// UpdateCallbackGUI.h
#ifndef ZIP7_INC_UPDATE_CALLBACK_GUI_H
#define ZIP7_INC_UPDATE_CALLBACK_GUI_H
#include "../Common/Update.h"
#include "../Common/ArchiveOpenCallback.h"
#include "UpdateCallbackGUI2.h"
class CUpdateCallbackGUI Z7_final:
public IOpenCallbackUI,
public IUpdateCallbackUI2,
public CUpdateCallbackGUI2
{
Z7_IFACE_IMP(IOpenCallbackUI)
Z7_IFACE_IMP(IUpdateCallbackUI)
Z7_IFACE_IMP(IDirItemsCallback)
Z7_IFACE_IMP(IUpdateCallbackUI2)
public:
bool AskPassword;
FStringVector FailedFiles;
CUpdateCallbackGUI():
AskPassword(false)
{}
void Init();
};
#endif
@@ -0,0 +1,130 @@
// UpdateCallbackGUI2.cpp
#include "StdAfx.h"
#include "../FileManager/LangUtils.h"
#include "../FileManager/PasswordDialog.h"
#include "resource2.h"
#include "resource3.h"
#include "ExtractRes.h"
#include "../FileManager/resourceGui.h"
#include "UpdateCallbackGUI.h"
using namespace NWindows;
static const UINT k_UpdNotifyLangs[] =
{
IDS_PROGRESS_ADD,
IDS_PROGRESS_UPDATE,
IDS_PROGRESS_ANALYZE,
IDS_PROGRESS_REPLICATE,
IDS_PROGRESS_REPACK,
IDS_PROGRESS_SKIPPING,
IDS_PROGRESS_DELETE,
IDS_PROGRESS_HEADER
};
void CUpdateCallbackGUI2::Init()
{
NumFiles = 0;
LangString(IDS_PROGRESS_REMOVE, _lang_Removing);
LangString(IDS_MOVING, _lang_Moving);
_lang_Ops.Clear();
for (unsigned i = 0; i < Z7_ARRAY_SIZE(k_UpdNotifyLangs); i++)
_lang_Ops.Add(LangString(k_UpdNotifyLangs[i]));
}
HRESULT CUpdateCallbackGUI2::SetOperation_Base(UInt32 notifyOp, const wchar_t *name, bool isDir)
{
const UString *s = NULL;
if (notifyOp < _lang_Ops.Size())
s = &(_lang_Ops[(unsigned)notifyOp]);
else
s = &_emptyString;
return ProgressDialog->Sync.Set_Status2(*s, name, isDir);
}
HRESULT CUpdateCallbackGUI2::ShowAskPasswordDialog()
{
CPasswordDialog dialog;
ProgressDialog->WaitCreating();
if (dialog.Create(*ProgressDialog) != IDOK)
return E_ABORT;
Password = dialog.Password;
PasswordIsDefined = true;
return S_OK;
}
HRESULT CUpdateCallbackGUI2::MoveArc_UpdateStatus()
{
UString s;
s.Add_UInt64(_arcMoving_percents);
s.Add_Char('%');
const bool totalDefined = (_arcMoving_total != 0 && _arcMoving_total != (UInt64)(Int64)-1);
if (totalDefined || _arcMoving_current != 0)
{
s += " : ";
s.Add_UInt64(_arcMoving_current >> 20);
s += " MiB";
}
if (totalDefined)
{
s += " / ";
s.Add_UInt64((_arcMoving_total + ((1 << 20) - 1)) >> 20);
s += " MiB";
}
s += " : ";
s += _lang_Moving;
s += " : ";
// s.Add_Char('\"');
s += _arcMoving_name1;
// s.Add_Char('\"');
return ProgressDialog->Sync.Set_Status2(s, _arcMoving_name2,
false); // isDir
}
HRESULT CUpdateCallbackGUI2::MoveArc_Start_Base(const wchar_t *srcTempPath, const wchar_t *destFinalPath, UInt64 totalSize, Int32 updateMode)
{
_arcMoving_percents = 0;
_arcMoving_total = totalSize;
_arcMoving_current = 0;
_arcMoving_updateMode = updateMode;
_arcMoving_name1 = srcTempPath;
_arcMoving_name2 = destFinalPath;
return MoveArc_UpdateStatus();
}
HRESULT CUpdateCallbackGUI2::MoveArc_Progress_Base(UInt64 totalSize, UInt64 currentSize)
{
_arcMoving_total = totalSize;
_arcMoving_current = currentSize;
UInt64 percents = 0;
if (totalSize != 0)
{
if (totalSize < ((UInt64)1 << 57))
percents = currentSize * 100 / totalSize;
else
percents = currentSize / (totalSize / 100);
}
if (percents == _arcMoving_percents)
return ProgressDialog->Sync.CheckStop();
// Sleep(300); // for debug
_arcMoving_percents = percents;
return MoveArc_UpdateStatus();
}
HRESULT CUpdateCallbackGUI2::MoveArc_Finish_Base()
{
return ProgressDialog->Sync.Set_Status2(L"", L"", false);
}
@@ -0,0 +1,53 @@
// UpdateCallbackGUI2.h
#ifndef ZIP7_INC_UPDATE_CALLBACK_GUI2_H
#define ZIP7_INC_UPDATE_CALLBACK_GUI2_H
#include "../FileManager/ProgressDialog2.h"
class CUpdateCallbackGUI2
{
public:
CProgressDialog *ProgressDialog;
protected:
UString _arcMoving_name1;
UString _arcMoving_name2;
UInt64 _arcMoving_percents;
UInt64 _arcMoving_total;
UInt64 _arcMoving_current;
Int32 _arcMoving_updateMode;
public:
bool PasswordIsDefined;
bool PasswordWasAsked;
UInt64 NumFiles;
UString Password;
protected:
UStringVector _lang_Ops;
UString _lang_Removing;
UString _lang_Moving;
UString _emptyString;
HRESULT MoveArc_UpdateStatus();
HRESULT MoveArc_Start_Base(const wchar_t *srcTempPath, const wchar_t *destFinalPath, UInt64 /* totalSize */, Int32 updateMode);
HRESULT MoveArc_Progress_Base(UInt64 totalSize, UInt64 currentSize);
HRESULT MoveArc_Finish_Base();
public:
CUpdateCallbackGUI2():
_arcMoving_percents(0),
_arcMoving_total(0),
_arcMoving_current(0),
_arcMoving_updateMode(0),
PasswordIsDefined(false),
PasswordWasAsked(false),
NumFiles(0)
{}
void Init();
HRESULT SetOperation_Base(UInt32 notifyOp, const wchar_t *name, bool isDir);
HRESULT ShowAskPasswordDialog();
};
#endif
@@ -0,0 +1,605 @@
// UpdateGUI.cpp
#include "StdAfx.h"
#include "../../../Common/IntToString.h"
#include "../../../Common/StringConvert.h"
#include "../../../Common/StringToInt.h"
#include "../../../Windows/DLL.h"
#include "../../../Windows/FileDir.h"
#include "../../../Windows/FileName.h"
#include "../../../Windows/Thread.h"
#include "../Common/WorkDir.h"
#include "../Explorer/MyMessages.h"
#include "../FileManager/LangUtils.h"
#include "../FileManager/StringUtils.h"
#include "../FileManager/resourceGui.h"
#include "CompressDialog.h"
#include "UpdateGUI.h"
#include "resource2.h"
using namespace NWindows;
using namespace NFile;
using namespace NDir;
static const char * const kDefaultSfxModule = "7z.sfx";
static const char * const kSFXExtension = "exe";
extern void AddMessageToString(UString &dest, const UString &src);
UString HResultToMessage(HRESULT errorCode);
class CThreadUpdating: public CProgressThreadVirt
{
HRESULT ProcessVirt() Z7_override;
public:
CCodecs *codecs;
const CObjectVector<COpenType> *formatIndices;
const UString *cmdArcPath;
CUpdateCallbackGUI *UpdateCallbackGUI;
NWildcard::CCensor *WildcardCensor;
CUpdateOptions *Options;
bool needSetPath;
};
HRESULT CThreadUpdating::ProcessVirt()
{
CUpdateErrorInfo ei;
HRESULT res = UpdateArchive(codecs, *formatIndices, *cmdArcPath,
*WildcardCensor, *Options,
ei, UpdateCallbackGUI, UpdateCallbackGUI, needSetPath);
FinalMessage.ErrorMessage.Message = ei.Message.Ptr();
ErrorPaths = ei.FileNames;
if (res != S_OK)
return res;
return HRESULT_FROM_WIN32(ei.SystemError);
}
// parse command line properties
static bool ParseProp_Time_BoolPair(const CProperty &prop, const char *name, CBoolPair &bp)
{
if (!prop.Name.IsPrefixedBy_Ascii_NoCase(name))
return false;
const UString rem = prop.Name.Ptr((unsigned)strlen(name));
UString val = prop.Value;
if (!rem.IsEmpty())
{
if (!val.IsEmpty())
return true;
val = rem;
}
bool res;
if (StringToBool(val, res))
{
bp.Val = res;
bp.Def = true;
}
return true;
}
static void ParseProp(
const CProperty &prop,
NCompressDialog::CInfo &di)
{
if (ParseProp_Time_BoolPair(prop, "tm", di.MTime)) return;
if (ParseProp_Time_BoolPair(prop, "tc", di.CTime)) return;
if (ParseProp_Time_BoolPair(prop, "ta", di.ATime)) return;
}
static void ParseProperties(
const CObjectVector<CProperty> &properties,
NCompressDialog::CInfo &di)
{
FOR_VECTOR (i, properties)
{
ParseProp(properties[i], di);
}
}
static void AddProp_UString(CObjectVector<CProperty> &properties, const char *name, const UString &value)
{
CProperty prop;
prop.Name = name;
prop.Value = value;
properties.Add(prop);
}
static void AddProp_UInt32(CObjectVector<CProperty> &properties, const char *name, UInt32 value)
{
UString s;
s.Add_UInt32(value);
AddProp_UString(properties, name, s);
}
static void AddProp_bool(CObjectVector<CProperty> &properties, const char *name, bool value)
{
AddProp_UString(properties, name, UString(value ? "on": "off"));
}
static void AddProp_BoolPair(CObjectVector<CProperty> &properties,
const char *name, const CBoolPair &bp)
{
if (bp.Def)
AddProp_bool(properties, name, bp.Val);
}
static void SplitOptionsToStrings(const UString &src, UStringVector &strings)
{
SplitString(src, strings);
FOR_VECTOR (i, strings)
{
UString &s = strings[i];
if (s.Len() > 2
&& s[0] == '-'
&& MyCharLower_Ascii(s[1]) == 'm')
s.DeleteFrontal(2);
}
}
static bool IsThereMethodOverride(bool is7z, const UStringVector &strings)
{
FOR_VECTOR (i, strings)
{
const UString &s = strings[i];
if (is7z)
{
const wchar_t *end;
UInt64 n = ConvertStringToUInt64(s, &end);
if (n == 0 && *end == L'=')
return true;
}
else
{
if (s.Len() > 0)
if (s[0] == L'm' && s[1] == L'=')
return true;
}
}
return false;
}
static void ParseAndAddPropertires(CObjectVector<CProperty> &properties,
const UStringVector &strings)
{
FOR_VECTOR (i, strings)
{
const UString &s = strings[i];
CProperty property;
const int index = s.Find(L'=');
if (index < 0)
property.Name = s;
else
{
property.Name.SetFrom(s, (unsigned)index);
property.Value = s.Ptr(index + 1);
}
properties.Add(property);
}
}
static void AddProp_Size(CObjectVector<CProperty> &properties, const char *name, const UInt64 size)
{
UString s;
s.Add_UInt64(size);
s.Add_Char('b');
AddProp_UString(properties, name, s);
}
static void SetOutProperties(
CObjectVector<CProperty> &properties,
const NCompressDialog::CInfo &di,
bool is7z,
bool setMethod)
{
if (di.Level != (UInt32)(Int32)-1)
AddProp_UInt32(properties, "x", (UInt32)di.Level);
if (setMethod)
{
if (!di.Method.IsEmpty())
AddProp_UString(properties, is7z ? "0": "m", di.Method);
if (di.Dict64 != (UInt64)(Int64)-1)
{
AString name;
if (is7z)
name = "0";
name += (di.OrderMode ? "mem" : "d");
AddProp_Size(properties, name, di.Dict64);
}
/*
if (di.Dict64_Chain != (UInt64)(Int64)-1)
{
AString name;
if (is7z)
name = "0";
name += "dc";
AddProp_Size(properties, name, di.Dict64_Chain);
}
*/
if (di.Order != (UInt32)(Int32)-1)
{
AString name;
if (is7z)
name = "0";
name += (di.OrderMode ? "o" : "fb");
AddProp_UInt32(properties, name, (UInt32)di.Order);
}
}
if (!di.EncryptionMethod.IsEmpty())
AddProp_UString(properties, "em", di.EncryptionMethod);
if (di.EncryptHeadersIsAllowed)
AddProp_bool(properties, "he", di.EncryptHeaders);
if (di.SolidIsSpecified)
AddProp_Size(properties, "s", di.SolidBlockSize);
if (
// di.MultiThreadIsAllowed &&
di.NumThreads != (UInt32)(Int32)-1)
AddProp_UInt32(properties, "mt", di.NumThreads);
const NCompression::CMemUse &memUse = di.MemUsage;
if (memUse.IsDefined)
{
const char *kMemUse = "memuse";
if (memUse.IsPercent)
{
UString s;
// s += 'p'; // for debug: alternate percent method
s.Add_UInt64(memUse.Val);
s.Add_Char('%');
AddProp_UString(properties, kMemUse, s);
}
else
AddProp_Size(properties, kMemUse, memUse.Val);
}
AddProp_BoolPair(properties, "tm", di.MTime);
AddProp_BoolPair(properties, "tc", di.CTime);
AddProp_BoolPair(properties, "ta", di.ATime);
if (di.TimePrec != (UInt32)(Int32)-1)
AddProp_UInt32(properties, "tp", di.TimePrec);
}
struct C_UpdateMode_ToAction_Pair
{
NCompressDialog::NUpdateMode::EEnum UpdateMode;
const NUpdateArchive::CActionSet *ActionSet;
};
static const C_UpdateMode_ToAction_Pair g_UpdateMode_Pairs[] =
{
{ NCompressDialog::NUpdateMode::kAdd, &NUpdateArchive::k_ActionSet_Add },
{ NCompressDialog::NUpdateMode::kUpdate, &NUpdateArchive::k_ActionSet_Update },
{ NCompressDialog::NUpdateMode::kFresh, &NUpdateArchive::k_ActionSet_Fresh },
{ NCompressDialog::NUpdateMode::kSync, &NUpdateArchive::k_ActionSet_Sync }
};
static int FindActionSet(const NUpdateArchive::CActionSet &actionSet)
{
for (unsigned i = 0; i < Z7_ARRAY_SIZE(g_UpdateMode_Pairs); i++)
if (actionSet.IsEqualTo(*g_UpdateMode_Pairs[i].ActionSet))
return (int)i;
return -1;
}
static int FindUpdateMode(NCompressDialog::NUpdateMode::EEnum mode)
{
for (unsigned i = 0; i < Z7_ARRAY_SIZE(g_UpdateMode_Pairs); i++)
if (mode == g_UpdateMode_Pairs[i].UpdateMode)
return (int)i;
return -1;
}
static HRESULT ShowDialog(
CCodecs *codecs,
const CObjectVector<NWildcard::CCensorPath> &censor,
CUpdateOptions &options,
CUpdateCallbackGUI *callback, HWND hwndParent)
{
if (options.Commands.Size() != 1)
throw "It must be one command";
/*
FString currentDirPrefix;
#ifndef UNDER_CE
{
if (!MyGetCurrentDirectory(currentDirPrefix))
return E_FAIL;
NName::NormalizeDirPathPrefix(currentDirPrefix);
}
#endif
*/
bool oneFile = false;
NFind::CFileInfo fileInfo;
UString name;
/*
if (censor.Pairs.Size() > 0)
{
const NWildcard::CPair &pair = censor.Pairs[0];
if (pair.Head.IncludeItems.Size() > 0)
{
const NWildcard::CItem &item = pair.Head.IncludeItems[0];
if (item.ForFile)
{
name = pair.Prefix;
FOR_VECTOR (i, item.PathParts)
{
if (i > 0)
name.Add_PathSepar();
name += item.PathParts[i];
}
if (fileInfo.Find(us2fs(name)))
{
if (censor.Pairs.Size() == 1 && pair.Head.IncludeItems.Size() == 1)
oneFile = !fileInfo.IsDir();
}
}
}
}
*/
if (censor.Size() > 0)
{
const NWildcard::CCensorPath &cp = censor[0];
if (cp.Include)
{
{
if (fileInfo.Find(us2fs(cp.Path)))
{
if (censor.Size() == 1)
oneFile = !fileInfo.IsDir();
}
}
}
}
/*
// v23: we restore current dir in dialog code
#if defined(_WIN32) && !defined(UNDER_CE)
CCurrentDirRestorer curDirRestorer;
#endif
*/
CCompressDialog dialog;
NCompressDialog::CInfo &di = dialog.Info;
dialog.ArcFormats = &codecs->Formats;
{
CObjectVector<CCodecInfoUser> userCodecs;
codecs->Get_CodecsInfoUser_Vector(userCodecs);
dialog.SetMethods(userCodecs);
}
if (options.MethodMode.Type_Defined)
di.FormatIndex = options.MethodMode.Type.FormatIndex;
FOR_VECTOR (i, codecs->Formats)
{
const CArcInfoEx &ai = codecs->Formats[i];
if (!ai.UpdateEnabled)
continue;
if (!oneFile && ai.Flags_KeepName())
continue;
if ((int)i != di.FormatIndex)
{
if (ai.Flags_HashHandler())
continue;
if (ai.Name.IsEqualTo_Ascii_NoCase("swfc"))
if (!oneFile || name.Len() < 4 || !StringsAreEqualNoCase_Ascii(name.RightPtr(4), ".swf"))
continue;
}
dialog.ArcIndices.Add(i);
}
if (dialog.ArcIndices.IsEmpty())
{
ShowErrorMessage(L"No Update Engines");
return E_FAIL;
}
// di.ArchiveName = options.ArchivePath.GetFinalPath();
di.ArcPath = options.ArchivePath.GetPathWithoutExt();
dialog.OriginalFileName = fs2us(fileInfo.Name);
di.PathMode = options.PathMode;
// di.CurrentDirPrefix = currentDirPrefix;
di.SFXMode = options.SfxMode;
di.OpenShareForWrite = options.OpenShareForWrite;
di.DeleteAfterCompressing = options.DeleteAfterCompressing;
di.SymLinks = options.SymLinks;
di.HardLinks = options.HardLinks;
di.AltStreams = options.AltStreams;
di.NtSecurity = options.NtSecurity;
if (options.SetArcMTime)
di.SetArcMTime.SetTrueTrue();
if (options.PreserveATime)
di.PreserveATime.SetTrueTrue();
if (callback->PasswordIsDefined)
di.Password = callback->Password;
di.KeepName = !oneFile;
NUpdateArchive::CActionSet &actionSet = options.Commands.Front().ActionSet;
{
int index = FindActionSet(actionSet);
if (index < 0)
return E_NOTIMPL;
di.UpdateMode = g_UpdateMode_Pairs[(unsigned)index].UpdateMode;
}
ParseProperties(options.MethodMode.Properties, di);
if (dialog.Create(hwndParent) != IDOK)
return E_ABORT;
options.DeleteAfterCompressing = di.DeleteAfterCompressing;
options.SymLinks = di.SymLinks;
options.HardLinks = di.HardLinks;
options.AltStreams = di.AltStreams;
options.NtSecurity = di.NtSecurity;
options.SetArcMTime = di.SetArcMTime.Val;
if (di.PreserveATime.Def)
options.PreserveATime = di.PreserveATime.Val;
/*
#if defined(_WIN32) && !defined(UNDER_CE)
curDirRestorer.NeedRestore = dialog.CurrentDirWasChanged;
#endif
*/
options.VolumesSizes = di.VolumeSizes;
/*
if (di.VolumeSizeIsDefined)
{
MyMessageBox(L"Splitting to volumes is not supported");
return E_FAIL;
}
*/
{
int index = FindUpdateMode(di.UpdateMode);
if (index < 0)
return E_FAIL;
actionSet = *g_UpdateMode_Pairs[index].ActionSet;
}
options.PathMode = di.PathMode;
const CArcInfoEx &archiverInfo = codecs->Formats[di.FormatIndex];
callback->PasswordIsDefined = (!di.Password.IsEmpty());
if (callback->PasswordIsDefined)
callback->Password = di.Password;
// we clear command line options, and fill options form Dialog
options.MethodMode.Properties.Clear();
const bool is7z = archiverInfo.Is_7z();
UStringVector optionStrings;
SplitOptionsToStrings(di.Options, optionStrings);
const bool methodOverride = IsThereMethodOverride(is7z, optionStrings);
SetOutProperties(options.MethodMode.Properties, di,
is7z,
!methodOverride); // setMethod
options.OpenShareForWrite = di.OpenShareForWrite;
ParseAndAddPropertires(options.MethodMode.Properties, optionStrings);
if (di.SFXMode)
options.SfxMode = true;
options.MethodMode.Type = COpenType();
options.MethodMode.Type_Defined = true;
options.MethodMode.Type.FormatIndex = di.FormatIndex;
options.ArchivePath.VolExtension = archiverInfo.GetMainExt();
if (di.SFXMode)
options.ArchivePath.BaseExtension = kSFXExtension;
else
options.ArchivePath.BaseExtension = options.ArchivePath.VolExtension;
options.ArchivePath.ParseFromPath(di.ArcPath, k_ArcNameMode_Smart);
NWorkDir::CInfo workDirInfo;
workDirInfo.Load();
options.WorkingDir.Empty();
if (workDirInfo.Mode != NWorkDir::NMode::kCurrent)
{
FString fullPath;
MyGetFullPathName(us2fs(di.ArcPath), fullPath);
FString namePart;
options.WorkingDir = GetWorkDir(workDirInfo, fullPath, namePart);
CreateComplexDir(options.WorkingDir);
}
return S_OK;
}
HRESULT UpdateGUI(
CCodecs *codecs,
const CObjectVector<COpenType> &formatIndices,
const UString &cmdArcPath,
NWildcard::CCensor &censor,
CUpdateOptions &options,
bool showDialog,
bool &messageWasDisplayed,
CUpdateCallbackGUI *callback,
HWND hwndParent)
{
messageWasDisplayed = false;
bool needSetPath = true;
if (showDialog)
{
RINOK(ShowDialog(codecs, censor.CensorPaths, options, callback, hwndParent))
needSetPath = false;
}
if (options.SfxMode && options.SfxModule.IsEmpty())
{
options.SfxModule = NWindows::NDLL::GetModuleDirPrefix();
options.SfxModule += kDefaultSfxModule;
}
CThreadUpdating tu;
tu.needSetPath = needSetPath;
tu.codecs = codecs;
tu.formatIndices = &formatIndices;
tu.cmdArcPath = &cmdArcPath;
tu.UpdateCallbackGUI = callback;
tu.UpdateCallbackGUI->ProgressDialog = &tu;
tu.UpdateCallbackGUI->Init();
UString title = LangString(IDS_PROGRESS_COMPRESSING);
if (!formatIndices.IsEmpty())
{
const int fin = formatIndices[0].FormatIndex;
if (fin >= 0)
if (codecs->Formats[fin].Flags_HashHandler())
title = LangString(IDS_CHECKSUM_CALCULATING);
}
/*
if (hwndParent != 0)
{
tu.ProgressDialog.MainWindow = hwndParent;
// tu.ProgressDialog.MainTitle = fileName;
tu.ProgressDialog.MainAddTitle = title + L' ';
}
*/
tu.WildcardCensor = &censor;
tu.Options = &options;
tu.IconID = IDI_ICON;
RINOK(tu.Create(title, hwndParent))
messageWasDisplayed = tu.ThreadFinishedOK && tu.MessagesDisplayed;
return tu.Result;
}
@@ -0,0 +1,33 @@
// GUI/UpdateGUI.h
#ifndef ZIP7_INC_UPDATE_GUI_H
#define ZIP7_INC_UPDATE_GUI_H
#include "../Common/Update.h"
#include "UpdateCallbackGUI.h"
/*
callback->FailedFiles contains names of files for that there were problems.
RESULT can be S_OK, even if there are such warnings!!!
RESULT = E_ABORT - user break.
RESULT != E_ABORT:
{
messageWasDisplayed = true - message was displayed already.
messageWasDisplayed = false - there was some internal error, so you must show error message.
}
*/
HRESULT UpdateGUI(
CCodecs *codecs,
const CObjectVector<COpenType> &formatIndices,
const UString &cmdArcPath2,
NWildcard::CCensor &censor,
CUpdateOptions &options,
bool showDialog,
bool &messageWasDisplayed,
CUpdateCallbackGUI *callback,
HWND hwndParent = NULL);
#endif
+149
View File
@@ -0,0 +1,149 @@
PROG = 7zG.exe
CFLAGS = $(CFLAGS) \
-DZ7_LANG \
-DZ7_EXTERNAL_CODECS \
!IFDEF UNDER_CE
LIBS = $(LIBS) ceshell.lib Commctrl.lib
!ELSE
LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib gdi32.lib
CFLAGS = $(CFLAGS) -DZ7_DEVICE_FILE
# -DZ7_LONG_PATH -DZ7_LARGE_PAGES
!ENDIF
GUI_OBJS = \
$O\BenchmarkDialog.obj \
$O\CompressDialog.obj \
$O\ExtractDialog.obj \
$O\ExtractGUI.obj \
$O\GUI.obj \
$O\HashGUI.obj \
$O\UpdateCallbackGUI.obj \
$O\UpdateCallbackGUI2.obj \
$O\UpdateGUI.obj \
COMMON_OBJS = \
$O\CommandLineParser.obj \
$O\CRC.obj \
$O\DynLimBuf.obj \
$O\IntToString.obj \
$O\Lang.obj \
$O\ListFileUtils.obj \
$O\MyString.obj \
$O\MyVector.obj \
$O\NewHandler.obj \
$O\StringConvert.obj \
$O\StringToInt.obj \
$O\UTFConvert.obj \
$O\Wildcard.obj \
WIN_OBJS = \
$O\Clipboard.obj \
$O\CommonDialog.obj \
$O\DLL.obj \
$O\ErrorMsg.obj \
$O\FileDir.obj \
$O\FileFind.obj \
$O\FileIO.obj \
$O\FileLink.obj \
$O\FileName.obj \
$O\FileSystem.obj \
$O\MemoryGlobal.obj \
$O\MemoryLock.obj \
$O\PropVariant.obj \
$O\PropVariantConv.obj \
$O\Registry.obj \
$O\ResourceString.obj \
$O\Shell.obj \
$O\Synchronization.obj \
$O\System.obj \
$O\SystemInfo.obj \
$O\TimeUtils.obj \
$O\Window.obj \
WIN_CTRL_OBJS = \
$O\ComboBox.obj \
$O\Dialog.obj \
$O\ListView.obj \
7ZIP_COMMON_OBJS = \
$O\CreateCoder.obj \
$O\FilePathAutoRename.obj \
$O\FileStreams.obj \
$O\FilterCoder.obj \
$O\LimitedStreams.obj \
$O\MethodProps.obj \
$O\MultiOutStream.obj \
$O\ProgressUtils.obj \
$O\PropId.obj \
$O\StreamObjects.obj \
$O\StreamUtils.obj \
$O\UniqBlocks.obj \
UI_COMMON_OBJS = \
$O\ArchiveCommandLine.obj \
$O\ArchiveExtractCallback.obj \
$O\ArchiveOpenCallback.obj \
$O\Bench.obj \
$O\DefaultName.obj \
$O\EnumDirItems.obj \
$O\Extract.obj \
$O\ExtractingFilePath.obj \
$O\HashCalc.obj \
$O\LoadCodecs.obj \
$O\OpenArchive.obj \
$O\PropIDUtils.obj \
$O\SetProperties.obj \
$O\SortUtils.obj \
$O\TempFiles.obj \
$O\Update.obj \
$O\UpdateAction.obj \
$O\UpdateCallback.obj \
$O\UpdatePair.obj \
$O\UpdateProduce.obj \
$O\WorkDir.obj \
$O\ZipRegistry.obj \
AR_COMMON_OBJS = \
$O\ItemNameUtils.obj \
$O\OutStreamWithCRC.obj \
FM_OBJS = \
$O\EditDialog.obj \
$O\ExtractCallback.obj \
$O\FormatUtils.obj \
$O\HelpUtils.obj \
$O\LangUtils.obj \
$O\ListViewDialog.obj \
$O\MemDialog.obj \
$O\OpenCallback.obj \
$O\ProgramLocation.obj \
$O\PropertyName.obj \
$O\RegistryUtils.obj \
$O\SplitUtils.obj \
$O\StringUtils.obj \
$O\OverwriteDialog.obj \
$O\PasswordDialog.obj \
$O\ProgressDialog2.obj \
FM_OBJS = $(FM_OBJS) \
$O\BrowseDialog.obj \
$O\ComboDialog.obj \
$O\SysIconUtils.obj \
EXPLORER_OBJS = \
$O\MyMessages.obj \
COMPRESS_OBJS = \
$O\CopyCoder.obj \
C_OBJS = \
$O\Alloc.obj \
$O\CpuArch.obj \
$O\DllSecur.obj \
$O\Threads.obj \
!include "../../Crc.mak"
!include "../../Sort.mak"
!include "../../7zip.mak"
@@ -0,0 +1,26 @@
#include "../../MyVersionInfo.rc"
// #include <winnt.h>
#include "resource2.rc"
#include "resource3.rc"
#include "../FileManager/resourceGui.rc"
MY_VERSION_INFO(MY_VFT_APP, "7-Zip GUI", "7zg", "7zg.exe")
IDI_ICON ICON "FM.ico"
#ifndef UNDER_CE
1 24 MOVEABLE PURE "7zG.exe.manifest"
#endif
#include "../FileManager/PropertyName.rc"
#include "../FileManager/MemDialog.rc"
#include "../FileManager/OverwriteDialog.rc"
#include "../FileManager/PasswordDialog.rc"
#include "../FileManager/ProgressDialog2.rc"
#include "Extract.rc"
#include "../FileManager/BrowseDialog.rc"
#include "../FileManager/ComboDialog.rc"
#include "../FileManager/EditDialog.rc"
#include "../FileManager/ListViewDialog.rc"
@@ -0,0 +1,2 @@
#define IDS_PROGRESS_COMPRESSING 3301
#define IDS_ARCHIVES_COLON 3907
@@ -0,0 +1,10 @@
#include "ExtractDialog.rc"
#include "CompressDialog.rc"
#include "BenchmarkDialog.rc"
#include "resource2.h"
STRINGTABLE
BEGIN
IDS_PROGRESS_COMPRESSING "Compressing"
IDS_ARCHIVES_COLON "Archives:"
END
@@ -0,0 +1,10 @@
#define IDS_PROGRESS_REMOVE 3305
#define IDS_PROGRESS_ADD 3320
#define IDS_PROGRESS_UPDATE 3321
#define IDS_PROGRESS_ANALYZE 3322
#define IDS_PROGRESS_REPLICATE 3323
#define IDS_PROGRESS_REPACK 3324
#define IDS_PROGRESS_DELETE 3326
#define IDS_PROGRESS_HEADER 3327
@@ -0,0 +1,15 @@
#include "resource3.h"
STRINGTABLE
BEGIN
IDS_PROGRESS_REMOVE "Removing"
IDS_PROGRESS_ADD "Adding"
IDS_PROGRESS_UPDATE "Updating"
IDS_PROGRESS_ANALYZE "Analyzing"
IDS_PROGRESS_REPLICATE "Replicating"
IDS_PROGRESS_REPACK "Repacking"
IDS_PROGRESS_DELETE "Deleting"
IDS_PROGRESS_HEADER "Header creating"
END