mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-16 22:11:49 -06:00
4.20
This commit is contained in:
committed by
Kornel Lesiński
parent
8c1b5c7b7e
commit
3c510ba80b
@@ -10,7 +10,9 @@
|
||||
#include "Windows/FileFind.h"
|
||||
#include "Windows/FileName.h"
|
||||
#include "Windows/DLL.h"
|
||||
#ifdef _WIN32
|
||||
#include "Windows/Registry.h"
|
||||
#endif
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "../../Archive/IArchive.h"
|
||||
|
||||
@@ -48,7 +50,7 @@ static void SplitString(const UString &srcString, UStringVector &destStrings)
|
||||
destStrings.Add(string);
|
||||
}
|
||||
|
||||
typedef UINT32 (WINAPI * GetHandlerPropertyFunc)(
|
||||
typedef UInt32 (WINAPI * GetHandlerPropertyFunc)(
|
||||
PROPID propID, PROPVARIANT *value);
|
||||
|
||||
/*
|
||||
@@ -72,7 +74,7 @@ static wchar_t *kFormatFolderName = L"Formats";
|
||||
static LPCTSTR kRegistryPath = TEXT("Software\\7-zip");
|
||||
static LPCTSTR kProgramPathValue = TEXT("Path");
|
||||
|
||||
UString GetBaseFolderPrefix()
|
||||
static UString GetBaseFolderPrefixFromRegistry()
|
||||
{
|
||||
UString moduleFolderPrefix = GetModuleFolderPrefix();
|
||||
NFind::CFileInfoW fileInfo;
|
||||
@@ -80,6 +82,7 @@ UString GetBaseFolderPrefix()
|
||||
if (fileInfo.IsDirectory())
|
||||
return moduleFolderPrefix;
|
||||
CSysString pathSys;
|
||||
#ifdef _WIN32
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
if(key.Open(HKEY_CURRENT_USER, kRegistryPath, KEY_READ) == ERROR_SUCCESS)
|
||||
@@ -100,16 +103,25 @@ UString GetBaseFolderPrefix()
|
||||
return path;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return moduleFolderPrefix;
|
||||
}
|
||||
|
||||
typedef UINT32 (WINAPI *CreateObjectPointer)(
|
||||
typedef UInt32 (WINAPI *CreateObjectPointer)(
|
||||
const GUID *clsID,
|
||||
const GUID *interfaceID,
|
||||
void **outObject);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _SFX
|
||||
static void SetBuffer(CByteBuffer &bb, const Byte *data, int size)
|
||||
{
|
||||
bb.SetCapacity(size);
|
||||
memmove((Byte *)bb, data, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers)
|
||||
{
|
||||
archivers.Clear();
|
||||
@@ -123,6 +135,10 @@ void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers)
|
||||
item.KeepName = false;
|
||||
item.Name = L"7z";
|
||||
item.Extensions.Add(CArchiverExtInfo(L"7z"));
|
||||
#ifndef _SFX
|
||||
const unsigned char kSig[] = {'7' , 'z', 0xBC, 0xAF, 0x27, 0x1C};
|
||||
SetBuffer(item.StartSignature, kSig, 6);
|
||||
#endif
|
||||
archivers.Add(item);
|
||||
}
|
||||
#endif
|
||||
@@ -135,6 +151,10 @@ void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers)
|
||||
item.Name = L"BZip2";
|
||||
item.Extensions.Add(CArchiverExtInfo(L"bz2"));
|
||||
item.Extensions.Add(CArchiverExtInfo(L"tbz2", L".tar"));
|
||||
#ifndef _SFX
|
||||
const unsigned char sig[] = {'B' , 'Z', 'h' };
|
||||
SetBuffer(item.StartSignature, sig, 3);
|
||||
#endif
|
||||
archivers.Add(item);
|
||||
}
|
||||
#endif
|
||||
@@ -147,6 +167,21 @@ void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers)
|
||||
item.Name = L"GZip";
|
||||
item.Extensions.Add(CArchiverExtInfo(L"gz"));
|
||||
item.Extensions.Add(CArchiverExtInfo(L"tgz", L".tar"));
|
||||
#ifndef _SFX
|
||||
const unsigned char sig[] = { 0x1F, 0x8B };
|
||||
SetBuffer(item.StartSignature, sig, 2);
|
||||
#endif
|
||||
archivers.Add(item);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FORMAT_SPLIT
|
||||
{
|
||||
CArchiverInfo item;
|
||||
item.UpdateEnabled = false;
|
||||
item.KeepName = true;
|
||||
item.Name = L"Split";
|
||||
item.Extensions.Add(CArchiverExtInfo(L"001"));
|
||||
archivers.Add(item);
|
||||
}
|
||||
#endif
|
||||
@@ -169,6 +204,10 @@ void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers)
|
||||
item.KeepName = false;
|
||||
item.Name = L"Zip";
|
||||
item.Extensions.Add(CArchiverExtInfo(L"zip"));
|
||||
#ifndef _SFX
|
||||
const unsigned char sig[] = { 0x50, 0x4B, 0x03, 0x04 };
|
||||
SetBuffer(item.StartSignature, sig, 4);
|
||||
#endif
|
||||
archivers.Add(item);
|
||||
}
|
||||
#endif
|
||||
@@ -199,13 +238,31 @@ void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers)
|
||||
item.UpdateEnabled = false;
|
||||
item.Name = L"Arj";
|
||||
item.Extensions.Add(CArchiverExtInfo(L"arj"));
|
||||
#ifndef _SFX
|
||||
const unsigned char sig[] = { 0x60, 0xEA };
|
||||
SetBuffer(item.StartSignature, sig, 2);
|
||||
#endif
|
||||
archivers.Add(item);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FORMAT_Z
|
||||
{
|
||||
CArchiverInfo item;
|
||||
item.UpdateEnabled = false;
|
||||
item.Name = L"Z";
|
||||
item.Extensions.Add(CArchiverExtInfo(L"Z"));
|
||||
#ifndef _SFX
|
||||
const unsigned char sig[] = { 0x1F, 0x9D };
|
||||
SetBuffer(item.StartSignature, sig, 2);
|
||||
#endif
|
||||
archivers.Add(item);
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
UString folderPath = GetBaseFolderPrefix() +
|
||||
UString folderPath = GetBaseFolderPrefixFromRegistry() +
|
||||
kFormatFolderName + L"\\";
|
||||
NFind::CEnumeratorW enumerator(folderPath + L"*");
|
||||
NFind::CFileInfoW fileInfo;
|
||||
@@ -253,6 +310,7 @@ void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers)
|
||||
|
||||
UString ext = prop.bstrVal;
|
||||
// item.Extension = prop.bstrVal;
|
||||
prop.Clear();
|
||||
|
||||
UString addExt;
|
||||
|
||||
@@ -282,23 +340,30 @@ void ReadArchiverInfoList(CObjectVector<CArchiverInfo> &archivers)
|
||||
item.Extensions.Add(extInfo);
|
||||
}
|
||||
|
||||
if (getHandlerProperty(NArchive::kUpdate, &prop) != S_OK)
|
||||
continue;
|
||||
if (prop.vt != VT_BOOL)
|
||||
continue;
|
||||
item.UpdateEnabled = VARIANT_BOOLToBool(prop.boolVal);
|
||||
if (getHandlerProperty(NArchive::kUpdate, &prop) == S_OK)
|
||||
if (prop.vt == VT_BOOL)
|
||||
item.UpdateEnabled = VARIANT_BOOLToBool(prop.boolVal);
|
||||
prop.Clear();
|
||||
|
||||
if (item.UpdateEnabled)
|
||||
{
|
||||
if (getHandlerProperty(NArchive::kKeepName, &prop) != S_OK)
|
||||
continue;
|
||||
if (prop.vt != VT_BOOL)
|
||||
continue;
|
||||
item.KeepName = VARIANT_BOOLToBool(prop.boolVal);
|
||||
if (getHandlerProperty(NArchive::kKeepName, &prop) == S_OK)
|
||||
if (prop.vt == VT_BOOL)
|
||||
item.KeepName = VARIANT_BOOLToBool(prop.boolVal);
|
||||
prop.Clear();
|
||||
}
|
||||
|
||||
if (getHandlerProperty(NArchive::kStartSignature, &prop) == S_OK)
|
||||
{
|
||||
if (prop.vt == VT_BSTR)
|
||||
{
|
||||
UINT len = ::SysStringByteLen(prop.bstrVal);
|
||||
item.StartSignature.SetCapacity(len);
|
||||
memmove(item.StartSignature, prop.bstrVal, len);
|
||||
}
|
||||
}
|
||||
prop.Clear();
|
||||
|
||||
archivers.Add(item);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user