mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 18:07:15 -06:00
16.03
This commit is contained in:
committed by
Kornel Lesiński
parent
1eddf527ca
commit
232ce79574
@@ -1,9 +1,9 @@
|
|||||||
#define MY_VER_MAJOR 16
|
#define MY_VER_MAJOR 16
|
||||||
#define MY_VER_MINOR 02
|
#define MY_VER_MINOR 03
|
||||||
#define MY_VER_BUILD 0
|
#define MY_VER_BUILD 0
|
||||||
#define MY_VERSION_NUMBERS "16.02"
|
#define MY_VERSION_NUMBERS "16.03"
|
||||||
#define MY_VERSION "16.02"
|
#define MY_VERSION "16.03"
|
||||||
#define MY_DATE "2016-05-21"
|
#define MY_DATE "2016-09-28"
|
||||||
#undef MY_COPYRIGHT
|
#undef MY_COPYRIGHT
|
||||||
#undef MY_VERSION_COPYRIGHT_DATE
|
#undef MY_VERSION_COPYRIGHT_DATE
|
||||||
#define MY_AUTHOR_NAME "Igor Pavlov"
|
#define MY_AUTHOR_NAME "Igor Pavlov"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* CpuArch.h -- CPU specific code
|
/* CpuArch.h -- CPU specific code
|
||||||
2015-12-01: Igor Pavlov : Public domain */
|
2016-06-09: Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __CPU_ARCH_H
|
#ifndef __CPU_ARCH_H
|
||||||
#define __CPU_ARCH_H
|
#define __CPU_ARCH_H
|
||||||
@@ -66,6 +66,7 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
|
|||||||
|| defined(__MIPSEL__) \
|
|| defined(__MIPSEL__) \
|
||||||
|| defined(__MIPSEL) \
|
|| defined(__MIPSEL) \
|
||||||
|| defined(_MIPSEL) \
|
|| defined(_MIPSEL) \
|
||||||
|
|| defined(__BFIN__) \
|
||||||
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
|
|| (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
|
||||||
#define MY_CPU_LE
|
#define MY_CPU_LE
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
87
C/DllSecur.c
Normal file
87
C/DllSecur.c
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/* DllSecur.c -- DLL loading security
|
||||||
|
2016-09-15 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#include "Precomp.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "DllSecur.h"
|
||||||
|
|
||||||
|
#ifndef UNDER_CE
|
||||||
|
|
||||||
|
typedef BOOL (WINAPI *Func_SetDefaultDllDirectories)(DWORD DirectoryFlags);
|
||||||
|
|
||||||
|
#define MY_LOAD_LIBRARY_SEARCH_USER_DIRS 0x400
|
||||||
|
#define MY_LOAD_LIBRARY_SEARCH_SYSTEM32 0x800
|
||||||
|
|
||||||
|
static const char * const g_Dlls =
|
||||||
|
#ifndef _CONSOLE
|
||||||
|
"UXTHEME\0"
|
||||||
|
#endif
|
||||||
|
"USERENV\0"
|
||||||
|
"SETUPAPI\0"
|
||||||
|
"APPHELP\0"
|
||||||
|
"PROPSYS\0"
|
||||||
|
"DWMAPI\0"
|
||||||
|
"CRYPTBASE\0"
|
||||||
|
"OLEACC\0"
|
||||||
|
"CLBCATQ\0"
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void LoadSecurityDlls()
|
||||||
|
{
|
||||||
|
#ifndef UNDER_CE
|
||||||
|
|
||||||
|
wchar_t buf[MAX_PATH + 100];
|
||||||
|
|
||||||
|
{
|
||||||
|
// at Vista (ver 6.0) : CoCreateInstance(CLSID_ShellLink, ...) doesn't work after SetDefaultDllDirectories() : Check it ???
|
||||||
|
OSVERSIONINFO vi;
|
||||||
|
vi.dwOSVersionInfoSize = sizeof(vi);
|
||||||
|
if (!GetVersionEx(&vi) || vi.dwMajorVersion != 6 || vi.dwMajorVersion != 0)
|
||||||
|
{
|
||||||
|
Func_SetDefaultDllDirectories setDllDirs = (Func_SetDefaultDllDirectories)
|
||||||
|
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "SetDefaultDllDirectories");
|
||||||
|
if (setDllDirs)
|
||||||
|
if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2);
|
||||||
|
if (len == 0 || len > MAX_PATH)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const char *dll;
|
||||||
|
unsigned pos = (unsigned)lstrlenW(buf);
|
||||||
|
|
||||||
|
if (buf[pos - 1] != '\\')
|
||||||
|
buf[pos++] = '\\';
|
||||||
|
|
||||||
|
for (dll = g_Dlls; dll[0] != 0;)
|
||||||
|
{
|
||||||
|
unsigned k = 0;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
char c = *dll++;
|
||||||
|
buf[pos + k] = c;
|
||||||
|
k++;
|
||||||
|
if (c == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lstrcatW(buf, L".dll");
|
||||||
|
LoadLibraryExW(buf, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
19
C/DllSecur.h
Normal file
19
C/DllSecur.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/* DllSecur.h -- DLL loading for security
|
||||||
|
2016-06-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
|
#ifndef __DLL_SECUR_H
|
||||||
|
#define __DLL_SECUR_H
|
||||||
|
|
||||||
|
#include "7zTypes.h"
|
||||||
|
|
||||||
|
EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
void LoadSecurityDlls();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EXTERN_C_END
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/* 7zipInstall.c - 7-Zip Installer
|
/* 7zipInstall.c - 7-Zip Installer
|
||||||
2015-12-09 : Igor Pavlov : Public domain */
|
2016-06-08 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#include "Precomp.h"
|
#include "Precomp.h"
|
||||||
|
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "../../7zFile.h"
|
#include "../../7zFile.h"
|
||||||
#include "../../7zVersion.h"
|
#include "../../7zVersion.h"
|
||||||
#include "../../CpuArch.h"
|
#include "../../CpuArch.h"
|
||||||
|
#include "../../DllSecur.h"
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
@@ -876,6 +877,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
UNUSED_VAR(nCmdShow)
|
UNUSED_VAR(nCmdShow)
|
||||||
|
|
||||||
#ifndef UNDER_CE
|
#ifndef UNDER_CE
|
||||||
|
LoadSecurityDlls();
|
||||||
CoInitialize(NULL);
|
CoInitialize(NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -191,6 +191,14 @@ SOURCE=..\..\Delta.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\DllSecur.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\DllSecur.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\Lzma2Dec.c
|
SOURCE=..\..\Lzma2Dec.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ C_OBJS = \
|
|||||||
$O\7zStream.obj \
|
$O\7zStream.obj \
|
||||||
$O\Bcj2.obj \
|
$O\Bcj2.obj \
|
||||||
$O\CpuArch.obj \
|
$O\CpuArch.obj \
|
||||||
|
$O\DllSecur.obj \
|
||||||
$O\LzmaDec.obj \
|
$O\LzmaDec.obj \
|
||||||
|
|
||||||
OBJS = \
|
OBJS = \
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "../../7zCrc.h"
|
#include "../../7zCrc.h"
|
||||||
#include "../../7zFile.h"
|
#include "../../7zFile.h"
|
||||||
#include "../../CpuArch.h"
|
#include "../../CpuArch.h"
|
||||||
|
#include "../../DllSecur.h"
|
||||||
|
|
||||||
#define k_EXE_ExtIndex 2
|
#define k_EXE_ExtIndex 2
|
||||||
|
|
||||||
@@ -254,6 +255,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||||||
Bool useShellExecute = True;
|
Bool useShellExecute = True;
|
||||||
DWORD exitCode = 0;
|
DWORD exitCode = 0;
|
||||||
|
|
||||||
|
LoadSecurityDlls();
|
||||||
|
|
||||||
#ifdef _CONSOLE
|
#ifdef _CONSOLE
|
||||||
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
|
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -187,6 +187,14 @@ SOURCE=..\..\Delta.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\DllSecur.c
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\DllSecur.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\Lzma2Dec.c
|
SOURCE=..\..\Lzma2Dec.c
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ C_OBJS = \
|
|||||||
$O\BraIA64.obj \
|
$O\BraIA64.obj \
|
||||||
$O\CpuArch.obj \
|
$O\CpuArch.obj \
|
||||||
$O\Delta.obj \
|
$O\Delta.obj \
|
||||||
|
$O\DllSecur.obj \
|
||||||
$O\Lzma2Dec.obj \
|
$O\Lzma2Dec.obj \
|
||||||
$O\LzmaDec.obj \
|
$O\LzmaDec.obj \
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ C_OBJS = \
|
|||||||
$O\BraIA64.obj \
|
$O\BraIA64.obj \
|
||||||
$O\CpuArch.obj \
|
$O\CpuArch.obj \
|
||||||
$O\Delta.obj \
|
$O\Delta.obj \
|
||||||
|
$O\DllSecur.obj \
|
||||||
$O\Lzma2Dec.obj \
|
$O\Lzma2Dec.obj \
|
||||||
$O\LzmaDec.obj \
|
$O\LzmaDec.obj \
|
||||||
|
|
||||||
|
|||||||
@@ -1097,7 +1097,10 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
|
|||||||
if (CrcCalc(data, unpackSize) != folders.FolderCRCs.Vals[i])
|
if (CrcCalc(data, unpackSize) != folders.FolderCRCs.Vals[i])
|
||||||
ThrowIncorrect();
|
ThrowIncorrect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (folders.PackPositions)
|
||||||
HeadersSize += folders.PackPositions[folders.NumPackStreams];
|
HeadersSize += folders.PackPositions[folders.NumPackStreams];
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ struct CFilterMode
|
|||||||
{
|
{
|
||||||
if (Id == k_IA64)
|
if (Id == k_IA64)
|
||||||
Delta = 16;
|
Delta = 16;
|
||||||
else if (Id == k_ARM || Id == k_PPC || Id == k_PPC)
|
else if (Id == k_ARM || Id == k_PPC || Id == k_SPARC)
|
||||||
Delta = 4;
|
Delta = 4;
|
||||||
else if (Id == k_ARMT)
|
else if (Id == k_ARMT)
|
||||||
Delta = 2;
|
Delta = 2;
|
||||||
@@ -779,7 +779,7 @@ struct CSolidGroup
|
|||||||
CRecordVector<CFolderRepack> folderRefs;
|
CRecordVector<CFolderRepack> folderRefs;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *g_ExeExts[] =
|
static const char * const g_ExeExts[] =
|
||||||
{
|
{
|
||||||
"dll"
|
"dll"
|
||||||
, "exe"
|
, "exe"
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
|||||||
|
|
||||||
case kpidVolumeIndex:
|
case kpidVolumeIndex:
|
||||||
{
|
{
|
||||||
if (m_Database.Volumes.Size() == 1)
|
if (!m_Database.Volumes.IsEmpty())
|
||||||
{
|
{
|
||||||
const CDatabaseEx &db = m_Database.Volumes[0];
|
const CDatabaseEx &db = m_Database.Volumes[0];
|
||||||
const CInArcInfo &ai = db.ArcInfo;
|
const CInArcInfo &ai = db.ArcInfo;
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ bool CHeader::Parse(const Byte *p)
|
|||||||
|
|
||||||
#define PT_PHDR 6
|
#define PT_PHDR 6
|
||||||
|
|
||||||
static const char *g_SegnmentTypes[] =
|
static const char * const g_SegnmentTypes[] =
|
||||||
{
|
{
|
||||||
"Unused",
|
"Unused",
|
||||||
"Loadable segment",
|
"Loadable segment",
|
||||||
@@ -554,13 +554,31 @@ static const CUInt32PCharPair g_OS[] =
|
|||||||
{ 255, "Standalone" }
|
{ 255, "Standalone" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define k_Machine_ARM 40
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define EF_ARM_ABIMASK 0xFF000000
|
||||||
|
#define EF_ARM_BE8 0x00800000
|
||||||
|
#define EF_ARM_GCCMASK 0x00400FFF
|
||||||
|
#define EF_ARM_ABI_FLOAT_SOFT 0x00000200
|
||||||
|
#define EF_ARM_ABI_FLOAT_HARD 0x00000400
|
||||||
|
*/
|
||||||
|
|
||||||
|
static const CUInt32PCharPair g_ARM_Flags[] =
|
||||||
|
{
|
||||||
|
{ 9, "SF" },
|
||||||
|
{ 10, "HF" },
|
||||||
|
{ 23, "BE8" }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#define ET_NONE 0
|
#define ET_NONE 0
|
||||||
#define ET_REL 1
|
#define ET_REL 1
|
||||||
#define ET_EXEC 2
|
#define ET_EXEC 2
|
||||||
#define ET_DYN 3
|
#define ET_DYN 3
|
||||||
#define ET_CORE 4
|
#define ET_CORE 4
|
||||||
|
|
||||||
static const char *g_Types[] =
|
static const char * const g_Types[] =
|
||||||
{
|
{
|
||||||
"None",
|
"None",
|
||||||
"Relocatable file",
|
"Relocatable file",
|
||||||
@@ -569,6 +587,9 @@ static const char *g_Types[] =
|
|||||||
"Core file"
|
"Core file"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CHandler:
|
class CHandler:
|
||||||
public IInArchive,
|
public IInArchive,
|
||||||
public IArchiveAllowTail,
|
public IArchiveAllowTail,
|
||||||
@@ -659,7 +680,29 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
|||||||
case kpidBit64: if (_header.Mode64) prop = _header.Mode64; break;
|
case kpidBit64: if (_header.Mode64) prop = _header.Mode64; break;
|
||||||
case kpidBigEndian: if (_header.Be) prop = _header.Be; break;
|
case kpidBigEndian: if (_header.Be) prop = _header.Be; break;
|
||||||
case kpidShortComment:
|
case kpidShortComment:
|
||||||
case kpidCpu: PAIR_TO_PROP(g_Machines, _header.Machine, prop); break;
|
|
||||||
|
case kpidCpu:
|
||||||
|
{
|
||||||
|
AString s = TypePairToString(g_Machines, ARRAY_SIZE(g_Machines), _header.Machine);
|
||||||
|
UInt32 flags = _header.Flags;
|
||||||
|
if (flags != 0)
|
||||||
|
{
|
||||||
|
char sz[16];
|
||||||
|
s.Add_Space();
|
||||||
|
if (_header.Machine == k_Machine_ARM)
|
||||||
|
{
|
||||||
|
s += FlagsToString(g_ARM_Flags, ARRAY_SIZE(g_ARM_Flags), flags & (((UInt32)1 << 24) - 1));
|
||||||
|
s += " ABI:";
|
||||||
|
ConvertUInt32ToString(flags >> 24, sz);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ConvertUInt32ToHex(flags, sz);
|
||||||
|
s += sz;
|
||||||
|
}
|
||||||
|
prop = s;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case kpidHostOS: PAIR_TO_PROP(g_OS, _header.Os, prop); break;
|
case kpidHostOS: PAIR_TO_PROP(g_OS, _header.Os, prop); break;
|
||||||
case kpidCharacts: TYPE_TO_PROP(g_Types, _header.Type, prop); break;
|
case kpidCharacts: TYPE_TO_PROP(g_Types, _header.Type, prop); break;
|
||||||
case kpidExtension:
|
case kpidExtension:
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ static const Byte kProps[] =
|
|||||||
IMP_IInArchive_Props
|
IMP_IInArchive_Props
|
||||||
IMP_IInArchive_ArcProps_NO_Table
|
IMP_IInArchive_ArcProps_NO_Table
|
||||||
|
|
||||||
static const char *g_AudioTypes[16] =
|
static const char * const g_AudioTypes[16] =
|
||||||
{
|
{
|
||||||
"pcm"
|
"pcm"
|
||||||
, "adpcm"
|
, "adpcm"
|
||||||
@@ -113,7 +113,7 @@ static const char *g_AudioTypes[16] =
|
|||||||
, "audio15"
|
, "audio15"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *g_VideoTypes[16] =
|
static const char * const g_VideoTypes[16] =
|
||||||
{
|
{
|
||||||
"video0"
|
"video0"
|
||||||
, "jpeg"
|
, "jpeg"
|
||||||
@@ -133,7 +133,7 @@ static const char *g_VideoTypes[16] =
|
|||||||
, "video15"
|
, "video15"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *g_Rates[4] =
|
static const char * const g_Rates[4] =
|
||||||
{
|
{
|
||||||
"5.5 kHz"
|
"5.5 kHz"
|
||||||
, "11 kHz"
|
, "11 kHz"
|
||||||
|
|||||||
@@ -244,9 +244,31 @@ HRESULT CHandler::Open2(IInStream *stream)
|
|||||||
_items.Add(item);
|
_items.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt64 end = (backupLba + 1) * kSectorSize;
|
{
|
||||||
|
const UInt64 end = (backupLba + 1) * kSectorSize;
|
||||||
if (_totalSize < end)
|
if (_totalSize < end)
|
||||||
_totalSize = end;
|
_totalSize = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
UInt64 fileEnd;
|
||||||
|
RINOK(stream->Seek(0, STREAM_SEEK_END, &fileEnd));
|
||||||
|
|
||||||
|
if (_totalSize < fileEnd)
|
||||||
|
{
|
||||||
|
const UInt64 rem = fileEnd - _totalSize;
|
||||||
|
const UInt64 kRemMax = 1 << 22;
|
||||||
|
if (rem <= kRemMax)
|
||||||
|
{
|
||||||
|
RINOK(stream->Seek(_totalSize, STREAM_SEEK_SET, NULL));
|
||||||
|
bool areThereNonZeros = false;
|
||||||
|
UInt64 numZeros = 0;
|
||||||
|
if (ReadZeroTail(stream, areThereNonZeros, numZeros, kRemMax) == S_OK)
|
||||||
|
if (!areThereNonZeros)
|
||||||
|
_totalSize += numZeros;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -507,7 +507,7 @@ HRESULT CHeaderRec::Parse(const Byte *p)
|
|||||||
// LeafRecords = Get32(p + 6);
|
// LeafRecords = Get32(p + 6);
|
||||||
FirstLeafNode = Get32(p + 0xA);
|
FirstLeafNode = Get32(p + 0xA);
|
||||||
// LastLeafNode = Get32(p + 0xE);
|
// LastLeafNode = Get32(p + 0xE);
|
||||||
UInt32 nodeSize = Get16(p + 0x12);
|
const UInt32 nodeSize = Get16(p + 0x12);
|
||||||
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 9; ((UInt32)1 << i) != nodeSize; i++)
|
for (i = 9; ((UInt32)1 << i) != nodeSize; i++)
|
||||||
@@ -583,9 +583,9 @@ HRESULT CDatabase::LoadExtentFile(const CFork &fork, IInStream *inStream, CObjec
|
|||||||
|
|
||||||
for (unsigned i = 0; i < desc.NumRecords; i++)
|
for (unsigned i = 0; i < desc.NumRecords; i++)
|
||||||
{
|
{
|
||||||
UInt32 nodeSize = (UInt32)1 << hr.NodeSizeLog;
|
const UInt32 nodeSize = (UInt32)1 << hr.NodeSizeLog;
|
||||||
UInt32 offs = Get16(p + nodeOffset + nodeSize - (i + 1) * 2);
|
const UInt32 offs = Get16(p + nodeOffset + nodeSize - (i + 1) * 2);
|
||||||
UInt32 offsNext = Get16(p + nodeOffset + nodeSize - (i + 2) * 2);
|
const UInt32 offsNext = Get16(p + nodeOffset + nodeSize - (i + 2) * 2);
|
||||||
if (offs > nodeSize || offsNext > nodeSize)
|
if (offs > nodeSize || offsNext > nodeSize)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
UInt32 recSize = offsNext - offs;
|
UInt32 recSize = offsNext - offs;
|
||||||
@@ -727,12 +727,12 @@ HRESULT CDatabase::LoadAttrs(const CFork &fork, IInStream *inStream, IArchiveOpe
|
|||||||
|
|
||||||
for (unsigned i = 0; i < desc.NumRecords; i++)
|
for (unsigned i = 0; i < desc.NumRecords; i++)
|
||||||
{
|
{
|
||||||
UInt32 nodeSize = (1 << hr.NodeSizeLog);
|
const UInt32 nodeSize = (1 << hr.NodeSizeLog);
|
||||||
UInt32 offs = Get16(p + nodeOffset + nodeSize - (i + 1) * 2);
|
const UInt32 offs = Get16(p + nodeOffset + nodeSize - (i + 1) * 2);
|
||||||
UInt32 offsNext = Get16(p + nodeOffset + nodeSize - (i + 2) * 2);
|
const UInt32 offsNext = Get16(p + nodeOffset + nodeSize - (i + 2) * 2);
|
||||||
UInt32 recSize = offsNext - offs;
|
UInt32 recSize = offsNext - offs;
|
||||||
if (offs >= nodeSize
|
if (offs >= nodeSize
|
||||||
|| offsNext >= nodeSize
|
|| offsNext > nodeSize
|
||||||
|| offsNext < offs)
|
|| offsNext < offs)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
@@ -898,7 +898,7 @@ HRESULT CDatabase::LoadCatalog(const CFork &fork, const CObjectVector<CIdExtents
|
|||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
usedBuf[node] = 1;
|
usedBuf[node] = 1;
|
||||||
|
|
||||||
size_t nodeOffset = (size_t)node << hr.NodeSizeLog;
|
const size_t nodeOffset = (size_t)node << hr.NodeSizeLog;
|
||||||
CNodeDescriptor desc;
|
CNodeDescriptor desc;
|
||||||
desc.Parse(p + nodeOffset);
|
desc.Parse(p + nodeOffset);
|
||||||
if (!desc.CheckNumRecords(hr.NodeSizeLog))
|
if (!desc.CheckNumRecords(hr.NodeSizeLog))
|
||||||
@@ -908,12 +908,12 @@ HRESULT CDatabase::LoadCatalog(const CFork &fork, const CObjectVector<CIdExtents
|
|||||||
|
|
||||||
for (unsigned i = 0; i < desc.NumRecords; i++)
|
for (unsigned i = 0; i < desc.NumRecords; i++)
|
||||||
{
|
{
|
||||||
UInt32 nodeSize = (1 << hr.NodeSizeLog);
|
const UInt32 nodeSize = (1 << hr.NodeSizeLog);
|
||||||
UInt32 offs = Get16(p + nodeOffset + nodeSize - (i + 1) * 2);
|
const UInt32 offs = Get16(p + nodeOffset + nodeSize - (i + 1) * 2);
|
||||||
UInt32 offsNext = Get16(p + nodeOffset + nodeSize - (i + 2) * 2);
|
const UInt32 offsNext = Get16(p + nodeOffset + nodeSize - (i + 2) * 2);
|
||||||
UInt32 recSize = offsNext - offs;
|
UInt32 recSize = offsNext - offs;
|
||||||
if (offs >= nodeSize
|
if (offs >= nodeSize
|
||||||
|| offs >= nodeSize
|
|| offsNext > nodeSize
|
||||||
|| offsNext < offs
|
|| offsNext < offs
|
||||||
|| recSize < 6)
|
|| recSize < 6)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|||||||
@@ -30,7 +30,14 @@ static const Byte kProps[] =
|
|||||||
kpidIsDir,
|
kpidIsDir,
|
||||||
kpidSize,
|
kpidSize,
|
||||||
kpidPackSize,
|
kpidPackSize,
|
||||||
kpidMTime
|
kpidMTime,
|
||||||
|
// kpidCTime,
|
||||||
|
// kpidATime,
|
||||||
|
kpidPosixAttrib,
|
||||||
|
// kpidUser,
|
||||||
|
// kpidGroup,
|
||||||
|
// kpidLinks,
|
||||||
|
kpidSymLink
|
||||||
};
|
};
|
||||||
|
|
||||||
static const Byte kArcProps[] =
|
static const Byte kArcProps[] =
|
||||||
@@ -213,17 +220,87 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
|||||||
prop = s;
|
prop = s;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kpidSymLink:
|
||||||
|
if (_archive.IsSusp)
|
||||||
|
{
|
||||||
|
UString s;
|
||||||
|
UInt32 mode;
|
||||||
|
if (item.GetPx(_archive.SuspSkipSize, k_Px_Mode, mode))
|
||||||
|
{
|
||||||
|
if (((mode >> 12) & 0xF) == 10)
|
||||||
|
{
|
||||||
|
AString s8;
|
||||||
|
if (item.GetSymLink(_archive.SuspSkipSize, s8))
|
||||||
|
{
|
||||||
|
s = MultiByteToUnicodeString(s8, CP_OEMCP);
|
||||||
|
prop = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case kpidPosixAttrib:
|
||||||
|
/*
|
||||||
|
case kpidLinks:
|
||||||
|
case kpidUser:
|
||||||
|
case kpidGroup:
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
if (_archive.IsSusp)
|
||||||
|
{
|
||||||
|
UInt32 t = 0;
|
||||||
|
switch (propID)
|
||||||
|
{
|
||||||
|
case kpidPosixAttrib: t = k_Px_Mode; break;
|
||||||
|
/*
|
||||||
|
case kpidLinks: t = k_Px_Links; break;
|
||||||
|
case kpidUser: t = k_Px_User; break;
|
||||||
|
case kpidGroup: t = k_Px_Group; break;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
UInt32 v;
|
||||||
|
if (item.GetPx(_archive.SuspSkipSize, t, v))
|
||||||
|
prop = v;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case kpidIsDir: prop = item.IsDir(); break;
|
case kpidIsDir: prop = item.IsDir(); break;
|
||||||
case kpidSize:
|
case kpidSize:
|
||||||
case kpidPackSize:
|
case kpidPackSize:
|
||||||
if (!item.IsDir())
|
if (!item.IsDir())
|
||||||
prop = (UInt64)ref.TotalSize;
|
prop = (UInt64)ref.TotalSize;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kpidMTime:
|
case kpidMTime:
|
||||||
|
// case kpidCTime:
|
||||||
|
// case kpidATime:
|
||||||
{
|
{
|
||||||
FILETIME utc;
|
FILETIME utc;
|
||||||
if (item.DateTime.GetFileTime(utc))
|
if (/* propID == kpidMTime && */ item.DateTime.GetFileTime(utc))
|
||||||
prop = utc;
|
prop = utc;
|
||||||
|
/*
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UInt32 t = 0;
|
||||||
|
switch (propID)
|
||||||
|
{
|
||||||
|
case kpidMTime: t = k_Tf_MTime; break;
|
||||||
|
case kpidCTime: t = k_Tf_CTime; break;
|
||||||
|
case kpidATime: t = k_Tf_ATime; break;
|
||||||
|
}
|
||||||
|
CRecordingDateTime dt;
|
||||||
|
if (item.GetTf(_archive.SuspSkipSize, t, dt))
|
||||||
|
{
|
||||||
|
FILETIME utc;
|
||||||
|
if (dt.GetFileTime(utc))
|
||||||
|
prop = utc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -321,8 +398,10 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
|||||||
UInt64 offset = 0;
|
UInt64 offset = 0;
|
||||||
for (UInt32 e = 0; e < ref.NumExtents; e++)
|
for (UInt32 e = 0; e < ref.NumExtents; e++)
|
||||||
{
|
{
|
||||||
lps->InSize = lps->OutSize = currentTotalSize + offset;
|
|
||||||
const CDir &item2 = ref.Dir->_subItems[ref.Index + e];
|
const CDir &item2 = ref.Dir->_subItems[ref.Index + e];
|
||||||
|
if (item2.Size == 0)
|
||||||
|
continue;
|
||||||
|
lps->InSize = lps->OutSize = currentTotalSize + offset;
|
||||||
RINOK(_stream->Seek((UInt64)item2.ExtentLocation * kBlockSize, STREAM_SEEK_SET, NULL));
|
RINOK(_stream->Seek((UInt64)item2.ExtentLocation * kBlockSize, STREAM_SEEK_SET, NULL));
|
||||||
streamSpec->Init(item2.Size);
|
streamSpec->Init(item2.Size);
|
||||||
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
|
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
|
||||||
|
|||||||
@@ -608,7 +608,7 @@ HRESULT CInArchive::Open2()
|
|||||||
for (UInt32 j = 0; j < ref.NumExtents; j++)
|
for (UInt32 j = 0; j < ref.NumExtents; j++)
|
||||||
{
|
{
|
||||||
const CDir &item = ref.Dir->_subItems[ref.Index + j];
|
const CDir &item = ref.Dir->_subItems[ref.Index + j];
|
||||||
if (!item.IsDir())
|
if (!item.IsDir() && item.Size != 0)
|
||||||
UpdatePhySize(item.ExtentLocation, item.Size);
|
UpdatePhySize(item.ExtentLocation, item.Size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
#ifndef __ARCHIVE_ISO_ITEM_H
|
#ifndef __ARCHIVE_ISO_ITEM_H
|
||||||
#define __ARCHIVE_ISO_ITEM_H
|
#define __ARCHIVE_ISO_ITEM_H
|
||||||
|
|
||||||
|
#include "../../../../C/CpuArch.h"
|
||||||
|
|
||||||
#include "../../../Common/MyString.h"
|
#include "../../../Common/MyString.h"
|
||||||
#include "../../../Common/MyBuffer.h"
|
#include "../../../Common/MyBuffer.h"
|
||||||
|
|
||||||
@@ -38,6 +40,32 @@ struct CRecordingDateTime
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum EPx
|
||||||
|
{
|
||||||
|
k_Px_Mode,
|
||||||
|
k_Px_Links,
|
||||||
|
k_Px_User,
|
||||||
|
k_Px_Group,
|
||||||
|
k_Px_SerialNumber
|
||||||
|
|
||||||
|
// k_Px_Num
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
enum ETf
|
||||||
|
{
|
||||||
|
k_Tf_CTime,
|
||||||
|
k_Tf_MTime,
|
||||||
|
k_Tf_ATime,
|
||||||
|
k_Tf_Attrib,
|
||||||
|
k_Tf_Backup,
|
||||||
|
k_Tf_Expiration,
|
||||||
|
k_Tf_Effective
|
||||||
|
|
||||||
|
// k_Tf_Num
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
struct CDirRecord
|
struct CDirRecord
|
||||||
{
|
{
|
||||||
UInt32 ExtentLocation;
|
UInt32 ExtentLocation;
|
||||||
@@ -69,7 +97,8 @@ struct CDirRecord
|
|||||||
return (b == 0 || b == 1);
|
return (b == 0 || b == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Byte* FindSuspName(unsigned skipSize, unsigned &lenRes) const
|
|
||||||
|
const Byte* FindSuspRecord(unsigned skipSize, Byte id0, Byte id1, unsigned &lenRes) const
|
||||||
{
|
{
|
||||||
lenRes = 0;
|
lenRes = 0;
|
||||||
if (SystemUse.Size() < skipSize)
|
if (SystemUse.Size() < skipSize)
|
||||||
@@ -81,12 +110,12 @@ struct CDirRecord
|
|||||||
unsigned len = p[2];
|
unsigned len = p[2];
|
||||||
if (len < 3 || len > rem)
|
if (len < 3 || len > rem)
|
||||||
return 0;
|
return 0;
|
||||||
if (p[0] == 'N' && p[1] == 'M' && p[3] == 1)
|
if (p[0] == id0 && p[1] == id1 && p[3] == 1)
|
||||||
{
|
{
|
||||||
if (len < 5)
|
if (len < 4)
|
||||||
return 0; // Check it
|
return 0; // Check it
|
||||||
lenRes = len - 5;
|
lenRes = len - 4;
|
||||||
return p + 5;
|
return p + 4;
|
||||||
}
|
}
|
||||||
p += len;
|
p += len;
|
||||||
rem -= len;
|
rem -= len;
|
||||||
@@ -94,17 +123,23 @@ struct CDirRecord
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Byte* GetNameCur(bool checkSusp, int skipSize, unsigned &nameLenRes) const
|
const Byte* GetNameCur(bool checkSusp, int skipSize, unsigned &nameLenRes) const
|
||||||
{
|
{
|
||||||
const Byte *res = NULL;
|
const Byte *res = NULL;
|
||||||
unsigned len = 0;
|
unsigned len = 0;
|
||||||
if (checkSusp)
|
if (checkSusp)
|
||||||
res = FindSuspName(skipSize, len);
|
res = FindSuspRecord(skipSize, 'N', 'M', len);
|
||||||
if (!res)
|
if (!res || len < 1)
|
||||||
{
|
{
|
||||||
res = (const Byte *)FileId;
|
res = (const Byte *)FileId;
|
||||||
len = (unsigned)FileId.Size();
|
len = (unsigned)FileId.Size();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res++;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
if (res[i] == 0)
|
if (res[i] == 0)
|
||||||
@@ -114,6 +149,141 @@ struct CDirRecord
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const bool GetSymLink(int skipSize, AString &link) const
|
||||||
|
{
|
||||||
|
link.Empty();
|
||||||
|
const Byte *p = NULL;
|
||||||
|
unsigned len = 0;
|
||||||
|
p = FindSuspRecord(skipSize, 'S', 'L', len);
|
||||||
|
if (!p || len < 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (*p != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
p++;
|
||||||
|
len--;
|
||||||
|
|
||||||
|
while (len != 0)
|
||||||
|
{
|
||||||
|
if (len < 2)
|
||||||
|
return false;
|
||||||
|
unsigned flags = p[0];
|
||||||
|
unsigned cl = p[1];
|
||||||
|
p += 2;
|
||||||
|
len -= 2;
|
||||||
|
|
||||||
|
if (cl > len)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool needSlash = false;
|
||||||
|
|
||||||
|
if (flags & (1 << 1)) link += "./";
|
||||||
|
else if (flags & (1 << 2)) link += "../";
|
||||||
|
else if (flags & (1 << 3)) link += '/';
|
||||||
|
else
|
||||||
|
needSlash = true;
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < cl; i++)
|
||||||
|
{
|
||||||
|
char c = p[i];
|
||||||
|
if (c == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
// return false;
|
||||||
|
}
|
||||||
|
link += c;
|
||||||
|
}
|
||||||
|
|
||||||
|
p += cl;
|
||||||
|
len -= cl;
|
||||||
|
|
||||||
|
if (len == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (needSlash)
|
||||||
|
link += '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const bool GetLe32Be32(const Byte *p, UInt32 &dest)
|
||||||
|
{
|
||||||
|
UInt32 v1 = GetUi32(p);
|
||||||
|
UInt32 v2 = GetBe32(p + 4);
|
||||||
|
if (v1 == v2)
|
||||||
|
{
|
||||||
|
dest = v1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const bool GetPx(int skipSize, unsigned pxType, UInt32 &val) const
|
||||||
|
{
|
||||||
|
const Byte *p = NULL;
|
||||||
|
unsigned len = 0;
|
||||||
|
p = FindSuspRecord(skipSize, 'P', 'X', len);
|
||||||
|
if (!p)
|
||||||
|
return false;
|
||||||
|
// px.Clear();
|
||||||
|
if (len < ((unsigned)pxType + 1) * 8)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return GetLe32Be32(p + pxType * 8, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
const bool GetTf(int skipSize, unsigned pxType, CRecordingDateTime &t) const
|
||||||
|
{
|
||||||
|
const Byte *p = NULL;
|
||||||
|
unsigned len = 0;
|
||||||
|
p = FindSuspRecord(skipSize, 'T', 'F', len);
|
||||||
|
if (!p)
|
||||||
|
return false;
|
||||||
|
if (len < 1)
|
||||||
|
return false;
|
||||||
|
Byte flags = *p++;
|
||||||
|
len--;
|
||||||
|
|
||||||
|
unsigned step = 7;
|
||||||
|
if (flags & 0x80)
|
||||||
|
{
|
||||||
|
step = 17;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((flags & (1 << pxType)) == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < pxType; i++)
|
||||||
|
{
|
||||||
|
if (len < step)
|
||||||
|
return false;
|
||||||
|
if (flags & (1 << i))
|
||||||
|
{
|
||||||
|
p += step;
|
||||||
|
len -= step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (len < step)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
t.Year = p[0];
|
||||||
|
t.Month = p[1];
|
||||||
|
t.Day = p[2];
|
||||||
|
t.Hour = p[3];
|
||||||
|
t.Minute = p[4];
|
||||||
|
t.Second = p[5];
|
||||||
|
t.GmtOffset = (signed char)p[6];
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
bool CheckSusp(const Byte *p, unsigned &startPos) const
|
bool CheckSusp(const Byte *p, unsigned &startPos) const
|
||||||
{
|
{
|
||||||
if (p[0] == 'S' &&
|
if (p[0] == 'S' &&
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ static const CUInt32PCharPair g_CpuPairs[] =
|
|||||||
|
|
||||||
#define SECT_ATTR_ZEROFILL 1
|
#define SECT_ATTR_ZEROFILL 1
|
||||||
|
|
||||||
static const char *g_SectTypes[] =
|
static const char * const g_SectTypes[] =
|
||||||
{
|
{
|
||||||
"REGULAR"
|
"REGULAR"
|
||||||
, "ZEROFILL"
|
, "ZEROFILL"
|
||||||
@@ -108,7 +108,7 @@ enum EFileType
|
|||||||
kType_DSYM
|
kType_DSYM
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *g_FileTypes[] =
|
static const char * const g_FileTypes[] =
|
||||||
{
|
{
|
||||||
"0"
|
"0"
|
||||||
, "OBJECT"
|
, "OBJECT"
|
||||||
@@ -124,7 +124,7 @@ static const char *g_FileTypes[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const char *g_ArcFlags[] =
|
static const char * const g_ArcFlags[] =
|
||||||
{
|
{
|
||||||
"NOUNDEFS"
|
"NOUNDEFS"
|
||||||
, "INCRLINK"
|
, "INCRLINK"
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "../../Compress/BcjCoder.h"
|
#include "../../Compress/BcjCoder.h"
|
||||||
#include "../../Compress/BZip2Decoder.h"
|
#include "../../Compress/BZip2Decoder.h"
|
||||||
#include "../../Compress/DeflateDecoder.h"
|
|
||||||
|
|
||||||
#define Get32(p) GetUi32(p)
|
#define Get32(p) GetUi32(p)
|
||||||
|
|
||||||
@@ -27,12 +26,16 @@ HRESULT CDecoder::Init(ISequentialInStream *inStream, bool &useFilter)
|
|||||||
if (Method != _curMethod)
|
if (Method != _curMethod)
|
||||||
Release();
|
Release();
|
||||||
_curMethod = Method;
|
_curMethod = Method;
|
||||||
|
|
||||||
if (!_codecInStream)
|
if (!_codecInStream)
|
||||||
{
|
{
|
||||||
switch (Method)
|
switch (Method)
|
||||||
{
|
{
|
||||||
// case NMethodType::kCopy: return E_NOTIMPL;
|
// case NMethodType::kCopy: return E_NOTIMPL;
|
||||||
case NMethodType::kDeflate: _codecInStream = new NCompress::NDeflate::NDecoder::CNsisCOMCoder(); break;
|
case NMethodType::kDeflate:
|
||||||
|
_deflateDecoder = new NCompress::NDeflate::NDecoder::CCOMCoder();
|
||||||
|
_codecInStream = _deflateDecoder;
|
||||||
|
break;
|
||||||
case NMethodType::kBZip2: _codecInStream = new NCompress::NBZip2::CNsisDecoder(); break;
|
case NMethodType::kBZip2: _codecInStream = new NCompress::NBZip2::CNsisDecoder(); break;
|
||||||
case NMethodType::kLZMA:
|
case NMethodType::kLZMA:
|
||||||
_lzmaDecoder = new NCompress::NLzma::CDecoder();
|
_lzmaDecoder = new NCompress::NLzma::CDecoder();
|
||||||
@@ -42,6 +45,9 @@ HRESULT CDecoder::Init(ISequentialInStream *inStream, bool &useFilter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Method == NMethodType::kDeflate)
|
||||||
|
_deflateDecoder->SetNsisMode(IsNsisDeflate);
|
||||||
|
|
||||||
if (FilterFlag)
|
if (FilterFlag)
|
||||||
{
|
{
|
||||||
Byte flag;
|
Byte flag;
|
||||||
@@ -199,8 +205,7 @@ HRESULT CDecoder::Decode(CByteBuffer *outBuf, bool unpackSizeDefined, UInt32 unp
|
|||||||
|
|
||||||
if (outBuf)
|
if (outBuf)
|
||||||
{
|
{
|
||||||
if (!unpackSizeDefined)
|
if (unpackSizeDefined)
|
||||||
return S_FALSE;
|
|
||||||
outBuf->Alloc(unpackSize);
|
outBuf->Alloc(unpackSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,6 +218,8 @@ HRESULT CDecoder::Decode(CByteBuffer *outBuf, bool unpackSizeDefined, UInt32 unp
|
|||||||
unpackSize = 0xFFFFFFFF;
|
unpackSize = 0xFFFFFFFF;
|
||||||
UInt32 offset = 0;
|
UInt32 offset = 0;
|
||||||
|
|
||||||
|
HRESULT res = S_OK;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
size_t rem = unpackSize - offset;
|
size_t rem = unpackSize - offset;
|
||||||
@@ -225,11 +232,25 @@ HRESULT CDecoder::Decode(CByteBuffer *outBuf, bool unpackSizeDefined, UInt32 unp
|
|||||||
if (size == 0)
|
if (size == 0)
|
||||||
{
|
{
|
||||||
if (unpackSizeDefined)
|
if (unpackSizeDefined)
|
||||||
return S_FALSE;
|
res = S_FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outBuf)
|
if (outBuf)
|
||||||
|
{
|
||||||
|
size_t nextSize = offset + size;
|
||||||
|
if (outBuf->Size() < nextSize)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
const size_t nextSize2 = outBuf->Size() * 2;
|
||||||
|
if (nextSize < nextSize2)
|
||||||
|
nextSize = nextSize2;
|
||||||
|
}
|
||||||
|
outBuf->ChangeSize_KeepData(nextSize, offset);
|
||||||
|
}
|
||||||
memcpy((Byte *)*outBuf + (size_t)offset, Buffer, size);
|
memcpy((Byte *)*outBuf + (size_t)offset, Buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
StreamPos += size;
|
StreamPos += size;
|
||||||
offset += (UInt32)size;
|
offset += (UInt32)size;
|
||||||
|
|
||||||
@@ -243,9 +264,17 @@ HRESULT CDecoder::Decode(CByteBuffer *outBuf, bool unpackSizeDefined, UInt32 unp
|
|||||||
UInt64 outSize = offset;
|
UInt64 outSize = offset;
|
||||||
RINOK(progress->SetRatioInfo(&inSize, &outSize));
|
RINOK(progress->SetRatioInfo(&inSize, &outSize));
|
||||||
if (realOutStream)
|
if (realOutStream)
|
||||||
RINOK(WriteStream(realOutStream, Buffer, size));
|
{
|
||||||
|
res = WriteStream(realOutStream, Buffer, size);
|
||||||
|
if (res != S_OK)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return S_OK;
|
}
|
||||||
|
|
||||||
|
if (outBuf && offset != outBuf->Size())
|
||||||
|
outBuf->ChangeSize_KeepData(offset, offset);
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "../../Common/FilterCoder.h"
|
#include "../../Common/FilterCoder.h"
|
||||||
#include "../../Common/StreamUtils.h"
|
#include "../../Common/StreamUtils.h"
|
||||||
|
|
||||||
|
#include "../../Compress/DeflateDecoder.h"
|
||||||
#include "../../Compress/LzmaDecoder.h"
|
#include "../../Compress/LzmaDecoder.h"
|
||||||
|
|
||||||
namespace NArchive {
|
namespace NArchive {
|
||||||
@@ -37,6 +38,7 @@ class CDecoder
|
|||||||
CMyComPtr<ISequentialInStream> _codecInStream;
|
CMyComPtr<ISequentialInStream> _codecInStream;
|
||||||
CMyComPtr<ISequentialInStream> _decoderInStream;
|
CMyComPtr<ISequentialInStream> _decoderInStream;
|
||||||
|
|
||||||
|
NCompress::NDeflate::NDecoder::CCOMCoder *_deflateDecoder;
|
||||||
NCompress::NLzma::CDecoder *_lzmaDecoder;
|
NCompress::NLzma::CDecoder *_lzmaDecoder;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -46,9 +48,16 @@ public:
|
|||||||
NMethodType::EEnum Method;
|
NMethodType::EEnum Method;
|
||||||
bool FilterFlag;
|
bool FilterFlag;
|
||||||
bool Solid;
|
bool Solid;
|
||||||
|
bool IsNsisDeflate;
|
||||||
|
|
||||||
CByteBuffer Buffer; // temp buf.
|
CByteBuffer Buffer; // temp buf.
|
||||||
|
|
||||||
|
CDecoder():
|
||||||
|
FilterFlag(false),
|
||||||
|
Solid(true),
|
||||||
|
IsNsisDeflate(true)
|
||||||
|
{}
|
||||||
|
|
||||||
void Release()
|
void Release()
|
||||||
{
|
{
|
||||||
_filterInStream.Release();
|
_filterInStream.Release();
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ static const CCommandInfo k_Commands[kNumCmds] =
|
|||||||
{ 0 }, // "BringToFront" },
|
{ 0 }, // "BringToFront" },
|
||||||
{ 2 }, // "SetDetailsView" },
|
{ 2 }, // "SetDetailsView" },
|
||||||
{ 2 }, // "SetFileAttributes" },
|
{ 2 }, // "SetFileAttributes" },
|
||||||
{ 2 }, // CreateDirectory, SetOutPath
|
{ 3 }, // CreateDirectory, SetOutPath
|
||||||
{ 3 }, // "IfFileExists" },
|
{ 3 }, // "IfFileExists" },
|
||||||
{ 3 }, // SetRebootFlag, ...
|
{ 3 }, // SetRebootFlag, ...
|
||||||
{ 4 }, // "If" }, // IfAbort, IfSilent, IfErrors, IfRebootFlag
|
{ 4 }, // "If" }, // IfAbort, IfSilent, IfErrors, IfRebootFlag
|
||||||
@@ -1395,7 +1395,7 @@ void CInArchive::AddRegRoot(UInt32 val)
|
|||||||
Script += s;
|
Script += s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *g_WinAttrib[] =
|
static const char * const g_WinAttrib[] =
|
||||||
{
|
{
|
||||||
"READONLY"
|
"READONLY"
|
||||||
, "HIDDEN"
|
, "HIDDEN"
|
||||||
@@ -3362,6 +3362,11 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
|||||||
#ifdef NSIS_SCRIPT
|
#ifdef NSIS_SCRIPT
|
||||||
s += isSetOutPath ? "SetOutPath" : "CreateDirectory";
|
s += isSetOutPath ? "SetOutPath" : "CreateDirectory";
|
||||||
AddParam(params[0]);
|
AddParam(params[0]);
|
||||||
|
if (params[2] != 0)
|
||||||
|
{
|
||||||
|
SmallSpaceComment();
|
||||||
|
s += "CreateRestrictedDirectory";
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -3377,14 +3382,11 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
|||||||
if (IsVarStr(params[1], kVar_OUTDIR) &&
|
if (IsVarStr(params[1], kVar_OUTDIR) &&
|
||||||
params[2] == 0 &&
|
params[2] == 0 &&
|
||||||
params[3] == 0)
|
params[3] == 0)
|
||||||
{
|
|
||||||
if (IsVarStr(params[1], kVar_OUTDIR))
|
|
||||||
{
|
{
|
||||||
spec_outdir_U = UPrefixes.Back(); // outdir_U;
|
spec_outdir_U = UPrefixes.Back(); // outdir_U;
|
||||||
spec_outdir_A = APrefixes.Back(); // outdir_A;
|
spec_outdir_A = APrefixes.Back(); // outdir_A;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef NSIS_SCRIPT
|
#ifdef NSIS_SCRIPT
|
||||||
|
|
||||||
@@ -5045,6 +5047,9 @@ HRESULT CInArchive::Parse()
|
|||||||
|
|
||||||
DetectNsisType(bhEntries, _data + bhEntries.Offset);
|
DetectNsisType(bhEntries, _data + bhEntries.Offset);
|
||||||
|
|
||||||
|
Decoder.IsNsisDeflate = (NsisType != k_NsisType_Nsis3);
|
||||||
|
|
||||||
|
|
||||||
#ifdef NSIS_SCRIPT
|
#ifdef NSIS_SCRIPT
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -5606,6 +5611,9 @@ HRESULT CInArchive::Open2(const Byte *sig, size_t size)
|
|||||||
Decoder.Method = Method;
|
Decoder.Method = Method;
|
||||||
Decoder.FilterFlag = FilterFlag;
|
Decoder.FilterFlag = FilterFlag;
|
||||||
Decoder.Solid = IsSolid;
|
Decoder.Solid = IsSolid;
|
||||||
|
|
||||||
|
Decoder.IsNsisDeflate = true; // we need some smart check that NSIS is not NSIS3 here.
|
||||||
|
|
||||||
Decoder.InputStream = _stream;
|
Decoder.InputStream = _stream;
|
||||||
Decoder.Buffer.Alloc(kInputBufSize);
|
Decoder.Buffer.Alloc(kInputBufSize);
|
||||||
Decoder.StreamPos = 0;
|
Decoder.StreamPos = 0;
|
||||||
|
|||||||
@@ -2157,7 +2157,7 @@ STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
const CItem &item = Items[index];
|
const CItem &item = Items[index];
|
||||||
const CMftRec &rec = Recs[item.RecIndex];
|
const CMftRec &rec = Recs[item.RecIndex];
|
||||||
if (rec.SiAttr.SecurityId >= 0)
|
if (rec.SiAttr.SecurityId > 0)
|
||||||
{
|
{
|
||||||
UInt64 offset;
|
UInt64 offset;
|
||||||
UInt32 size;
|
UInt32 size;
|
||||||
@@ -2169,6 +2169,7 @@ STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ bool COptHeader::Parse(const Byte *p, UInt32 size)
|
|||||||
if (NumDirItems > (1 << 16))
|
if (NumDirItems > (1 << 16))
|
||||||
return false;
|
return false;
|
||||||
pos += 4;
|
pos += 4;
|
||||||
if (pos + 8 * NumDirItems != size)
|
if (pos + 8 * NumDirItems > size)
|
||||||
return false;
|
return false;
|
||||||
for (UInt32 i = 0; i < NumDirItems && i < kNumDirItemsMax; i++)
|
for (UInt32 i = 0; i < NumDirItems && i < kNumDirItemsMax; i++)
|
||||||
DirItems[i].Parse(p + pos + i * 8);
|
DirItems[i].Parse(p + pos + i * 8);
|
||||||
|
|||||||
@@ -959,7 +959,7 @@ static HRESULT LzoDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *src
|
|||||||
*srcLen = 0;
|
*srcLen = 0;
|
||||||
const Byte *destStart = dest;
|
const Byte *destStart = dest;
|
||||||
const Byte *srcStart = src;
|
const Byte *srcStart = src;
|
||||||
unsigned mode = 2;
|
unsigned mode = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
if (srcRem == 0)
|
if (srcRem == 0)
|
||||||
@@ -970,7 +970,7 @@ static HRESULT LzoDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *src
|
|||||||
src++;
|
src++;
|
||||||
srcRem--;
|
srcRem--;
|
||||||
b -= 17;
|
b -= 17;
|
||||||
mode = (b < 4 ? 0 : 1);
|
mode = (b < 4 ? 1 : 4);
|
||||||
if (b > srcRem || b > destRem)
|
if (b > srcRem || b > destRem)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
srcRem -= b;
|
srcRem -= b;
|
||||||
@@ -988,6 +988,7 @@ static HRESULT LzoDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *src
|
|||||||
UInt32 b = *src++;
|
UInt32 b = *src++;
|
||||||
srcRem--;
|
srcRem--;
|
||||||
UInt32 len, back;
|
UInt32 len, back;
|
||||||
|
|
||||||
if (b >= 64)
|
if (b >= 64)
|
||||||
{
|
{
|
||||||
srcRem--;
|
srcRem--;
|
||||||
@@ -996,7 +997,7 @@ static HRESULT LzoDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *src
|
|||||||
}
|
}
|
||||||
else if (b < 16)
|
else if (b < 16)
|
||||||
{
|
{
|
||||||
if (mode == 2)
|
if (mode == 0)
|
||||||
{
|
{
|
||||||
if (b == 0)
|
if (b == 0)
|
||||||
{
|
{
|
||||||
@@ -1013,21 +1014,23 @@ static HRESULT LzoDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *src
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b += 3;
|
b += 3;
|
||||||
if (b > srcRem || b > destRem)
|
if (b > srcRem || b > destRem)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
srcRem -= b;
|
srcRem -= b;
|
||||||
destRem -= b;
|
destRem -= b;
|
||||||
mode = 1;
|
mode = 4;
|
||||||
do
|
do
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
while (--b);
|
while (--b);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
srcRem--;
|
srcRem--;
|
||||||
back = (b >> 2) + (*src++ << 2);
|
back = (b >> 2) + (*src++ << 2);
|
||||||
len = 2;
|
len = 2;
|
||||||
if (mode == 1)
|
if (mode == 4)
|
||||||
{
|
{
|
||||||
back += (1 << 11);
|
back += (1 << 11);
|
||||||
len = 3;
|
len = 3;
|
||||||
@@ -1038,6 +1041,7 @@ static HRESULT LzoDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *src
|
|||||||
UInt32 bOld = b;
|
UInt32 bOld = b;
|
||||||
b = (b < 32 ? 7 : 31);
|
b = (b < 32 ? 7 : 31);
|
||||||
len = bOld & b;
|
len = bOld & b;
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
{
|
{
|
||||||
for (len = b;; len += 255)
|
for (len = b;; len += 255)
|
||||||
@@ -1053,6 +1057,7 @@ static HRESULT LzoDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *src
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
len += 2;
|
len += 2;
|
||||||
if (srcRem < 2)
|
if (srcRem < 2)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
@@ -1062,38 +1067,39 @@ static HRESULT LzoDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *src
|
|||||||
srcRem -= 2;
|
srcRem -= 2;
|
||||||
if (bOld < 32)
|
if (bOld < 32)
|
||||||
{
|
{
|
||||||
|
back += ((bOld & 8) << 11);
|
||||||
if (back == 0)
|
if (back == 0)
|
||||||
{
|
{
|
||||||
*destLen = dest - destStart;
|
*destLen = dest - destStart;
|
||||||
*srcLen = src - srcStart;
|
*srcLen = src - srcStart;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
back += ((bOld & 8) << 11) + (1 << 14) - 1;
|
back += (1 << 14) - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
back++;
|
back++;
|
||||||
if (len > destRem || (size_t)(dest - destStart) < back)
|
if (len > destRem || (size_t)(dest - destStart) < back)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
destRem -= len;
|
destRem -= len;
|
||||||
Byte *destTemp = dest - back;
|
Byte *destTemp = dest - back;
|
||||||
dest += len;
|
dest += len;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
*(destTemp + back) = *destTemp;
|
*(destTemp + back) = *destTemp;
|
||||||
destTemp++;
|
destTemp++;
|
||||||
}
|
}
|
||||||
while (--len);
|
while (--len);
|
||||||
|
|
||||||
b &= 3;
|
b &= 3;
|
||||||
|
mode = b;
|
||||||
if (b == 0)
|
if (b == 0)
|
||||||
{
|
|
||||||
mode = 2;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (b > srcRem || b > destRem)
|
if (b > srcRem || b > destRem)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
srcRem -= b;
|
srcRem -= b;
|
||||||
destRem -= b;
|
destRem -= b;
|
||||||
mode = 0;
|
|
||||||
*dest++ = *src++;
|
*dest++ = *src++;
|
||||||
if (b > 1)
|
if (b > 1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -646,7 +646,7 @@ STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *g_TagDesc[92] =
|
static const char * const g_TagDesc[92] =
|
||||||
{
|
{
|
||||||
"End"
|
"End"
|
||||||
, "ShowFrame"
|
, "ShowFrame"
|
||||||
|
|||||||
@@ -72,6 +72,13 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case kpidWarningFlags:
|
||||||
|
{
|
||||||
|
if (_warning)
|
||||||
|
prop = kpv_ErrorFlags_HeadersError;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case kpidCodePage:
|
case kpidCodePage:
|
||||||
{
|
{
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
@@ -98,7 +105,13 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
|||||||
HRESULT CHandler::ReadItem2(ISequentialInStream *stream, bool &filled, CItemEx &item)
|
HRESULT CHandler::ReadItem2(ISequentialInStream *stream, bool &filled, CItemEx &item)
|
||||||
{
|
{
|
||||||
item.HeaderPos = _phySize;
|
item.HeaderPos = _phySize;
|
||||||
RINOK(ReadItem(stream, filled, item, _error));
|
EErrorType error;
|
||||||
|
HRESULT res = ReadItem(stream, filled, item, error);
|
||||||
|
if (error == k_ErrorType_Warning)
|
||||||
|
_warning = true;
|
||||||
|
else if (error != k_ErrorType_OK)
|
||||||
|
_error = error;
|
||||||
|
RINOK(res);
|
||||||
if (filled)
|
if (filled)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -233,6 +246,7 @@ STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream)
|
|||||||
STDMETHODIMP CHandler::Close()
|
STDMETHODIMP CHandler::Close()
|
||||||
{
|
{
|
||||||
_isArc = false;
|
_isArc = false;
|
||||||
|
_warning = false;
|
||||||
_error = k_ErrorType_OK;
|
_error = k_ErrorType_OK;
|
||||||
|
|
||||||
_phySizeDefined = false;
|
_phySizeDefined = false;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ private:
|
|||||||
UInt64 _headersSize;
|
UInt64 _headersSize;
|
||||||
bool _phySizeDefined;
|
bool _phySizeDefined;
|
||||||
EErrorType _error;
|
EErrorType _error;
|
||||||
|
bool _warning;
|
||||||
bool _isArc;
|
bool _isArc;
|
||||||
|
|
||||||
// bool _isSparse;
|
// bool _isSparse;
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
|||||||
{
|
{
|
||||||
COM_TRY_BEGIN
|
COM_TRY_BEGIN
|
||||||
|
|
||||||
if ((_stream && (_error != k_ErrorType_OK /* || _isSparse */)) || _seqStream)
|
if ((_stream && (_error != k_ErrorType_OK || _warning /* || _isSparse */)) || _seqStream)
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
CObjectVector<CUpdateItem> updateItems;
|
CObjectVector<CUpdateItem> updateItems;
|
||||||
UINT codePage = (_forceCodePage ? _specifiedCodePage : _openCodePage);
|
UINT codePage = (_forceCodePage ? _specifiedCodePage : _openCodePage);
|
||||||
|
|||||||
@@ -328,13 +328,63 @@ static HRESULT GetNextItemReal(ISequentialInStream *stream, bool &filled, CItemE
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static HRESULT ReadDataToString(ISequentialInStream *stream, CItemEx &item, AString &s, EErrorType &error)
|
||||||
|
{
|
||||||
|
const unsigned packSize = (unsigned)item.GetPackSizeAligned();
|
||||||
|
size_t processedSize = packSize;
|
||||||
|
HRESULT res = ReadStream(stream, s.GetBuf(packSize), &processedSize);
|
||||||
|
item.HeaderSize += (unsigned)processedSize;
|
||||||
|
s.ReleaseBuf_CalcLen((unsigned)item.PackSize);
|
||||||
|
RINOK(res);
|
||||||
|
if (processedSize != packSize)
|
||||||
|
error = k_ErrorType_UnexpectedEnd;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ParsePaxLongName(const AString &src, AString &dest)
|
||||||
|
{
|
||||||
|
dest.Empty();
|
||||||
|
for (unsigned pos = 0;;)
|
||||||
|
{
|
||||||
|
if (pos >= src.Len())
|
||||||
|
return false;
|
||||||
|
const char *start = src.Ptr(pos);
|
||||||
|
const char *end;
|
||||||
|
const UInt32 lineLen = ConvertStringToUInt32(start, &end);
|
||||||
|
if (end == start)
|
||||||
|
return false;
|
||||||
|
if (*end != ' ')
|
||||||
|
return false;
|
||||||
|
if (lineLen > src.Len() - pos)
|
||||||
|
return false;
|
||||||
|
unsigned offset = (unsigned)(end - start) + 1;
|
||||||
|
if (lineLen < offset)
|
||||||
|
return false;
|
||||||
|
if (IsString1PrefixedByString2(src.Ptr(pos + offset), "path="))
|
||||||
|
{
|
||||||
|
offset += 5; // "path="
|
||||||
|
dest = src.Mid(pos + offset, lineLen - offset);
|
||||||
|
if (dest.IsEmpty())
|
||||||
|
return false;
|
||||||
|
if (dest.Back() != '\n')
|
||||||
|
return false;
|
||||||
|
dest.DeleteBack();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
pos += lineLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &item, EErrorType &error)
|
HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &item, EErrorType &error)
|
||||||
{
|
{
|
||||||
item.HeaderSize = 0;
|
item.HeaderSize = 0;
|
||||||
|
|
||||||
bool flagL = false;
|
bool flagL = false;
|
||||||
bool flagK = false;
|
bool flagK = false;
|
||||||
AString nameL;
|
AString nameL;
|
||||||
AString nameK;
|
AString nameK;
|
||||||
|
AString pax;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@@ -363,18 +413,11 @@ HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &item, EErro
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
if (item.PackSize > (1 << 14))
|
if (item.PackSize > (1 << 14))
|
||||||
return S_OK;
|
return S_OK;
|
||||||
unsigned packSize = (unsigned)item.GetPackSizeAligned();
|
|
||||||
char *buf = name->GetBuf(packSize);
|
RINOK(ReadDataToString(stream, item, *name, error));
|
||||||
size_t processedSize = packSize;
|
if (error != k_ErrorType_OK)
|
||||||
HRESULT res = ReadStream(stream, buf, &processedSize);
|
|
||||||
item.HeaderSize += (unsigned)processedSize;
|
|
||||||
name->ReleaseBuf_CalcLen((unsigned)item.PackSize);
|
|
||||||
RINOK(res);
|
|
||||||
if (processedSize != packSize)
|
|
||||||
{
|
|
||||||
error = k_ErrorType_UnexpectedEnd;
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,6 +428,14 @@ HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &item, EErro
|
|||||||
case 'X':
|
case 'X':
|
||||||
{
|
{
|
||||||
// pax Extended Header
|
// pax Extended Header
|
||||||
|
if (item.Name.IsPrefixedBy("PaxHeader/"))
|
||||||
|
{
|
||||||
|
RINOK(ReadDataToString(stream, item, pax, error));
|
||||||
|
if (error != k_ErrorType_OK)
|
||||||
|
return S_OK;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NFileHeader::NLinkFlag::kDumpDir:
|
case NFileHeader::NLinkFlag::kDumpDir:
|
||||||
@@ -415,6 +466,16 @@ HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &item, EErro
|
|||||||
}
|
}
|
||||||
|
|
||||||
error = k_ErrorType_OK;
|
error = k_ErrorType_OK;
|
||||||
|
|
||||||
|
if (!pax.IsEmpty())
|
||||||
|
{
|
||||||
|
AString name;
|
||||||
|
if (ParsePaxLongName(pax, name))
|
||||||
|
item.Name = name;
|
||||||
|
else
|
||||||
|
error = k_ErrorType_Warning;
|
||||||
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ enum EErrorType
|
|||||||
k_ErrorType_OK,
|
k_ErrorType_OK,
|
||||||
k_ErrorType_Corrupted,
|
k_ErrorType_Corrupted,
|
||||||
k_ErrorType_UnexpectedEnd,
|
k_ErrorType_UnexpectedEnd,
|
||||||
|
k_ErrorType_Warning
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &itemInfo, EErrorType &error);
|
HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &itemInfo, EErrorType &error);
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ enum
|
|||||||
FV_FILETYPE_FFS_PAD = 0xF0
|
FV_FILETYPE_FFS_PAD = 0xF0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *g_FileTypes[] =
|
static const char * const g_FileTypes[] =
|
||||||
{
|
{
|
||||||
"ALL"
|
"ALL"
|
||||||
, "RAW"
|
, "RAW"
|
||||||
|
|||||||
@@ -298,7 +298,8 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
|||||||
|
|
||||||
AString res;
|
AString res;
|
||||||
|
|
||||||
bool numMethods = 0;
|
unsigned numMethods = 0;
|
||||||
|
|
||||||
for (unsigned i = 0; i < ARRAY_SIZE(k_Methods); i++)
|
for (unsigned i = 0; i < ARRAY_SIZE(k_Methods); i++)
|
||||||
{
|
{
|
||||||
if (methodMask & ((UInt32)1 << i))
|
if (methodMask & ((UInt32)1 << i))
|
||||||
|
|||||||
@@ -255,13 +255,13 @@ static bool AddItem(const CXmlItem &item, CObjectVector<CFile> &files, int paren
|
|||||||
if (encodingItem.IsTag)
|
if (encodingItem.IsTag)
|
||||||
{
|
{
|
||||||
AString s = encodingItem.GetPropVal("style");
|
AString s = encodingItem.GetPropVal("style");
|
||||||
if (s.Len() >= 0)
|
if (!s.IsEmpty())
|
||||||
{
|
{
|
||||||
AString appl = "application/";
|
const AString appl = "application/";
|
||||||
if (s.IsPrefixedBy(appl))
|
if (s.IsPrefixedBy(appl))
|
||||||
{
|
{
|
||||||
s.DeleteFrontal(appl.Len());
|
s.DeleteFrontal(appl.Len());
|
||||||
AString xx = "x-";
|
const AString xx = "x-";
|
||||||
if (s.IsPrefixedBy(xx))
|
if (s.IsPrefixedBy(xx))
|
||||||
{
|
{
|
||||||
s.DeleteFrontal(xx.Len());
|
s.DeleteFrontal(xx.Len());
|
||||||
@@ -365,12 +365,12 @@ HRESULT CHandler::Open2(IInStream *stream)
|
|||||||
{
|
{
|
||||||
const CFile &file = _files[i];
|
const CFile &file = _files[i];
|
||||||
file.UpdateTotalPackSize(totalPackSize);
|
file.UpdateTotalPackSize(totalPackSize);
|
||||||
if (file.Name == "Payload")
|
if (file.Name == "Payload" || file.Name == "Content")
|
||||||
{
|
{
|
||||||
_mainSubfile = i;
|
_mainSubfile = i;
|
||||||
numMainFiles++;
|
numMainFiles++;
|
||||||
}
|
}
|
||||||
if (file.Name == "PackageInfo")
|
else if (file.Name == "PackageInfo")
|
||||||
_is_pkg = true;
|
_is_pkg = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -723,7 +723,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
|||||||
static const Byte k_Signature[] = { 'x', 'a', 'r', '!', 0, 0x1C };
|
static const Byte k_Signature[] = { 'x', 'a', 'r', '!', 0, 0x1C };
|
||||||
|
|
||||||
REGISTER_ARC_I(
|
REGISTER_ARC_I(
|
||||||
"Xar", "xar pkg", 0, 0xE1,
|
"Xar", "xar pkg xip", 0, 0xE1,
|
||||||
k_Signature,
|
k_Signature,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
|||||||
EXTERNAL_CODECS_VARS
|
EXTERNAL_CODECS_VARS
|
||||||
m_Items, updateItems, outStream,
|
m_Items, updateItems, outStream,
|
||||||
m_Archive.IsOpen() ? &m_Archive : NULL, _removeSfxBlock,
|
m_Archive.IsOpen() ? &m_Archive : NULL, _removeSfxBlock,
|
||||||
&options, callback);
|
options, callback);
|
||||||
|
|
||||||
COM_TRY_END2
|
COM_TRY_END2
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1454,7 +1454,10 @@ HRESULT CVols::ParseArcName(IArchiveOpenVolumeCallback *volCallback)
|
|||||||
if (result == S_FALSE || !ZipStream)
|
if (result == S_FALSE || !ZipStream)
|
||||||
{
|
{
|
||||||
if (MissingName.IsEmpty())
|
if (MissingName.IsEmpty())
|
||||||
|
{
|
||||||
|
MissingZip = true;
|
||||||
MissingName = volName;
|
MissingName = volName;
|
||||||
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1988,6 +1991,12 @@ HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items)
|
|||||||
|
|
||||||
if (!IsMultiVol)
|
if (!IsMultiVol)
|
||||||
{
|
{
|
||||||
|
if (EcdVolIndex == 0 && Vols.MissingZip && Vols.StartIsExe)
|
||||||
|
{
|
||||||
|
Vols.MissingName.Empty();
|
||||||
|
Vols.MissingZip = false;
|
||||||
|
}
|
||||||
|
|
||||||
UseDisk_in_SingleVol = true;
|
UseDisk_in_SingleVol = true;
|
||||||
|
|
||||||
if (localsWereRead)
|
if (localsWereRead)
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ public:
|
|||||||
bool StartIsZ; // is .zip or .zNN
|
bool StartIsZ; // is .zip or .zNN
|
||||||
bool StartIsZip; // is .zip
|
bool StartIsZip; // is .zip
|
||||||
bool IsUpperCase;
|
bool IsUpperCase;
|
||||||
|
bool MissingZip;
|
||||||
Int32 StartVolIndex; // = (NN - 1), if StartStream is .zNN
|
Int32 StartVolIndex; // = (NN - 1), if StartStream is .zNN
|
||||||
|
|
||||||
Int32 StartParsingVol; // if we need local parsing, we must use that stream
|
Int32 StartParsingVol; // if we need local parsing, we must use that stream
|
||||||
@@ -173,6 +174,7 @@ public:
|
|||||||
BaseName.Empty();
|
BaseName.Empty();
|
||||||
MissingName.Empty();
|
MissingName.Empty();
|
||||||
|
|
||||||
|
MissingZip = false;
|
||||||
ecd_wasRead = false;
|
ecd_wasRead = false;
|
||||||
|
|
||||||
Streams.Clear();
|
Streams.Clear();
|
||||||
|
|||||||
@@ -584,7 +584,7 @@ static HRESULT Update2(
|
|||||||
CInArchive *inArchive,
|
CInArchive *inArchive,
|
||||||
const CObjectVector<CItemEx> &inputItems,
|
const CObjectVector<CItemEx> &inputItems,
|
||||||
CObjectVector<CUpdateItem> &updateItems,
|
CObjectVector<CUpdateItem> &updateItems,
|
||||||
const CCompressionMethodMode *options,
|
const CCompressionMethodMode &options,
|
||||||
const CByteBuffer *comment,
|
const CByteBuffer *comment,
|
||||||
IArchiveUpdateCallback *updateCallback)
|
IArchiveUpdateCallback *updateCallback)
|
||||||
{
|
{
|
||||||
@@ -629,17 +629,15 @@ static HRESULT Update2(
|
|||||||
|
|
||||||
UInt64 totalComplexity = complexity;
|
UInt64 totalComplexity = complexity;
|
||||||
|
|
||||||
CAddCommon compressor(*options);
|
CAddCommon compressor(options);
|
||||||
|
|
||||||
complexity = 0;
|
complexity = 0;
|
||||||
|
|
||||||
CCompressionMethodMode options2;
|
CCompressionMethodMode options2 = options;
|
||||||
if (options != 0)
|
|
||||||
options2 = *options;
|
|
||||||
|
|
||||||
#ifndef _7ZIP_ST
|
#ifndef _7ZIP_ST
|
||||||
|
|
||||||
UInt32 numThreads = options->NumThreads;
|
UInt32 numThreads = options.NumThreads;
|
||||||
const UInt32 kNumMaxThreads = 64;
|
const UInt32 kNumMaxThreads = 64;
|
||||||
if (numThreads > kNumMaxThreads)
|
if (numThreads > kNumMaxThreads)
|
||||||
numThreads = kNumMaxThreads;
|
numThreads = kNumMaxThreads;
|
||||||
@@ -652,12 +650,12 @@ static HRESULT Update2(
|
|||||||
const size_t kMemPerThread = (1 << 25);
|
const size_t kMemPerThread = (1 << 25);
|
||||||
const size_t kBlockSize = 1 << 16;
|
const size_t kBlockSize = 1 << 16;
|
||||||
|
|
||||||
bool mtMode = ((options != 0) && (numThreads > 1));
|
bool mtMode = (numThreads > 1);
|
||||||
|
|
||||||
if (numFilesToCompress <= 1)
|
if (numFilesToCompress <= 1)
|
||||||
mtMode = false;
|
mtMode = false;
|
||||||
|
|
||||||
Byte method = options->MethodSequence.Front();
|
Byte method = options.MethodSequence.Front();
|
||||||
|
|
||||||
if (!mtMode)
|
if (!mtMode)
|
||||||
{
|
{
|
||||||
@@ -670,7 +668,7 @@ static HRESULT Update2(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (method == NFileHeader::NCompressionMethod::kStored && !options->PasswordIsDefined)
|
if (method == NFileHeader::NCompressionMethod::kStored && !options.PasswordIsDefined)
|
||||||
numThreads = 1;
|
numThreads = 1;
|
||||||
if (method == NFileHeader::NCompressionMethod::kBZip2)
|
if (method == NFileHeader::NCompressionMethod::kBZip2)
|
||||||
{
|
{
|
||||||
@@ -855,16 +853,16 @@ static HRESULT Update2(
|
|||||||
|
|
||||||
if (isDir)
|
if (isDir)
|
||||||
{
|
{
|
||||||
WriteDirHeader(archive, options, ui, item);
|
WriteDirHeader(archive, &options, ui, item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (lastRealStreamItemIndex < (int)itemIndex)
|
if (lastRealStreamItemIndex < (int)itemIndex)
|
||||||
{
|
{
|
||||||
lastRealStreamItemIndex = itemIndex;
|
lastRealStreamItemIndex = itemIndex;
|
||||||
SetFileHeader(archive, *options, ui, item);
|
SetFileHeader(archive, options, ui, item);
|
||||||
// file Size can be 64-bit !!!
|
// file Size can be 64-bit !!!
|
||||||
archive.PrepareWriteCompressedData(item.Name.Len(), ui.Size, options->IsRealAesMode());
|
archive.PrepareWriteCompressedData(item.Name.Len(), ui.Size, options.IsRealAesMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
CMemBlocks2 &memRef = refs.Refs[itemIndex];
|
CMemBlocks2 &memRef = refs.Refs[itemIndex];
|
||||||
@@ -874,12 +872,12 @@ static HRESULT Update2(
|
|||||||
CMyComPtr<IOutStream> outStream;
|
CMyComPtr<IOutStream> outStream;
|
||||||
archive.CreateStreamForCompressing(&outStream);
|
archive.CreateStreamForCompressing(&outStream);
|
||||||
memRef.WriteToStream(memManager.GetBlockSize(), outStream);
|
memRef.WriteToStream(memManager.GetBlockSize(), outStream);
|
||||||
SetFileHeader(archive, *options, ui, item);
|
SetFileHeader(archive, options, ui, item);
|
||||||
// the BUG was fixed in 9.26:
|
// the BUG was fixed in 9.26:
|
||||||
// SetItemInfoFromCompressingResult must be after SetFileHeader
|
// SetItemInfoFromCompressingResult must be after SetFileHeader
|
||||||
// to write correct Size.
|
// to write correct Size.
|
||||||
SetItemInfoFromCompressingResult(memRef.CompressingResult,
|
SetItemInfoFromCompressingResult(memRef.CompressingResult,
|
||||||
options->IsRealAesMode(), options->AesKeyMode, item);
|
options.IsRealAesMode(), options.AesKeyMode, item);
|
||||||
archive.WriteLocalHeader_And_SeekToNextFile(item);
|
archive.WriteLocalHeader_And_SeekToNextFile(item);
|
||||||
// RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
|
// RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
|
||||||
memRef.FreeOpt(&memManager);
|
memRef.FreeOpt(&memManager);
|
||||||
@@ -920,9 +918,9 @@ static HRESULT Update2(
|
|||||||
{
|
{
|
||||||
RINOK(threadInfo.OutStreamSpec->WriteToRealStream());
|
RINOK(threadInfo.OutStreamSpec->WriteToRealStream());
|
||||||
threadInfo.OutStreamSpec->ReleaseOutStream();
|
threadInfo.OutStreamSpec->ReleaseOutStream();
|
||||||
SetFileHeader(archive, *options, ui, item);
|
SetFileHeader(archive, options, ui, item);
|
||||||
SetItemInfoFromCompressingResult(threadInfo.CompressingResult,
|
SetItemInfoFromCompressingResult(threadInfo.CompressingResult,
|
||||||
options->IsRealAesMode(), options->AesKeyMode, item);
|
options.IsRealAesMode(), options.AesKeyMode, item);
|
||||||
archive.WriteLocalHeader_And_SeekToNextFile(item);
|
archive.WriteLocalHeader_And_SeekToNextFile(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1173,7 +1171,7 @@ HRESULT Update(
|
|||||||
CObjectVector<CUpdateItem> &updateItems,
|
CObjectVector<CUpdateItem> &updateItems,
|
||||||
ISequentialOutStream *seqOutStream,
|
ISequentialOutStream *seqOutStream,
|
||||||
CInArchive *inArchive, bool removeSfx,
|
CInArchive *inArchive, bool removeSfx,
|
||||||
CCompressionMethodMode *compressionMethodMode,
|
const CCompressionMethodMode &compressionMethodMode,
|
||||||
IArchiveUpdateCallback *updateCallback)
|
IArchiveUpdateCallback *updateCallback)
|
||||||
{
|
{
|
||||||
if (inArchive)
|
if (inArchive)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ HRESULT Update(
|
|||||||
CObjectVector<CUpdateItem> &updateItems,
|
CObjectVector<CUpdateItem> &updateItems,
|
||||||
ISequentialOutStream *seqOutStream,
|
ISequentialOutStream *seqOutStream,
|
||||||
CInArchive *inArchive, bool removeSfx,
|
CInArchive *inArchive, bool removeSfx,
|
||||||
CCompressionMethodMode *compressionMethodMode,
|
const CCompressionMethodMode &compressionMethodMode,
|
||||||
IArchiveUpdateCallback *updateCallback);
|
IArchiveUpdateCallback *updateCallback);
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -749,11 +749,10 @@ static int main2(int numArgs, const char *args[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stdOutMode)
|
|
||||||
Print_Size("Output size: ", outStreamSpec->ProcessedSize);
|
|
||||||
|
|
||||||
if (outStreamSpec)
|
if (outStreamSpec)
|
||||||
{
|
{
|
||||||
|
if (!stdOutMode)
|
||||||
|
Print_Size("Output size: ", outStreamSpec->ProcessedSize);
|
||||||
if (outStreamSpec->Close() != S_OK)
|
if (outStreamSpec->Close() != S_OK)
|
||||||
throw "File closing error";
|
throw "File closing error";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -804,6 +804,15 @@ SOURCE=..\..\..\..\C\Delta.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\..\C\DllSecur.c
|
||||||
|
# SUBTRACT CPP /YX /Yc /Yu
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\..\C\DllSecur.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\Lzma2Dec.c
|
SOURCE=..\..\..\..\C\Lzma2Dec.c
|
||||||
# SUBTRACT CPP /YX /Yc /Yu
|
# SUBTRACT CPP /YX /Yc /Yu
|
||||||
# End Source File
|
# End Source File
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include "../../MyVersion.h"
|
#include "../../MyVersion.h"
|
||||||
|
|
||||||
|
#include "../../../../C/DllSecur.h"
|
||||||
|
|
||||||
using namespace NWindows;
|
using namespace NWindows;
|
||||||
using namespace NFile;
|
using namespace NFile;
|
||||||
using namespace NDir;
|
using namespace NDir;
|
||||||
@@ -103,7 +105,7 @@ static const wchar_t *kUniversalWildcard = L"*";
|
|||||||
static const int kCommandIndex = 0;
|
static const int kCommandIndex = 0;
|
||||||
|
|
||||||
static const char *kHelpString =
|
static const char *kHelpString =
|
||||||
"\nUsage: 7zSFX [<command>] [<switches>...]\n"
|
"\nUsage: 7zSFX [<command>] [<switches>...] [<file_name>...]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"<Commands>\n"
|
"<Commands>\n"
|
||||||
// " l: List contents of archive\n"
|
// " l: List contents of archive\n"
|
||||||
@@ -222,13 +224,6 @@ void AddCommandLineWildcardToCensor(NWildcard::CCensor &wildcardCensor,
|
|||||||
ShowMessageAndThrowException(kIncorrectWildcardInCommandLine, NExitCode::kUserError);
|
ShowMessageAndThrowException(kIncorrectWildcardInCommandLine, NExitCode::kUserError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddToCensorFromNonSwitchesStrings(NWildcard::CCensor &wildcardCensor,
|
|
||||||
const UStringVector & /* nonSwitchStrings */, NRecursedType::EEnum type,
|
|
||||||
bool /* thereAreSwitchIncludeWildcards */)
|
|
||||||
{
|
|
||||||
AddCommandLineWildcardToCensor(wildcardCensor, kUniversalWildcard, true, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static void GetArguments(int numArgs, const char *args[], UStringVector &parts)
|
static void GetArguments(int numArgs, const char *args[], UStringVector &parts)
|
||||||
@@ -248,6 +243,11 @@ int Main2(
|
|||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
// do we need load Security DLLs for console program?
|
||||||
|
LoadSecurityDlls();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||||
SetFileApisToOEM();
|
SetFileApisToOEM();
|
||||||
#endif
|
#endif
|
||||||
@@ -283,9 +283,16 @@ int Main2(
|
|||||||
commandStrings.Delete(0);
|
commandStrings.Delete(0);
|
||||||
|
|
||||||
NCommandLineParser::CParser parser(kNumSwitches);
|
NCommandLineParser::CParser parser(kNumSwitches);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
parser.ParseStrings(kSwitchForms, commandStrings);
|
if (!parser.ParseStrings(kSwitchForms, commandStrings))
|
||||||
|
{
|
||||||
|
g_StdOut << "Command line error:" << endl
|
||||||
|
<< parser.ErrorMessage << endl
|
||||||
|
<< parser.ErrorLine << endl;
|
||||||
|
return NExitCode::kUserError;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{
|
{
|
||||||
@@ -297,19 +304,23 @@ int Main2(
|
|||||||
PrintHelp();
|
PrintHelp();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
|
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
|
||||||
|
|
||||||
int numNonSwitchStrings = nonSwitchStrings.Size();
|
unsigned curCommandIndex = 0;
|
||||||
|
|
||||||
CArchiveCommand command;
|
CArchiveCommand command;
|
||||||
if (numNonSwitchStrings == 0)
|
if (nonSwitchStrings.IsEmpty())
|
||||||
command.CommandType = NCommandType::kFullExtract;
|
command.CommandType = NCommandType::kFullExtract;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (numNonSwitchStrings > 1)
|
const UString &cmd = nonSwitchStrings[curCommandIndex];
|
||||||
PrintHelpAndExit();
|
if (!ParseArchiveCommand(cmd, command))
|
||||||
if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], command))
|
{
|
||||||
PrintHelpAndExit();
|
g_StdOut << "ERROR: Unknown command:" << endl << cmd << endl;
|
||||||
|
return NExitCode::kUserError;
|
||||||
|
}
|
||||||
|
curCommandIndex = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -318,11 +329,17 @@ int Main2(
|
|||||||
|
|
||||||
NWildcard::CCensor wildcardCensor;
|
NWildcard::CCensor wildcardCensor;
|
||||||
|
|
||||||
bool thereAreSwitchIncludeWildcards;
|
{
|
||||||
thereAreSwitchIncludeWildcards = false;
|
if (nonSwitchStrings.Size() == curCommandIndex)
|
||||||
|
AddCommandLineWildcardToCensor(wildcardCensor, kUniversalWildcard, true, recursedType);
|
||||||
AddToCensorFromNonSwitchesStrings(wildcardCensor, nonSwitchStrings, recursedType,
|
for (; curCommandIndex < nonSwitchStrings.Size(); curCommandIndex++)
|
||||||
thereAreSwitchIncludeWildcards);
|
{
|
||||||
|
const UString &s = nonSwitchStrings[curCommandIndex];
|
||||||
|
if (s.IsEmpty())
|
||||||
|
throw "Empty file path";
|
||||||
|
AddCommandLineWildcardToCensor(wildcardCensor, s, true, recursedType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool yesToAll = parser[NKey::kYes].ThereIs;
|
bool yesToAll = parser[NKey::kYes].ThereIs;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ CFLAGS = $(CFLAGS) \
|
|||||||
-DEXTRACT_ONLY \
|
-DEXTRACT_ONLY \
|
||||||
-DNO_READ_FROM_CODER \
|
-DNO_READ_FROM_CODER \
|
||||||
-D_SFX \
|
-D_SFX \
|
||||||
|
-D_CONSOLE \
|
||||||
|
|
||||||
CURRENT_OBJS = \
|
CURRENT_OBJS = \
|
||||||
$O\SfxCon.obj \
|
$O\SfxCon.obj \
|
||||||
@@ -114,6 +115,7 @@ C_OBJS = \
|
|||||||
$O\BraIA64.obj \
|
$O\BraIA64.obj \
|
||||||
$O\CpuArch.obj \
|
$O\CpuArch.obj \
|
||||||
$O\Delta.obj \
|
$O\Delta.obj \
|
||||||
|
$O\DllSecur.obj \
|
||||||
$O\Lzma2Dec.obj \
|
$O\Lzma2Dec.obj \
|
||||||
$O\LzmaDec.obj \
|
$O\LzmaDec.obj \
|
||||||
$O\Ppmd7.obj \
|
$O\Ppmd7.obj \
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ struct CThreadExtracting
|
|||||||
Result = ArchiveLink.Open2(options, ExtractCallbackSpec);
|
Result = ArchiveLink.Open2(options, ExtractCallbackSpec);
|
||||||
if (Result != S_OK)
|
if (Result != S_OK)
|
||||||
{
|
{
|
||||||
if (Result != S_OK)
|
|
||||||
ErrorMessage = kCantOpenArchive;
|
ErrorMessage = kCantOpenArchive;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -706,6 +706,15 @@ SOURCE=..\..\..\..\C\Delta.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\..\C\DllSecur.c
|
||||||
|
# SUBTRACT CPP /YX /Yc /Yu
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\..\C\DllSecur.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\Lzma2Dec.c
|
SOURCE=..\..\..\..\C\Lzma2Dec.c
|
||||||
# SUBTRACT CPP /YX /Yc /Yu
|
# SUBTRACT CPP /YX /Yc /Yu
|
||||||
# End Source File
|
# End Source File
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
#include "ExtractEngine.h"
|
#include "ExtractEngine.h"
|
||||||
|
|
||||||
|
#include "../../../../C/DllSecur.h"
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
using namespace NWindows;
|
using namespace NWindows;
|
||||||
@@ -135,6 +137,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
|||||||
|
|
||||||
NT_CHECK
|
NT_CHECK
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
LoadSecurityDlls();
|
||||||
|
#endif
|
||||||
|
|
||||||
// InitCommonControls();
|
// InitCommonControls();
|
||||||
|
|
||||||
UString archiveName, switches;
|
UString archiveName, switches;
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ C_OBJS = \
|
|||||||
$O\BraIA64.obj \
|
$O\BraIA64.obj \
|
||||||
$O\CpuArch.obj \
|
$O\CpuArch.obj \
|
||||||
$O\Delta.obj \
|
$O\Delta.obj \
|
||||||
|
$O\DllSecur.obj \
|
||||||
$O\Lzma2Dec.obj \
|
$O\Lzma2Dec.obj \
|
||||||
$O\LzmaDec.obj \
|
$O\LzmaDec.obj \
|
||||||
$O\Threads.obj \
|
$O\Threads.obj \
|
||||||
|
|||||||
@@ -888,6 +888,15 @@ SOURCE=..\..\..\..\C\Delta.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\..\C\DllSecur.c
|
||||||
|
# SUBTRACT CPP /YX /Yc /Yu
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\..\C\DllSecur.h
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\..\C\Lzma2Dec.c
|
SOURCE=..\..\..\..\C\Lzma2Dec.c
|
||||||
# SUBTRACT CPP /YX /Yc /Yu
|
# SUBTRACT CPP /YX /Yc /Yu
|
||||||
# End Source File
|
# End Source File
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
#include "../../UI/GUI/ExtractGUI.h"
|
#include "../../UI/GUI/ExtractGUI.h"
|
||||||
#include "../../UI/GUI/ExtractRes.h"
|
#include "../../UI/GUI/ExtractRes.h"
|
||||||
|
|
||||||
|
#include "../../../../C/DllSecur.h"
|
||||||
|
|
||||||
using namespace NWindows;
|
using namespace NWindows;
|
||||||
using namespace NFile;
|
using namespace NFile;
|
||||||
using namespace NDir;
|
using namespace NDir;
|
||||||
@@ -220,6 +222,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
LoadSecurityDlls();
|
||||||
|
#endif
|
||||||
|
|
||||||
return WinMain2();
|
return WinMain2();
|
||||||
}
|
}
|
||||||
catch(const CNewException &)
|
catch(const CNewException &)
|
||||||
|
|||||||
@@ -131,8 +131,9 @@ C_OBJS = \
|
|||||||
$O\Bra.obj \
|
$O\Bra.obj \
|
||||||
$O\Bra86.obj \
|
$O\Bra86.obj \
|
||||||
$O\BraIA64.obj \
|
$O\BraIA64.obj \
|
||||||
$O\Delta.obj \
|
|
||||||
$O\CpuArch.obj \
|
$O\CpuArch.obj \
|
||||||
|
$O\Delta.obj \
|
||||||
|
$O\DllSecur.obj \
|
||||||
$O\Lzma2Dec.obj \
|
$O\Lzma2Dec.obj \
|
||||||
$O\LzmaDec.obj \
|
$O\LzmaDec.obj \
|
||||||
$O\Ppmd7.obj \
|
$O\Ppmd7.obj \
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ namespace NCompress {
|
|||||||
namespace NDeflate {
|
namespace NDeflate {
|
||||||
namespace NDecoder {
|
namespace NDecoder {
|
||||||
|
|
||||||
CCoder::CCoder(bool deflate64Mode, bool deflateNSIS):
|
CCoder::CCoder(bool deflate64Mode):
|
||||||
_deflate64Mode(deflate64Mode),
|
_deflate64Mode(deflate64Mode),
|
||||||
_deflateNSIS(deflateNSIS),
|
_deflateNSIS(false),
|
||||||
_keepHistory(false),
|
_keepHistory(false),
|
||||||
_needFinishInput(false),
|
_needFinishInput(false),
|
||||||
_needInitInStream(true),
|
_needInitInStream(true),
|
||||||
|
|||||||
@@ -79,9 +79,11 @@ public:
|
|||||||
bool ZlibMode;
|
bool ZlibMode;
|
||||||
Byte ZlibFooter[4];
|
Byte ZlibFooter[4];
|
||||||
|
|
||||||
CCoder(bool deflate64Mode, bool deflateNSIS = false);
|
CCoder(bool deflate64Mode);
|
||||||
virtual ~CCoder() {};
|
virtual ~CCoder() {};
|
||||||
|
|
||||||
|
void SetNsisMode(bool nsisMode) { _deflateNSIS = nsisMode; }
|
||||||
|
|
||||||
void Set_KeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
|
void Set_KeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
|
||||||
void Set_NeedFinishInput(bool needFinishInput) { _needFinishInput = needFinishInput; }
|
void Set_NeedFinishInput(bool needFinishInput) { _needFinishInput = needFinishInput; }
|
||||||
|
|
||||||
@@ -147,7 +149,6 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class CCOMCoder : public CCoder { public: CCOMCoder(): CCoder(false) {} };
|
class CCOMCoder : public CCoder { public: CCOMCoder(): CCoder(false) {} };
|
||||||
class CNsisCOMCoder : public CCoder { public: CNsisCOMCoder(): CCoder(false, true) {} };
|
|
||||||
class CCOMCoder64 : public CCoder { public: CCOMCoder64(): CCoder(true) {} };
|
class CCOMCoder64 : public CCoder { public: CCOMCoder64(): CCoder(true) {} };
|
||||||
|
|
||||||
}}}
|
}}}
|
||||||
|
|||||||
@@ -862,22 +862,26 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream
|
|||||||
_numCorrectDistSymbols = newSizeLog * 2;
|
_numCorrectDistSymbols = newSizeLog * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_window || _winSize != newSize)
|
// If dictionary was reduced, we use allocated dictionary block
|
||||||
|
// for compatibility with original unRAR decoder.
|
||||||
|
|
||||||
|
if (_window && newSize < _winSizeAllocated)
|
||||||
|
_winSize = _winSizeAllocated;
|
||||||
|
else if (!_window || _winSize != newSize)
|
||||||
{
|
{
|
||||||
if (!_isSolid && newSize > _winSizeAllocated)
|
if (!_isSolid)
|
||||||
{
|
{
|
||||||
::MidFree(_window);
|
::MidFree(_window);
|
||||||
_window = NULL;
|
_window = NULL;
|
||||||
_winSizeAllocated = 0;
|
_winSizeAllocated = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte *win = _window;
|
Byte *win;
|
||||||
if (!_window || newSize > _winSizeAllocated)
|
|
||||||
{
|
{
|
||||||
win = (Byte *)::MidAlloc(newSize);
|
win = (Byte *)::MidAlloc(newSize);
|
||||||
if (!win)
|
if (!win)
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
_winSizeAllocated = newSize;
|
|
||||||
memset(win, 0, newSize);
|
memset(win, 0, newSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,16 +896,18 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream
|
|||||||
size_t newMask = newSize - 1;
|
size_t newMask = newSize - 1;
|
||||||
size_t oldMask = _winSize - 1;
|
size_t oldMask = _winSize - 1;
|
||||||
size_t winPos = _winPos;
|
size_t winPos = _winPos;
|
||||||
for (size_t i = 1; i < oldSize; i++) // i < oldSize) ?
|
for (size_t i = 1; i <= oldSize; i++)
|
||||||
win[(winPos - i) & newMask] = winOld[(winPos - i) & oldMask];
|
win[(winPos - i) & newMask] = winOld[(winPos - i) & oldMask];
|
||||||
::MidFree(_window);
|
::MidFree(_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
_window = win;
|
_window = win;
|
||||||
|
_winSizeAllocated = newSize;
|
||||||
_winSize = newSize;
|
_winSize = newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
_winMask = _winSize - 1;
|
_winMask = _winSize - 1;
|
||||||
|
_winPos &= _winMask;
|
||||||
|
|
||||||
if (!_inputBuf)
|
if (!_inputBuf)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ static void AddRenamePair(CObjectVector<CRenamePair> *renamePairs,
|
|||||||
val.Add_LF();
|
val.Add_LF();
|
||||||
if (type == NRecursedType::kRecursed)
|
if (type == NRecursedType::kRecursed)
|
||||||
val.AddAscii("-r");
|
val.AddAscii("-r");
|
||||||
else if (type == NRecursedType::kRecursed)
|
else if (type == NRecursedType::kWildcardOnlyRecursed)
|
||||||
val.AddAscii("-r0");
|
val.AddAscii("-r0");
|
||||||
throw CArcCmdLineException("Unsupported rename command:", val);
|
throw CArcCmdLineException("Unsupported rename command:", val);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -359,14 +359,11 @@ HRESULT Extract(
|
|||||||
op.stream = NULL;
|
op.stream = NULL;
|
||||||
op.filePath = arcPath;
|
op.filePath = arcPath;
|
||||||
|
|
||||||
HRESULT result = arcLink.Open3(op, openCallback);
|
HRESULT result = arcLink.Open_Strict(op, openCallback);
|
||||||
|
|
||||||
if (result == E_ABORT)
|
if (result == E_ABORT)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (result == S_OK && arcLink.NonOpen_ErrorInfo.ErrorFormatIndex >= 0)
|
|
||||||
result = S_FALSE;
|
|
||||||
|
|
||||||
// arcLink.Set_ErrorsText();
|
// arcLink.Set_ErrorsText();
|
||||||
RINOK(extractCallback->OpenResult(codecs, arcLink, arcPath, result));
|
RINOK(extractCallback->OpenResult(codecs, arcLink, arcPath, result));
|
||||||
|
|
||||||
|
|||||||
@@ -401,6 +401,14 @@ struct CArchiveLink
|
|||||||
HRESULT Open2(COpenOptions &options, IOpenCallbackUI *callbackUI);
|
HRESULT Open2(COpenOptions &options, IOpenCallbackUI *callbackUI);
|
||||||
HRESULT Open3(COpenOptions &options, IOpenCallbackUI *callbackUI);
|
HRESULT Open3(COpenOptions &options, IOpenCallbackUI *callbackUI);
|
||||||
|
|
||||||
|
HRESULT Open_Strict(COpenOptions &options, IOpenCallbackUI *callbackUI)
|
||||||
|
{
|
||||||
|
HRESULT result = Open3(options, callbackUI);
|
||||||
|
if (result == S_OK && NonOpen_ErrorInfo.ErrorFormatIndex >= 0)
|
||||||
|
result = S_FALSE;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
HRESULT ReOpen(COpenOptions &options);
|
HRESULT ReOpen(COpenOptions &options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -251,8 +251,6 @@ STDMETHODIMP COutMultiVolStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *n
|
|||||||
|
|
||||||
STDMETHODIMP COutMultiVolStream::SetSize(UInt64 newSize)
|
STDMETHODIMP COutMultiVolStream::SetSize(UInt64 newSize)
|
||||||
{
|
{
|
||||||
if (newSize < 0)
|
|
||||||
return E_INVALIDARG;
|
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
while (i < Streams.Size())
|
while (i < Streams.Size())
|
||||||
{
|
{
|
||||||
@@ -1108,14 +1106,11 @@ HRESULT UpdateArchive(
|
|||||||
|
|
||||||
RINOK(callback->StartOpenArchive(arcPath));
|
RINOK(callback->StartOpenArchive(arcPath));
|
||||||
|
|
||||||
HRESULT result = arcLink.Open3(op, openCallback);
|
HRESULT result = arcLink.Open_Strict(op, openCallback);
|
||||||
|
|
||||||
if (result == E_ABORT)
|
if (result == E_ABORT)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (result == S_OK && arcLink.NonOpen_ErrorInfo.ErrorFormatIndex >= 0)
|
|
||||||
result = S_FALSE;
|
|
||||||
|
|
||||||
HRESULT res2 = callback->OpenResult(codecs, arcLink, arcPath, result);
|
HRESULT res2 = callback->OpenResult(codecs, arcLink, arcPath, result);
|
||||||
/*
|
/*
|
||||||
if (result == S_FALSE)
|
if (result == S_FALSE)
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ HRESULT CHashCallbackConsole::SetOperationResult(UInt64 fileSize, const CHashBun
|
|||||||
return CheckBreak2();
|
return CheckBreak2();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *k_DigestTitles[] =
|
static const char * const k_DigestTitles[] =
|
||||||
{
|
{
|
||||||
" : "
|
" : "
|
||||||
, " for data: "
|
, " for data: "
|
||||||
|
|||||||
@@ -1068,7 +1068,7 @@ HRESULT ListArchives(CCodecs *codecs,
|
|||||||
g_StdOut << endl << kListing << arcPath << endl << endl;
|
g_StdOut << endl << kListing << arcPath << endl << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT result = arcLink.Open3(options, &openCallback);
|
HRESULT result = arcLink.Open_Strict(options, &openCallback);
|
||||||
|
|
||||||
if (result != S_OK)
|
if (result != S_OK)
|
||||||
{
|
{
|
||||||
@@ -1095,9 +1095,6 @@ HRESULT ListArchives(CCodecs *codecs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
if (arcLink.NonOpen_ErrorInfo.ErrorFormatIndex >= 0)
|
|
||||||
numErrors++;
|
|
||||||
|
|
||||||
FOR_VECTOR (r, arcLink.Arcs)
|
FOR_VECTOR (r, arcLink.Arcs)
|
||||||
{
|
{
|
||||||
const CArcErrorInfo &arc = arcLink.Arcs[r].ErrorInfo;
|
const CArcErrorInfo &arc = arcLink.Arcs[r].ErrorInfo;
|
||||||
|
|||||||
@@ -577,7 +577,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
|||||||
|
|
||||||
if (!needExtract)
|
if (!needExtract)
|
||||||
{
|
{
|
||||||
FOR_VECTOR (i, _fileNames)
|
for (unsigned i = 1; i < _fileNames.Size(); i++)
|
||||||
{
|
{
|
||||||
NFind::CFileInfo fi;
|
NFind::CFileInfo fi;
|
||||||
if (!fi.Find(us2fs(_fileNames[i])))
|
if (!fi.Find(us2fs(_fileNames[i])))
|
||||||
@@ -594,57 +594,52 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
|||||||
|
|
||||||
if (needExtract)
|
if (needExtract)
|
||||||
{
|
{
|
||||||
// Extract
|
{
|
||||||
|
UString baseFolder = fs2us(folderPrefix);
|
||||||
|
if (_dropMode)
|
||||||
|
baseFolder = _dropPath;
|
||||||
|
|
||||||
|
UString specFolder = L'*';
|
||||||
|
if (_fileNames.Size() == 1)
|
||||||
|
specFolder = GetSubFolderNameForExtract(fs2us(fi0.Name));
|
||||||
|
specFolder.Add_PathSepar();
|
||||||
|
|
||||||
if ((contextMenuFlags & NContextMenuFlags::kExtract) != 0)
|
if ((contextMenuFlags & NContextMenuFlags::kExtract) != 0)
|
||||||
{
|
{
|
||||||
|
// Extract
|
||||||
CCommandMapItem commandMapItem;
|
CCommandMapItem commandMapItem;
|
||||||
FillCommand(kExtract, mainString, commandMapItem);
|
FillCommand(kExtract, mainString, commandMapItem);
|
||||||
if (_dropMode)
|
commandMapItem.Folder = baseFolder + specFolder;
|
||||||
commandMapItem.Folder = _dropPath;
|
|
||||||
else
|
|
||||||
commandMapItem.Folder = fs2us(folderPrefix);
|
|
||||||
commandMapItem.Folder += GetSubFolderNameForExtract(fs2us(fi0.Name));
|
|
||||||
commandMapItem.Folder.Add_PathSepar();
|
|
||||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString, bitmap);
|
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString, bitmap);
|
||||||
_commandMap.Add(commandMapItem);
|
_commandMap.Add(commandMapItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract Here
|
|
||||||
if ((contextMenuFlags & NContextMenuFlags::kExtractHere) != 0)
|
if ((contextMenuFlags & NContextMenuFlags::kExtractHere) != 0)
|
||||||
{
|
{
|
||||||
|
// Extract Here
|
||||||
CCommandMapItem commandMapItem;
|
CCommandMapItem commandMapItem;
|
||||||
FillCommand(kExtractHere, mainString, commandMapItem);
|
FillCommand(kExtractHere, mainString, commandMapItem);
|
||||||
|
commandMapItem.Folder = baseFolder;
|
||||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString, bitmap);
|
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString, bitmap);
|
||||||
if (_dropMode)
|
|
||||||
commandMapItem.Folder = _dropPath;
|
|
||||||
else
|
|
||||||
commandMapItem.Folder = fs2us(folderPrefix);
|
|
||||||
_commandMap.Add(commandMapItem);
|
_commandMap.Add(commandMapItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract To
|
|
||||||
if ((contextMenuFlags & NContextMenuFlags::kExtractTo) != 0)
|
if ((contextMenuFlags & NContextMenuFlags::kExtractTo) != 0)
|
||||||
{
|
{
|
||||||
|
// Extract To
|
||||||
CCommandMapItem commandMapItem;
|
CCommandMapItem commandMapItem;
|
||||||
UString s;
|
UString s;
|
||||||
FillCommand(kExtractTo, s, commandMapItem);
|
FillCommand(kExtractTo, s, commandMapItem);
|
||||||
UString folder = L'*';
|
commandMapItem.Folder = baseFolder + specFolder;
|
||||||
if (_fileNames.Size() == 1)
|
MyFormatNew_ReducedName(s, specFolder);
|
||||||
folder = GetSubFolderNameForExtract(fs2us(fi0.Name));
|
|
||||||
if (_dropMode)
|
|
||||||
commandMapItem.Folder = _dropPath;
|
|
||||||
else
|
|
||||||
commandMapItem.Folder = fs2us(folderPrefix);
|
|
||||||
commandMapItem.Folder += folder;
|
|
||||||
folder.Add_PathSepar();
|
|
||||||
MyFormatNew_ReducedName(s, folder);
|
|
||||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s, bitmap);
|
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s, bitmap);
|
||||||
_commandMap.Add(commandMapItem);
|
_commandMap.Add(commandMapItem);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test
|
|
||||||
if ((contextMenuFlags & NContextMenuFlags::kTest) != 0)
|
if ((contextMenuFlags & NContextMenuFlags::kTest) != 0)
|
||||||
{
|
{
|
||||||
|
// Test
|
||||||
CCommandMapItem commandMapItem;
|
CCommandMapItem commandMapItem;
|
||||||
FillCommand(kTest, mainString, commandMapItem);
|
FillCommand(kTest, mainString, commandMapItem);
|
||||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString, bitmap);
|
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString, bitmap);
|
||||||
|
|||||||
@@ -396,8 +396,7 @@ static HANDLE MyOpenFilePluginW(const wchar_t *name)
|
|||||||
agent,
|
agent,
|
||||||
(const wchar_t *)archiveType
|
(const wchar_t *)archiveType
|
||||||
);
|
);
|
||||||
if (!plugin)
|
|
||||||
return INVALID_HANDLE_VALUE;
|
|
||||||
plugin->PasswordIsDefined = openArchiveCallbackSpec->PasswordIsDefined;
|
plugin->PasswordIsDefined = openArchiveCallbackSpec->PasswordIsDefined;
|
||||||
plugin->Password = openArchiveCallbackSpec->Password;
|
plugin->Password = openArchiveCallbackSpec->Password;
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ CEnumFormatEtc::CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats)
|
|||||||
m_Index = 0;
|
m_Index = 0;
|
||||||
m_NumFormats = 0;
|
m_NumFormats = 0;
|
||||||
m_Formats = new FORMATETC[numFormats];
|
m_Formats = new FORMATETC[numFormats];
|
||||||
if (m_Formats)
|
// if (m_Formats)
|
||||||
{
|
{
|
||||||
m_NumFormats = numFormats;
|
m_NumFormats = numFormats;
|
||||||
for (ULONG i = 0; i < numFormats; i++)
|
for (ULONG i = 0; i < numFormats; i++)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
|
|
||||||
#include <Windowsx.h>
|
#include <Windowsx.h>
|
||||||
|
// #include <stdio.h>
|
||||||
|
|
||||||
#include "../../../Common/IntToString.h"
|
#include "../../../Common/IntToString.h"
|
||||||
#include "../../../Common/StringConvert.h"
|
#include "../../../Common/StringConvert.h"
|
||||||
@@ -619,10 +620,47 @@ bool CPanel::OnNotifyReBar(LPNMHDR header, LRESULT & /* result */)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
UInt32 g_OnNotify = 0;
|
||||||
|
UInt32 g_LVIF_TEXT = 0;
|
||||||
|
UInt32 g_Time = 0;
|
||||||
|
|
||||||
|
void Print_OnNotify(const char *name)
|
||||||
|
{
|
||||||
|
char s[256];
|
||||||
|
DWORD tim = GetTickCount();
|
||||||
|
sprintf(s,
|
||||||
|
"Time = %7u ms, Notify = %9u, TEXT = %9u, %s",
|
||||||
|
tim - g_Time,
|
||||||
|
g_OnNotify,
|
||||||
|
g_LVIF_TEXT,
|
||||||
|
name);
|
||||||
|
g_Time = tim;
|
||||||
|
OutputDebugStringA(s);
|
||||||
|
g_OnNotify = 0;
|
||||||
|
g_LVIF_TEXT = 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result)
|
bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
g_OnNotify++;
|
||||||
|
|
||||||
|
if (header->hwndFrom == _listView)
|
||||||
|
{
|
||||||
|
if (header->code == LVN_GETDISPINFOW)
|
||||||
|
{
|
||||||
|
LV_DISPINFOW *dispInfo = (LV_DISPINFOW *)header;
|
||||||
|
if ((dispInfo->item.mask & LVIF_TEXT))
|
||||||
|
g_LVIF_TEXT++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if (!_processNotify)
|
if (!_processNotify)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (header->hwndFrom == _headerComboBox)
|
if (header->hwndFrom == _headerComboBox)
|
||||||
return OnNotifyComboBox(header, result);
|
return OnNotifyComboBox(header, result);
|
||||||
else if (header->hwndFrom == _headerReBar)
|
else if (header->hwndFrom == _headerReBar)
|
||||||
|
|||||||
@@ -361,6 +361,7 @@ public:
|
|||||||
// CMyComboBox _headerComboBox;
|
// CMyComboBox _headerComboBox;
|
||||||
CMyComboBoxEdit _comboBoxEdit;
|
CMyComboBoxEdit _comboBoxEdit;
|
||||||
CMyListView _listView;
|
CMyListView _listView;
|
||||||
|
bool _thereAre_ListView_Items;
|
||||||
NWindows::NControl::CStatusBar _statusBar;
|
NWindows::NControl::CStatusBar _statusBar;
|
||||||
bool _lastFocusedIsList;
|
bool _lastFocusedIsList;
|
||||||
// NWindows::NControl::CStatusBar _statusBar2;
|
// NWindows::NControl::CStatusBar _statusBar2;
|
||||||
@@ -380,6 +381,18 @@ public:
|
|||||||
|
|
||||||
bool PanelCreated;
|
bool PanelCreated;
|
||||||
|
|
||||||
|
void DeleteListItems()
|
||||||
|
{
|
||||||
|
if (_thereAre_ListView_Items)
|
||||||
|
{
|
||||||
|
bool b = _enableItemChangeNotify;
|
||||||
|
_enableItemChangeNotify = false;
|
||||||
|
_listView.DeleteAllItems();
|
||||||
|
_thereAre_ListView_Items = false;
|
||||||
|
_enableItemChangeNotify = b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HWND GetParent();
|
HWND GetParent();
|
||||||
|
|
||||||
UInt32 GetRealIndex(const LVITEMW &item) const
|
UInt32 GetRealIndex(const LVITEMW &item) const
|
||||||
@@ -502,6 +515,7 @@ public:
|
|||||||
_flatModeForDisk(false),
|
_flatModeForDisk(false),
|
||||||
_flatModeForArc(false),
|
_flatModeForArc(false),
|
||||||
PanelCreated(false),
|
PanelCreated(false),
|
||||||
|
_thereAre_ListView_Items(false),
|
||||||
|
|
||||||
// _showNtfsStrems_Mode(false),
|
// _showNtfsStrems_Mode(false),
|
||||||
// _showNtfsStrems_ModeForDisk(false),
|
// _showNtfsStrems_ModeForDisk(false),
|
||||||
|
|||||||
@@ -404,8 +404,11 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (res != DRAGDROP_S_CANCEL && res != S_OK)
|
// we ignore E_UNEXPECTED that is returned if we drag file to printer
|
||||||
|
if (res != DRAGDROP_S_CANCEL && res != S_OK
|
||||||
|
&& res != E_UNEXPECTED)
|
||||||
MessageBoxError(res);
|
MessageBoxError(res);
|
||||||
|
|
||||||
res = dropSourceSpec->Result;
|
res = dropSourceSpec->Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ using namespace NFind;
|
|||||||
|
|
||||||
void CPanel::ReleaseFolder()
|
void CPanel::ReleaseFolder()
|
||||||
{
|
{
|
||||||
|
DeleteListItems();
|
||||||
|
|
||||||
_folder.Release();
|
_folder.Release();
|
||||||
|
|
||||||
_folderCompare.Release();
|
_folderCompare.Release();
|
||||||
@@ -175,15 +177,36 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
|||||||
}
|
}
|
||||||
else if (fileInfo.IsDir())
|
else if (fileInfo.IsDir())
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (DoesNameContainWildcard(sysPath))
|
||||||
|
{
|
||||||
|
FString dirPrefix, fileName;
|
||||||
|
NDir::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName);
|
||||||
|
if (DoesNameContainWildcard(dirPrefix))
|
||||||
|
return E_INVALIDARG;
|
||||||
|
sysPath = fs2us(dirPrefix + fileInfo.Name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
NName::NormalizeDirPathPrefix(sysPath);
|
NName::NormalizeDirPathPrefix(sysPath);
|
||||||
_folder->BindToFolder(sysPath, &newFolder);
|
_folder->BindToFolder(sysPath, &newFolder);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FString dirPrefix, fileName;
|
FString dirPrefix, fileName;
|
||||||
|
|
||||||
NDir::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName);
|
NDir::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName);
|
||||||
HRESULT res;
|
|
||||||
// = OpenAsArc(fs2us(fileName), arcFormat, encrypted);
|
HRESULT res = S_OK;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (DoesNameContainWildcard(dirPrefix))
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
if (DoesNameContainWildcard(fileName))
|
||||||
|
res = S_FALSE;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
CTempFileInfo tfi;
|
CTempFileInfo tfi;
|
||||||
tfi.RelPath = fs2us(fileName);
|
tfi.RelPath = fs2us(fileName);
|
||||||
@@ -258,9 +281,9 @@ HRESULT CPanel::BindToPathAndRefresh(const UString &path)
|
|||||||
CDisableTimerProcessing disableTimerProcessing(*this);
|
CDisableTimerProcessing disableTimerProcessing(*this);
|
||||||
CDisableNotify disableNotify(*this);
|
CDisableNotify disableNotify(*this);
|
||||||
bool archiveIsOpened, encrypted;
|
bool archiveIsOpened, encrypted;
|
||||||
RINOK(BindToPath(path, UString(), archiveIsOpened, encrypted));
|
HRESULT res = BindToPath(path, UString(), archiveIsOpened, encrypted);
|
||||||
RefreshListCtrl(UString(), -1, true, UStringVector());
|
RefreshListCtrl(UString(), -1, true, UStringVector());
|
||||||
return S_OK;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPanel::SetBookmark(unsigned index)
|
void CPanel::SetBookmark(unsigned index)
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ HRESULT CPanel::InitColumns()
|
|||||||
{
|
{
|
||||||
SaveListViewInfo();
|
SaveListViewInfo();
|
||||||
|
|
||||||
_listView.DeleteAllItems();
|
// DeleteListItems();
|
||||||
_selectedStatusVector.Clear();
|
_selectedStatusVector.Clear();
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -411,9 +411,21 @@ void CPanel::SetFocusedSelectedItem(int index, bool select)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #define PRINT_STAT
|
||||||
|
|
||||||
|
#ifdef PRINT_STAT
|
||||||
|
void Print_OnNotify(const char *name);
|
||||||
|
#else
|
||||||
|
#define Print_OnNotify(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
|
HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
|
||||||
const UStringVector &selectedNames)
|
const UStringVector &selectedNames)
|
||||||
{
|
{
|
||||||
|
if (!_folder)
|
||||||
|
return S_OK;
|
||||||
|
|
||||||
_dontShowMode = false;
|
_dontShowMode = false;
|
||||||
LoadFullPathAndShow();
|
LoadFullPathAndShow();
|
||||||
// OutputDebugStringA("=======\n");
|
// OutputDebugStringA("=======\n");
|
||||||
@@ -431,10 +443,10 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
|||||||
ZeroMemory(&item, sizeof(item));
|
ZeroMemory(&item, sizeof(item));
|
||||||
|
|
||||||
// DWORD tickCount0 = GetTickCount();
|
// DWORD tickCount0 = GetTickCount();
|
||||||
_enableItemChangeNotify = false;
|
|
||||||
_listView.DeleteAllItems();
|
|
||||||
_enableItemChangeNotify = true;
|
|
||||||
|
|
||||||
|
// _enableItemChangeNotify = false;
|
||||||
|
DeleteListItems();
|
||||||
|
_enableItemChangeNotify = true;
|
||||||
|
|
||||||
int listViewItemCount = 0;
|
int listViewItemCount = 0;
|
||||||
|
|
||||||
@@ -512,6 +524,12 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_thereAre_ListView_Items = true;
|
||||||
|
|
||||||
|
// OutputDebugStringA("\n\n");
|
||||||
|
|
||||||
|
Print_OnNotify("===== Before Load");
|
||||||
|
|
||||||
if (showDots)
|
if (showDots)
|
||||||
{
|
{
|
||||||
UString itemName = L"..";
|
UString itemName = L"..";
|
||||||
@@ -642,7 +660,8 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
|||||||
// item.pszText = const_cast<wchar_t *>((const wchar_t *)name);
|
// item.pszText = const_cast<wchar_t *>((const wchar_t *)name);
|
||||||
item.pszText = LPSTR_TEXTCALLBACKW;
|
item.pszText = LPSTR_TEXTCALLBACKW;
|
||||||
/* LPSTR_TEXTCALLBACKW works, but in some cases there are problems,
|
/* LPSTR_TEXTCALLBACKW works, but in some cases there are problems,
|
||||||
since we block notify handler. */
|
since we block notify handler.
|
||||||
|
LPSTR_TEXTCALLBACKW can be 2-3 times faster for loading in this loop. */
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt32 attrib = 0;
|
UInt32 attrib = 0;
|
||||||
@@ -687,14 +706,35 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
|||||||
listViewItemCount++;
|
listViewItemCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OutputDebugStringA("End2\n");
|
/*
|
||||||
|
xp-64: there is different order when Windows calls CPanel::OnNotify for _listView modes:
|
||||||
|
Details : after whole code
|
||||||
|
List : 2 times:
|
||||||
|
1) - ListView.SotRedraw()
|
||||||
|
2) - after whole code
|
||||||
|
Small Icons :
|
||||||
|
Large icons : 2 times:
|
||||||
|
1) - ListView.Sort()
|
||||||
|
2) - after whole code (calls with reverse order of items)
|
||||||
|
|
||||||
|
So we need to allow Notify(), when windows requests names during the following code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Print_OnNotify("after Load");
|
||||||
|
|
||||||
|
disableNotify.SetMemMode_Enable();
|
||||||
|
disableNotify.Restore();
|
||||||
|
|
||||||
if (_listView.GetItemCount() > 0 && cursorIndex >= 0)
|
if (_listView.GetItemCount() > 0 && cursorIndex >= 0)
|
||||||
SetFocusedSelectedItem(cursorIndex, selectFocused);
|
SetFocusedSelectedItem(cursorIndex, selectFocused);
|
||||||
// DWORD tickCount3 = GetTickCount();
|
|
||||||
|
Print_OnNotify("after SetFocusedSelectedItem");
|
||||||
|
|
||||||
SetSortRawStatus();
|
SetSortRawStatus();
|
||||||
_listView.SortItems(CompareItems, (LPARAM)this);
|
_listView.SortItems(CompareItems, (LPARAM)this);
|
||||||
// DWORD tickCount4 = GetTickCount();
|
|
||||||
|
Print_OnNotify("after Sort");
|
||||||
|
|
||||||
if (cursorIndex < 0 && _listView.GetItemCount() > 0)
|
if (cursorIndex < 0 && _listView.GetItemCount() > 0)
|
||||||
{
|
{
|
||||||
if (focusedPos >= _listView.GetItemCount())
|
if (focusedPos >= _listView.GetItemCount())
|
||||||
@@ -702,23 +742,29 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
|||||||
// we select item only in showDots mode.
|
// we select item only in showDots mode.
|
||||||
SetFocusedSelectedItem(focusedPos, showDots);
|
SetFocusedSelectedItem(focusedPos, showDots);
|
||||||
}
|
}
|
||||||
// m_RedrawEnabled = true;
|
|
||||||
// DWORD tickCount5 = GetTickCount();
|
|
||||||
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
|
|
||||||
// DWORD tickCount6 = GetTickCount();
|
|
||||||
|
|
||||||
disableNotify.SetMemMode_Enable();
|
// m_RedrawEnabled = true;
|
||||||
disableNotify.Restore();
|
|
||||||
|
Print_OnNotify("after SetFocusedSelectedItem2");
|
||||||
|
|
||||||
|
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
|
||||||
|
|
||||||
|
// disableNotify.SetMemMode_Enable();
|
||||||
|
// disableNotify.Restore();
|
||||||
|
|
||||||
|
Print_OnNotify("after EnsureVisible");
|
||||||
|
|
||||||
_listView.SetRedraw(true);
|
_listView.SetRedraw(true);
|
||||||
// DWORD tickCount7 = GetTickCount();
|
|
||||||
|
Print_OnNotify("after SetRedraw");
|
||||||
|
|
||||||
_listView.InvalidateRect(NULL, true);
|
_listView.InvalidateRect(NULL, true);
|
||||||
// DWORD tickCount8 = GetTickCount();
|
|
||||||
// OutputDebugStringA("End1\n");
|
Print_OnNotify("after InvalidateRect");
|
||||||
/*
|
/*
|
||||||
_listView.UpdateWindow();
|
_listView.UpdateWindow();
|
||||||
*/
|
*/
|
||||||
Refresh_StatusBar();
|
Refresh_StatusBar();
|
||||||
// DWORD tickCount9 = GetTickCount();
|
|
||||||
/*
|
/*
|
||||||
char s[256];
|
char s[256];
|
||||||
sprintf(s,
|
sprintf(s,
|
||||||
|
|||||||
@@ -356,8 +356,8 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
|
|||||||
i += t;
|
i += t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
text[dest] = 0;
|
text[dest] = 0;
|
||||||
|
// OutputDebugStringW(text);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
|
|||||||
|
|
||||||
// We need clear all items to disable GetText before Reload:
|
// We need clear all items to disable GetText before Reload:
|
||||||
// number of items can change.
|
// number of items can change.
|
||||||
// _listView.DeleteAllItems();
|
// DeleteListItems();
|
||||||
// But seems it can still call GetText (maybe for current item)
|
// But seems it can still call GetText (maybe for current item)
|
||||||
// so we can't delete items.
|
// so we can't delete items.
|
||||||
|
|
||||||
|
|||||||
@@ -9,24 +9,19 @@ void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2)
|
|||||||
dest1.Empty();
|
dest1.Empty();
|
||||||
dest2.Empty();
|
dest2.Empty();
|
||||||
bool quoteMode = false;
|
bool quoteMode = false;
|
||||||
unsigned i;
|
for (unsigned i = 0; i < src.Len(); i++)
|
||||||
for (i = 0; i < src.Len(); i++)
|
|
||||||
{
|
{
|
||||||
wchar_t c = src[i];
|
const wchar_t c = src[i];
|
||||||
if (c == L'\"')
|
if (c == L'\"')
|
||||||
quoteMode = !quoteMode;
|
quoteMode = !quoteMode;
|
||||||
else if (c == L' ' && !quoteMode)
|
else if (c == L' ' && !quoteMode)
|
||||||
{
|
{
|
||||||
if (!quoteMode)
|
dest2 = src.Ptr(i + 1);
|
||||||
{
|
return;
|
||||||
i++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dest1 += c;
|
dest1 += c;
|
||||||
}
|
}
|
||||||
dest2 = src.Ptr(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitString(const UString &srcString, UStringVector &destStrings)
|
void SplitString(const UString &srcString, UStringVector &destStrings)
|
||||||
|
|||||||
@@ -767,7 +767,7 @@ static void ParseNumberString(const UString &s, NCOM::CPropVariant &prop)
|
|||||||
|
|
||||||
HRESULT Benchmark(
|
HRESULT Benchmark(
|
||||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||||
const CObjectVector<CProperty> props, HWND hwndParent)
|
const CObjectVector<CProperty> &props, HWND hwndParent)
|
||||||
{
|
{
|
||||||
CThreadBenchmark benchmarker;
|
CThreadBenchmark benchmarker;
|
||||||
#ifdef EXTERNAL_CODECS
|
#ifdef EXTERNAL_CODECS
|
||||||
|
|||||||
@@ -175,6 +175,6 @@ public:
|
|||||||
|
|
||||||
HRESULT Benchmark(
|
HRESULT Benchmark(
|
||||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||||
const CObjectVector<CProperty> props, HWND hwndParent = NULL);
|
const CObjectVector<CProperty> &props, HWND hwndParent = NULL);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
~CDynLimBuf() { MyFree(_chars); }
|
~CDynLimBuf() { MyFree(_chars); }
|
||||||
|
|
||||||
size_t Len() const { return _pos; }
|
size_t Len() const { return _pos; }
|
||||||
void Empty() { _pos = 0; }
|
void Empty() { _pos = 0; _error = false; }
|
||||||
|
|
||||||
operator const Byte *() const { return _chars; }
|
operator const Byte *() const { return _chars; }
|
||||||
// const char *Ptr() const { return _chars; }
|
// const char *Ptr() const { return _chars; }
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ unsigned GetNumPrefixParts_if_DrivePath(UStringVector &pathParts)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static unsigned GetNumPrefixParts(const UStringVector pathParts)
|
static unsigned GetNumPrefixParts(const UStringVector &pathParts)
|
||||||
{
|
{
|
||||||
if (pathParts.IsEmpty())
|
if (pathParts.IsEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -130,7 +130,10 @@ WinXP-64 FindFirstFile():
|
|||||||
\\Server\ - ERROR_INVALID_NAME
|
\\Server\ - ERROR_INVALID_NAME
|
||||||
|
|
||||||
\\Server\Share - ERROR_BAD_NETPATH
|
\\Server\Share - ERROR_BAD_NETPATH
|
||||||
\\Server\Share - ERROR_BAD_NET_NAME (Win7)
|
\\Server\Share - ERROR_BAD_NET_NAME (Win7).
|
||||||
|
!!! There is problem : Win7 makes some requests for "\\Server\Shar" (look in Procmon),
|
||||||
|
when we call it for "\\Server\Share"
|
||||||
|
|
||||||
\\Server\Share\ - ERROR_FILE_NOT_FOUND
|
\\Server\Share\ - ERROR_FILE_NOT_FOUND
|
||||||
|
|
||||||
\\?\UNC\Server\Share - ERROR_INVALID_NAME
|
\\?\UNC\Server\Share - ERROR_INVALID_NAME
|
||||||
@@ -508,11 +511,10 @@ bool CFileInfo::Find(CFSTR path)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
CFindFile finder;
|
CFindFile finder;
|
||||||
if (finder.FindFirst(path, *this))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
DWORD lastError = GetLastError();
|
DWORD lastError = GetLastError();
|
||||||
if (lastError == ERROR_FILE_NOT_FOUND
|
if (lastError == ERROR_FILE_NOT_FOUND
|
||||||
|| lastError == ERROR_BAD_NETPATH // XP64: "\\Server\Share"
|
|| lastError == ERROR_BAD_NETPATH // XP64: "\\Server\Share"
|
||||||
@@ -520,22 +522,13 @@ bool CFileInfo::Find(CFSTR path)
|
|||||||
|| lastError == ERROR_INVALID_NAME // XP64: "\\?\UNC\Server\Share"
|
|| lastError == ERROR_INVALID_NAME // XP64: "\\?\UNC\Server\Share"
|
||||||
|| lastError == ERROR_BAD_PATHNAME // Win7: "\\?\UNC\Server\Share"
|
|| lastError == ERROR_BAD_PATHNAME // Win7: "\\?\UNC\Server\Share"
|
||||||
)
|
)
|
||||||
{
|
*/
|
||||||
|
|
||||||
unsigned rootSize = 0;
|
unsigned rootSize = 0;
|
||||||
if (IsSuperPath(path))
|
if (IsSuperPath(path))
|
||||||
rootSize = kSuperPathPrefixSize;
|
rootSize = kSuperPathPrefixSize;
|
||||||
if (IS_PATH_SEPAR(path[0]) && path[1] == 0)
|
|
||||||
{
|
if (NName::IsDrivePath(path + rootSize) && path[rootSize + 3] == 0)
|
||||||
DWORD attrib = GetFileAttrib(path);
|
|
||||||
if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
|
||||||
{
|
|
||||||
ClearBase();
|
|
||||||
Name.Empty();
|
|
||||||
Attrib = attrib;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (NName::IsDrivePath(path + rootSize) && path[rootSize + 3] == 0)
|
|
||||||
{
|
{
|
||||||
DWORD attrib = GetFileAttrib(path);
|
DWORD attrib = GetFileAttrib(path);
|
||||||
if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||||
@@ -547,9 +540,21 @@ bool CFileInfo::Find(CFSTR path)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (IS_PATH_SEPAR(path[0]))
|
||||||
|
if (path[1] == 0)
|
||||||
|
{
|
||||||
|
DWORD attrib = GetFileAttrib(path);
|
||||||
|
if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||||
|
{
|
||||||
|
ClearBase();
|
||||||
|
Name.Empty();
|
||||||
|
Attrib = attrib;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned prefixSize = GetNetworkServerPrefixSize(path);
|
const unsigned prefixSize = GetNetworkServerPrefixSize(path);
|
||||||
if (prefixSize > 0 && path[prefixSize] != 0)
|
if (prefixSize > 0 && path[prefixSize] != 0)
|
||||||
{
|
{
|
||||||
if (NName::FindSepar(path + prefixSize) < 0)
|
if (NName::FindSepar(path + prefixSize) < 0)
|
||||||
@@ -563,7 +568,7 @@ bool CFileInfo::Find(CFSTR path)
|
|||||||
{
|
{
|
||||||
if (Name == FTEXT("."))
|
if (Name == FTEXT("."))
|
||||||
{
|
{
|
||||||
Name = path + prefixSize;;
|
Name = path + prefixSize;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
isOK = true;
|
isOK = true;
|
||||||
@@ -583,17 +588,17 @@ bool CFileInfo::Find(CFSTR path)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
::SetLastError(lastError);
|
// ::SetLastError(lastError);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return finder.FindFirst(path, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DoesFileExist(CFSTR name)
|
bool DoesFileExist(CFSTR name)
|
||||||
{
|
{
|
||||||
CFileInfo fi;
|
CFileInfo fi;
|
||||||
@@ -706,7 +711,7 @@ bool MyGetLogicalDriveStrings(CObjectVector<FString> &driveStrings)
|
|||||||
driveStrings.Add(fas2fs(s));
|
driveStrings.Add(fas2fs(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return prev == newSize;;
|
return prev == newSize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -374,43 +374,55 @@ static bool ResolveDotsFolders(UString &s)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// s.Replace(L'/', WCHAR_PATH_SEPARATOR);
|
// s.Replace(L'/', WCHAR_PATH_SEPARATOR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (unsigned i = 0;;)
|
for (unsigned i = 0;;)
|
||||||
{
|
{
|
||||||
wchar_t c = s[i];
|
const wchar_t c = s[i];
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
return true;
|
return true;
|
||||||
if (c == '.' && (i == 0 || IS_SEPAR(s[i - 1])))
|
if (c == '.' && (i == 0 || IS_SEPAR(s[i - 1])))
|
||||||
{
|
{
|
||||||
wchar_t c1 = s[i + 1];
|
const wchar_t c1 = s[i + 1];
|
||||||
if (c1 == '.')
|
if (c1 == '.')
|
||||||
{
|
{
|
||||||
wchar_t c2 = s[i + 2];
|
const wchar_t c2 = s[i + 2];
|
||||||
if (IS_SEPAR(c2) || c2 == 0)
|
if (IS_SEPAR(c2) || c2 == 0)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
return false;
|
return false;
|
||||||
int k = i - 2;
|
int k = i - 2;
|
||||||
for (; k >= 0; k--)
|
i += 2;
|
||||||
if (IS_SEPAR(s[(unsigned)k]))
|
|
||||||
|
for (;; k--)
|
||||||
|
{
|
||||||
|
if (k < 0)
|
||||||
|
return false;
|
||||||
|
if (!IS_SEPAR(s[(unsigned)k]))
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
k--;
|
||||||
|
while (k >= 0 && !IS_SEPAR(s[(unsigned)k]));
|
||||||
|
|
||||||
unsigned num;
|
unsigned num;
|
||||||
|
|
||||||
if (k >= 0)
|
if (k >= 0)
|
||||||
{
|
{
|
||||||
num = i + 2 - k;
|
num = i - k;
|
||||||
i = k;
|
i = k;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
num = (c2 == 0 ? (i + 2) : (i + 3));
|
num = (c2 == 0 ? i : (i + 1));
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Delete(i, num);
|
s.Delete(i, num);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (IS_SEPAR(c1) || c1 == 0)
|
||||||
{
|
|
||||||
if (IS_SEPAR(c1) || c1 == 0)
|
|
||||||
{
|
{
|
||||||
unsigned num = 2;
|
unsigned num = 2;
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
@@ -421,7 +433,7 @@ static bool ResolveDotsFolders(UString &s)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ AppName = "7-Zip"
|
|||||||
InstallDir = %CE1%\%AppName%
|
InstallDir = %CE1%\%AppName%
|
||||||
|
|
||||||
[Strings]
|
[Strings]
|
||||||
AppVer = "16.02"
|
AppVer = "16.03"
|
||||||
AppDate = "2016-05-21"
|
AppDate = "2016-10-28"
|
||||||
|
|
||||||
[CEDevice]
|
[CEDevice]
|
||||||
; ProcessorType = 2577 ; ARM
|
; ProcessorType = 2577 ; ARM
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
;Defines
|
;Defines
|
||||||
|
|
||||||
!define VERSION_MAJOR 16
|
!define VERSION_MAJOR 16
|
||||||
!define VERSION_MINOR 02
|
!define VERSION_MINOR 03
|
||||||
!define VERSION_POSTFIX_FULL ""
|
!define VERSION_POSTFIX_FULL ""
|
||||||
!ifdef WIN64
|
!ifdef WIN64
|
||||||
!ifdef IA64
|
!ifdef IA64
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
<?define VerMajor = "16" ?>
|
<?define VerMajor = "16" ?>
|
||||||
<?define VerMinor = "02" ?>
|
<?define VerMinor = "03" ?>
|
||||||
<?define VerBuild = "00" ?>
|
<?define VerBuild = "00" ?>
|
||||||
<?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?>
|
<?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?>
|
||||||
<?define MmHex = "$(var.VerMajor)$(var.VerMinor)" ?>
|
<?define MmHex = "$(var.VerMajor)$(var.VerMinor)" ?>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
7-Zip method IDs for 7z and xz archives
|
7-Zip method IDs for 7z and xz archives
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
Version: 15.06
|
Version: 16.03
|
||||||
Date: 2015-06-23
|
Date: 2016-09-27
|
||||||
|
|
||||||
Each compression or crypto method in 7z is associated with unique binary value (ID).
|
Each compression or crypto method in 7z is associated with unique binary value (ID).
|
||||||
The length of ID in bytes is arbitrary but it can not exceed 63 bits (8 bytes).
|
The length of ID in bytes is arbitrary but it can not exceed 63 bits (8 bytes).
|
||||||
@@ -122,7 +122,8 @@ List of defined IDs
|
|||||||
F7 - External codecs (that are not included to 7-Zip)
|
F7 - External codecs (that are not included to 7-Zip)
|
||||||
|
|
||||||
0x xx - reserved
|
0x xx - reserved
|
||||||
10 xx - reserved
|
10 xx - reserved (LZHAM)
|
||||||
|
11 xx - reserved (Zstd)
|
||||||
|
|
||||||
|
|
||||||
06.. - Crypto
|
06.. - Crypto
|
||||||
|
|||||||
Reference in New Issue
Block a user