mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 20:07:05 -06:00
4.34 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
02516d3fce
commit
0f60a4933b
@@ -27,7 +27,7 @@ using namespace NCommandLineParser;
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
|
||||
static const int kNumSwitches = 25;
|
||||
static const int kNumSwitches = 26;
|
||||
|
||||
namespace NKey {
|
||||
enum Enum
|
||||
@@ -56,7 +56,8 @@ enum Enum
|
||||
kOverwrite,
|
||||
kEmail,
|
||||
kShowDialog,
|
||||
kLargePages
|
||||
kLargePages,
|
||||
kCharSet
|
||||
};
|
||||
|
||||
}
|
||||
@@ -119,7 +120,8 @@ static const CSwitchForm kSwitchForms[kNumSwitches] =
|
||||
{ L"AO", NSwitchType::kPostChar, false, 1, 1, kOverwritePostCharSet},
|
||||
{ L"SEML", NSwitchType::kUnLimitedPostString, false, 0},
|
||||
{ L"AD", NSwitchType::kSimple, false },
|
||||
{ L"SLP", NSwitchType::kUnLimitedPostString, false, 0}
|
||||
{ L"SLP", NSwitchType::kUnLimitedPostString, false, 0},
|
||||
{ L"SCS", NSwitchType::kUnLimitedPostString, false, 0}
|
||||
};
|
||||
|
||||
static const int kNumCommandForms = 7;
|
||||
@@ -234,15 +236,13 @@ static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline UINT GetCurrentCodePage()
|
||||
{ return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
static inline GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
|
||||
|
||||
static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
|
||||
LPCWSTR fileName, bool include, NRecursedType::EEnum type)
|
||||
LPCWSTR fileName, bool include, NRecursedType::EEnum type, UINT codePage)
|
||||
{
|
||||
UStringVector names;
|
||||
if (!ReadNamesFromListFile(GetSystemString(fileName,
|
||||
GetCurrentCodePage()), names))
|
||||
if (!ReadNamesFromListFile(GetSystemString(fileName, GetCurrentCodePage()), names, codePage))
|
||||
throw kIncorrectListFile;
|
||||
for (int i = 0; i < names.Size(); i++)
|
||||
if (!AddNameToCensor(wildcardCensor, names[i], include, type))
|
||||
@@ -260,7 +260,7 @@ static void AddToCensorFromNonSwitchesStrings(
|
||||
int startIndex,
|
||||
NWildcard::CCensor &wildcardCensor,
|
||||
const UStringVector &nonSwitchStrings, NRecursedType::EEnum type,
|
||||
bool thereAreSwitchIncludes)
|
||||
bool thereAreSwitchIncludes, UINT codePage)
|
||||
{
|
||||
if(nonSwitchStrings.Size() == startIndex && (!thereAreSwitchIncludes))
|
||||
AddCommandLineWildCardToCensr(wildcardCensor, kUniversalWildcard, true, type);
|
||||
@@ -268,7 +268,7 @@ static void AddToCensorFromNonSwitchesStrings(
|
||||
{
|
||||
const UString &s = nonSwitchStrings[i];
|
||||
if (s[0] == kFileListID)
|
||||
AddToCensorFromListFile(wildcardCensor, s.Mid(1), true, type);
|
||||
AddToCensorFromListFile(wildcardCensor, s.Mid(1), true, type, codePage);
|
||||
else
|
||||
AddCommandLineWildCardToCensr(wildcardCensor, s, true, type);
|
||||
}
|
||||
@@ -341,7 +341,7 @@ static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
|
||||
|
||||
static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor,
|
||||
const UStringVector &strings, bool include,
|
||||
NRecursedType::EEnum commonRecursedType)
|
||||
NRecursedType::EEnum commonRecursedType, UINT codePage)
|
||||
{
|
||||
for(int i = 0; i < strings.Size(); i++)
|
||||
{
|
||||
@@ -366,7 +366,7 @@ static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor,
|
||||
if (name[pos] == kImmediateNameID)
|
||||
AddCommandLineWildCardToCensr(wildcardCensor, tail, include, recursedType);
|
||||
else if (name[pos] == kFileListID)
|
||||
AddToCensorFromListFile(wildcardCensor, tail, include, recursedType);
|
||||
AddToCensorFromListFile(wildcardCensor, tail, include, recursedType, codePage);
|
||||
#ifdef _WIN32
|
||||
else if (name[pos] == kMapNameID)
|
||||
ParseMapWithPaths(wildcardCensor, tail, include, recursedType);
|
||||
@@ -632,8 +632,7 @@ static void SetAddCommandOptions(
|
||||
}
|
||||
}
|
||||
|
||||
static void SetMethodOptions(const CParser &parser,
|
||||
CUpdateOptions &options)
|
||||
static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &properties)
|
||||
{
|
||||
if (parser[NKey::kProperty].ThereIs)
|
||||
{
|
||||
@@ -650,7 +649,7 @@ static void SetMethodOptions(const CParser &parser,
|
||||
property.Name = postString.Left(index);
|
||||
property.Value = postString.Mid(index + 1);
|
||||
}
|
||||
options.MethodMode.Properties.Add(property);
|
||||
properties.Add(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -723,6 +722,21 @@ void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings,
|
||||
#endif
|
||||
}
|
||||
|
||||
struct CCodePagePair
|
||||
{
|
||||
const wchar_t *Name;
|
||||
UINT CodePage;
|
||||
};
|
||||
|
||||
static CCodePagePair g_CodePagePairs[] =
|
||||
{
|
||||
{ L"UTF-8", CP_UTF8 },
|
||||
{ L"WIN", CP_ACP },
|
||||
{ L"DOS", CP_OEMCP }
|
||||
};
|
||||
|
||||
static const int kNumCodePages = sizeof(g_CodePagePairs) / sizeof(g_CodePagePairs[0]);
|
||||
|
||||
void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
{
|
||||
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
|
||||
@@ -739,16 +753,35 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
else
|
||||
recursedType = NRecursedType::kNonRecursed;
|
||||
|
||||
UINT codePage = CP_UTF8;
|
||||
if (parser[NKey::kCharSet].ThereIs)
|
||||
{
|
||||
UString name = parser[NKey::kCharSet].PostStrings.Front();
|
||||
name.MakeUpper();
|
||||
int i;
|
||||
for (i = 0; i < kNumCodePages; i++)
|
||||
{
|
||||
const CCodePagePair &pair = g_CodePagePairs[i];
|
||||
if (name.Compare(pair.Name) == 0)
|
||||
{
|
||||
codePage = pair.CodePage;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i >= kNumCodePages)
|
||||
throw kUserErrorMessage;
|
||||
}
|
||||
|
||||
bool thereAreSwitchIncludes = false;
|
||||
if (parser[NKey::kInclude].ThereIs)
|
||||
{
|
||||
thereAreSwitchIncludes = true;
|
||||
AddSwitchWildCardsToCensor(options.WildcardCensor,
|
||||
parser[NKey::kInclude].PostStrings, true, recursedType);
|
||||
parser[NKey::kInclude].PostStrings, true, recursedType, codePage);
|
||||
}
|
||||
if (parser[NKey::kExclude].ThereIs)
|
||||
AddSwitchWildCardsToCensor(options.WildcardCensor,
|
||||
parser[NKey::kExclude].PostStrings, false, recursedType);
|
||||
parser[NKey::kExclude].PostStrings, false, recursedType, codePage);
|
||||
|
||||
int curCommandIndex = kCommandIndex + 1;
|
||||
bool thereIsArchiveName = !parser[NKey::kNoArName].ThereIs;
|
||||
@@ -761,7 +794,7 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
|
||||
AddToCensorFromNonSwitchesStrings(
|
||||
curCommandIndex, options.WildcardCensor,
|
||||
nonSwitchStrings, recursedType, thereAreSwitchIncludes);
|
||||
nonSwitchStrings, recursedType, thereAreSwitchIncludes, codePage);
|
||||
|
||||
options.YesToAll = parser[NKey::kYes].ThereIs;
|
||||
|
||||
@@ -787,11 +820,11 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
if (parser[NKey::kArInclude].ThereIs)
|
||||
{
|
||||
AddSwitchWildCardsToCensor(archiveWildcardCensor,
|
||||
parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed);
|
||||
parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed, codePage);
|
||||
}
|
||||
if (parser[NKey::kArExclude].ThereIs)
|
||||
AddSwitchWildCardsToCensor(archiveWildcardCensor,
|
||||
parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed);
|
||||
parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed, codePage);
|
||||
|
||||
if (thereIsArchiveName)
|
||||
AddCommandLineWildCardToCensr(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed);
|
||||
@@ -840,6 +873,7 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
|
||||
if(isExtractGroupCommand)
|
||||
{
|
||||
SetMethodOptions(parser, options.ExtractProperties);
|
||||
if (options.StdOutMode && options.IsStdOutTerminal)
|
||||
throw kTerminalOutError;
|
||||
if(parser[NKey::kOutputDir].ThereIs)
|
||||
@@ -882,10 +916,9 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
|
||||
updateOptions.ArchivePath.BaseExtension = extension;
|
||||
updateOptions.ArchivePath.VolExtension = typeExtension;
|
||||
updateOptions.ArchivePath.ParseFromPath(options.ArchiveName);
|
||||
SetAddCommandOptions(options.Command.CommandType, parser,
|
||||
updateOptions);
|
||||
SetAddCommandOptions(options.Command.CommandType, parser, updateOptions);
|
||||
|
||||
SetMethodOptions(parser, updateOptions);
|
||||
SetMethodOptions(parser, updateOptions.MethodMode.Properties);
|
||||
|
||||
options.EnablePercents = !parser[NKey::kDisablePercents].ThereIs;
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ struct CArchiveCommandLineOptions
|
||||
NExtract::NOverwriteMode::EEnum OverwriteMode;
|
||||
UStringVector ArchivePathsSorted;
|
||||
UStringVector ArchivePathsFullSorted;
|
||||
CObjectVector<CProperty> ExtractProperties;
|
||||
|
||||
CUpdateOptions UpdateOptions;
|
||||
bool EnablePercents;
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
#include "Extract.h"
|
||||
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/FileDir.h"
|
||||
|
||||
#include "OpenArchive.h"
|
||||
#include "SetProperties.h"
|
||||
|
||||
#ifndef EXCLUDE_COM
|
||||
#include "Windows/DLL.h"
|
||||
@@ -68,6 +68,10 @@ HRESULT DecompressArchive(
|
||||
options.ArchiveFileInfo.LastWriteTime,
|
||||
options.ArchiveFileInfo.Attributes);
|
||||
|
||||
#ifdef COMPRESS_MT
|
||||
RINOK(SetProperties(archive, options.Properties));
|
||||
#endif
|
||||
|
||||
HRESULT result = archive->Extract(&realIndices.Front(),
|
||||
realIndices.Size(), options.TestMode? 1: 0,
|
||||
extractCallback);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "ArchiveExtractCallback.h"
|
||||
#include "ArchiveOpenCallback.h"
|
||||
#include "ExtractMode.h"
|
||||
#include "Property.h"
|
||||
|
||||
class CExtractOptions
|
||||
{
|
||||
@@ -27,6 +28,9 @@ public:
|
||||
// bool ShowDialog;
|
||||
// bool PasswordEnabled;
|
||||
// UString Password;
|
||||
#ifdef COMPRESS_MT
|
||||
CObjectVector<CProperty> Properties;
|
||||
#endif
|
||||
|
||||
NExtract::NOverwriteMode::EEnum OverwriteMode;
|
||||
|
||||
|
||||
14
7zip/UI/Common/Property.h
Executable file
14
7zip/UI/Common/Property.h
Executable file
@@ -0,0 +1,14 @@
|
||||
// Property.h
|
||||
|
||||
#ifndef __PROPERTY_H
|
||||
#define __PROPERTY_H
|
||||
|
||||
#include "Common/String.h"
|
||||
|
||||
struct CProperty
|
||||
{
|
||||
UString Name;
|
||||
UString Value;
|
||||
};
|
||||
|
||||
#endif
|
||||
65
7zip/UI/Common/SetProperties.cpp
Executable file
65
7zip/UI/Common/SetProperties.cpp
Executable file
@@ -0,0 +1,65 @@
|
||||
// SetProperties.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "SetProperties.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Common/String.h"
|
||||
#include "Common/StringToInt.h"
|
||||
#include "Common/MyCom.h"
|
||||
|
||||
#include "../../Archive/IArchive.h"
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NCOM;
|
||||
|
||||
static void ParseNumberString(const UString &s, NCOM::CPropVariant &prop)
|
||||
{
|
||||
const wchar_t *endPtr;
|
||||
UInt64 result = ConvertStringToUInt64(s, &endPtr);
|
||||
if (endPtr - (const wchar_t *)s != s.Length())
|
||||
prop = s;
|
||||
else if (result <= 0xFFFFFFFF)
|
||||
prop = (UInt32)result;
|
||||
else
|
||||
prop = result;
|
||||
}
|
||||
|
||||
HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &properties)
|
||||
{
|
||||
if (properties.IsEmpty())
|
||||
return S_OK;
|
||||
CMyComPtr<ISetProperties> setProperties;
|
||||
unknown->QueryInterface(IID_ISetProperties, (void **)&setProperties);
|
||||
if (!setProperties)
|
||||
return S_OK;
|
||||
|
||||
UStringVector realNames;
|
||||
CPropVariant *values = new CPropVariant[properties.Size()];
|
||||
try
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < properties.Size(); i++)
|
||||
{
|
||||
const CProperty &property = properties[i];
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (!property.Value.IsEmpty())
|
||||
ParseNumberString(property.Value, propVariant);
|
||||
realNames.Add(property.Name);
|
||||
values[i] = propVariant;
|
||||
}
|
||||
CRecordVector<const wchar_t *> names;
|
||||
for(i = 0; i < realNames.Size(); i++)
|
||||
names.Add((const wchar_t *)realNames[i]);
|
||||
|
||||
RINOK(setProperties->SetProperties(&names.Front(), values, names.Size()));
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete []values;
|
||||
throw;
|
||||
}
|
||||
delete []values;
|
||||
return S_OK;
|
||||
}
|
||||
10
7zip/UI/Common/SetProperties.h
Executable file
10
7zip/UI/Common/SetProperties.h
Executable file
@@ -0,0 +1,10 @@
|
||||
// SetProperties.h
|
||||
|
||||
#ifndef __SETPROPERTIES_H
|
||||
#define __SETPROPERTIES_H
|
||||
|
||||
#include "Property.h"
|
||||
|
||||
HRESULT SetProperties(IUnknown *unknown, const CObjectVector<CProperty> &properties);
|
||||
|
||||
#endif
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "Update.h"
|
||||
|
||||
#include "Common/IntToString.h"
|
||||
#include "Common/StringToInt.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/CommandLineParser.h"
|
||||
|
||||
@@ -36,6 +35,7 @@
|
||||
#include "TempFiles.h"
|
||||
#include "UpdateCallback.h"
|
||||
#include "EnumDirItems.h"
|
||||
#include "SetProperties.h"
|
||||
|
||||
#ifdef FORMAT_7Z
|
||||
#include "../../Archive/7z/7zHandler.h"
|
||||
@@ -77,18 +77,6 @@ static const char *kIllegalFileNameMessage = "Illegal file name for temp archive
|
||||
|
||||
using namespace NUpdateArchive;
|
||||
|
||||
static void ParseNumberString(const UString &s, NCOM::CPropVariant &prop)
|
||||
{
|
||||
const wchar_t *endPtr;
|
||||
UInt64 result = ConvertStringToUInt64(s, &endPtr);
|
||||
if (endPtr - (const wchar_t *)s != s.Length())
|
||||
prop = s;
|
||||
else if (result <= 0xFFFFFFFF)
|
||||
prop = (UInt32)result;
|
||||
else
|
||||
prop = result;
|
||||
}
|
||||
|
||||
static HRESULT CopyBlock(ISequentialInStream *inStream, ISequentialOutStream *outStream)
|
||||
{
|
||||
CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
|
||||
@@ -439,36 +427,7 @@ static HRESULT Compress(
|
||||
*/
|
||||
}
|
||||
|
||||
CMyComPtr<ISetProperties> setProperties;
|
||||
if (outArchive.QueryInterface(IID_ISetProperties, &setProperties) == S_OK)
|
||||
{
|
||||
UStringVector realNames;
|
||||
CPropVariant *values = new CPropVariant[compressionMethod.Properties.Size()];
|
||||
try
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < compressionMethod.Properties.Size(); i++)
|
||||
{
|
||||
const CProperty &property = compressionMethod.Properties[i];
|
||||
NCOM::CPropVariant propVariant;
|
||||
if (!property.Value.IsEmpty())
|
||||
ParseNumberString(property.Value, propVariant);
|
||||
realNames.Add(property.Name);
|
||||
values[i] = propVariant;
|
||||
}
|
||||
CRecordVector<const wchar_t *> names;
|
||||
for(i = 0; i < realNames.Size(); i++)
|
||||
names.Add((const wchar_t *)realNames[i]);
|
||||
|
||||
RINOK(setProperties->SetProperties(&names.Front(), values, names.Size()));
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete []values;
|
||||
throw;
|
||||
}
|
||||
delete []values;
|
||||
}
|
||||
RINOK(SetProperties(outArchive, compressionMethod.Properties));
|
||||
|
||||
if (sfxMode)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "UpdateAction.h"
|
||||
#include "ArchiveOpenCallback.h"
|
||||
#include "UpdateCallback.h"
|
||||
#include "Property.h"
|
||||
|
||||
struct CArchivePath
|
||||
{
|
||||
@@ -75,12 +76,6 @@ struct CUpdateArchiveCommand
|
||||
NUpdateArchive::CActionSet ActionSet;
|
||||
};
|
||||
|
||||
struct CProperty
|
||||
{
|
||||
UString Name;
|
||||
UString Value;
|
||||
};
|
||||
|
||||
struct CCompressionMethodMode
|
||||
{
|
||||
#ifndef EXCLUDE_COM
|
||||
@@ -111,7 +106,7 @@ struct CUpdateOptions
|
||||
bool EMailRemoveAfter;
|
||||
UString EMailAddress;
|
||||
|
||||
UString WorkingDir;
|
||||
UString WorkingDir;
|
||||
|
||||
CUpdateOptions():
|
||||
UpdateArchiveItself(true),
|
||||
|
||||
Reference in New Issue
Block a user