mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-16 22:11:49 -06:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2eb60a0598 | ||
|
|
044e4bb741 | ||
|
|
e279500d76 |
@@ -1,7 +1,7 @@
|
||||
#define MY_VER_MAJOR 9
|
||||
#define MY_VER_MINOR 14
|
||||
#define MY_VER_MINOR 17
|
||||
#define MY_VER_BUILD 0
|
||||
#define MY_VERSION "9.14 beta"
|
||||
#define MY_DATE "2010-06-04"
|
||||
#define MY_VERSION "9.17 beta"
|
||||
#define MY_DATE "2010-10-04"
|
||||
#define MY_COPYRIGHT ": Igor Pavlov : Public domain"
|
||||
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Lzma2Enc.c -- LZMA2 Encoder
|
||||
2010-04-16 : Igor Pavlov : Public domain */
|
||||
2010-09-24 : Igor Pavlov : Public domain */
|
||||
|
||||
/* #include <stdio.h> */
|
||||
#include <string.h>
|
||||
@@ -269,7 +269,7 @@ static SRes Lzma2Enc_EncodeMt1(CLzma2EncInt *p, CLzma2Enc *mainEncoder,
|
||||
|
||||
if (mainEncoder->outBuf == 0)
|
||||
{
|
||||
mainEncoder->outBuf = IAlloc_Alloc(mainEncoder->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
|
||||
mainEncoder->outBuf = (Byte *)IAlloc_Alloc(mainEncoder->alloc, LZMA2_CHUNK_SIZE_COMPRESSED_MAX);
|
||||
if (mainEncoder->outBuf == 0)
|
||||
return SZ_ERROR_MEM;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* MtCoder.c -- Multi-thread Coder
|
||||
2010-03-24 : Igor Pavlov : Public domain */
|
||||
2010-09-24 : Igor Pavlov : Public domain */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -148,7 +148,7 @@ static void CMtThread_Destruct(CMtThread *p)
|
||||
#define MY_BUF_ALLOC(buf, size, newSize) \
|
||||
if (buf == 0 || size != newSize) \
|
||||
{ IAlloc_Free(p->mtCoder->alloc, buf); \
|
||||
size = newSize; buf = IAlloc_Alloc(p->mtCoder->alloc, size); \
|
||||
size = newSize; buf = (Byte *)IAlloc_Alloc(p->mtCoder->alloc, size); \
|
||||
if (buf == 0) return SZ_ERROR_MEM; }
|
||||
|
||||
static SRes CMtThread_Prepare(CMtThread *p)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* Crypto/Sha256.c -- SHA-256 Hash function
|
||||
2008-11-06 : Igor Pavlov : Public domain
|
||||
/* Crypto/Sha256.c -- SHA-256 Hash
|
||||
2010-06-11 : Igor Pavlov : Public domain
|
||||
This code is based on public domain code from Wei Dai's Crypto++ library. */
|
||||
|
||||
#include "Sha256.h"
|
||||
#include "RotateDefs.h"
|
||||
#include "Sha256.h"
|
||||
|
||||
/* define it for speed optimization */
|
||||
/* #define _SHA256_UNROLL */
|
||||
@@ -71,7 +71,7 @@ void Sha256_Init(CSha256 *p)
|
||||
|
||||
#endif
|
||||
|
||||
const UInt32 K[64] = {
|
||||
static const UInt32 K[64] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
||||
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
||||
|
||||
10
C/Sha256.h
10
C/Sha256.h
@@ -1,14 +1,12 @@
|
||||
/* Sha256.h -- SHA-256 Hash
|
||||
2009-02-07 : Igor Pavlov : Public domain */
|
||||
2010-06-11 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __CRYPTO_SHA256_H
|
||||
#define __CRYPTO_SHA256_H
|
||||
|
||||
#include "Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
#define SHA256_DIGEST_SIZE 32
|
||||
|
||||
@@ -23,8 +21,6 @@ void Sha256_Init(CSha256 *p);
|
||||
void Sha256_Update(CSha256 *p, const Byte *data, size_t size);
|
||||
void Sha256_Final(CSha256 *p, Byte *digest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
||||
|
||||
4
C/Sort.c
4
C/Sort.c
@@ -1,7 +1,5 @@
|
||||
/* Sort.c -- Sort functions
|
||||
2008-08-17
|
||||
Igor Pavlov
|
||||
Public domain */
|
||||
2010-09-17 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Sort.h"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* 7zMain.c - Test application for 7z Decoder
|
||||
2010-03-12 : Igor Pavlov : Public domain */
|
||||
2010-09-20 : Igor Pavlov : Public domain */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -104,7 +104,7 @@ static SRes Utf16_To_Utf8Buf(CBuf *dest, const UInt16 *src, size_t srcLen)
|
||||
}
|
||||
#endif
|
||||
|
||||
static WRes Utf16_To_Char(CBuf *buf, const UInt16 *s, int fileMode)
|
||||
static SRes Utf16_To_Char(CBuf *buf, const UInt16 *s, int fileMode)
|
||||
{
|
||||
int len = 0;
|
||||
for (len = 0; s[len] != '\0'; len++);
|
||||
@@ -172,15 +172,16 @@ static WRes OutFile_OpenUtf16(CSzFile *p, const UInt16 *name)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void PrintString(const UInt16 *s)
|
||||
static SRes PrintString(const UInt16 *s)
|
||||
{
|
||||
CBuf buf;
|
||||
SRes res;
|
||||
Buf_Init(&buf);
|
||||
if (Utf16_To_Char(&buf, s, 0) == 0)
|
||||
{
|
||||
printf("%s", buf.data);
|
||||
res = Utf16_To_Char(&buf, s, 0);
|
||||
if (res == SZ_OK)
|
||||
fputs((const char *)buf.data, stdout);
|
||||
Buf_Free(&buf, &g_Alloc);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void UInt64ToStr(UInt64 value, char *s)
|
||||
@@ -398,16 +399,21 @@ int MY_CDECL main(int numargs, char *args[])
|
||||
}
|
||||
|
||||
printf("%s %s %10s ", t, attr, s);
|
||||
PrintString(temp);
|
||||
res = PrintString(temp);
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
if (f->IsDir)
|
||||
printf("/");
|
||||
printf("\n");
|
||||
continue;
|
||||
}
|
||||
printf(testCommand ?
|
||||
fputs(testCommand ?
|
||||
"Testing ":
|
||||
"Extracting ");
|
||||
PrintString(temp);
|
||||
"Extracting ",
|
||||
stdout);
|
||||
res = PrintString(temp);
|
||||
if (res != SZ_OK)
|
||||
break;
|
||||
if (f->IsDir)
|
||||
printf("/");
|
||||
else
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* LzmaUtil.c -- Test application for LZMA compression
|
||||
2009-08-14 : Igor Pavlov : Public domain */
|
||||
2010-09-20 : Igor Pavlov : Public domain */
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
@@ -249,6 +249,6 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
{
|
||||
char rs[800] = { 0 };
|
||||
int res = main2(numArgs, args, rs);
|
||||
printf(rs);
|
||||
fputs(rs, stdout);
|
||||
return res;
|
||||
}
|
||||
|
||||
12
C/Xz.h
12
C/Xz.h
@@ -1,14 +1,12 @@
|
||||
/* Xz.h - Xz interface
|
||||
2009-04-15 : Igor Pavlov : Public domain */
|
||||
2010-09-17 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __XZ_H
|
||||
#define __XZ_H
|
||||
|
||||
#include "Sha256.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
#define XZ_ID_Subblock 1
|
||||
#define XZ_ID_Delta 3
|
||||
@@ -140,7 +138,7 @@ typedef enum
|
||||
CODER_STATUS_NOT_SPECIFIED, /* use main error code instead */
|
||||
CODER_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
|
||||
CODER_STATUS_NOT_FINISHED, /* stream was not finished */
|
||||
CODER_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
|
||||
CODER_STATUS_NEEDS_MORE_INPUT /* you must provide more input bytes */
|
||||
} ECoderStatus;
|
||||
|
||||
typedef enum
|
||||
@@ -249,8 +247,6 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
|
||||
|
||||
Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "7zHandler.h"
|
||||
#include "7zFolderOutStream.h"
|
||||
#include "../../../Common/ComTry.h"
|
||||
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
|
||||
#include "7zDecode.h"
|
||||
// #include "7z1Decode.h"
|
||||
|
||||
#include "../../../Common/ComTry.h"
|
||||
#include "../../Common/StreamObjects.h"
|
||||
#include "../../Common/ProgressUtils.h"
|
||||
#include "../../Common/LimitedStreams.h"
|
||||
#include "7zFolderOutStream.h"
|
||||
#include "7zHandler.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace N7z {
|
||||
@@ -73,13 +72,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
*/
|
||||
|
||||
CObjectVector<CExtractFolderInfo> extractFolderInfoVector;
|
||||
for(UInt32 ii = 0; ii < numItems; ii++)
|
||||
for (UInt32 ii = 0; ii < numItems; ii++)
|
||||
{
|
||||
// UInt32 fileIndex = allFilesMode ? indexIndex : indices[indexIndex];
|
||||
UInt32 ref2Index = allFilesMode ? ii : indices[ii];
|
||||
// const CRef2 &ref2 = _refs[ref2Index];
|
||||
|
||||
// for(UInt32 ri = 0; ri < ref2.Refs.Size(); ri++)
|
||||
// for (UInt32 ri = 0; ri < ref2.Refs.Size(); ri++)
|
||||
{
|
||||
#ifdef _7Z_VOL
|
||||
// const CRef &ref = ref2.Refs[ri];
|
||||
@@ -149,27 +148,26 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
);
|
||||
// CDecoder1 decoder;
|
||||
|
||||
UInt64 currentTotalPacked = 0;
|
||||
UInt64 currentTotalUnpacked = 0;
|
||||
UInt64 totalFolderUnpacked;
|
||||
UInt64 totalFolderPacked;
|
||||
UInt64 totalPacked = 0;
|
||||
UInt64 totalUnpacked = 0;
|
||||
UInt64 curPacked, curUnpacked;
|
||||
|
||||
CLocalProgress *lps = new CLocalProgress;
|
||||
CMyComPtr<ICompressProgressInfo> progress = lps;
|
||||
lps->Init(extractCallback, false);
|
||||
|
||||
for(int i = 0; i < extractFolderInfoVector.Size(); i++,
|
||||
currentTotalUnpacked += totalFolderUnpacked,
|
||||
currentTotalPacked += totalFolderPacked)
|
||||
for (int i = 0;; i++, totalUnpacked += curUnpacked, totalPacked += curPacked)
|
||||
{
|
||||
lps->OutSize = currentTotalUnpacked;
|
||||
lps->InSize = currentTotalPacked;
|
||||
lps->OutSize = totalUnpacked;
|
||||
lps->InSize = totalPacked;
|
||||
RINOK(lps->SetCur());
|
||||
|
||||
const CExtractFolderInfo &efi = extractFolderInfoVector[i];
|
||||
totalFolderUnpacked = efi.UnpackSize;
|
||||
if (i >= extractFolderInfoVector.Size())
|
||||
break;
|
||||
|
||||
totalFolderPacked = 0;
|
||||
const CExtractFolderInfo &efi = extractFolderInfoVector[i];
|
||||
curUnpacked = efi.UnpackSize;
|
||||
curPacked = 0;
|
||||
|
||||
CFolderOutStream *folderOutStream = new CFolderOutStream;
|
||||
CMyComPtr<ISequentialOutStream> outStream(folderOutStream);
|
||||
@@ -187,7 +185,6 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
else
|
||||
startIndex = db.FolderStartFileIndex[efi.FolderIndex];
|
||||
|
||||
|
||||
HRESULT result = folderOutStream->Init(&db,
|
||||
#ifdef _7Z_VOL
|
||||
volume.StartRef2Index,
|
||||
@@ -205,7 +202,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
CNum folderIndex = efi.FolderIndex;
|
||||
const CFolder &folderInfo = db.Folders[folderIndex];
|
||||
|
||||
totalFolderPacked = _db.GetFolderFullPackSize(folderIndex);
|
||||
curPacked = _db.GetFolderFullPackSize(folderIndex);
|
||||
|
||||
CNum packStreamIndex = db.FolderStartPackStreamIndex[folderIndex];
|
||||
UInt64 folderStartPackPos = db.GetFolderStreamPos(folderIndex, 0);
|
||||
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
kUnsupportedVersion = 0,
|
||||
kUnsupported,
|
||||
kIncorrect,
|
||||
kEndOfData,
|
||||
kEndOfData
|
||||
} Cause;
|
||||
CInArchiveException(CCauseType cause): Cause(cause) {};
|
||||
};
|
||||
|
||||
@@ -19,32 +19,33 @@ struct CPropMap
|
||||
|
||||
CPropMap kPropMap[] =
|
||||
{
|
||||
{ NID::kName, NULL, kpidPath, VT_BSTR},
|
||||
{ NID::kSize, NULL, kpidSize, VT_UI8},
|
||||
{ NID::kPackInfo, NULL, kpidPackSize, VT_UI8},
|
||||
{ NID::kName, { NULL, kpidPath, VT_BSTR } },
|
||||
{ NID::kSize, { NULL, kpidSize, VT_UI8 } },
|
||||
{ NID::kPackInfo, { NULL, kpidPackSize, VT_UI8 } },
|
||||
|
||||
#ifdef _MULTI_PACK
|
||||
{ 100, L"Pack0", kpidPackedSize0, VT_UI8},
|
||||
{ 101, L"Pack1", kpidPackedSize1, VT_UI8},
|
||||
{ 102, L"Pack2", kpidPackedSize2, VT_UI8},
|
||||
{ 103, L"Pack3", kpidPackedSize3, VT_UI8},
|
||||
{ 104, L"Pack4", kpidPackedSize4, VT_UI8},
|
||||
{ 100, { L"Pack0", kpidPackedSize0, VT_UI8 } },
|
||||
{ 101, { L"Pack1", kpidPackedSize1, VT_UI8 } },
|
||||
{ 102, { L"Pack2", kpidPackedSize2, VT_UI8 } },
|
||||
{ 103, { L"Pack3", kpidPackedSize3, VT_UI8 } },
|
||||
{ 104, { L"Pack4", kpidPackedSize4, VT_UI8 } },
|
||||
#endif
|
||||
|
||||
{ NID::kCTime, NULL, kpidCTime, VT_FILETIME},
|
||||
{ NID::kMTime, NULL, kpidMTime, VT_FILETIME},
|
||||
{ NID::kATime, NULL, kpidATime, VT_FILETIME},
|
||||
{ NID::kWinAttributes, NULL, kpidAttrib, VT_UI4},
|
||||
{ NID::kStartPos, NULL, kpidPosition, VT_UI4},
|
||||
{ NID::kCTime, { NULL, kpidCTime, VT_FILETIME } },
|
||||
{ NID::kMTime, { NULL, kpidMTime, VT_FILETIME } },
|
||||
{ NID::kATime, { NULL, kpidATime, VT_FILETIME } },
|
||||
{ NID::kWinAttributes, { NULL, kpidAttrib, VT_UI4 } },
|
||||
{ NID::kStartPos, { NULL, kpidPosition, VT_UI4 } },
|
||||
|
||||
{ NID::kCRC, NULL, kpidCRC, VT_UI4},
|
||||
{ NID::kCRC, { NULL, kpidCRC, VT_UI4 } },
|
||||
|
||||
{ NID::kAnti, NULL, kpidIsAnti, VT_BOOL},
|
||||
{ NID::kAnti, { NULL, kpidIsAnti, VT_BOOL } }
|
||||
|
||||
#ifndef _SFX
|
||||
{ 97, NULL, kpidEncrypted, VT_BOOL},
|
||||
{ 98, NULL, kpidMethod, VT_BSTR},
|
||||
{ 99, NULL, kpidBlock, VT_UI4}
|
||||
,
|
||||
{ 97, { NULL,kpidEncrypted, VT_BOOL } },
|
||||
{ 98, { NULL,kpidMethod, VT_BSTR } },
|
||||
{ 99, { NULL,kpidBlock, VT_UI4 } }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ STDAPI CreateArchiver(const GUID *clsid, const GUID *iid, void **outObject)
|
||||
|
||||
STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
if (formatIndex >= g_NumArcs)
|
||||
return E_INVALIDARG;
|
||||
const CArcInfo &arc = *g_Arcs[formatIndex];
|
||||
@@ -119,6 +120,7 @@ STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value
|
||||
}
|
||||
prop.Detach(value);
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
|
||||
|
||||
@@ -264,7 +264,7 @@ struct CInArchiveException
|
||||
{
|
||||
kUnexpectedEndOfArchive = 0,
|
||||
kCRCError,
|
||||
kIncorrectArchive,
|
||||
kIncorrectArchive
|
||||
}
|
||||
Cause;
|
||||
CInArchiveException(CCauseType cause): Cause(cause) {};
|
||||
|
||||
@@ -41,7 +41,7 @@ enum
|
||||
};
|
||||
#endif
|
||||
|
||||
STATPROPSTG kProps[] =
|
||||
static STATPROPSTG kProps[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidSize, VT_UI8},
|
||||
@@ -57,18 +57,18 @@ STATPROPSTG kProps[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
static const wchar_t *kMethods[] =
|
||||
static const char *kMethods[] =
|
||||
{
|
||||
L"None",
|
||||
L"MSZip",
|
||||
L"Quantum",
|
||||
L"LZX"
|
||||
"None",
|
||||
"MSZip",
|
||||
"Quantum",
|
||||
"LZX"
|
||||
};
|
||||
|
||||
static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
|
||||
static const wchar_t *kUnknownMethod = L"Unknown";
|
||||
static const char *kUnknownMethod = "Unknown";
|
||||
|
||||
STATPROPSTG kArcProps[] =
|
||||
static STATPROPSTG kArcProps[] =
|
||||
{
|
||||
{ NULL, kpidMethod, VT_BSTR},
|
||||
// { NULL, kpidSolid, VT_BOOL},
|
||||
@@ -87,7 +87,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
{
|
||||
case kpidMethod:
|
||||
{
|
||||
UString resString;
|
||||
AString resString;
|
||||
CRecordVector<Byte> ids;
|
||||
int i;
|
||||
for (int v = 0; v < m_Database.Volumes.Size(); v++)
|
||||
@@ -99,9 +99,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
for (i = 0; i < ids.Size(); i++)
|
||||
{
|
||||
Byte id = ids[i];
|
||||
UString method = (id < kNumMethods) ? kMethods[id] : kUnknownMethod;
|
||||
AString method = (id < kNumMethods) ? kMethods[id] : kUnknownMethod;
|
||||
if (!resString.IsEmpty())
|
||||
resString += L' ';
|
||||
resString += ' ';
|
||||
resString += method;
|
||||
}
|
||||
prop = resString;
|
||||
@@ -171,12 +171,12 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
|
||||
UInt32 realFolderIndex = item.GetFolderIndex(db.Folders.Size());
|
||||
const CFolder &folder = db.Folders[realFolderIndex];
|
||||
int methodIndex = folder.GetCompressionMethod();
|
||||
UString method = (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
|
||||
AString method = (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
|
||||
if (methodIndex == NHeader::NCompressionMethodMajor::kLZX ||
|
||||
methodIndex == NHeader::NCompressionMethodMajor::kQuantum)
|
||||
{
|
||||
method += L":";
|
||||
wchar_t temp[32];
|
||||
method += ':';
|
||||
char temp[32];
|
||||
ConvertUInt64ToString(folder.CompressionTypeMinor, temp);
|
||||
method += temp;
|
||||
}
|
||||
|
||||
@@ -9,18 +9,15 @@
|
||||
|
||||
#include "ChmIn.h"
|
||||
|
||||
namespace NArchive{
|
||||
namespace NChm{
|
||||
namespace NArchive {
|
||||
namespace NChm {
|
||||
|
||||
// define CHM_LOW, if you want to see low level items
|
||||
// #define CHM_LOW
|
||||
|
||||
static const GUID kChmLzxGuid =
|
||||
{ 0x7FC28940, 0x9D31, 0x11D0, 0x9B, 0x27, 0x00, 0xA0, 0xC9, 0x1E, 0x9C, 0x7C };
|
||||
static const GUID kHelp2LzxGuid =
|
||||
{ 0x0A9007C6, 0x4076, 0x11D3, 0x87, 0x89, 0x00, 0x00, 0xF8, 0x10, 0x57, 0x54 };
|
||||
static const GUID kDesGuid =
|
||||
{ 0x67F6E4A2, 0x60BF, 0x11D3, 0x85, 0x40, 0x00, 0xC0, 0x4F, 0x58, 0xC3, 0xCF };
|
||||
static const GUID kChmLzxGuid = { 0x7FC28940, 0x9D31, 0x11D0, { 0x9B, 0x27, 0x00, 0xA0, 0xC9, 0x1E, 0x9C, 0x7C } };
|
||||
static const GUID kHelp2LzxGuid = { 0x0A9007C6, 0x4076, 0x11D3, { 0x87, 0x89, 0x00, 0x00, 0xF8, 0x10, 0x57, 0x54 } };
|
||||
static const GUID kDesGuid = { 0x67F6E4A2, 0x60BF, 0x11D3, { 0x85, 0x40, 0x00, 0xC0, 0x4F, 0x58, 0xC3, 0xCF } };
|
||||
|
||||
static bool AreGuidsEqual(REFGUID g1, REFGUID g2)
|
||||
{
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Common/ComTry.h"
|
||||
#include "Common/StringToInt.h"
|
||||
#include "Common/StringConvert.h"
|
||||
#include "Common/StringToInt.h"
|
||||
|
||||
#include "Windows/PropVariant.h"
|
||||
#include "Windows/Time.h"
|
||||
@@ -25,10 +25,10 @@ namespace NFileHeader
|
||||
{
|
||||
namespace NMagic
|
||||
{
|
||||
extern const char *kMagic1 = "070701";
|
||||
extern const char *kMagic2 = "070702";
|
||||
extern const char *kMagic3 = "070707";
|
||||
extern const char *kEndName = "TRAILER!!!";
|
||||
const char *kMagic1 = "070701";
|
||||
const char *kMagic2 = "070702";
|
||||
const char *kMagic3 = "070707";
|
||||
const char *kEndName = "TRAILER!!!";
|
||||
|
||||
const Byte kMagicForRecord2[2] = { 0xC7, 0x71 };
|
||||
}
|
||||
|
||||
@@ -526,7 +526,14 @@ HRESULT CDatabase::ReadDir(Int32 parent, UInt32 cluster, int level)
|
||||
item.Attrib = attrib;
|
||||
item.Flags = p[12];
|
||||
item.Size = Get32(p + 28);
|
||||
item.Cluster = Get16(p + 26) | ((UInt32)Get16(p + 20) << 16);
|
||||
item.Cluster = Get16(p + 26);
|
||||
if (Header.NumFatBits > 16)
|
||||
item.Cluster |= ((UInt32)Get16(p + 20) << 16);
|
||||
else
|
||||
{
|
||||
// OS/2 and WinNT probably can store EA (extended atributes) in that field.
|
||||
}
|
||||
|
||||
item.CTime = Get32(p + 14);
|
||||
item.CTime2 = p[13];
|
||||
item.ADate = Get16(p + 18);
|
||||
@@ -578,8 +585,12 @@ HRESULT CDatabase::Open()
|
||||
return S_FALSE;
|
||||
UInt64 fileSize;
|
||||
RINOK(InStream->Seek(0, STREAM_SEEK_END, &fileSize));
|
||||
|
||||
/* we comment that check to support truncated images */
|
||||
/*
|
||||
if (fileSize < Header.GetPhySize())
|
||||
return S_FALSE;
|
||||
*/
|
||||
|
||||
if (Header.IsFat32())
|
||||
{
|
||||
|
||||
@@ -378,7 +378,7 @@ static const char *GetOS(Byte osId)
|
||||
if (g_OsPairs[i].Id == osId)
|
||||
return g_OsPairs[i].Name;
|
||||
return kUnknownOS;
|
||||
};
|
||||
}
|
||||
|
||||
static STATPROPSTG kProps[] =
|
||||
{
|
||||
@@ -400,7 +400,7 @@ public:
|
||||
static UInt16 Table[256];
|
||||
static void InitTable();
|
||||
|
||||
CCRC(): _value(0){};
|
||||
CCRC(): _value(0) {}
|
||||
void Init() { _value = 0; }
|
||||
void Update(const void *data, size_t size);
|
||||
UInt16 GetDigest() const { return _value; }
|
||||
@@ -460,7 +460,6 @@ public:
|
||||
void ReleaseStream() { _stream.Release(); }
|
||||
UInt32 GetCRC() const { return _crc.GetDigest(); }
|
||||
void InitCRC() { _crc.Init(); }
|
||||
|
||||
};
|
||||
|
||||
STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
|
||||
@@ -332,7 +332,7 @@ enum
|
||||
{
|
||||
kpidPrimary = kpidUserDefined,
|
||||
kpidBegChs,
|
||||
kpidEndChs,
|
||||
kpidEndChs
|
||||
};
|
||||
|
||||
STATPROPSTG kProps[] =
|
||||
|
||||
@@ -7,15 +7,14 @@
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "../../Common/MethodId.h"
|
||||
#include "../../Common/CreateCoder.h"
|
||||
|
||||
#include "../../Compress/BZip2Decoder.h"
|
||||
#include "../../Compress/DeflateDecoder.h"
|
||||
#include "../../Compress/LzmaDecoder.h"
|
||||
|
||||
namespace NArchive {
|
||||
namespace NNsis {
|
||||
|
||||
static const CMethodId k_Copy = 0x0;
|
||||
static const CMethodId k_Deflate = 0x040901;
|
||||
static const CMethodId k_BZip2 = 0x040902;
|
||||
static const CMethodId k_LZMA = 0x030101;
|
||||
static const CMethodId k_BCJ_X86 = 0x03030103;
|
||||
|
||||
HRESULT CDecoder::Init(
|
||||
@@ -31,24 +30,14 @@ HRESULT CDecoder::Init(
|
||||
_method = method;
|
||||
if (!_codecInStream)
|
||||
{
|
||||
CMethodId methodID;
|
||||
switch (method)
|
||||
{
|
||||
case NMethodType::kCopy: methodID = k_Copy; break;
|
||||
case NMethodType::kDeflate: methodID = k_Deflate; break;
|
||||
case NMethodType::kBZip2: methodID = k_BZip2; break;
|
||||
case NMethodType::kLZMA: methodID = k_LZMA; break;
|
||||
// case NMethodType::kCopy: return E_NOTIMPL;
|
||||
case NMethodType::kDeflate: _codecInStream = new NCompress::NDeflate::NDecoder::CNsisCOMCoder(); break;
|
||||
case NMethodType::kBZip2: _codecInStream = new NCompress::NBZip2::CNsisDecoder(); break;
|
||||
case NMethodType::kLZMA: _codecInStream = new NCompress::NLzma::CDecoder(); break;
|
||||
default: return E_NOTIMPL;
|
||||
}
|
||||
CMyComPtr<ICompressCoder> coder;
|
||||
RINOK(CreateCoder(
|
||||
EXTERNAL_CODECS_LOC_VARS
|
||||
methodID, coder, false));
|
||||
if (!coder)
|
||||
return E_NOTIMPL;
|
||||
coder.QueryInterface(IID_ISequentialInStream, &_codecInStream);
|
||||
if (!_codecInStream)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
if (thereIsFilterFlag)
|
||||
|
||||
@@ -87,7 +87,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 * maxCheckStartPosit
|
||||
COM_TRY_BEGIN
|
||||
Close();
|
||||
{
|
||||
if(_archive.Open(
|
||||
if (_archive.Open(
|
||||
EXTERNAL_CODECS_VARS
|
||||
stream, maxCheckStartPosition) != S_OK)
|
||||
return S_FALSE;
|
||||
@@ -264,12 +264,12 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
bool allFilesMode = (numItems == (UInt32)-1);
|
||||
if (allFilesMode)
|
||||
GetNumberOfItems(&numItems);
|
||||
if(numItems == 0)
|
||||
if (numItems == 0)
|
||||
return S_OK;
|
||||
UInt64 totalSize = 0;
|
||||
|
||||
UInt32 i;
|
||||
for(i = 0; i < numItems; i++)
|
||||
for (i = 0; i < numItems; i++)
|
||||
{
|
||||
UInt32 index = (allFilesMode ? i : indices[i]);
|
||||
#ifdef NSIS_SCRIPT
|
||||
@@ -313,6 +313,8 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
byteBuf.SetCapacity(kBufferLength);
|
||||
Byte *buffer = byteBuf;
|
||||
|
||||
CByteBuffer tempBuf;
|
||||
|
||||
bool dataError = false;
|
||||
for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
|
||||
{
|
||||
@@ -330,7 +332,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
if (index >= (UInt32)_archive.Items.Size())
|
||||
{
|
||||
currentItemSize = _archive.Script.Length();
|
||||
if(!testMode && !realOutStream)
|
||||
if (!testMode && !realOutStream)
|
||||
continue;
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
if (!testMode)
|
||||
@@ -346,7 +348,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
else
|
||||
GetCompressedSize(index, currentItemSize);
|
||||
|
||||
if(!testMode && !realOutStream)
|
||||
if (!testMode && !realOutStream)
|
||||
continue;
|
||||
|
||||
RINOK(extractCallback->PrepareOperation(askMode));
|
||||
@@ -357,10 +359,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
bool sizeIsKnown = false;
|
||||
UInt32 fullSize = 0;
|
||||
|
||||
bool writeToTemp = false;
|
||||
bool readFromTemp = false;
|
||||
|
||||
if (_archive.IsSolid)
|
||||
{
|
||||
UInt64 pos = _archive.GetPosOfSolidItem(index);
|
||||
while(streamPos < pos)
|
||||
while (streamPos < pos)
|
||||
{
|
||||
size_t processedSize = (UInt32)MyMin(pos - streamPos, (UInt64)kBufferLength);
|
||||
HRESULT res = _archive.Decoder.Read(buffer, &processedSize);
|
||||
@@ -389,8 +394,21 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
fullSize = Get32(buffer2);
|
||||
sizeIsKnown = true;
|
||||
needDecompress = true;
|
||||
|
||||
if (!testMode && i + 1 < numItems)
|
||||
{
|
||||
UInt64 nextPos = _archive.GetPosOfSolidItem(allFilesMode ? i : indices[i + 1]);
|
||||
if (nextPos < streamPos + fullSize)
|
||||
{
|
||||
tempBuf.Free();
|
||||
tempBuf.SetCapacity(fullSize);
|
||||
writeToTemp = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
readFromTemp = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RINOK(_inStream->Seek(_archive.GetPosOfNonSolidItem(index) + 4, STREAM_SEEK_SET, NULL));
|
||||
@@ -413,7 +431,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
if (needDecompress)
|
||||
{
|
||||
UInt64 offset = 0;
|
||||
while(!sizeIsKnown || fullSize > 0)
|
||||
while (!sizeIsKnown || fullSize > 0)
|
||||
{
|
||||
UInt32 curSize = kBufferLength;
|
||||
if (sizeIsKnown && curSize > fullSize)
|
||||
@@ -434,6 +452,9 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
break;
|
||||
}
|
||||
|
||||
if (writeToTemp)
|
||||
memcpy((Byte *)tempBuf + (size_t)offset, buffer, processedSize);
|
||||
|
||||
fullSize -= (UInt32)processedSize;
|
||||
streamPos += processedSize;
|
||||
offset += processedSize;
|
||||
@@ -450,7 +471,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
||||
}
|
||||
else
|
||||
{
|
||||
while(fullSize > 0)
|
||||
if (readFromTemp)
|
||||
{
|
||||
if (!testMode)
|
||||
RINOK(WriteStream(realOutStream, tempBuf, tempBuf.GetCapacity()));
|
||||
}
|
||||
else
|
||||
while (fullSize > 0)
|
||||
{
|
||||
UInt32 curSize = MyMin(fullSize, kBufferLength);
|
||||
UInt32 processedSize;
|
||||
|
||||
@@ -1151,16 +1151,25 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
|
||||
bool sameName = IsUnicode ?
|
||||
(Items[i].NameU == Items[i + 1].NameU) :
|
||||
(Items[i].NameA == Items[i + 1].NameA);
|
||||
if (Items[i].Pos == Items[i + 1].Pos && (IsSolid || sameName))
|
||||
if (Items[i].Pos == Items[i + 1].Pos && sameName)
|
||||
Items.Delete(i + 1);
|
||||
else
|
||||
i++;
|
||||
}
|
||||
for (i = 0; i + 1 < Items.Size(); i++)
|
||||
for (i = 0; i < Items.Size(); i++)
|
||||
{
|
||||
CItem &item = Items[i];
|
||||
UInt32 curPos = item.Pos + 4;
|
||||
for (int nextIndex = i + 1; nextIndex < Items.Size(); nextIndex++)
|
||||
{
|
||||
UInt32 nextPos = Items[nextIndex].Pos;
|
||||
if (curPos <= nextPos)
|
||||
{
|
||||
item.EstimatedSizeIsDefined = true;
|
||||
item.EstimatedSize = Items[i + 1].Pos - item.Pos - 4;
|
||||
item.EstimatedSize = nextPos - curPos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!IsSolid)
|
||||
{
|
||||
@@ -1275,6 +1284,11 @@ static bool IsLZMA(const Byte *p, UInt32 &dictionary, bool &thereIsFlag)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool IsBZip2(const Byte *p)
|
||||
{
|
||||
return (p[0] == 0x31 && p[1] < 14);
|
||||
}
|
||||
|
||||
HRESULT CInArchive::Open2(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS2
|
||||
)
|
||||
@@ -1312,8 +1326,15 @@ HRESULT CInArchive::Open2(
|
||||
else if (sig[3] == 0x80)
|
||||
{
|
||||
IsSolid = false;
|
||||
if (IsBZip2(sig + 4))
|
||||
Method = NMethodType::kBZip2;
|
||||
else
|
||||
Method = NMethodType::kDeflate;
|
||||
}
|
||||
else if (IsBZip2(sig))
|
||||
{
|
||||
Method = NMethodType::kBZip2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Method = NMethodType::kDeflate;
|
||||
|
||||
@@ -156,7 +156,7 @@ struct CMftRef
|
||||
#define ATNAME(n) ATTR_TYPE_ ## n
|
||||
#define DEF_ATTR_TYPE(v, n) ATNAME(n) = v
|
||||
|
||||
typedef enum
|
||||
enum
|
||||
{
|
||||
DEF_ATTR_TYPE(0x00, UNUSED),
|
||||
DEF_ATTR_TYPE(0x10, STANDARD_INFO),
|
||||
@@ -873,7 +873,7 @@ STDMETHODIMP CByteBufStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPo
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT DataParseExtents(int clusterSizeLog, const CObjectVector<CAttr> attrs,
|
||||
static HRESULT DataParseExtents(int clusterSizeLog, const CObjectVector<CAttr> &attrs,
|
||||
int attrIndex, int attrIndexLim, UInt64 numPhysClusters, CRecordVector<CExtent> &Extents)
|
||||
{
|
||||
CExtent e;
|
||||
@@ -969,6 +969,7 @@ struct CMftRec
|
||||
void ParseDataNames();
|
||||
HRESULT GetStream(IInStream *mainStream, int dataIndex,
|
||||
int clusterSizeLog, UInt64 numPhysClusters, IInStream **stream) const;
|
||||
int GetNumExtents(int dataIndex, int clusterSizeLog, UInt64 numPhysClusters) const;
|
||||
|
||||
UInt64 GetSize(int dataIndex) const { return DataAttrs[DataRefs[dataIndex].Start].GetSize(); }
|
||||
|
||||
@@ -1036,6 +1037,35 @@ HRESULT CMftRec::GetStream(IInStream *mainStream, int dataIndex,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int CMftRec::GetNumExtents(int dataIndex, int clusterSizeLog, UInt64 numPhysClusters) const
|
||||
{
|
||||
if (dataIndex < 0)
|
||||
return 0;
|
||||
{
|
||||
const CDataRef &ref = DataRefs[dataIndex];
|
||||
int numNonResident = 0;
|
||||
int i;
|
||||
for (i = ref.Start; i < ref.Start + ref.Num; i++)
|
||||
if (DataAttrs[i].NonResident)
|
||||
numNonResident++;
|
||||
|
||||
const CAttr &attr0 = DataAttrs[ref.Start];
|
||||
|
||||
if (numNonResident != 0 || ref.Num != 1)
|
||||
{
|
||||
if (numNonResident != ref.Num || !attr0.IsCompressionUnitSupported())
|
||||
return 0; // error;
|
||||
CRecordVector<CExtent> extents;
|
||||
if (DataParseExtents(clusterSizeLog, DataAttrs, ref.Start, ref.Start + ref.Num, numPhysClusters, extents) != S_OK)
|
||||
return 0; // error;
|
||||
return extents.Size() - 1;
|
||||
}
|
||||
// if (attr0.Data.GetCapacity() != 0)
|
||||
// return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool CMftRec::Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNumber,
|
||||
CObjectVector<CAttr> *attrs)
|
||||
{
|
||||
@@ -1425,7 +1455,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
STATPROPSTG kProps[] =
|
||||
static const STATPROPSTG kProps[] =
|
||||
{
|
||||
{ NULL, kpidPath, VT_BSTR},
|
||||
{ NULL, kpidIsDir, VT_BOOL},
|
||||
@@ -1435,10 +1465,11 @@ STATPROPSTG kProps[] =
|
||||
{ NULL, kpidCTime, VT_FILETIME},
|
||||
{ NULL, kpidATime, VT_FILETIME},
|
||||
{ NULL, kpidAttrib, VT_UI4},
|
||||
{ NULL, kpidLinks, VT_UI4}
|
||||
{ NULL, kpidLinks, VT_UI4},
|
||||
{ NULL, kpidNumBlocks, VT_UI4}
|
||||
};
|
||||
|
||||
STATPROPSTG kArcProps[] =
|
||||
static const STATPROPSTG kArcProps[] =
|
||||
{
|
||||
{ NULL, kpidVolumeName, VT_BSTR},
|
||||
{ NULL, kpidFileSystem, VT_BSTR},
|
||||
@@ -1582,6 +1613,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
case kpidLinks: prop = rec.MyNumNameLinks; break;
|
||||
case kpidSize: if (data) prop = data->GetSize(); break;
|
||||
case kpidPackSize: if (data) prop = data->GetPackSize(); break;
|
||||
case kpidNumBlocks: if (data) prop = (UInt32)rec.GetNumExtents(item.DataIndex, Header.ClusterSizeLog, Header.NumClusters); break;
|
||||
}
|
||||
prop.Detach(value);
|
||||
return S_OK;
|
||||
|
||||
@@ -98,7 +98,7 @@ void CDirLink::Parse(const Byte *p)
|
||||
{
|
||||
Va = Get32(p);
|
||||
Size = Get32(p + 4);
|
||||
};
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -991,7 +991,7 @@ bool CBitmapInfoHeader::Parse(const Byte *p, size_t size)
|
||||
Compression = Get32(p + 16);
|
||||
SizeImage = Get32(p + 20);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
static UInt32 GetImageSize(UInt32 xSize, UInt32 ySize, UInt32 bitCount)
|
||||
{
|
||||
|
||||
@@ -107,8 +107,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
|
||||
if (prop.vt != VT_UI8)
|
||||
return E_INVALIDARG;
|
||||
ui.Size = prop.uhVal.QuadPart;
|
||||
/*
|
||||
// now we support GNU extension for big files
|
||||
if (ui.Size >= ((UInt64)1 << 33))
|
||||
return E_INVALIDARG;
|
||||
*/
|
||||
}
|
||||
updateItems.Add(ui);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../../C/CpuArch.h"
|
||||
|
||||
#include "Common/StringToInt.h"
|
||||
|
||||
#include "../../Common/StreamUtils.h"
|
||||
@@ -92,7 +94,16 @@ static HRESULT GetNextItemReal(ISequentialInStream *stream, bool &filled, CItemE
|
||||
if (!OctalToNumber32(p, 8, item.UID)) item.UID = 0; p += 8;
|
||||
if (!OctalToNumber32(p, 8, item.GID)) item.GID = 0; p += 8;
|
||||
|
||||
RIF(OctalToNumber(p, 12, item.Size)); p += 12;
|
||||
if (GetBe32(p) == (UInt32)1 << 31)
|
||||
{
|
||||
// GNU extension
|
||||
item.Size = GetBe64(p + 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
RIF(OctalToNumber(p, 12, item.Size));
|
||||
}
|
||||
p += 12;
|
||||
RIF(OctalToNumber32(p, 12, item.MTime)); p += 12;
|
||||
|
||||
UInt32 checkSum;
|
||||
|
||||
@@ -53,17 +53,23 @@ static bool MakeOctalString8(char *s, UInt32 value)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool MakeOctalString12(char *s, UInt64 value)
|
||||
static void MakeOctalString12(char *s, UInt64 value)
|
||||
{
|
||||
AString tempString = MakeOctalString(value);
|
||||
const int kMaxSize = 12;
|
||||
if (tempString.Length() > kMaxSize)
|
||||
return false;
|
||||
{
|
||||
// GNU extension;
|
||||
s[0] = (char)(Byte)0x80;
|
||||
s[1] = s[2] = s[3] = 0;
|
||||
for (int i = 0; i < 8; i++, value <<= 8)
|
||||
s[4 + i] = (char)(value >> 56);
|
||||
return;
|
||||
}
|
||||
int numSpaces = kMaxSize - tempString.Length();
|
||||
for(int i = 0; i < numSpaces; i++)
|
||||
s[i] = ' ';
|
||||
memmove(s + numSpaces, (const char *)tempString, tempString.Length());
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool CopyString(char *dest, const AString &src, int maxSize)
|
||||
@@ -90,17 +96,12 @@ HRESULT COutArchive::WriteHeaderReal(const CItem &item)
|
||||
MyStrNCpy(cur, item.Name, NFileHeader::kNameSize);
|
||||
cur += NFileHeader::kNameSize;
|
||||
|
||||
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.Mode));
|
||||
cur += 8;
|
||||
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.UID));
|
||||
cur += 8;
|
||||
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.GID));
|
||||
cur += 8;
|
||||
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.Mode)); cur += 8;
|
||||
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.UID)); cur += 8;
|
||||
RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.GID)); cur += 8;
|
||||
|
||||
RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.Size));
|
||||
cur += 12;
|
||||
RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.MTime));
|
||||
cur += 12;
|
||||
MakeOctalString12(cur, item.Size); cur += 12;
|
||||
MakeOctalString12(cur, item.MTime); cur += 12;
|
||||
|
||||
memmove(cur, NFileHeader::kCheckSumBlanks, 8);
|
||||
cur += 8;
|
||||
|
||||
@@ -35,4 +35,3 @@ public:
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -202,7 +202,7 @@ enum EDescriptorType
|
||||
DESC_TYPE_UnallocatedSpace = 263,
|
||||
DESC_TYPE_SpaceBitmap = 264,
|
||||
DESC_TYPE_PartitionIntegrity = 265,
|
||||
DESC_TYPE_ExtendedFile = 266,
|
||||
DESC_TYPE_ExtendedFile = 266
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ static STATPROPSTG kArcProps[] =
|
||||
{ NULL, kpidCTime, VT_FILETIME},
|
||||
{ NULL, kpidMTime, VT_FILETIME},
|
||||
{ NULL, kpidComment, VT_BSTR},
|
||||
{ NULL, kpidUnpackVer, VT_BSTR},
|
||||
{ NULL, kpidIsVolume, VT_BOOL},
|
||||
{ NULL, kpidVolume, VT_UI4},
|
||||
{ NULL, kpidNumVolumes, VT_UI4}
|
||||
@@ -226,6 +227,28 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
||||
}
|
||||
break;
|
||||
|
||||
case kpidUnpackVer:
|
||||
{
|
||||
UInt32 ver1 = _version >> 16;
|
||||
UInt32 ver2 = (_version >> 8) & 0xFF;
|
||||
UInt32 ver3 = (_version) & 0xFF;
|
||||
|
||||
char s[16];
|
||||
ConvertUInt32ToString(ver1, s);
|
||||
AString res = s;
|
||||
res += '.';
|
||||
ConvertUInt32ToString(ver2, s);
|
||||
res += s;
|
||||
if (ver3 != 0)
|
||||
{
|
||||
res += '.';
|
||||
ConvertUInt32ToString(ver3, s);
|
||||
res += s;
|
||||
}
|
||||
prop = res;
|
||||
break;
|
||||
}
|
||||
|
||||
case kpidIsVolume:
|
||||
if (_xmls.Size() > 0)
|
||||
{
|
||||
@@ -303,8 +326,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
prop = _db.GetItemPath(realIndex);
|
||||
else
|
||||
{
|
||||
char sz[32];
|
||||
ConvertUInt64ToString(item.StreamIndex, sz);
|
||||
char sz[16];
|
||||
ConvertUInt32ToString(item.StreamIndex, sz);
|
||||
AString s = sz;
|
||||
while (s.Length() < _nameLenForStreams)
|
||||
s = '0' + s;
|
||||
@@ -342,8 +365,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
{
|
||||
case kpidPath:
|
||||
{
|
||||
char sz[32];
|
||||
ConvertUInt64ToString(_xmls[index].VolIndex, sz);
|
||||
char sz[16];
|
||||
ConvertUInt32ToString(_xmls[index].VolIndex, sz);
|
||||
prop = (AString)"[" + (AString)sz + "].xml";
|
||||
break;
|
||||
}
|
||||
@@ -379,8 +402,8 @@ public:
|
||||
|
||||
UString GetNextName(UInt32 index)
|
||||
{
|
||||
wchar_t s[32];
|
||||
ConvertUInt64ToString((index), s);
|
||||
wchar_t s[16];
|
||||
ConvertUInt32ToString(index, s);
|
||||
return _before + (UString)s + _after;
|
||||
}
|
||||
};
|
||||
@@ -391,7 +414,6 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
Close();
|
||||
try
|
||||
{
|
||||
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
|
||||
|
||||
@@ -427,6 +449,8 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
continue;
|
||||
return res;
|
||||
}
|
||||
_version = header.Version;
|
||||
_isOldVersion = header.IsOldVersion();
|
||||
if (firstVolumeIndex >= 0)
|
||||
if (!header.AreFromOnArchive(_volumes[firstVolumeIndex].Header))
|
||||
break;
|
||||
@@ -482,16 +506,12 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
|
||||
_db.DetectPathMode();
|
||||
RINOK(_db.Sort(_db.SkipRoot));
|
||||
|
||||
wchar_t sz[32];
|
||||
ConvertUInt64ToString(_db.Streams.Size(), sz);
|
||||
wchar_t sz[16];
|
||||
ConvertUInt32ToString(_db.Streams.Size(), sz);
|
||||
_nameLenForStreams = MyStringLen(sz);
|
||||
|
||||
_xmlInComments = (_xmls.Size() == 1 && !_db.ShowImageNumber);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return S_FALSE;
|
||||
}
|
||||
return S_OK;
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ class CHandler:
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CDatabase _db;
|
||||
UInt32 _version;
|
||||
bool _isOldVersion;
|
||||
CObjectVector<CVolume> _volumes;
|
||||
CObjectVector<CXml> _xmls;
|
||||
int _nameLenForStreams;
|
||||
|
||||
@@ -258,7 +258,7 @@ static size_t WriteItem(const CUpdateItem &item, Byte *p, const Byte *hash)
|
||||
return totalLen;
|
||||
}
|
||||
|
||||
void WriteTree(const CDir &tree, CRecordVector<CSha1Hash> &digests,
|
||||
static void WriteTree(const CDir &tree, CRecordVector<CSha1Hash> &digests,
|
||||
CUpdateItem &defaultDirItem,
|
||||
CObjectVector<CUpdateItem> &updateItems, Byte *dest, size_t &pos)
|
||||
{
|
||||
@@ -488,11 +488,15 @@ static HRESULT UpdateArchive(ISequentialOutStream *seqOutStream,
|
||||
const UInt32 kSecuritySize = 8;
|
||||
size_t pos = kSecuritySize;
|
||||
WriteTree(rootFolder, hashes.Digests, ri, updateItems, NULL, pos);
|
||||
|
||||
CByteBuffer meta;
|
||||
meta.SetCapacity(pos);
|
||||
// memset(meta, 0, kSecuritySize);
|
||||
Set32((Byte *)meta, 0); // only if there is no security data, we can use 0 here.
|
||||
|
||||
// we can write 0 here only if there is no security data, imageX does it,
|
||||
// but some programs expect size = 8
|
||||
Set32((Byte *)meta, 8); // size of security data
|
||||
Set32((Byte *)meta + 4, 0); // num security entries
|
||||
|
||||
pos = kSecuritySize;
|
||||
WriteTree(rootFolder, hashes.Digests, ri, updateItems, (Byte *)meta, pos);
|
||||
|
||||
|
||||
@@ -258,12 +258,22 @@ void CResource::Parse(const Byte *p)
|
||||
|
||||
#define GetResource(p, res) res.Parse(p)
|
||||
|
||||
static void GetStream(const Byte *p, CStreamInfo &s)
|
||||
static void GetStream(bool oldVersion, const Byte *p, CStreamInfo &s)
|
||||
{
|
||||
s.Resource.Parse(p);
|
||||
if (oldVersion)
|
||||
{
|
||||
s.PartNumber = 1;
|
||||
s.Id = Get32(p + 24);
|
||||
s.RefCount = Get32(p + 28);
|
||||
memcpy(s.Hash, p + 32, kHashSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
s.PartNumber = Get16(p + 24);
|
||||
s.RefCount = Get32(p + 26);
|
||||
memcpy(s.Hash, p + 30, kHashSize);
|
||||
}
|
||||
}
|
||||
|
||||
static const wchar_t *kLongPath = L"[LongPath]";
|
||||
@@ -373,26 +383,48 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent)
|
||||
DirProcessed += 8;
|
||||
return S_OK;
|
||||
}
|
||||
if ((len & 7) != 0 || len < 0x28 || rem < len)
|
||||
if ((len & 7) != 0 || rem < len)
|
||||
return S_FALSE;
|
||||
if (!IsOldVersion)
|
||||
if (len < 0x28)
|
||||
return S_FALSE;
|
||||
DirProcessed += (size_t)len;
|
||||
if (DirProcessed > DirSize)
|
||||
return S_FALSE;
|
||||
if (Get64(p + 8) == 0)
|
||||
int extraOffset = 0;
|
||||
if (IsOldVersion)
|
||||
{
|
||||
if (len < 0x40 || (/* Get32(p + 12) == 0 && */ Get32(p + 0x14) != 0))
|
||||
{
|
||||
extraOffset = 0x10;
|
||||
}
|
||||
}
|
||||
else if (Get64(p + 8) == 0)
|
||||
extraOffset = 0x24;
|
||||
if (extraOffset)
|
||||
{
|
||||
if (prevIndex == -1)
|
||||
return S_FALSE;
|
||||
|
||||
UInt32 fileNameLen = Get16(p + 0x24);
|
||||
if ((fileNameLen & 1) != 0 || ((0x26 + fileNameLen + 6) & ~7) != len)
|
||||
UInt32 fileNameLen = Get16(p + extraOffset);
|
||||
if ((fileNameLen & 1) != 0)
|
||||
return S_FALSE;
|
||||
/* Probably different versions of ImageX can use different number of
|
||||
additional ZEROs. So we don't use exact check. */
|
||||
UInt32 fileNameLen2 = (fileNameLen == 0 ? fileNameLen : fileNameLen + 2);
|
||||
if (((extraOffset + 2 + fileNameLen2 + 6) & ~7) > len)
|
||||
return S_FALSE;
|
||||
|
||||
UString name;
|
||||
RINOK(ReadName(p + 0x26, fileNameLen, name));
|
||||
RINOK(ReadName(p + extraOffset + 2, fileNameLen, name));
|
||||
|
||||
CItem &prevItem = Items[prevIndex];
|
||||
if (name.IsEmpty() && !prevItem.HasStream())
|
||||
{
|
||||
if (IsOldVersion)
|
||||
prevItem.Id = Get32(p + 8);
|
||||
else
|
||||
memcpy(prevItem.Hash, p + 0x10, kHashSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
CItem item;
|
||||
@@ -400,6 +432,12 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent)
|
||||
item.CTime = prevItem.CTime;
|
||||
item.ATime = prevItem.ATime;
|
||||
item.MTime = prevItem.MTime;
|
||||
if (IsOldVersion)
|
||||
{
|
||||
item.Id = Get32(p + 8);
|
||||
memset(item.Hash, 0, kHashSize);
|
||||
}
|
||||
else
|
||||
memcpy(item.Hash, p + 0x10, kHashSize);
|
||||
item.Attrib = 0;
|
||||
item.Order = Order++;
|
||||
@@ -409,30 +447,41 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent)
|
||||
pos += (size_t)len;
|
||||
continue;
|
||||
}
|
||||
if (len < kDirRecordSize)
|
||||
|
||||
UInt32 dirRecordSize = IsOldVersion ? kDirRecordSizeOld : kDirRecordSize;
|
||||
if (len < dirRecordSize)
|
||||
return S_FALSE;
|
||||
|
||||
CItem item;
|
||||
item.Attrib = Get32(p + 8);
|
||||
// item.SecurityId = Get32(p + 0xC);
|
||||
UInt64 subdirOffset = Get64(p + 0x10);
|
||||
GetFileTimeFromMem(p + 0x28, &item.CTime);
|
||||
GetFileTimeFromMem(p + 0x30, &item.ATime);
|
||||
GetFileTimeFromMem(p + 0x38, &item.MTime);
|
||||
UInt32 timeOffset = IsOldVersion ? 0x18: 0x28;
|
||||
GetFileTimeFromMem(p + timeOffset, &item.CTime);
|
||||
GetFileTimeFromMem(p + timeOffset + 8, &item.ATime);
|
||||
GetFileTimeFromMem(p + timeOffset + 16, &item.MTime);
|
||||
if (IsOldVersion)
|
||||
{
|
||||
item.Id = Get32(p + 0x10);
|
||||
memset(item.Hash, 0, kHashSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(item.Hash, p + 0x40, kHashSize);
|
||||
}
|
||||
// UInt32 numStreams = Get16(p + dirRecordSize - 6);
|
||||
UInt32 shortNameLen = Get16(p + dirRecordSize - 4);
|
||||
UInt32 fileNameLen = Get16(p + dirRecordSize - 2);
|
||||
|
||||
UInt32 shortNameLen = Get16(p + 98);
|
||||
UInt32 fileNameLen = Get16(p + 100);
|
||||
if ((shortNameLen & 1) != 0 || (fileNameLen & 1) != 0)
|
||||
return S_FALSE;
|
||||
|
||||
UInt32 shortNameLen2 = (shortNameLen == 0 ? shortNameLen : shortNameLen + 2);
|
||||
UInt32 fileNameLen2 = (fileNameLen == 0 ? fileNameLen : fileNameLen + 2);
|
||||
|
||||
if (((kDirRecordSize + fileNameLen2 + shortNameLen2 + 6) & ~7) > len)
|
||||
if (((dirRecordSize + fileNameLen2 + shortNameLen2 + 6) & ~7) > len)
|
||||
return S_FALSE;
|
||||
|
||||
p += kDirRecordSize;
|
||||
p += dirRecordSize;
|
||||
|
||||
RINOK(ReadName(p, fileNameLen, item.Name));
|
||||
RINOK(ReadName(p + fileNameLen2, shortNameLen, item.ShortName));
|
||||
@@ -442,9 +491,9 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent)
|
||||
|
||||
/*
|
||||
// there are some extra data for some files.
|
||||
p -= kDirRecordSize;
|
||||
p += ((kDirRecordSize + fileNameLen2 + shortNameLen2 + 6) & ~7);
|
||||
if (((kDirRecordSize + fileNameLen2 + shortNameLen2 + 6) & ~7) != len)
|
||||
p -= dirRecordSize;
|
||||
p += ((dirRecordSize + fileNameLen2 + shortNameLen2 + 6) & ~7);
|
||||
if (((dirRecordSize + fileNameLen2 + shortNameLen2 + 6) & ~7) != len)
|
||||
p = p;
|
||||
*/
|
||||
|
||||
@@ -480,6 +529,29 @@ HRESULT CDatabase::ParseImageDirs(const CByteBuffer &buf, int parent)
|
||||
return S_FALSE;
|
||||
const Byte *p = DirData;
|
||||
UInt32 totalLength = Get32(p);
|
||||
if (IsOldVersion)
|
||||
{
|
||||
for (pos = 4;; pos += 8)
|
||||
{
|
||||
if (pos + 4 > DirSize)
|
||||
return S_FALSE;
|
||||
UInt32 n = Get32(p + pos);
|
||||
if (n == 0)
|
||||
break;
|
||||
if (pos + 8 > DirSize)
|
||||
return S_FALSE;
|
||||
totalLength += Get32(p + pos + 4);
|
||||
if (totalLength > DirSize)
|
||||
return S_FALSE;
|
||||
}
|
||||
pos += totalLength + 4;
|
||||
pos = (pos + 7) & ~(size_t)7;
|
||||
if (pos > DirSize)
|
||||
return S_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// UInt32 numEntries = Get32(p + 4);
|
||||
pos += 8;
|
||||
{
|
||||
@@ -495,7 +567,7 @@ HRESULT CDatabase::ParseImageDirs(const CByteBuffer &buf, int parent)
|
||||
sum += len;
|
||||
pos += 8;
|
||||
}
|
||||
pos += sum; // skip security descriptors
|
||||
pos += (size_t)sum; // skip security descriptors
|
||||
while ((pos & 7) != 0)
|
||||
pos++;
|
||||
if (pos != totalLength)
|
||||
@@ -508,6 +580,7 @@ HRESULT CDatabase::ParseImageDirs(const CByteBuffer &buf, int parent)
|
||||
else
|
||||
pos = totalLength;
|
||||
}
|
||||
}
|
||||
DirStartOffset = DirProcessed = pos;
|
||||
RINOK(ParseDirItem(pos, parent));
|
||||
if (DirProcessed == DirSize)
|
||||
@@ -522,9 +595,7 @@ HRESULT CDatabase::ParseImageDirs(const CByteBuffer &buf, int parent)
|
||||
|
||||
HRESULT CHeader::Parse(const Byte *p)
|
||||
{
|
||||
UInt32 haderSize = Get32(p + 8);
|
||||
if (haderSize < 0x74)
|
||||
return S_FALSE;
|
||||
UInt32 headerSize = Get32(p + 8);
|
||||
Version = Get32(p + 0x0C);
|
||||
Flags = Get32(p + 0x10);
|
||||
if (!IsSupported())
|
||||
@@ -532,21 +603,36 @@ HRESULT CHeader::Parse(const Byte *p)
|
||||
ChunkSize = Get32(p + 0x14);
|
||||
if (ChunkSize != kChunkSize && ChunkSize != 0)
|
||||
return S_FALSE;
|
||||
int offset;
|
||||
if (IsOldVersion())
|
||||
{
|
||||
if (headerSize != 0x60)
|
||||
return S_FALSE;
|
||||
memset(Guid, 0, 16);
|
||||
offset = 0x18;
|
||||
PartNumber = 1;
|
||||
NumParts = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (headerSize < 0x74)
|
||||
return S_FALSE;
|
||||
memcpy(Guid, p + 0x18, 16);
|
||||
PartNumber = Get16(p + 0x28);
|
||||
NumParts = Get16(p + 0x2A);
|
||||
int offset = 0x2C;
|
||||
offset = 0x2C;
|
||||
if (IsNewVersion())
|
||||
{
|
||||
NumImages = Get32(p + offset);
|
||||
offset += 4;
|
||||
}
|
||||
}
|
||||
GetResource(p + offset, OffsetResource);
|
||||
GetResource(p + offset + 0x18, XmlResource);
|
||||
GetResource(p + offset + 0x30, MetadataResource);
|
||||
if (IsNewVersion())
|
||||
{
|
||||
if (haderSize < 0xD0)
|
||||
if (headerSize < 0xD0)
|
||||
return S_FALSE;
|
||||
BootIndex = Get32(p + 0x48);
|
||||
IntegrityResource.Parse(p + offset + 0x4C);
|
||||
@@ -565,26 +651,36 @@ HRESULT ReadHeader(IInStream *inStream, CHeader &h)
|
||||
return h.Parse(p);
|
||||
}
|
||||
|
||||
static HRESULT ReadStreams(IInStream *inStream, const CHeader &h, CDatabase &db)
|
||||
static HRESULT ReadStreams(bool oldVersion, IInStream *inStream, const CHeader &h, CDatabase &db)
|
||||
{
|
||||
CByteBuffer offsetBuf;
|
||||
RINOK(UnpackData(inStream, h.OffsetResource, h.IsLzxMode(), offsetBuf, NULL));
|
||||
size_t i;
|
||||
for (i = 0; offsetBuf.GetCapacity() - i >= kStreamInfoSize; i += kStreamInfoSize)
|
||||
size_t streamInfoSize = oldVersion ? kStreamInfoSize + 2 : kStreamInfoSize;
|
||||
for (i = 0; offsetBuf.GetCapacity() - i >= streamInfoSize; i += streamInfoSize)
|
||||
{
|
||||
CStreamInfo s;
|
||||
GetStream((const Byte *)offsetBuf + i, s);
|
||||
GetStream(oldVersion, (const Byte *)offsetBuf + i, s);
|
||||
if (s.PartNumber == h.PartNumber)
|
||||
db.Streams.Add(s);
|
||||
}
|
||||
return (i == offsetBuf.GetCapacity()) ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
static bool IsEmptySha(const Byte *data)
|
||||
{
|
||||
for (int i = 0; i < kHashSize; i++)
|
||||
if (data[i] != 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
HRESULT CDatabase::Open(IInStream *inStream, const CHeader &h, CByteBuffer &xml, IArchiveOpenCallback *openCallback)
|
||||
{
|
||||
OpenCallback = openCallback;
|
||||
IsOldVersion = h.IsOldVersion();
|
||||
RINOK(UnpackData(inStream, h.XmlResource, h.IsLzxMode(), xml, NULL));
|
||||
RINOK(ReadStreams(inStream, h, *this));
|
||||
RINOK(ReadStreams(h.IsOldVersion(), inStream, h, *this));
|
||||
bool needBootMetadata = !h.MetadataResource.IsEmpty();
|
||||
Order = 0;
|
||||
if (h.PartNumber == 1)
|
||||
@@ -599,7 +695,8 @@ HRESULT CDatabase::Open(IInStream *inStream, const CHeader &h, CByteBuffer &xml,
|
||||
Byte hash[kHashSize];
|
||||
CByteBuffer metadata;
|
||||
RINOK(UnpackData(inStream, si.Resource, h.IsLzxMode(), metadata, hash));
|
||||
if (memcmp(hash, si.Hash, kHashSize) != 0)
|
||||
if (memcmp(hash, si.Hash, kHashSize) != 0 &&
|
||||
!(h.IsOldVersion() && IsEmptySha(si.Hash)))
|
||||
return S_FALSE;
|
||||
NumImages++;
|
||||
RINOK(ParseImageDirs(metadata, -(int)(++imageIndex)));
|
||||
@@ -628,12 +725,37 @@ static int CompareStreamsByPos(const CStreamInfo *p1, const CStreamInfo *p2, voi
|
||||
return MyCompare(p1->Resource.Offset, p2->Resource.Offset);
|
||||
}
|
||||
|
||||
static int CompareIDs(const int *p1, const int *p2, void *param)
|
||||
{
|
||||
const CRecordVector<CStreamInfo> &streams = *(const CRecordVector<CStreamInfo> *)param;
|
||||
return MyCompare(streams[*p1].Id, streams[*p2].Id);
|
||||
}
|
||||
|
||||
static int CompareHashRefs(const int *p1, const int *p2, void *param)
|
||||
{
|
||||
const CRecordVector<CStreamInfo> &streams = *(const CRecordVector<CStreamInfo> *)param;
|
||||
return memcmp(streams[*p1].Hash, streams[*p2].Hash, kHashSize);
|
||||
}
|
||||
|
||||
static int FindId(const CRecordVector<CStreamInfo> &streams,
|
||||
const CIntVector &sortedByHash, UInt32 id)
|
||||
{
|
||||
int left = 0, right = streams.Size();
|
||||
while (left != right)
|
||||
{
|
||||
int mid = (left + right) / 2;
|
||||
int streamIndex = sortedByHash[mid];
|
||||
UInt32 id2 = streams[streamIndex].Id;
|
||||
if (id == id2)
|
||||
return streamIndex;
|
||||
if (id < id2)
|
||||
right = mid;
|
||||
else
|
||||
left = mid + 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int FindHash(const CRecordVector<CStreamInfo> &streams,
|
||||
const CIntVector &sortedByHash, const Byte *hash)
|
||||
{
|
||||
@@ -680,6 +802,9 @@ HRESULT CDatabase::Sort(bool skipRootDir)
|
||||
{
|
||||
for (int i = 0; i < Streams.Size(); i++)
|
||||
sortedByHash.Add(i);
|
||||
if (IsOldVersion)
|
||||
sortedByHash.Sort(CompareIDs, &Streams);
|
||||
else
|
||||
sortedByHash.Sort(CompareHashRefs, &Streams);
|
||||
}
|
||||
|
||||
@@ -688,6 +813,9 @@ HRESULT CDatabase::Sort(bool skipRootDir)
|
||||
CItem &item = Items[i];
|
||||
item.StreamIndex = -1;
|
||||
if (item.HasStream())
|
||||
if (IsOldVersion)
|
||||
item.StreamIndex = FindId(Streams, sortedByHash, item.Id);
|
||||
else
|
||||
item.StreamIndex = FindHash(Streams, sortedByHash, item.Hash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,8 @@ struct CHeader
|
||||
bool IsSupported() const { return (!IsCompressed() || (Flags & NHeaderFlags::kLZX) != 0 || (Flags & NHeaderFlags::kXPRESS) != 0 ) ; }
|
||||
bool IsLzxMode() const { return (Flags & NHeaderFlags::kLZX) != 0; }
|
||||
bool IsSpanned() const { return (!IsCompressed() || (Flags & NHeaderFlags::kSpanned) != 0); }
|
||||
bool IsNewVersion()const { return (Version > 0x010C00); }
|
||||
bool IsOldVersion() const { return (Version <= 0x010A00); }
|
||||
bool IsNewVersion() const { return (Version > 0x010C00); }
|
||||
|
||||
bool AreFromOnArchive(const CHeader &h)
|
||||
{
|
||||
@@ -171,11 +172,13 @@ struct CStreamInfo
|
||||
CResource Resource;
|
||||
UInt16 PartNumber;
|
||||
UInt32 RefCount;
|
||||
UInt32 Id;
|
||||
BYTE Hash[kHashSize];
|
||||
|
||||
void WriteTo(Byte *p) const;
|
||||
};
|
||||
|
||||
const UInt32 kDirRecordSizeOld = 62;
|
||||
const UInt32 kDirRecordSize = 102;
|
||||
|
||||
struct CItem
|
||||
@@ -185,25 +188,25 @@ struct CItem
|
||||
UInt32 Attrib;
|
||||
// UInt32 SecurityId;
|
||||
BYTE Hash[kHashSize];
|
||||
UInt32 Id;
|
||||
FILETIME CTime;
|
||||
FILETIME ATime;
|
||||
FILETIME MTime;
|
||||
// UInt32 ReparseTag;
|
||||
// UInt64 HardLink;
|
||||
// UInt16 NumStreams;
|
||||
// UInt16 ShortNameLen;
|
||||
int StreamIndex;
|
||||
int Parent;
|
||||
unsigned Order;
|
||||
bool HasMetadata;
|
||||
CItem(): HasMetadata(true), StreamIndex(-1) {}
|
||||
CItem(): HasMetadata(true), StreamIndex(-1), Id(0) {}
|
||||
bool IsDir() const { return HasMetadata && ((Attrib & 0x10) != 0); }
|
||||
bool HasStream() const
|
||||
{
|
||||
for (unsigned i = 0; i < kHashSize; i++)
|
||||
if (Hash[i] != 0)
|
||||
return true;
|
||||
return false;
|
||||
return Id != 0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -227,6 +230,8 @@ public:
|
||||
bool SkipRoot;
|
||||
bool ShowImageNumber;
|
||||
|
||||
bool IsOldVersion;
|
||||
|
||||
UInt64 GetUnpackSize() const
|
||||
{
|
||||
UInt64 res = 0;
|
||||
@@ -252,6 +257,7 @@ public:
|
||||
|
||||
SkipRoot = true;
|
||||
ShowImageNumber = true;
|
||||
IsOldVersion = false;
|
||||
}
|
||||
|
||||
UString GetItemPath(int index) const;
|
||||
|
||||
@@ -146,6 +146,7 @@ HRESULT CAddCommon::Compress(
|
||||
opRes.ExtractVersion = NFileHeader::NCompressionMethod::kExtractVersion_Default;
|
||||
if (inCrcStreamSpec != 0)
|
||||
RINOK(inCrcStreamSpec->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
RINOK(outStream->SetSize(0));
|
||||
RINOK(outStream->Seek(0, STREAM_SEEK_SET, NULL));
|
||||
if (_options.PasswordIsDefined)
|
||||
{
|
||||
@@ -218,7 +219,7 @@ HRESULT CAddCommon::Compress(
|
||||
_options.Algo,
|
||||
_options.DicSize,
|
||||
_options.NumFastBytes,
|
||||
(BSTR)(const wchar_t *)_options.MatchFinder,
|
||||
const_cast<BSTR>((const wchar_t *)_options.MatchFinder),
|
||||
_options.NumMatchFinderCycles
|
||||
};
|
||||
PROPID propIDs[] =
|
||||
@@ -373,7 +374,7 @@ HRESULT CAddCommon::Compress(
|
||||
RINOK(outStream->Seek(0, STREAM_SEEK_CUR, &opRes.PackSize));
|
||||
}
|
||||
opRes.Method = method;
|
||||
return outStream->SetSize(opRes.PackSize);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace NFileHeader
|
||||
kWzAES = 0x63
|
||||
};
|
||||
const int kNumCompressionMethods = 11;
|
||||
const Byte kMadeByProgramVersion = 20;
|
||||
const Byte kMadeByProgramVersion = 63;
|
||||
|
||||
const Byte kExtractVersion_Default = 10;
|
||||
const Byte kExtractVersion_Dir = 20;
|
||||
|
||||
@@ -544,7 +544,17 @@ HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
|
||||
UInt64 curPos = endPosition - bufSize + i;
|
||||
UInt64 cdEnd = cdInfo.Size + cdInfo.Offset;
|
||||
if (curPos != cdEnd)
|
||||
{
|
||||
/*
|
||||
if (cdInfo.Offset <= 16 && cdInfo.Size != 0)
|
||||
{
|
||||
// here we support some rare ZIP files with Central directory at the start
|
||||
ArcInfo.Base = 0;
|
||||
}
|
||||
else
|
||||
*/
|
||||
ArcInfo.Base = curPos - cdEnd;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../../C/Alloc.h"
|
||||
|
||||
#include "Common/AutoPtr.h"
|
||||
#include "Common/Defs.h"
|
||||
#include "Common/StringConvert.h"
|
||||
@@ -16,6 +18,7 @@
|
||||
#ifndef _7ZIP_ST
|
||||
#include "../../Common/ProgressMt.h"
|
||||
#endif
|
||||
#include "../../Common/StreamUtils.h"
|
||||
|
||||
#include "../../Compress/CopyCoder.h"
|
||||
|
||||
@@ -798,6 +801,216 @@ static HRESULT Update2(
|
||||
#endif
|
||||
}
|
||||
|
||||
static const size_t kCacheBlockSize = (1 << 20);
|
||||
static const size_t kCacheSize = (kCacheBlockSize << 2);
|
||||
static const size_t kCacheMask = (kCacheSize - 1);
|
||||
|
||||
class CCacheOutStream:
|
||||
public IOutStream,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
CMyComPtr<IOutStream> _stream;
|
||||
Byte *_cache;
|
||||
UInt64 _virtPos;
|
||||
UInt64 _virtSize;
|
||||
UInt64 _phyPos;
|
||||
UInt64 _phySize; // <= _virtSize
|
||||
UInt64 _cachedPos; // (_cachedPos + _cachedSize) <= _virtSize
|
||||
size_t _cachedSize;
|
||||
|
||||
HRESULT MyWrite(size_t size);
|
||||
HRESULT MyWriteBlock()
|
||||
{
|
||||
return MyWrite(kCacheBlockSize - ((size_t)_cachedPos & (kCacheBlockSize - 1)));
|
||||
}
|
||||
HRESULT FlushCache();
|
||||
public:
|
||||
CCacheOutStream(): _cache(0) {}
|
||||
~CCacheOutStream();
|
||||
bool Allocate();
|
||||
HRESULT Init(IOutStream *stream);
|
||||
|
||||
MY_UNKNOWN_IMP
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||
STDMETHOD(SetSize)(UInt64 newSize);
|
||||
};
|
||||
|
||||
bool CCacheOutStream::Allocate()
|
||||
{
|
||||
if (!_cache)
|
||||
_cache = (Byte *)::MidAlloc(kCacheSize);
|
||||
return (_cache != NULL);
|
||||
}
|
||||
|
||||
HRESULT CCacheOutStream::Init(IOutStream *stream)
|
||||
{
|
||||
_virtPos = _phyPos = 0;
|
||||
_stream = stream;
|
||||
RINOK(_stream->Seek(0, STREAM_SEEK_CUR, &_virtPos));
|
||||
RINOK(_stream->Seek(0, STREAM_SEEK_END, &_virtSize));
|
||||
RINOK(_stream->Seek(_virtPos, STREAM_SEEK_SET, &_virtPos));
|
||||
_phyPos = _virtPos;
|
||||
_phySize = _virtSize;
|
||||
_cachedPos = 0;
|
||||
_cachedSize = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CCacheOutStream::MyWrite(size_t size)
|
||||
{
|
||||
while (size != 0 && _cachedSize != 0)
|
||||
{
|
||||
if (_phyPos != _cachedPos)
|
||||
{
|
||||
RINOK(_stream->Seek(_cachedPos, STREAM_SEEK_SET, &_phyPos));
|
||||
}
|
||||
size_t pos = (size_t)_cachedPos & kCacheMask;
|
||||
size_t curSize = MyMin(kCacheSize - pos, _cachedSize);
|
||||
curSize = MyMin(curSize, size);
|
||||
RINOK(WriteStream(_stream, _cache + pos, curSize));
|
||||
_phyPos += curSize;
|
||||
if (_phySize < _phyPos)
|
||||
_phySize = _phyPos;
|
||||
_cachedPos += curSize;
|
||||
_cachedSize -= curSize;
|
||||
size -= curSize;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CCacheOutStream::FlushCache()
|
||||
{
|
||||
return MyWrite(_cachedSize);
|
||||
}
|
||||
|
||||
CCacheOutStream::~CCacheOutStream()
|
||||
{
|
||||
FlushCache();
|
||||
if (_virtSize != _phySize)
|
||||
_stream->SetSize(_virtSize);
|
||||
if (_virtPos != _phyPos)
|
||||
_stream->Seek(_virtPos, STREAM_SEEK_SET, NULL);
|
||||
::MidFree(_cache);
|
||||
}
|
||||
|
||||
STDMETHODIMP CCacheOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
if (processedSize)
|
||||
*processedSize = 0;
|
||||
if (size == 0)
|
||||
return S_OK;
|
||||
|
||||
UInt64 zerosStart = _virtPos;
|
||||
if (_cachedSize != 0)
|
||||
{
|
||||
if (_virtPos < _cachedPos)
|
||||
{
|
||||
RINOK(FlushCache());
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt64 cachedEnd = _cachedPos + _cachedSize;
|
||||
if (cachedEnd < _virtPos)
|
||||
{
|
||||
if (cachedEnd < _phySize)
|
||||
{
|
||||
RINOK(FlushCache());
|
||||
}
|
||||
else
|
||||
zerosStart = cachedEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_cachedSize == 0 && _phySize < _virtPos)
|
||||
_cachedPos = zerosStart = _phySize;
|
||||
|
||||
if (zerosStart != _virtPos)
|
||||
{
|
||||
// write zeros to [cachedEnd ... _virtPos)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
UInt64 cachedEnd = _cachedPos + _cachedSize;
|
||||
size_t endPos = (size_t)cachedEnd & kCacheMask;
|
||||
size_t curSize = kCacheSize - endPos;
|
||||
if (curSize > _virtPos - cachedEnd)
|
||||
curSize = (size_t)(_virtPos - cachedEnd);
|
||||
if (curSize == 0)
|
||||
break;
|
||||
while (curSize > (kCacheSize - _cachedSize))
|
||||
{
|
||||
RINOK(MyWriteBlock());
|
||||
}
|
||||
memset(_cache + endPos, 0, curSize);
|
||||
_cachedSize += curSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (_cachedSize == 0)
|
||||
_cachedPos = _virtPos;
|
||||
|
||||
size_t pos = (size_t)_virtPos & kCacheMask;
|
||||
size = (UInt32)MyMin((size_t)size, kCacheSize - pos);
|
||||
UInt64 cachedEnd = _cachedPos + _cachedSize;
|
||||
if (_virtPos != cachedEnd) // _virtPos < cachedEnd
|
||||
size = (UInt32)MyMin((size_t)size, (size_t)(cachedEnd - _virtPos));
|
||||
else
|
||||
{
|
||||
// _virtPos == cachedEnd
|
||||
if (_cachedSize == kCacheSize)
|
||||
{
|
||||
RINOK(MyWriteBlock());
|
||||
}
|
||||
size_t startPos = (size_t)_cachedPos & kCacheMask;
|
||||
if (startPos > pos)
|
||||
size = (UInt32)MyMin((size_t)size, (size_t)(startPos - pos));
|
||||
_cachedSize += size;
|
||||
}
|
||||
memcpy(_cache + pos, data, size);
|
||||
if (processedSize)
|
||||
*processedSize = size;
|
||||
_virtPos += size;
|
||||
if (_virtSize < _virtPos)
|
||||
_virtSize = _virtPos;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CCacheOutStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
|
||||
{
|
||||
switch(seekOrigin)
|
||||
{
|
||||
case STREAM_SEEK_SET: _virtPos = offset; break;
|
||||
case STREAM_SEEK_CUR: _virtPos += offset; break;
|
||||
case STREAM_SEEK_END: _virtPos = _virtSize + offset; break;
|
||||
default: return STG_E_INVALIDFUNCTION;
|
||||
}
|
||||
if (newPosition)
|
||||
*newPosition = _virtPos;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CCacheOutStream::SetSize(UInt64 newSize)
|
||||
{
|
||||
_virtSize = newSize;
|
||||
if (newSize < _phySize)
|
||||
{
|
||||
RINOK(_stream->SetSize(newSize));
|
||||
_phySize = newSize;
|
||||
}
|
||||
if (newSize <= _cachedPos)
|
||||
{
|
||||
_cachedSize = 0;
|
||||
_cachedPos = newSize;
|
||||
}
|
||||
if (newSize < _cachedPos + _cachedSize)
|
||||
_cachedSize = (size_t)(newSize - _cachedPos);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT Update(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
const CObjectVector<CItemEx> &inputItems,
|
||||
@@ -808,9 +1021,17 @@ HRESULT Update(
|
||||
IArchiveUpdateCallback *updateCallback)
|
||||
{
|
||||
CMyComPtr<IOutStream> outStream;
|
||||
RINOK(seqOutStream->QueryInterface(IID_IOutStream, (void **)&outStream));
|
||||
if (!outStream)
|
||||
{
|
||||
CMyComPtr<IOutStream> outStreamReal;
|
||||
seqOutStream->QueryInterface(IID_IOutStream, (void **)&outStreamReal);
|
||||
if (!outStreamReal)
|
||||
return E_NOTIMPL;
|
||||
CCacheOutStream *cacheStream = new CCacheOutStream();
|
||||
outStream = cacheStream;
|
||||
if (!cacheStream->Allocate())
|
||||
return E_OUTOFMEMORY;
|
||||
RINOK(cacheStream->Init(outStreamReal));
|
||||
}
|
||||
|
||||
if (inArchive)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_APP("7-Zip Standalone Console", "7za")
|
||||
MY_VERSION_INFO_APP("7-Zip Standalone Console", "7zr")
|
||||
|
||||
@@ -358,7 +358,6 @@ COMPRESS_OBJS = \
|
||||
$O\Deflate64Register.obj \
|
||||
$O\DeflateDecoder.obj \
|
||||
$O\DeflateEncoder.obj \
|
||||
$O\DeflateNsisRegister.obj \
|
||||
$O\DeflateRegister.obj \
|
||||
$O\DeltaFilter.obj \
|
||||
$O\ImplodeDecoder.obj \
|
||||
|
||||
@@ -539,10 +539,6 @@ SOURCE=..\..\Compress\DeflateEncoder.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\DeflateNsisRegister.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\Compress\DeflateRegister.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -210,7 +210,6 @@ COMPRESS_OBJS = \
|
||||
$O\Deflate64Register.obj \
|
||||
$O\DeflateDecoder.obj \
|
||||
$O\DeflateEncoder.obj \
|
||||
$O\DeflateNsisRegister.obj \
|
||||
$O\DeflateRegister.obj \
|
||||
$O\DeltaFilter.obj \
|
||||
$O\ImplodeDecoder.obj \
|
||||
|
||||
@@ -32,5 +32,5 @@ MY_VERSION_INFO_DLL("7z Standalone Plugin", "7za")
|
||||
|
||||
STRINGTABLE
|
||||
BEGIN
|
||||
100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 001:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15 lzma:16 dmg:17 hfs:18 xar:19 vhd:20 fat:21 ntfs:22 xz:23"
|
||||
100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 001:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15 lzma:16 dmg:17 hfs:18 xar:19 vhd:20 fat:21 ntfs:22 xz:23 txz:23"
|
||||
END
|
||||
|
||||
@@ -88,7 +88,7 @@ static const int kNumSwitches = sizeof(kSwitchForms) / sizeof(kSwitchForms[0]);
|
||||
|
||||
static void PrintMessage(const char *s)
|
||||
{
|
||||
fprintf(stderr, s);
|
||||
fputs(s, stderr);
|
||||
}
|
||||
|
||||
static void PrintHelp()
|
||||
@@ -425,7 +425,7 @@ int main2(int numArgs, const char *args[])
|
||||
props[5].ulVal = (UInt32)fb;
|
||||
|
||||
props[6].vt = VT_BSTR;
|
||||
props[6].bstrVal = (BSTR)(const wchar_t *)mf;
|
||||
props[6].bstrVal = const_cast<BSTR>((const wchar_t *)mf);
|
||||
|
||||
props[7].vt = VT_BOOL;
|
||||
props[7].boolVal = eos ? VARIANT_TRUE : VARIANT_FALSE;
|
||||
|
||||
@@ -164,7 +164,7 @@ Byte CByteInBufWrap::ReadByteFromNewBlock()
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" static Byte Wrap_ReadByte(void *pp)
|
||||
static Byte Wrap_ReadByte(void *pp)
|
||||
{
|
||||
CByteInBufWrap *p = (CByteInBufWrap *)pp;
|
||||
if (p->Cur != p->Lim)
|
||||
@@ -210,7 +210,7 @@ HRESULT CByteOutBufWrap::Flush()
|
||||
return Res;
|
||||
}
|
||||
|
||||
extern "C" static void Wrap_WriteByte(void *pp, Byte b)
|
||||
static void Wrap_WriteByte(void *pp, Byte b)
|
||||
{
|
||||
CByteOutBufWrap *p = (CByteOutBufWrap *)pp;
|
||||
Byte *dest = p->Cur;
|
||||
|
||||
@@ -353,7 +353,7 @@ STDMETHODIMP COutFileStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPo
|
||||
#endif
|
||||
}
|
||||
|
||||
STDMETHODIMP COutFileStream::SetSize(Int64 newSize)
|
||||
STDMETHODIMP COutFileStream::SetSize(UInt64 newSize)
|
||||
{
|
||||
#ifdef USE_WIN_FILE
|
||||
UInt64 currentPos;
|
||||
@@ -418,4 +418,5 @@ STDMETHODIMP CStdOutFileStream::Write(const void *data, UInt32 size, UInt32 *pro
|
||||
return S_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -127,7 +127,7 @@ public:
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||
STDMETHOD(SetSize)(Int64 newSize);
|
||||
STDMETHOD(SetSize)(UInt64 newSize);
|
||||
};
|
||||
|
||||
class CStdOutFileStream:
|
||||
|
||||
@@ -92,7 +92,7 @@ STDMETHODIMP CFilterCoder::ReleaseOutStream()
|
||||
{
|
||||
_outStream.Release();
|
||||
return S_OK;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CFilterCoder::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
@@ -164,7 +164,7 @@ STDMETHODIMP CFilterCoder::ReleaseInStream()
|
||||
{
|
||||
_inStream.Release();
|
||||
return S_OK;
|
||||
};
|
||||
}
|
||||
|
||||
STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ STDMETHODIMP COffsetOutStream::Seek(Int64 offset, UInt32 seekOrigin,
|
||||
return result;
|
||||
}
|
||||
|
||||
STDMETHODIMP COffsetOutStream::SetSize(Int64 newSize)
|
||||
STDMETHODIMP COffsetOutStream::SetSize(UInt64 newSize)
|
||||
{
|
||||
return _stream->SetSize(_offset + newSize);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||
STDMETHOD(SetSize)(Int64 newSize);
|
||||
STDMETHOD(SetSize)(UInt64 newSize);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -129,7 +129,7 @@ STDMETHODIMP COutMemStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPos
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP COutMemStream::SetSize(Int64 newSize)
|
||||
STDMETHODIMP COutMemStream::SetSize(UInt64 newSize)
|
||||
{
|
||||
if (_realStreamMode)
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||
STDMETHOD(SetSize)(Int64 newSize);
|
||||
STDMETHOD(SetSize)(UInt64 newSize);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,22 +4,20 @@
|
||||
|
||||
#include "../../../C/Alloc.h"
|
||||
|
||||
#include "../../Common/Defs.h"
|
||||
|
||||
#include "BZip2Crc.h"
|
||||
#include "BZip2Decoder.h"
|
||||
#include "Mtf8.h"
|
||||
|
||||
namespace NCompress {
|
||||
namespace NBZip2 {
|
||||
|
||||
#define NO_INLINE MY_FAST_CALL
|
||||
#undef NO_INLINE
|
||||
#define NO_INLINE
|
||||
|
||||
const UInt32 kNumThreadsMax = 4;
|
||||
static const UInt32 kNumThreadsMax = 4;
|
||||
|
||||
static const UInt32 kBufferSize = (1 << 17);
|
||||
|
||||
static Int16 kRandNums[512] = {
|
||||
static const UInt16 kRandNums[512] = {
|
||||
619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
|
||||
985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
|
||||
733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
|
||||
@@ -76,8 +74,8 @@ static Int16 kRandNums[512] = {
|
||||
|
||||
bool CState::Alloc()
|
||||
{
|
||||
if (Counters == 0)
|
||||
Counters = (UInt32 *)BigAlloc((256 + kBlockSizeMax) * sizeof(UInt32));
|
||||
if (!Counters)
|
||||
Counters = (UInt32 *)::BigAlloc((256 + kBlockSizeMax) * sizeof(UInt32));
|
||||
return (Counters != 0);
|
||||
}
|
||||
|
||||
@@ -87,7 +85,7 @@ void CState::Free()
|
||||
Counters = 0;
|
||||
}
|
||||
|
||||
UInt32 CDecoder::ReadBits(int numBits) { return m_InStream.ReadBits(numBits); }
|
||||
UInt32 CDecoder::ReadBits(unsigned numBits) { return m_InStream.ReadBits(numBits); }
|
||||
Byte CDecoder::ReadByte() {return (Byte)ReadBits(8); }
|
||||
bool CDecoder::ReadBit() { return ReadBits(1) != 0; }
|
||||
|
||||
@@ -102,12 +100,12 @@ UInt32 CDecoder::ReadCrc()
|
||||
return crc;
|
||||
}
|
||||
|
||||
UInt32 NO_INLINE ReadBits(NBitm::CDecoder<CInBuffer> *m_InStream, int num)
|
||||
static UInt32 NO_INLINE ReadBits(NBitm::CDecoder<CInBuffer> *m_InStream, unsigned num)
|
||||
{
|
||||
return m_InStream->ReadBits(num);
|
||||
}
|
||||
|
||||
UInt32 NO_INLINE ReadBit(NBitm::CDecoder<CInBuffer> *m_InStream)
|
||||
static UInt32 NO_INLINE ReadBit(NBitm::CDecoder<CInBuffer> *m_InStream)
|
||||
{
|
||||
return m_InStream->ReadBits(1);
|
||||
}
|
||||
@@ -116,6 +114,7 @@ static HRESULT NO_INLINE ReadBlock(NBitm::CDecoder<CInBuffer> *m_InStream,
|
||||
UInt32 *CharCounters, UInt32 blockSizeMax, Byte *m_Selectors, CHuffmanDecoder *m_HuffmanDecoders,
|
||||
UInt32 *blockSizeRes, UInt32 *origPtrRes, bool *randRes)
|
||||
{
|
||||
if (randRes)
|
||||
*randRes = ReadBit(m_InStream) ? true : false;
|
||||
*origPtrRes = ReadBits(m_InStream, kNumOrigBits);
|
||||
|
||||
@@ -258,7 +257,7 @@ static HRESULT NO_INLINE ReadBlock(NBitm::CDecoder<CInBuffer> *m_InStream,
|
||||
return (*origPtrRes < blockSize) ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
void NO_INLINE DecodeBlock1(UInt32 *charCounters, UInt32 blockSize)
|
||||
static void NO_INLINE DecodeBlock1(UInt32 *charCounters, UInt32 blockSize)
|
||||
{
|
||||
{
|
||||
UInt32 sum = 0;
|
||||
@@ -283,13 +282,13 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32
|
||||
|
||||
// it's for speed optimization: prefetch & prevByte_init;
|
||||
UInt32 tPos = tt[tt[OrigPtr] >> 8];
|
||||
unsigned int prevByte = (unsigned int)(tPos & 0xFF);
|
||||
unsigned prevByte = (unsigned)(tPos & 0xFF);
|
||||
|
||||
int numReps = 0;
|
||||
unsigned numReps = 0;
|
||||
|
||||
do
|
||||
{
|
||||
unsigned int b = (unsigned int)(tPos & 0xFF);
|
||||
unsigned b = (unsigned)(tPos & 0xFF);
|
||||
tPos = tt[tPos >> 8];
|
||||
|
||||
if (numReps == kRleModeRepSize)
|
||||
@@ -315,7 +314,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32
|
||||
m_OutStream.WriteByte((Byte)b);
|
||||
for (; --blockSize != 0;)
|
||||
{
|
||||
b = (unsigned int)(tPos & 0xFF);
|
||||
b = (unsigned)(tPos & 0xFF);
|
||||
tPos = tt[tPos >> 8];
|
||||
crc.UpdateByte(b);
|
||||
m_OutStream.WriteByte((Byte)b);
|
||||
@@ -327,7 +326,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32
|
||||
if (--blockSize == 0)
|
||||
break;
|
||||
|
||||
b = (unsigned int)(tPos & 0xFF);
|
||||
b = (unsigned)(tPos & 0xFF);
|
||||
tPos = tt[tPos >> 8];
|
||||
crc.UpdateByte(b);
|
||||
m_OutStream.WriteByte((Byte)b);
|
||||
@@ -339,7 +338,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32
|
||||
if (--blockSize == 0)
|
||||
break;
|
||||
|
||||
b = (unsigned int)(tPos & 0xFF);
|
||||
b = (unsigned)(tPos & 0xFF);
|
||||
tPos = tt[tPos >> 8];
|
||||
crc.UpdateByte(b);
|
||||
m_OutStream.WriteByte((Byte)b);
|
||||
@@ -354,7 +353,7 @@ static UInt32 NO_INLINE DecodeBlock2(const UInt32 *tt, UInt32 blockSize, UInt32
|
||||
if (blockSize == 0)
|
||||
break;
|
||||
|
||||
b = (unsigned int)(tPos & 0xFF);
|
||||
b = (unsigned)(tPos & 0xFF);
|
||||
tPos = tt[tPos >> 8];
|
||||
|
||||
for (; b > 0; b--)
|
||||
@@ -375,15 +374,15 @@ static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UIn
|
||||
UInt32 randIndex = 1;
|
||||
UInt32 randToGo = kRandNums[0] - 2;
|
||||
|
||||
int numReps = 0;
|
||||
unsigned numReps = 0;
|
||||
|
||||
// it's for speed optimization: prefetch & prevByte_init;
|
||||
UInt32 tPos = tt[tt[OrigPtr] >> 8];
|
||||
unsigned int prevByte = (unsigned int)(tPos & 0xFF);
|
||||
unsigned prevByte = (unsigned)(tPos & 0xFF);
|
||||
|
||||
do
|
||||
{
|
||||
unsigned int b = (unsigned int)(tPos & 0xFF);
|
||||
unsigned b = (unsigned)(tPos & 0xFF);
|
||||
tPos = tt[tPos >> 8];
|
||||
|
||||
{
|
||||
@@ -424,7 +423,7 @@ CDecoder::CDecoder()
|
||||
m_States = 0;
|
||||
m_NumThreadsPrev = 0;
|
||||
NumThreads = 1;
|
||||
#endif;
|
||||
#endif
|
||||
_needInStreamInit = true;
|
||||
}
|
||||
|
||||
@@ -449,7 +448,7 @@ HRESULT CDecoder::Create()
|
||||
try
|
||||
{
|
||||
m_States = new CState[NumThreads];
|
||||
if (m_States == 0)
|
||||
if (!m_States)
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
catch(...) { return E_OUTOFMEMORY; }
|
||||
@@ -487,6 +486,7 @@ void CDecoder::Free()
|
||||
delete []m_States;
|
||||
m_States = 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
|
||||
@@ -794,6 +794,7 @@ STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads)
|
||||
NumThreads = kNumThreadsMax;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HRESULT CDecoder::SetRatioProgress(UInt64 packSize)
|
||||
@@ -805,4 +806,138 @@ HRESULT CDecoder::SetRatioProgress(UInt64 packSize)
|
||||
return Progress->SetRatioInfo(&packSize, &unpackSize);
|
||||
}
|
||||
|
||||
|
||||
// ---------- NSIS ----------
|
||||
|
||||
enum
|
||||
{
|
||||
NSIS_STATE_INIT,
|
||||
NSIS_STATE_NEW_BLOCK,
|
||||
NSIS_STATE_DATA,
|
||||
NSIS_STATE_FINISHED,
|
||||
NSIS_STATE_ERROR
|
||||
};
|
||||
|
||||
STDMETHODIMP CNsisDecoder::SetInStream(ISequentialInStream *inStream) { m_InStream.SetStream(inStream); return S_OK; }
|
||||
STDMETHODIMP CNsisDecoder::ReleaseInStream() { m_InStream.ReleaseStream(); return S_OK; }
|
||||
|
||||
STDMETHODIMP CNsisDecoder::SetOutStreamSize(const UInt64 * /* outSize */)
|
||||
{
|
||||
_nsisState = NSIS_STATE_INIT;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CNsisDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
try {
|
||||
|
||||
*processedSize = 0;
|
||||
if (_nsisState == NSIS_STATE_FINISHED)
|
||||
return S_OK;
|
||||
if (_nsisState == NSIS_STATE_ERROR)
|
||||
return S_FALSE;
|
||||
if (size == 0)
|
||||
return S_OK;
|
||||
|
||||
CState &state = m_State;
|
||||
|
||||
if (_nsisState == NSIS_STATE_INIT)
|
||||
{
|
||||
if (!m_InStream.Create(kBufferSize))
|
||||
return E_OUTOFMEMORY;
|
||||
if (!state.Alloc())
|
||||
return E_OUTOFMEMORY;
|
||||
m_InStream.Init();
|
||||
_nsisState = NSIS_STATE_NEW_BLOCK;
|
||||
}
|
||||
|
||||
if (_nsisState == NSIS_STATE_NEW_BLOCK)
|
||||
{
|
||||
Byte b = (Byte)m_InStream.ReadBits(8);
|
||||
if (b == kFinSig0)
|
||||
{
|
||||
_nsisState = NSIS_STATE_FINISHED;
|
||||
return S_OK;
|
||||
}
|
||||
if (b != kBlockSig0)
|
||||
{
|
||||
_nsisState = NSIS_STATE_ERROR;
|
||||
return S_FALSE;
|
||||
}
|
||||
UInt32 origPtr;
|
||||
RINOK(ReadBlock(&m_InStream, state.Counters, 9 * kBlockSizeStep,
|
||||
m_Selectors, m_HuffmanDecoders, &_blockSize, &origPtr, NULL));
|
||||
DecodeBlock1(state.Counters, _blockSize);
|
||||
const UInt32 *tt = state.Counters + 256;
|
||||
_tPos = tt[tt[origPtr] >> 8];
|
||||
_prevByte = (unsigned)(_tPos & 0xFF);
|
||||
_numReps = 0;
|
||||
_repRem = 0;
|
||||
_nsisState = NSIS_STATE_DATA;
|
||||
}
|
||||
|
||||
UInt32 tPos = _tPos;
|
||||
unsigned prevByte = _prevByte;
|
||||
unsigned numReps = _numReps;
|
||||
UInt32 blockSize = _blockSize;
|
||||
const UInt32 *tt = state.Counters + 256;
|
||||
|
||||
while (_repRem)
|
||||
{
|
||||
_repRem--;
|
||||
*(Byte *)data = (Byte)prevByte;
|
||||
data = (Byte *)data + 1;
|
||||
(*processedSize)++;
|
||||
if (--size == 0)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (blockSize == 0)
|
||||
{
|
||||
_nsisState = NSIS_STATE_NEW_BLOCK;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
unsigned b = (unsigned)(tPos & 0xFF);
|
||||
tPos = tt[tPos >> 8];
|
||||
blockSize--;
|
||||
|
||||
if (numReps == kRleModeRepSize)
|
||||
{
|
||||
numReps = 0;
|
||||
while (b)
|
||||
{
|
||||
b--;
|
||||
*(Byte *)data = (Byte)prevByte;
|
||||
data = (Byte *)data + 1;
|
||||
(*processedSize)++;
|
||||
if (--size == 0)
|
||||
break;
|
||||
}
|
||||
_repRem = b;
|
||||
continue;
|
||||
}
|
||||
if (b != prevByte)
|
||||
numReps = 0;
|
||||
numReps++;
|
||||
prevByte = b;
|
||||
*(Byte *)data = (Byte)b;
|
||||
data = (Byte *)data + 1;
|
||||
(*processedSize)++;
|
||||
size--;
|
||||
}
|
||||
while (size && blockSize);
|
||||
_tPos = tPos;
|
||||
_prevByte = prevByte;
|
||||
_numReps = numReps;
|
||||
_blockSize = blockSize;
|
||||
return S_OK;
|
||||
|
||||
}
|
||||
catch(const CInBufferException &e) { return e.ErrorCode; }
|
||||
catch(...) { return S_FALSE; }
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -76,11 +76,10 @@ private:
|
||||
|
||||
bool _needInStreamInit;
|
||||
|
||||
UInt32 ReadBits(int numBits);
|
||||
UInt32 ReadBits(unsigned numBits);
|
||||
Byte ReadByte();
|
||||
bool ReadBit();
|
||||
UInt32 ReadCrc();
|
||||
HRESULT PrepareBlock(CState &state);
|
||||
HRESULT DecodeFile(bool &isBZ, ICompressProgressInfo *progress);
|
||||
HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream,
|
||||
bool &isBZ, ICompressProgressInfo *progress);
|
||||
@@ -168,6 +167,39 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
class CNsisDecoder :
|
||||
public ISequentialInStream,
|
||||
public ICompressSetInStream,
|
||||
public ICompressSetOutStreamSize,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
NBitm::CDecoder<CInBuffer> m_InStream;
|
||||
Byte m_Selectors[kNumSelectorsMax];
|
||||
CHuffmanDecoder m_HuffmanDecoders[kNumTablesMax];
|
||||
CState m_State;
|
||||
|
||||
int _nsisState;
|
||||
UInt32 _tPos;
|
||||
unsigned _prevByte;
|
||||
unsigned _repRem;
|
||||
unsigned _numReps;
|
||||
UInt32 _blockSize;
|
||||
|
||||
public:
|
||||
|
||||
MY_QUERYINTERFACE_BEGIN2(ISequentialInStream)
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetInStream)
|
||||
MY_QUERYINTERFACE_ENTRY(ICompressSetOutStreamSize)
|
||||
MY_QUERYINTERFACE_END
|
||||
MY_ADDREF_RELEASE
|
||||
|
||||
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(SetInStream)(ISequentialInStream *inStream);
|
||||
STDMETHOD(ReleaseInStream)();
|
||||
STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,8 +9,10 @@
|
||||
|
||||
#include "DeflateEncoder.h"
|
||||
|
||||
#if _MSC_VER >= 1300
|
||||
#define NO_INLINE __declspec(noinline)
|
||||
#undef NO_INLINE
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define NO_INLINE MY_NO_INLINE
|
||||
#else
|
||||
#define NO_INLINE
|
||||
#endif
|
||||
@@ -580,7 +582,7 @@ NO_INLINE UInt32 Huffman_GetPrice(const UInt32 *freqs, const Byte *lens, UInt32
|
||||
for (i = 0; i < num; i++)
|
||||
price += lens[i] * freqs[i];
|
||||
return price;
|
||||
};
|
||||
}
|
||||
|
||||
NO_INLINE UInt32 Huffman_GetPrice_Spec(const UInt32 *freqs, const Byte *lens, UInt32 num, const Byte *extraBits, UInt32 extraBase)
|
||||
{
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
// DeflateNsisRegister.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../Common/RegisterCodec.h"
|
||||
|
||||
#include "DeflateDecoder.h"
|
||||
|
||||
static void *CreateCodecDeflateNsis() { return (void *)(ICompressCoder *)(new NCompress::NDeflate::NDecoder::CNsisCOMCoder); }
|
||||
|
||||
static CCodecInfo g_CodecInfo =
|
||||
{ CreateCodecDeflateNsis, 0, 0x040901, L"DeflateNSIS", 1, false };
|
||||
|
||||
REGISTER_CODEC(DeflateNsis)
|
||||
@@ -164,7 +164,7 @@ void CDecoder::ClearPrevLevels()
|
||||
m_LastMainLevels[i] = 0;
|
||||
for (i = 0; i < kNumLenSymbols; i++)
|
||||
m_LastLenLevels[i] = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
HRESULT CDecoder::CodeSpec(UInt32 curSize)
|
||||
|
||||
@@ -627,7 +627,6 @@ public:
|
||||
CCoderReleaser(CDecoder *coder): m_Coder(coder) {}
|
||||
~CCoderReleaser()
|
||||
{
|
||||
// m_Coder->m_OutWindowStream.Flush();
|
||||
m_Coder->ReleaseStreams();
|
||||
}
|
||||
};
|
||||
@@ -821,7 +820,7 @@ HRESULT CDecoder::CodeReal(ICompressProgressInfo *progress)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
for(;;)
|
||||
for (;;)
|
||||
{
|
||||
bool keepDecompressing;
|
||||
if (_lzMode)
|
||||
@@ -838,9 +837,10 @@ HRESULT CDecoder::CodeReal(ICompressProgressInfo *progress)
|
||||
break;
|
||||
}
|
||||
RINOK(WriteBuf());
|
||||
UInt64 packSize = m_InBitStream.bitDecoder.GetProcessedSize();
|
||||
RINOK(progress->SetRatioInfo(&packSize, &_writtenFileSize));
|
||||
if (_writtenFileSize < _unpackSize)
|
||||
return S_FALSE;
|
||||
// return m_OutWindowStream.Flush();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -778,13 +778,13 @@ struct StandardFilterSignature
|
||||
}
|
||||
kStdFilters[]=
|
||||
{
|
||||
53, 0xad576887, SF_E8,
|
||||
57, 0x3cd7e57e, SF_E8E9,
|
||||
120, 0x3769893f, SF_ITANIUM,
|
||||
29, 0x0e06077d, SF_DELTA,
|
||||
149, 0x1c2c5dc8, SF_RGB,
|
||||
216, 0xbc85e701, SF_AUDIO,
|
||||
40, 0x46b9c560, SF_UPCASE
|
||||
{ 53, 0xad576887, SF_E8 },
|
||||
{ 57, 0x3cd7e57e, SF_E8E9 },
|
||||
{ 120, 0x3769893f, SF_ITANIUM },
|
||||
{ 29, 0x0e06077d, SF_DELTA },
|
||||
{ 149, 0x1c2c5dc8, SF_RGB },
|
||||
{ 216, 0xbc85e701, SF_AUDIO },
|
||||
{ 40, 0x46b9c560, SF_UPCASE }
|
||||
};
|
||||
|
||||
static int FindStandardFilter(const Byte *code, UInt32 codeSize)
|
||||
|
||||
@@ -106,9 +106,9 @@ void CDecoder::Calculate()
|
||||
unsigned i;
|
||||
for (i = 0; i < kNumRounds; i++)
|
||||
{
|
||||
sha.Update(rawPassword, rawLength, _rar350Mode);
|
||||
sha.UpdateRar(rawPassword, rawLength, _rar350Mode);
|
||||
Byte pswNum[3] = { (Byte)i, (Byte)(i >> 8), (Byte)(i >> 16) };
|
||||
sha.Update(pswNum, 3, _rar350Mode);
|
||||
sha.UpdateRar(pswNum, 3, _rar350Mode);
|
||||
if (i % (kNumRounds / 16) == 0)
|
||||
{
|
||||
NSha1::CContext shaTemp = sha;
|
||||
|
||||
@@ -112,11 +112,29 @@ void CContextBase::PrepareBlock(UInt32 *block, unsigned size) const
|
||||
block[curBufferPos++] = (UInt32)(lenInBits);
|
||||
}
|
||||
|
||||
void CContext::Update(Byte *data, size_t size, bool rar350Mode)
|
||||
void CContext::Update(const Byte *data, size_t size)
|
||||
{
|
||||
unsigned curBufferPos = _count2;
|
||||
while (size--)
|
||||
{
|
||||
int pos = (int)(curBufferPos & 3);
|
||||
if (pos == 0)
|
||||
_buffer[curBufferPos >> 2] = 0;
|
||||
_buffer[curBufferPos >> 2] |= ((UInt32)*data++) << (8 * (3 - pos));
|
||||
if (++curBufferPos == kBlockSize)
|
||||
{
|
||||
curBufferPos = 0;
|
||||
CContextBase::UpdateBlock(_buffer, false);
|
||||
}
|
||||
}
|
||||
_count2 = curBufferPos;
|
||||
}
|
||||
|
||||
void CContext::UpdateRar(Byte *data, size_t size, bool rar350Mode)
|
||||
{
|
||||
bool returnRes = false;
|
||||
unsigned curBufferPos = _count2;
|
||||
while (size-- > 0)
|
||||
while (size--)
|
||||
{
|
||||
int pos = (int)(curBufferPos & 3);
|
||||
if (pos == 0)
|
||||
@@ -179,7 +197,7 @@ void CContext::Final(Byte *digest)
|
||||
|
||||
void CContext32::Update(const UInt32 *data, size_t size)
|
||||
{
|
||||
while (size-- > 0)
|
||||
while (size--)
|
||||
{
|
||||
_buffer[_count2++] = *data++;
|
||||
if (_count2 == kBlockSizeInWords)
|
||||
|
||||
@@ -51,8 +51,8 @@ public:
|
||||
class CContext: public CContextBase2
|
||||
{
|
||||
public:
|
||||
void Update(Byte *data, size_t size, bool rar350Mode = false);
|
||||
void Update(const Byte *data, size_t size) { Update((Byte *)data, size, false); }
|
||||
void Update(const Byte *data, size_t size);
|
||||
void UpdateRar(Byte *data, size_t size, bool rar350Mode);
|
||||
void Final(Byte *digest);
|
||||
};
|
||||
|
||||
|
||||
@@ -114,6 +114,12 @@ HRESULT CDecoder::CheckPassword(bool &passwOK)
|
||||
_key.KeySize = 16 + algId * 8;
|
||||
if ((flags & 1) == 0)
|
||||
return E_NOTIMPL;
|
||||
if ((flags & 0x4000) != 0)
|
||||
{
|
||||
// Use 3DES
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
UInt32 rdSize = GetUi16(p + 8);
|
||||
if ((rdSize & 0xF) != 0 || rdSize + 16 > _remSize)
|
||||
return E_NOTIMPL;
|
||||
|
||||
@@ -42,7 +42,7 @@ STREAM_INTERFACE_SUB(IInStream, ISequentialInStream, 0x03)
|
||||
STREAM_INTERFACE_SUB(IOutStream, ISequentialOutStream, 0x04)
|
||||
{
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;
|
||||
STDMETHOD(SetSize)(Int64 newSize) PURE;
|
||||
STDMETHOD(SetSize)(UInt64 newSize) PURE;
|
||||
};
|
||||
|
||||
STREAM_INTERFACE(IStreamGetSize, 0x06)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#define MY_VER_MAJOR 9
|
||||
#define MY_VER_MINOR 14
|
||||
#define MY_VER_MINOR 17
|
||||
#define MY_VER_BUILD 0
|
||||
#define MY_VERSION "9.14 beta"
|
||||
#define MY_7ZIP_VERSION "7-Zip 9.14 beta"
|
||||
#define MY_DATE "2010-06-04"
|
||||
#define MY_VERSION "9.17 beta"
|
||||
#define MY_7ZIP_VERSION "7-Zip 9.17 beta"
|
||||
#define MY_DATE "2010-10-04"
|
||||
#define MY_COPYRIGHT "Copyright (c) 1999-2010 Igor Pavlov"
|
||||
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE
|
||||
|
||||
@@ -86,7 +86,7 @@ enum Enum
|
||||
kTechMode,
|
||||
kShareForWrite,
|
||||
kCaseSensitive,
|
||||
kCalcCrc,
|
||||
kCalcCrc
|
||||
};
|
||||
|
||||
}
|
||||
@@ -191,12 +191,12 @@ static const char *kSameTerminalError = "I won't write data and program's messag
|
||||
static void ThrowException(const char *errorMessage)
|
||||
{
|
||||
throw CArchiveCommandLineException(errorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
static void ThrowUserErrorException()
|
||||
{
|
||||
ThrowException(kUserErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
// ---------------------------
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
||||
STDMETHOD(SetSize)(Int64 newSize);
|
||||
STDMETHOD(SetSize)(UInt64 newSize);
|
||||
};
|
||||
|
||||
// static NSynchronization::CCriticalSection g_TempPathsCS;
|
||||
@@ -204,7 +204,7 @@ STDMETHODIMP COutMultiVolStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *n
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP COutMultiVolStream::SetSize(Int64 newSize)
|
||||
STDMETHODIMP COutMultiVolStream::SetSize(UInt64 newSize)
|
||||
{
|
||||
if (newSize < 0)
|
||||
return E_INVALIDARG;
|
||||
@@ -905,4 +905,3 @@ HRESULT UpdateArchive(
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace NUpdateArchive {
|
||||
|
||||
const CActionSet kAddActionSet =
|
||||
{
|
||||
{{
|
||||
NPairAction::kCopy,
|
||||
NPairAction::kCopy,
|
||||
NPairAction::kCompress,
|
||||
@@ -15,10 +15,10 @@ const CActionSet kAddActionSet =
|
||||
NPairAction::kCompress,
|
||||
NPairAction::kCompress,
|
||||
NPairAction::kCompress
|
||||
};
|
||||
}};
|
||||
|
||||
const CActionSet kUpdateActionSet =
|
||||
{
|
||||
{{
|
||||
NPairAction::kCopy,
|
||||
NPairAction::kCopy,
|
||||
NPairAction::kCompress,
|
||||
@@ -26,10 +26,10 @@ const CActionSet kUpdateActionSet =
|
||||
NPairAction::kCompress,
|
||||
NPairAction::kCopy,
|
||||
NPairAction::kCompress
|
||||
};
|
||||
}};
|
||||
|
||||
const CActionSet kFreshActionSet =
|
||||
{
|
||||
{{
|
||||
NPairAction::kCopy,
|
||||
NPairAction::kCopy,
|
||||
NPairAction::kIgnore,
|
||||
@@ -37,10 +37,10 @@ const CActionSet kFreshActionSet =
|
||||
NPairAction::kCompress,
|
||||
NPairAction::kCopy,
|
||||
NPairAction::kCompress
|
||||
};
|
||||
}};
|
||||
|
||||
const CActionSet kSynchronizeActionSet =
|
||||
{
|
||||
{{
|
||||
NPairAction::kCopy,
|
||||
NPairAction::kIgnore,
|
||||
NPairAction::kCompress,
|
||||
@@ -48,10 +48,10 @@ const CActionSet kSynchronizeActionSet =
|
||||
NPairAction::kCompress,
|
||||
NPairAction::kCopy,
|
||||
NPairAction::kCompress,
|
||||
};
|
||||
}};
|
||||
|
||||
const CActionSet kDeleteActionSet =
|
||||
{
|
||||
{{
|
||||
NPairAction::kCopy,
|
||||
NPairAction::kIgnore,
|
||||
NPairAction::kIgnore,
|
||||
@@ -59,6 +59,6 @@ const CActionSet kDeleteActionSet =
|
||||
NPairAction::kIgnore,
|
||||
NPairAction::kIgnore,
|
||||
NPairAction::kIgnore
|
||||
};
|
||||
}};
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace NUpdateArchive {
|
||||
kUnknowNewerFiles
|
||||
};
|
||||
}
|
||||
|
||||
namespace NPairAction
|
||||
{
|
||||
enum EEnum
|
||||
@@ -29,6 +30,7 @@ namespace NUpdateArchive {
|
||||
kCompressAsAnti
|
||||
};
|
||||
}
|
||||
|
||||
struct CActionSet
|
||||
{
|
||||
NPairAction::EEnum StateActions[NPairState::kNumValues];
|
||||
@@ -44,14 +46,12 @@ namespace NUpdateArchive {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
extern const CActionSet kAddActionSet;
|
||||
extern const CActionSet kUpdateActionSet;
|
||||
extern const CActionSet kFreshActionSet;
|
||||
extern const CActionSet kSynchronizeActionSet;
|
||||
extern const CActionSet kDeleteActionSet;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
virtual HRESULT SetOperationResult(Int32 operationResult) x; \
|
||||
virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) x; \
|
||||
virtual HRESULT CryptoGetTextPassword(BSTR *password) x; \
|
||||
// virtual HRESULT ShowDeleteFile(const wchar_t *name) x; \
|
||||
// virtual HRESULT CloseProgress() { return S_OK; };
|
||||
/* virtual HRESULT ShowDeleteFile(const wchar_t *name) x; */ \
|
||||
/* virtual HRESULT CloseProgress() { return S_OK; }; */
|
||||
|
||||
struct IUpdateCallbackUI
|
||||
{
|
||||
|
||||
@@ -76,7 +76,7 @@ static void PrintNumber(FILE *f, UInt64 value, int size)
|
||||
fprintf(f, " ");
|
||||
for (int len = (int)strlen(s); len < size; len++)
|
||||
fprintf(f, " ");
|
||||
fprintf(f, "%s", s);
|
||||
fputs(s, f);
|
||||
}
|
||||
|
||||
static void PrintRating(FILE *f, UInt64 rating)
|
||||
@@ -134,7 +134,7 @@ HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
|
||||
if (final)
|
||||
{
|
||||
UInt64 rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations);
|
||||
fprintf(f, kSep);
|
||||
fputs(kSep, f);
|
||||
CBenchInfo info2 = info;
|
||||
info2.UnpackSize *= info2.NumIterations;
|
||||
info2.PackSize *= info2.NumIterations;
|
||||
@@ -191,14 +191,14 @@ HRESULT LzmaBenchCon(
|
||||
{
|
||||
fprintf(f, " Speed Usage R/U Rating");
|
||||
if (j == 0)
|
||||
fprintf(f, kSep);
|
||||
fputs(kSep, f);
|
||||
}
|
||||
fprintf(f, "\n ");
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
fprintf(f, " KB/s %% MIPS MIPS");
|
||||
if (j == 0)
|
||||
fprintf(f, kSep);
|
||||
fputs(kSep, f);
|
||||
}
|
||||
fprintf(f, "\n\n");
|
||||
for (UInt32 i = 0; i < numIterations; i++)
|
||||
|
||||
@@ -514,11 +514,9 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
if (archive->GetArchivePropertyInfo(j, &name, &propID, &vt) != S_OK)
|
||||
continue;
|
||||
RINOK(archive->GetArchivePropertyInfo(j, &name, &propID, &vt));
|
||||
NCOM::CPropVariant prop;
|
||||
if (archive->GetArchiveProperty(propID, &prop) != S_OK)
|
||||
continue;
|
||||
RINOK(archive->GetArchiveProperty(propID, &prop));
|
||||
UString s = ConvertPropertyToString(prop, propID);
|
||||
if (!s.IsEmpty())
|
||||
PrintPropPair(GetPropName(propID, name), s);
|
||||
@@ -536,11 +534,9 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
|
||||
CMyComBSTR name;
|
||||
PROPID propID;
|
||||
VARTYPE vt;
|
||||
if (archive->GetPropertyInfo(j, &name, &propID, &vt) != S_OK)
|
||||
continue;
|
||||
RINOK(archive->GetPropertyInfo(j, &name, &propID, &vt));
|
||||
NCOM::CPropVariant prop;
|
||||
if (archive->GetProperty(mainIndex, propID, &prop) != S_OK)
|
||||
continue;
|
||||
RINOK(archive->GetProperty(mainIndex, propID, &prop));
|
||||
UString s = ConvertPropertyToString(prop, propID);
|
||||
if (!s.IsEmpty())
|
||||
PrintPropPair(GetPropName(propID, name), s);
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// CLSIDConst.cpp
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <initguid.h>
|
||||
|
||||
#include "../Agent/Agent.h"
|
||||
#include "../../IPassword.h"
|
||||
@@ -57,20 +57,21 @@ STDMETHODIMP CExtractCallBackImp::AskOverwrite(
|
||||
Int32 *answer)
|
||||
{
|
||||
NOverwriteDialog::CFileInfo oldFileInfo, newFileInfo;
|
||||
oldFileInfo.TimeIsDefined = (existTime != 0);
|
||||
if (oldFileInfo.TimeIsDefined)
|
||||
oldFileInfo.Time = *existTime;
|
||||
oldFileInfo.SizeIsDefined = (existSize != NULL);
|
||||
if (oldFileInfo.SizeIsDefined)
|
||||
oldFileInfo.Size = *existSize;
|
||||
oldFileInfo.Name = GetSystemString(existName, m_CodePage);
|
||||
oldFileInfo.Name = existName;
|
||||
|
||||
newFileInfo.TimeIsDefined = (newTime != 0);
|
||||
if (newFileInfo.TimeIsDefined)
|
||||
newFileInfo.Time = *newTime;
|
||||
|
||||
newFileInfo.SizeIsDefined = (newSize != NULL);
|
||||
if (newFileInfo.SizeIsDefined)
|
||||
newFileInfo.Size = *newSize;
|
||||
newFileInfo.Name = GetSystemString(newName, m_CodePage);
|
||||
newFileInfo.Name = newName;
|
||||
|
||||
NOverwriteDialog::NResult::EEnum result =
|
||||
NOverwriteDialog::Execute(oldFileInfo, newFileInfo);
|
||||
|
||||
@@ -1,20 +1,34 @@
|
||||
; 7-ZipFar.def : Declares the module parameters for the DLL.
|
||||
|
||||
LIBRARY "7-ZipFar"
|
||||
DESCRIPTION '7-ZipFar Windows Dynamic Link Library'
|
||||
|
||||
EXPORTS
|
||||
SetStartupInfo = _SetStartupInfo@4
|
||||
OpenPlugin = _OpenPlugin@8
|
||||
OpenFilePlugin = _OpenFilePlugin@12
|
||||
ClosePlugin = _ClosePlugin@4
|
||||
GetFindData = _GetFindData@16
|
||||
FreeFindData = _FreeFindData@12
|
||||
SetDirectory = _SetDirectory@12
|
||||
GetPluginInfo = _GetPluginInfo@4
|
||||
Configure = _Configure@4
|
||||
GetOpenPluginInfo = _GetOpenPluginInfo@8
|
||||
GetFiles = _GetFiles@24
|
||||
PutFiles = _PutFiles@20
|
||||
DeleteFiles = _DeleteFiles@16
|
||||
ProcessKey = _ProcessKey@12
|
||||
SetStartupInfo
|
||||
OpenPlugin
|
||||
OpenFilePlugin
|
||||
ClosePlugin
|
||||
GetFindData
|
||||
FreeFindData
|
||||
SetDirectory
|
||||
GetPluginInfo
|
||||
Configure
|
||||
GetOpenPluginInfo
|
||||
GetFiles
|
||||
PutFiles
|
||||
DeleteFiles
|
||||
ProcessKey
|
||||
|
||||
;SetStartupInfoW
|
||||
;OpenPluginW
|
||||
;OpenFilePluginW
|
||||
;ClosePluginW
|
||||
;GetFindDataW
|
||||
;FreeFindDataW
|
||||
;SetDirectoryW
|
||||
;GetPluginInfoW
|
||||
;ConfigureW
|
||||
;GetOpenPluginInfoW
|
||||
;GetFilesW
|
||||
;PutFilesW
|
||||
;DeleteFilesW
|
||||
;ProcessKeyW
|
||||
|
||||
@@ -53,7 +53,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\Far\Plugins\7-Zip\7-ZipFar.dll" /opt:NOWIN98
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\Far2\Plugins\7-Zip\7-ZipFar.dll" /opt:NOWIN98
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ELSEIF "$(CFG)" == "Far - Win32 Debug"
|
||||
@@ -80,7 +80,7 @@ BSC32=bscmake.exe
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\Far\Plugins\7-Zip\7-ZipFar.dll" /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\Far2\Plugins\7-Zip\7-ZipFar.dll" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
@@ -93,10 +93,6 @@ LINK32=link.exe
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\CLSIDConst.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Far.def
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -1,18 +1,37 @@
|
||||
// FarPlugin.h
|
||||
|
||||
#ifndef __FARPLUGIN_H
|
||||
#define __FARPLUGIN_H
|
||||
// #include "plugin.hpp"
|
||||
|
||||
const int kInfoPanelLineSize = 80;
|
||||
|
||||
// #define __FAR_PLUGIN_H
|
||||
|
||||
#ifdef UNDER_CE
|
||||
typedef struct _CHAR_INFO {
|
||||
union {
|
||||
WCHAR UnicodeChar;
|
||||
CHAR AsciiChar;
|
||||
} Char;
|
||||
WORD Attributes;
|
||||
} CHAR_INFO, *PCHAR_INFO;
|
||||
#endif
|
||||
|
||||
#ifndef __FAR_PLUGIN_H
|
||||
#define __FAR_PLUGIN_H
|
||||
|
||||
#ifndef _WIN64
|
||||
#if defined(__BORLANDC__) && (__BORLANDC <= 0x520)
|
||||
#pragma option -a1
|
||||
#elif defined(__GNUC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1100))
|
||||
#pragma pack(1)
|
||||
#else
|
||||
#pragma pack(push,1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if _MSC_VER
|
||||
#define _export
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define NM 260
|
||||
|
||||
@@ -41,8 +60,9 @@ struct PluginPanelItem
|
||||
char *Owner;
|
||||
char **CustomColumnData;
|
||||
int CustomColumnNumber;
|
||||
DWORD UserData;
|
||||
DWORD Reserved[3];
|
||||
DWORD_PTR UserData;
|
||||
DWORD CRC32;
|
||||
DWORD_PTR Reserved[2];
|
||||
};
|
||||
|
||||
#define PPIF_PROCESSDESCR 0x80000000
|
||||
@@ -58,7 +78,7 @@ enum {
|
||||
|
||||
|
||||
typedef int (WINAPI *FARAPIMENU)(
|
||||
int PluginNumber,
|
||||
INT_PTR PluginNumber,
|
||||
int X,
|
||||
int Y,
|
||||
int MaxHeight,
|
||||
@@ -73,7 +93,7 @@ typedef int (WINAPI *FARAPIMENU)(
|
||||
);
|
||||
|
||||
typedef int (WINAPI *FARAPIDIALOG)(
|
||||
int PluginNumber,
|
||||
INT_PTR PluginNumber,
|
||||
int X1,
|
||||
int Y1,
|
||||
int X2,
|
||||
@@ -92,7 +112,7 @@ enum {
|
||||
};
|
||||
|
||||
typedef int (WINAPI *FARAPIMESSAGE)(
|
||||
int PluginNumber,
|
||||
INT_PTR PluginNumber,
|
||||
unsigned int Flags,
|
||||
char *HelpTopic,
|
||||
char **Items,
|
||||
@@ -101,7 +121,7 @@ typedef int (WINAPI *FARAPIMESSAGE)(
|
||||
);
|
||||
|
||||
typedef char* (WINAPI *FARAPIGETMSG)(
|
||||
int PluginNumber,
|
||||
INT_PTR PluginNumber,
|
||||
int MsgId
|
||||
);
|
||||
|
||||
@@ -194,7 +214,8 @@ struct PanelInfo
|
||||
char CurDir[NM];
|
||||
int ShortNames;
|
||||
int SortMode;
|
||||
DWORD Reserved[2];
|
||||
DWORD Flags;
|
||||
DWORD Reserved;
|
||||
};
|
||||
|
||||
|
||||
@@ -222,7 +243,7 @@ typedef int (WINAPI *FARAPIGETDIRLIST)(
|
||||
);
|
||||
|
||||
typedef int (WINAPI *FARAPIGETPLUGINDIRLIST)(
|
||||
int PluginNumber,
|
||||
INT_PTR PluginNumber,
|
||||
HANDLE hPlugin,
|
||||
char *Dir,
|
||||
struct PluginPanelItem **pPanelItem,
|
||||
@@ -294,126 +315,11 @@ typedef int (WINAPI *FARAPIEDITORCONTROL)(
|
||||
void *Param
|
||||
);
|
||||
|
||||
|
||||
enum EDITOR_EVENTS {
|
||||
EE_READ,EE_SAVE,EE_REDRAW,EE_CLOSE
|
||||
};
|
||||
|
||||
enum EDITOR_CONTROL_COMMANDS {
|
||||
ECTL_GETSTRING,ECTL_SETSTRING,ECTL_INSERTSTRING,ECTL_DELETESTRING,
|
||||
ECTL_DELETECHAR,ECTL_INSERTTEXT,ECTL_GETINFO,ECTL_SETPOSITION,
|
||||
ECTL_SELECT,ECTL_REDRAW,ECTL_EDITORTOOEM,ECTL_OEMTOEDITOR,
|
||||
ECTL_TABTOREAL,ECTL_REALTOTAB,ECTL_EXPANDTABS,ECTL_SETTITLE,
|
||||
ECTL_READINPUT,ECTL_PROCESSINPUT,ECTL_ADDCOLOR,ECTL_GETCOLOR
|
||||
};
|
||||
|
||||
|
||||
struct EditorGetString
|
||||
{
|
||||
int StringNumber;
|
||||
char *StringText;
|
||||
char *StringEOL;
|
||||
int StringLength;
|
||||
int SelStart;
|
||||
int SelEnd;
|
||||
};
|
||||
|
||||
|
||||
struct EditorSetString
|
||||
{
|
||||
int StringNumber;
|
||||
char *StringText;
|
||||
char *StringEOL;
|
||||
int StringLength;
|
||||
};
|
||||
|
||||
|
||||
enum EDITOR_OPTIONS {
|
||||
EOPT_EXPANDTABS=1,EOPT_PERSISTENTBLOCKS=2,EOPT_DELREMOVESBLOCKS=4,
|
||||
EOPT_AUTOINDENT=8,EOPT_SAVEFILEPOSITION=16,EOPT_AUTODETECTTABLE=32,
|
||||
EOPT_CURSORBEYONDEOL=64
|
||||
};
|
||||
|
||||
|
||||
enum EDITOR_BLOCK_TYPES {
|
||||
BTYPE_NONE,BTYPE_STREAM,BTYPE_COLUMN
|
||||
};
|
||||
|
||||
|
||||
struct EditorInfo
|
||||
{
|
||||
int EditorID;
|
||||
char *FileName;
|
||||
int WindowSizeX;
|
||||
int WindowSizeY;
|
||||
int TotalLines;
|
||||
int CurLine;
|
||||
int CurPos;
|
||||
int CurTabPos;
|
||||
int TopScreenLine;
|
||||
int LeftPos;
|
||||
int Overtype;
|
||||
int BlockType;
|
||||
int BlockStartLine;
|
||||
int AnsiMode;
|
||||
int TableNum;
|
||||
DWORD Options;
|
||||
int TabSize;
|
||||
DWORD Reserved[8];
|
||||
};
|
||||
|
||||
|
||||
struct EditorSetPosition
|
||||
{
|
||||
int CurLine;
|
||||
int CurPos;
|
||||
int CurTabPos;
|
||||
int TopScreenLine;
|
||||
int LeftPos;
|
||||
int Overtype;
|
||||
};
|
||||
|
||||
|
||||
struct EditorSelect
|
||||
{
|
||||
int BlockType;
|
||||
int BlockStartLine;
|
||||
int BlockStartPos;
|
||||
int BlockWidth;
|
||||
int BlockHeight;
|
||||
};
|
||||
|
||||
|
||||
struct EditorConvertText
|
||||
{
|
||||
char *Text;
|
||||
int TextLength;
|
||||
};
|
||||
|
||||
|
||||
struct EditorConvertPos
|
||||
{
|
||||
int StringNumber;
|
||||
int SrcPos;
|
||||
int DestPos;
|
||||
};
|
||||
|
||||
|
||||
struct EditorColor
|
||||
{
|
||||
int StringNumber;
|
||||
int ColorItem;
|
||||
int StartPos;
|
||||
int EndPos;
|
||||
int Color;
|
||||
};
|
||||
|
||||
|
||||
struct PluginStartupInfo
|
||||
{
|
||||
int StructSize;
|
||||
char ModuleName[NM];
|
||||
int ModuleNumber;
|
||||
INT_PTR ModuleNumber;
|
||||
char *RootKey;
|
||||
FARAPIMENU Menu;
|
||||
FARAPIDIALOG Dialog;
|
||||
@@ -456,8 +362,6 @@ struct PluginInfo
|
||||
char *CommandPrefix;
|
||||
};
|
||||
|
||||
const int kInfoPanelLineSize = 80;
|
||||
|
||||
struct InfoPanelLine
|
||||
{
|
||||
char Text[kInfoPanelLineSize];
|
||||
@@ -567,6 +471,7 @@ enum OPERATION_MODES {
|
||||
OPM_DESCR=32
|
||||
};
|
||||
|
||||
#ifndef _WIN64
|
||||
#if defined(__BORLANDC__) && (__BORLANDC <= 0x520)
|
||||
#pragma option -a.
|
||||
#elif defined(__GNUC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1100))
|
||||
@@ -574,5 +479,41 @@ enum OPERATION_MODES {
|
||||
#else
|
||||
#pragma pack(pop)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
void WINAPI _export ClosePluginW(HANDLE hPlugin);
|
||||
int WINAPI _export CompareW(HANDLE hPlugin,const struct PluginPanelItem *Item1,const struct PluginPanelItem *Item2,unsigned int Mode);
|
||||
int WINAPI _export ConfigureW(int ItemNumber);
|
||||
int WINAPI _export DeleteFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int OpMode);
|
||||
void WINAPI _export ExitFARW(void);
|
||||
void WINAPI _export FreeFindDataW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber);
|
||||
void WINAPI _export FreeVirtualFindDataW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber);
|
||||
int WINAPI _export GetFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int Move,const wchar_t **DestPath,int OpMode);
|
||||
int WINAPI _export GetFindDataW(HANDLE hPlugin,struct PluginPanelItem **pPanelItem,int *pItemsNumber,int OpMode);
|
||||
int WINAPI _export GetMinFarVersionW(void);
|
||||
void WINAPI _export GetOpenPluginInfoW(HANDLE hPlugin,struct OpenPluginInfo *Info);
|
||||
void WINAPI _export GetPluginInfoW(struct PluginInfo *Info);
|
||||
int WINAPI _export GetVirtualFindDataW(HANDLE hPlugin,struct PluginPanelItem **pPanelItem,int *pItemsNumber,const wchar_t *Path);
|
||||
int WINAPI _export MakeDirectoryW(HANDLE hPlugin,const wchar_t **Name,int OpMode);
|
||||
HANDLE WINAPI _export OpenFilePluginW(const wchar_t *Name,const unsigned char *Data,int DataSize,int OpMode);
|
||||
HANDLE WINAPI _export OpenPluginW(int OpenFrom,INT_PTR Item);
|
||||
int WINAPI _export ProcessDialogEventW(int Event,void *Param);
|
||||
int WINAPI _export ProcessEditorEventW(int Event,void *Param);
|
||||
int WINAPI _export ProcessEditorInputW(const INPUT_RECORD *Rec);
|
||||
int WINAPI _export ProcessEventW(HANDLE hPlugin,int Event,void *Param);
|
||||
int WINAPI _export ProcessHostFileW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int OpMode);
|
||||
int WINAPI _export ProcessKeyW(HANDLE hPlugin,int Key,unsigned int ControlState);
|
||||
int WINAPI _export ProcessSynchroEventW(int Event,void *Param);
|
||||
int WINAPI _export ProcessViewerEventW(int Event,void *Param);
|
||||
int WINAPI _export PutFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int Move,const wchar_t *SrcPath,int OpMode);
|
||||
int WINAPI _export SetDirectoryW(HANDLE hPlugin,const wchar_t *Dir,int OpMode);
|
||||
int WINAPI _export SetFindListW(HANDLE hPlugin,const struct PluginPanelItem *PanelItem,int ItemsNumber);
|
||||
void WINAPI _export SetStartupInfoW(const struct PluginStartupInfo *Info);
|
||||
|
||||
EXTERN_C_END
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#ifndef UNDER_CE
|
||||
#include "Windows/Console.h"
|
||||
#endif
|
||||
#include "Windows/Defs.h"
|
||||
#include "Windows/Error.h"
|
||||
|
||||
#include "FarUtils.h"
|
||||
@@ -417,6 +420,9 @@ void PrintErrorMessage(const char *message, const wchar_t *text)
|
||||
|
||||
bool WasEscPressed()
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
return false;
|
||||
#else
|
||||
NConsole::CIn inConsole;
|
||||
HANDLE handle = ::GetStdHandle(STD_INPUT_HANDLE);
|
||||
if(handle == INVALID_HANDLE_VALUE)
|
||||
@@ -438,16 +444,16 @@ bool WasEscPressed()
|
||||
event.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ShowErrorMessage(DWORD errorCode)
|
||||
{
|
||||
CSysString message;
|
||||
UString message;
|
||||
NError::MyFormatMessage(errorCode, message);
|
||||
message.Replace(TEXT("\x0D"), TEXT(""));
|
||||
message.Replace(TEXT("\x0A"), TEXT(" "));
|
||||
g_StartupInfo.ShowMessage(SystemStringToOemString(message));
|
||||
|
||||
message.Replace(L"\x0D", L"");
|
||||
message.Replace(L"\x0A", L" ");
|
||||
g_StartupInfo.ShowMessage(UnicodeStringToMultiByte(message, CP_OEMCP));
|
||||
}
|
||||
|
||||
void ShowLastErrorMessage()
|
||||
|
||||
@@ -21,8 +21,8 @@ using namespace NWindows;
|
||||
using namespace NFar;
|
||||
|
||||
static const char *kCommandPrefix = "7-zip";
|
||||
static const char *kRegisrtryMainKeyName = "";
|
||||
static const char *kRegisrtryValueNameEnabled = "UsedByDefault3";
|
||||
static const TCHAR *kRegisrtryMainKeyName = TEXT("");
|
||||
static const TCHAR *kRegisrtryValueNameEnabled = TEXT("UsedByDefault3");
|
||||
static const char *kHelpTopicConfig = "Config";
|
||||
static bool kPluginEnabledDefault = true;
|
||||
|
||||
@@ -30,11 +30,17 @@ HINSTANCE g_hInstance;
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION return FALSE;
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
|
||||
BOOL WINAPI DllMain(
|
||||
#ifdef UNDER_CE
|
||||
HANDLE
|
||||
#else
|
||||
HINSTANCE
|
||||
#endif
|
||||
hInstance, DWORD dwReason, LPVOID)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
g_hInstance = hInstance;
|
||||
g_hInstance = (HINSTANCE)hInstance;
|
||||
NT_CHECK
|
||||
}
|
||||
return TRUE;
|
||||
@@ -45,9 +51,9 @@ static struct COptions
|
||||
bool Enabled;
|
||||
} g_Options;
|
||||
|
||||
static const char *kPliginNameForRegestry = "7-ZIP";
|
||||
static const TCHAR *kPliginNameForRegestry = TEXT("7-ZIP");
|
||||
|
||||
EXTERN_C void WINAPI SetStartupInfo(struct PluginStartupInfo *info)
|
||||
EXTERN_C void WINAPI SetStartupInfo(const PluginStartupInfo *info)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
g_StartupInfo.Init(*info, kPliginNameForRegestry);
|
||||
@@ -325,11 +331,9 @@ HRESULT OpenArchive(const CSysString &fileName,
|
||||
}
|
||||
*/
|
||||
|
||||
static HANDLE MyOpenFilePlugin(const char *name)
|
||||
static HANDLE MyOpenFilePluginW(const wchar_t *name)
|
||||
{
|
||||
UINT codePage = ::AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
|
||||
UString normalizedName = GetUnicodeString(name, codePage);
|
||||
UString normalizedName = name;
|
||||
normalizedName.Trim();
|
||||
UString fullName;
|
||||
int fileNamePartStartIndex;
|
||||
@@ -344,7 +348,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
|
||||
CMyComPtr<IInFolderArchive> archiveHandler;
|
||||
|
||||
// CArchiverInfo archiverInfoResult;
|
||||
// ::OutputDebugString("before OpenArchive\n");
|
||||
// ::OutputDebugStringA("before OpenArchive\n");
|
||||
|
||||
CScreenRestorer screenRestorer;
|
||||
{
|
||||
@@ -360,7 +364,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
|
||||
fullName.Left(fileNamePartStartIndex),
|
||||
fullName.Mid(fileNamePartStartIndex));
|
||||
|
||||
// ::OutputDebugString("before OpenArchive\n");
|
||||
// ::OutputDebugStringA("before OpenArchive\n");
|
||||
|
||||
archiveHandler = new CAgent;
|
||||
CMyComBSTR archiveType;
|
||||
@@ -377,7 +381,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
// ::OutputDebugString("after OpenArchive\n");
|
||||
// ::OutputDebugStringA("after OpenArchive\n");
|
||||
|
||||
CPlugin *plugin = new CPlugin(
|
||||
fullName,
|
||||
@@ -393,7 +397,18 @@ static HANDLE MyOpenFilePlugin(const char *name)
|
||||
return (HANDLE)(plugin);
|
||||
}
|
||||
|
||||
EXTERN_C HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char * /* data */, unsigned int /* dataSize */)
|
||||
static HANDLE MyOpenFilePlugin(const char *name)
|
||||
{
|
||||
UINT codePage =
|
||||
#ifdef UNDER_CE
|
||||
CP_OEMCP;
|
||||
#else
|
||||
::AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
#endif
|
||||
return MyOpenFilePluginW(GetUnicodeString(name, codePage));
|
||||
}
|
||||
|
||||
EXTERN_C HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char * /* data */, int /* dataSize */)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
if (name == NULL || (!g_Options.Enabled))
|
||||
@@ -405,12 +420,27 @@ EXTERN_C HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char * /* data
|
||||
MY_TRY_END2("OpenFilePlugin", INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, int item)
|
||||
/*
|
||||
EXTERN_C HANDLE WINAPI OpenFilePluginW(const wchar_t *name,const unsigned char *Data,int DataSize,int OpMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
if (name == NULL || (!g_Options.Enabled))
|
||||
{
|
||||
// if (!Opt.ProcessShiftF1)
|
||||
return(INVALID_HANDLE_VALUE);
|
||||
}
|
||||
return MyOpenFilePluginW(name);
|
||||
::OutputDebugStringA("OpenFilePluginW\n");
|
||||
MY_TRY_END2("OpenFilePluginW", INVALID_HANDLE_VALUE);
|
||||
}
|
||||
*/
|
||||
|
||||
EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, INT_PTR item)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
if(openFrom == OPEN_COMMANDLINE)
|
||||
{
|
||||
CSysString fileName = (const char *)(UINT_PTR)item;
|
||||
AString fileName = (const char *)item;
|
||||
if(fileName.IsEmpty())
|
||||
return INVALID_HANDLE_VALUE;
|
||||
if (fileName.Length() >= 2 &&
|
||||
@@ -482,7 +512,7 @@ EXTERN_C int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
MY_TRY_END2("GetFiles", NFileOperationReturnCode::kError);
|
||||
}
|
||||
|
||||
EXTERN_C int WINAPI SetDirectory(HANDLE plugin, char *dir, int opMode)
|
||||
EXTERN_C int WINAPI SetDirectory(HANDLE plugin, const char *dir, int opMode)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
return(((CPlugin *)plugin)->SetDirectory(dir, opMode));
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace NOverwriteDialog {
|
||||
|
||||
struct CFileInfoStrings
|
||||
{
|
||||
CSysString Size;
|
||||
CSysString Time;
|
||||
AString Size;
|
||||
AString Time;
|
||||
};
|
||||
|
||||
void SetFileInfoStrings(const CFileInfo &fileInfo,
|
||||
@@ -51,7 +51,7 @@ void SetFileInfoStrings(const CFileInfo &fileInfo,
|
||||
UString timeString = ConvertFileTimeToString(localFileTime);
|
||||
fileInfoStrings.Time = g_StartupInfo.GetMsgString(NMessageID::kOverwriteModifiedOn);
|
||||
fileInfoStrings.Time += " ";
|
||||
fileInfoStrings.Time += GetSystemString(timeString, CP_OEMCP);
|
||||
fileInfoStrings.Time += UnicodeStringToMultiByte(timeString, CP_OEMCP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,10 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf
|
||||
SetFileInfoStrings(oldFileInfo, oldFileInfoStrings);
|
||||
SetFileInfoStrings(newFileInfo, newFileInfoStrings);
|
||||
|
||||
struct CInitDialogItem anInitItems[]={
|
||||
AString oldName = UnicodeStringToMultiByte(oldFileInfo.Name, CP_OEMCP);
|
||||
AString newName = UnicodeStringToMultiByte(newFileInfo.Name, CP_OEMCP);
|
||||
|
||||
struct CInitDialogItem initItems[]={
|
||||
{ DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false, NMessageID::kOverwriteTitle, NULL, NULL },
|
||||
{ DI_TEXT, 5, 2, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessage1, NULL, NULL },
|
||||
|
||||
@@ -74,13 +77,13 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf
|
||||
|
||||
{ DI_TEXT, 5, 4, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWouldYouLike, NULL, NULL },
|
||||
|
||||
{ DI_TEXT, 7, 6, 0, 0, false, false, 0, false, -1, oldFileInfo.Name, NULL },
|
||||
{ DI_TEXT, 7, 6, 0, 0, false, false, 0, false, -1, oldName, NULL },
|
||||
{ DI_TEXT, 7, 7, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Size, NULL },
|
||||
{ DI_TEXT, 7, 8, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Time, NULL },
|
||||
|
||||
{ DI_TEXT, 5, 10, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWithtTisOne, NULL, NULL },
|
||||
|
||||
{ DI_TEXT, 7, 12, 0, 0, false, false, 0, false, -1, newFileInfo.Name, NULL },
|
||||
{ DI_TEXT, 7, 12, 0, 0, false, false, 0, false, -1, newName, NULL },
|
||||
{ DI_TEXT, 7, 13, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Size, NULL },
|
||||
{ DI_TEXT, 7, 14, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Time, NULL },
|
||||
|
||||
@@ -94,9 +97,9 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf
|
||||
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kOverwriteCancel, NULL, NULL }
|
||||
};
|
||||
|
||||
const int kNumDialogItems = sizeof(anInitItems) / sizeof(anInitItems[0]);
|
||||
const int kNumDialogItems = sizeof(initItems) / sizeof(initItems[0]);
|
||||
FarDialogItem aDialogItems[kNumDialogItems];
|
||||
g_StartupInfo.InitDialogItems(anInitItems, aDialogItems, kNumDialogItems);
|
||||
g_StartupInfo.InitDialogItems(initItems, aDialogItems, kNumDialogItems);
|
||||
int anAskCode = g_StartupInfo.ShowDialog(kXSize, kYSize,
|
||||
NULL, aDialogItems, kNumDialogItems);
|
||||
const int kButtonStartPos = kNumDialogItems - 6;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define OVERWRITEDIALOG_H
|
||||
|
||||
#include "Common/MyString.h"
|
||||
#include "Common/Types.h"
|
||||
|
||||
namespace NOverwriteDialog {
|
||||
|
||||
@@ -11,10 +12,11 @@ struct CFileInfo
|
||||
{
|
||||
bool SizeIsDefined;
|
||||
bool TimeIsDefined;
|
||||
UINT64 Size;
|
||||
UInt64 Size;
|
||||
FILETIME Time;
|
||||
CSysString Name;
|
||||
UString Name;
|
||||
};
|
||||
|
||||
namespace NResult
|
||||
{
|
||||
enum EEnum
|
||||
@@ -24,10 +26,11 @@ namespace NResult
|
||||
kNo,
|
||||
kNoToAll,
|
||||
kAutoRename,
|
||||
kCancel,
|
||||
kCancel
|
||||
};
|
||||
}
|
||||
NResult::EEnum Execute(const CFileInfo &anOldFileInfo, const CFileInfo &aNewFileInfo);
|
||||
|
||||
NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInfo);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
|
||||
if (prop.vt != VT_BSTR)
|
||||
throw 272340;
|
||||
|
||||
CSysString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
|
||||
AString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
|
||||
if (oemString == "..")
|
||||
oemString = kDotsReplaceString;
|
||||
|
||||
@@ -133,9 +133,9 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
|
||||
panelItem.CustomColumnData = NULL;
|
||||
panelItem.CustomColumnNumber = 0;
|
||||
|
||||
panelItem.CRC32 = 0;
|
||||
panelItem.Reserved[0] = 0;
|
||||
panelItem.Reserved[1] = 0;
|
||||
panelItem.Reserved[2] = 0;
|
||||
}
|
||||
|
||||
int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opMode)
|
||||
@@ -466,7 +466,7 @@ static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID)
|
||||
AString s;
|
||||
|
||||
if (prop.vt == VT_BSTR)
|
||||
s = GetSystemString(prop.bstrVal, CP_OEMCP);
|
||||
s = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
|
||||
else if (prop.vt == VT_BOOL)
|
||||
{
|
||||
int messageID = VARIANT_BOOLToBool(prop.boolVal) ?
|
||||
@@ -733,7 +733,7 @@ HRESULT CPlugin::ShowAttributesWindow()
|
||||
if (strcmp(pluginPanelItem.FindData.cFileName, "..") == 0 &&
|
||||
NFile::NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes))
|
||||
return S_FALSE;
|
||||
int itemIndex = pluginPanelItem.UserData;
|
||||
int itemIndex = (int)pluginPanelItem.UserData;
|
||||
|
||||
CObjectVector<CArchiveItemProperty> properties;
|
||||
UInt32 numProps;
|
||||
@@ -781,7 +781,7 @@ HRESULT CPlugin::ShowAttributesWindow()
|
||||
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(_folder->GetProperty(itemIndex, property.ID, &prop));
|
||||
CSysString s = PropToString(prop, property.ID);
|
||||
AString s = PropToString(prop, property.ID);
|
||||
values.Add(s);
|
||||
|
||||
{
|
||||
|
||||
@@ -82,8 +82,8 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
CRecordVector<UINT32> indices;
|
||||
indices.Reserve(numItems);
|
||||
int i;
|
||||
for(i = 0; i < numItems; i++)
|
||||
indices.Add(panelItems[i].UserData);
|
||||
for (i = 0; i < numItems; i++)
|
||||
indices.Add((UINT32)panelItems[i].UserData);
|
||||
|
||||
////////////////////////////
|
||||
// Save _folder;
|
||||
@@ -93,7 +93,7 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
|
||||
CMyComPtr<IOutFolderArchive> outArchive;
|
||||
HRESULT result = m_ArchiveHandler.QueryInterface(IID_IOutFolderArchive, &outArchive);
|
||||
if(result != S_OK)
|
||||
if (result != S_OK)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
|
||||
return FALSE;
|
||||
@@ -151,11 +151,11 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
{
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
_folder->BindToFolder(pathVector[i], &newFolder);
|
||||
if(!newFolder )
|
||||
if (!newFolder)
|
||||
break;
|
||||
_folder = newFolder;
|
||||
}
|
||||
GetCurrentDir();
|
||||
|
||||
return(TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -76,23 +76,25 @@ HRESULT CPlugin::ExtractFiles(
|
||||
}
|
||||
|
||||
NFileOperationReturnCode::EEnum CPlugin::GetFiles(struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, char *_aDestPath, int opMode)
|
||||
int itemsNumber, int move, char *destPath, int opMode)
|
||||
{
|
||||
return GetFilesReal(panelItems, itemsNumber, move,
|
||||
_aDestPath, opMode, (opMode & OPM_SILENT) == 0);
|
||||
destPath, opMode, (opMode & OPM_SILENT) == 0);
|
||||
}
|
||||
|
||||
NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *panelItems,
|
||||
int itemsNumber, int move, const char *_aDestPath, int opMode, bool showBox)
|
||||
int itemsNumber, int move, const char *destPathLoc, int opMode, bool showBox)
|
||||
{
|
||||
if(move != 0)
|
||||
if (move != 0)
|
||||
{
|
||||
g_StartupInfo.ShowMessage(NMessageID::kMoveIsNotSupported);
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
CSysString destPath = _aDestPath;
|
||||
NFile::NName::NormalizeDirPathPrefix(destPath);
|
||||
AString destPath = destPathLoc;
|
||||
UString destPathU = GetUnicodeString(destPath, CP_OEMCP);
|
||||
NFile::NName::NormalizeDirPathPrefix(destPathU);
|
||||
destPath = UnicodeStringToMultiByte(destPathU, CP_OEMCP);
|
||||
|
||||
bool extractSelectedFiles = true;
|
||||
|
||||
@@ -185,17 +187,22 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
if (askCode != kOkButtonIndex)
|
||||
return NFileOperationReturnCode::kInterruptedByUser;
|
||||
destPath = dialogItems[kPathIndex].Data;
|
||||
destPath.Trim();
|
||||
if (destPath.IsEmpty())
|
||||
destPathU = GetUnicodeString(destPath, CP_OEMCP);
|
||||
destPathU.Trim();
|
||||
if (destPathU.IsEmpty())
|
||||
{
|
||||
if(!NFile::NDirectory::MyGetCurrentDirectory(destPath))
|
||||
#ifdef UNDER_CE
|
||||
destPathU = L"\\";
|
||||
#else
|
||||
if (!NFile::NDirectory::MyGetCurrentDirectory(destPathU))
|
||||
throw 318016;
|
||||
NFile::NName::NormalizeDirPathPrefix(destPath);
|
||||
NFile::NName::NormalizeDirPathPrefix(destPathU);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(destPath[destPath.Length() - 1] == kDirDelimiter)
|
||||
if (destPathU.Back() == kDirDelimiter)
|
||||
break;
|
||||
}
|
||||
g_StartupInfo.ShowMessage("You must specify directory path");
|
||||
@@ -244,7 +251,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
passwordIsDefined = !password.IsEmpty();
|
||||
}
|
||||
|
||||
NFile::NDirectory::CreateComplexDirectory(destPath);
|
||||
NFile::NDirectory::CreateComplexDirectory(destPathU);
|
||||
|
||||
/*
|
||||
vector<int> realIndices;
|
||||
@@ -254,11 +261,11 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
CRecordVector<UINT32> indices;
|
||||
indices.Reserve(itemsNumber);
|
||||
for (int i = 0; i < itemsNumber; i++)
|
||||
indices.Add(panelItems[i].UserData);
|
||||
indices.Add((UINT32)panelItems[i].UserData);
|
||||
|
||||
HRESULT result = ExtractFiles(decompressAllItems, &indices.Front(), itemsNumber,
|
||||
!showBox, extractionInfo.PathMode, extractionInfo.OverwriteMode,
|
||||
MultiByteToUnicodeString(destPath, CP_OEMCP),
|
||||
destPathU,
|
||||
passwordIsDefined, password);
|
||||
// HRESULT result = ExtractFiles(decompressAllItems, realIndices, !showBox,
|
||||
// extractionInfo, destPath, passwordIsDefined, password);
|
||||
@@ -270,9 +277,9 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
// if(move != 0)
|
||||
// if (move != 0)
|
||||
// {
|
||||
// if(DeleteFiles(panelItems, itemsNumber, opMode) == FALSE)
|
||||
// if (DeleteFiles(panelItems, itemsNumber, opMode) == FALSE)
|
||||
// return NFileOperationReturnCode::kError;
|
||||
// }
|
||||
return NFileOperationReturnCode::kSuccess;
|
||||
|
||||
@@ -412,16 +412,17 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
for(i = 0; i < pluginPanelItems.Size(); i++)
|
||||
{
|
||||
const PluginPanelItem &panelItem = pluginPanelItems[i];
|
||||
CSysString fullName;
|
||||
UString fullName;
|
||||
if (strcmp(panelItem.FindData.cFileName, "..") == 0 &&
|
||||
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
|
||||
return E_FAIL;
|
||||
if (strcmp(panelItem.FindData.cFileName, ".") == 0 &&
|
||||
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
|
||||
return E_FAIL;
|
||||
if (!MyGetFullPathName(panelItem.FindData.cFileName, fullName))
|
||||
UString fileNameUnicode = MultiByteToUnicodeString(panelItem.FindData.cFileName, CP_OEMCP);
|
||||
if (!MyGetFullPathName(fileNameUnicode, fullName))
|
||||
return E_FAIL;
|
||||
fileNames.Add(MultiByteToUnicodeString(fullName, CP_OEMCP));
|
||||
fileNames.Add(fullName);
|
||||
}
|
||||
|
||||
NCompression::CInfo compressionInfo;
|
||||
@@ -496,7 +497,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex];
|
||||
|
||||
char updateAddToArchiveString[512];
|
||||
const AString s = GetSystemString(arcInfo.Name, CP_OEMCP);
|
||||
const AString s = UnicodeStringToMultiByte(arcInfo.Name, CP_OEMCP);
|
||||
|
||||
sprintf(updateAddToArchiveString,
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), (const char *)s);
|
||||
@@ -777,4 +778,3 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
PROG = 7-ZipFar.dll
|
||||
DEF_FILE = Far.def
|
||||
CFLAGS = $(CFLAGS) -I ../../../ \
|
||||
-DWIN_LONG_PATH \
|
||||
-DEXTERNAL_CODECS
|
||||
|
||||
!IFNDEF UNDER_CE
|
||||
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH
|
||||
!ENDIF
|
||||
|
||||
FAR_OBJS = \
|
||||
$O\CLSIDConst.obj \
|
||||
$O\ExtractEngine.obj \
|
||||
$O\FarUtils.obj \
|
||||
$O\Main.obj \
|
||||
|
||||
@@ -21,6 +21,6 @@ CAPTION "About 7-Zip"
|
||||
ICON IDI_LOGO, -1, m, m, 32, 32, SS_REALSIZEIMAGE
|
||||
LTEXT MY_7ZIP_VERSION, -1, m, 54, xc, 8
|
||||
LTEXT MY_COPYRIGHT, -1, m, 67, xc, 8
|
||||
LTEXT "7-Zip is free software. However, you can support development of 7-Zip by registering.",
|
||||
LTEXT "7-Zip is free software",
|
||||
IDC_ABOUT_STATIC_REGISTER_INFO, m, y, xc, (by - y - 1)
|
||||
}
|
||||
|
||||
@@ -111,5 +111,4 @@ struct CAppState
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -384,7 +384,7 @@ static const int kNumSwitches = 1;
|
||||
namespace NKey {
|
||||
enum Enum
|
||||
{
|
||||
kOpenArachive = 0,
|
||||
kOpenArachive = 0
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -920,7 +920,7 @@ HRESULT CThreadTest::ProcessVirt()
|
||||
OkMessage = s;
|
||||
}
|
||||
return S_OK;
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s)
|
||||
|
||||
@@ -236,12 +236,12 @@ private:
|
||||
|
||||
void ChangeWindowSize(int xSize, int ySize);
|
||||
|
||||
void InitColumns();
|
||||
HRESULT InitColumns();
|
||||
// void InitColumns2(PROPID sortID);
|
||||
void InsertColumn(int index);
|
||||
|
||||
void SetFocusedSelectedItem(int index, bool select);
|
||||
void RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
|
||||
HRESULT RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
|
||||
const UStringVector &selectedNames);
|
||||
|
||||
void OnShiftSelectMessage();
|
||||
@@ -335,8 +335,8 @@ public:
|
||||
|
||||
void GetSelectedNames(UStringVector &selectedNames);
|
||||
void SaveSelectedState(CSelectedState &s);
|
||||
void RefreshListCtrl(const CSelectedState &s);
|
||||
void RefreshListCtrlSaveFocused();
|
||||
HRESULT RefreshListCtrl(const CSelectedState &s);
|
||||
HRESULT RefreshListCtrlSaveFocused();
|
||||
|
||||
UString GetItemName(int itemIndex) const;
|
||||
UString GetItemPrefix(int itemIndex) const;
|
||||
@@ -517,7 +517,7 @@ public:
|
||||
// bool _passwordIsDefined;
|
||||
// UString _password;
|
||||
|
||||
void RefreshListCtrl();
|
||||
HRESULT RefreshListCtrl();
|
||||
|
||||
void MessageBoxInfo(LPCWSTR message, LPCWSTR caption);
|
||||
void MessageBox(LPCWSTR message);
|
||||
|
||||
@@ -169,7 +169,7 @@ static const char *kStartExtensions =
|
||||
#endif
|
||||
" exe bat com"
|
||||
" chm"
|
||||
" msi doc xls ppt pps wps wpt wks xlr wdb"
|
||||
" msi doc xls ppt pps wps wpt wks xlr wdb vsd"
|
||||
|
||||
" docx docm dotx dotm xlsx xlsm xltx xltm xlsb"
|
||||
" xlam pptx pptm potx potm ppam ppsx ppsm xsn"
|
||||
@@ -440,7 +440,7 @@ HRESULT CThreadCopyFrom::ProcessVirt()
|
||||
fileNames.Add(Name);
|
||||
fileNamePointers.Add(fileNames[0]);
|
||||
return FolderOperations->CopyFrom(PathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), UpdateCallback);
|
||||
};
|
||||
}
|
||||
|
||||
HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName,
|
||||
bool usePassword, const UString &password)
|
||||
|
||||
@@ -55,7 +55,7 @@ static int GetColumnAlign(PROPID propID, VARTYPE varType)
|
||||
}
|
||||
}
|
||||
|
||||
void CPanel::InitColumns()
|
||||
HRESULT CPanel::InitColumns()
|
||||
{
|
||||
if (_needSaveInfo)
|
||||
SaveListViewInfo();
|
||||
@@ -88,8 +88,7 @@ void CPanel::InitColumns()
|
||||
PROPID propID;
|
||||
VARTYPE varType;
|
||||
|
||||
if (_folder->GetPropertyInfo(i, &name, &propID, &varType) != S_OK)
|
||||
throw 1;
|
||||
RINOK(_folder->GetPropertyInfo(i, &name, &propID, &varType));
|
||||
|
||||
if (propID == kpidIsDir)
|
||||
continue;
|
||||
@@ -110,7 +109,7 @@ void CPanel::InitColumns()
|
||||
break;
|
||||
|
||||
int order = 0;
|
||||
for(i = 0; i < _listViewInfo.Columns.Size(); i++)
|
||||
for (i = 0; i < _listViewInfo.Columns.Size(); i++)
|
||||
{
|
||||
const CColumnInfo &columnInfo = _listViewInfo.Columns[i];
|
||||
int index = _properties.FindItemWithID(columnInfo.PropID);
|
||||
@@ -124,7 +123,7 @@ void CPanel::InitColumns()
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for(i = 0; i < _properties.Size(); i++)
|
||||
for (i = 0; i < _properties.Size(); i++)
|
||||
{
|
||||
CItemProperty &item = _properties[i];
|
||||
if (item.Order < 0)
|
||||
@@ -155,6 +154,7 @@ void CPanel::InitColumns()
|
||||
{
|
||||
InsertColumn(i);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CPanel::InsertColumn(int index)
|
||||
@@ -166,13 +166,13 @@ void CPanel::InsertColumn(int index)
|
||||
column.fmt = GetColumnAlign(prop.ID, prop.Type);
|
||||
column.iOrder = prop.Order;
|
||||
column.iSubItem = index;
|
||||
column.pszText = (wchar_t *)(const wchar_t *)prop.Name;
|
||||
column.pszText = const_cast<wchar_t *>((const wchar_t *)prop.Name);
|
||||
_listView.InsertColumn(index, &column);
|
||||
}
|
||||
|
||||
void CPanel::RefreshListCtrl()
|
||||
HRESULT CPanel::RefreshListCtrl()
|
||||
{
|
||||
RefreshListCtrl(UString(), -1, true, UStringVector());
|
||||
return RefreshListCtrl(UString(), -1, true, UStringVector());
|
||||
}
|
||||
|
||||
int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData);
|
||||
@@ -239,19 +239,19 @@ void CPanel::SaveSelectedState(CSelectedState &s)
|
||||
GetSelectedNames(s.SelectedNames);
|
||||
}
|
||||
|
||||
void CPanel::RefreshListCtrl(const CSelectedState &s)
|
||||
HRESULT CPanel::RefreshListCtrl(const CSelectedState &s)
|
||||
{
|
||||
bool selectFocused = s.SelectFocused;
|
||||
if (_mySelectMode)
|
||||
selectFocused = true;
|
||||
RefreshListCtrl(s.FocusedName, s.FocusedItem, selectFocused, s.SelectedNames);
|
||||
return RefreshListCtrl(s.FocusedName, s.FocusedItem, selectFocused, s.SelectedNames);
|
||||
}
|
||||
|
||||
void CPanel::RefreshListCtrlSaveFocused()
|
||||
HRESULT CPanel::RefreshListCtrlSaveFocused()
|
||||
{
|
||||
CSelectedState state;
|
||||
SaveSelectedState(state);
|
||||
RefreshListCtrl(state);
|
||||
return RefreshListCtrl(state);
|
||||
}
|
||||
|
||||
void CPanel::SetFocusedSelectedItem(int index, bool select)
|
||||
@@ -268,7 +268,7 @@ void CPanel::SetFocusedSelectedItem(int index, bool select)
|
||||
}
|
||||
}
|
||||
|
||||
void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
|
||||
HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
|
||||
const UStringVector &selectedNames)
|
||||
{
|
||||
_dontShowMode = false;
|
||||
@@ -309,11 +309,8 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
|
||||
if (folderSetFlatMode)
|
||||
folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode));
|
||||
|
||||
if (_folder->LoadItems() != S_OK)
|
||||
return;
|
||||
|
||||
InitColumns();
|
||||
|
||||
RINOK(_folder->LoadItems());
|
||||
RINOK(InitColumns());
|
||||
|
||||
// OutputDebugString(TEXT("Start Dir\n"));
|
||||
UInt32 numItems;
|
||||
@@ -340,18 +337,18 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
|
||||
int subItem = 0;
|
||||
item.iSubItem = subItem++;
|
||||
item.lParam = kParentIndex;
|
||||
item.pszText = (wchar_t *)(const wchar_t *)itemName;
|
||||
item.pszText = const_cast<wchar_t *>((const wchar_t *)itemName);
|
||||
UInt32 attrib = FILE_ATTRIBUTE_DIRECTORY;
|
||||
item.iImage = _extToIconMap.GetIconIndex(attrib, itemName);
|
||||
if (item.iImage < 0)
|
||||
item.iImage = 0;
|
||||
if(_listView.InsertItem(&item) == -1)
|
||||
return;
|
||||
if (_listView.InsertItem(&item) == -1)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// OutputDebugStringA("S1\n");
|
||||
|
||||
for(UInt32 i = 0; i < numItems; i++)
|
||||
for (UInt32 i = 0; i < numItems; i++)
|
||||
{
|
||||
UString itemName = GetItemName(i);
|
||||
const UString relPath = GetItemRelPath(i);
|
||||
@@ -394,13 +391,13 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
|
||||
pos = posNew;
|
||||
while (itemName[++pos] == ' ');
|
||||
}
|
||||
item.pszText = (wchar_t *)(const wchar_t *)correctedName;
|
||||
item.pszText = const_cast<wchar_t *>((const wchar_t *)correctedName);
|
||||
}
|
||||
else
|
||||
item.pszText = (wchar_t *)(const wchar_t *)itemName;
|
||||
item.pszText = const_cast<wchar_t *>((const wchar_t *)itemName);
|
||||
|
||||
NCOM::CPropVariant prop;
|
||||
_folder->GetProperty(i, kpidAttrib, &prop);
|
||||
RINOK(_folder->GetProperty(i, kpidAttrib, &prop));
|
||||
UInt32 attrib = 0;
|
||||
if (prop.vt == VT_UI4)
|
||||
attrib = prop.ulVal;
|
||||
@@ -430,12 +427,12 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
|
||||
if (item.iImage < 0)
|
||||
item.iImage = 0;
|
||||
|
||||
if(_listView.InsertItem(&item) == -1)
|
||||
return; // error
|
||||
if (_listView.InsertItem(&item) == -1)
|
||||
return E_FAIL; // error
|
||||
}
|
||||
// OutputDebugStringA("End2\n");
|
||||
|
||||
if(_listView.GetItemCount() > 0 && cursorIndex >= 0)
|
||||
if (_listView.GetItemCount() > 0 && cursorIndex >= 0)
|
||||
SetFocusedSelectedItem(cursorIndex, selectFocused);
|
||||
_listView.SortItems(CompareItems, (LPARAM)this);
|
||||
if (cursorIndex < 0 && _listView.GetItemCount() > 0)
|
||||
@@ -452,6 +449,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
|
||||
/*
|
||||
_listView.UpdateWindow();
|
||||
*/
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const
|
||||
@@ -482,7 +480,7 @@ void CPanel::GetOperatedItemIndices(CRecordVector<UInt32> &indices) const
|
||||
int focusedItem = _listView.GetFocusedItem();
|
||||
if (focusedItem >= 0)
|
||||
{
|
||||
if(_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
|
||||
if (_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
|
||||
{
|
||||
int realIndex = GetRealItemIndex(focusedItem);
|
||||
if (realIndex != kParentIndex)
|
||||
@@ -572,7 +570,7 @@ void CPanel::OpenSelectedItems(bool tryInternal)
|
||||
}
|
||||
|
||||
bool dirIsStarted = false;
|
||||
for(int i = 0; i < indices.Size(); i++)
|
||||
for (int i = 0; i < indices.Size(); i++)
|
||||
{
|
||||
UInt32 index = indices[i];
|
||||
// CFileInfo &aFile = m_Files[index];
|
||||
@@ -666,7 +664,7 @@ void CPanel::ReadListViewInfo()
|
||||
void CPanel::SaveListViewInfo()
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < _visibleProperties.Size(); i++)
|
||||
for (i = 0; i < _visibleProperties.Size(); i++)
|
||||
{
|
||||
CItemProperty &prop = _visibleProperties[i];
|
||||
LVCOLUMN winColumnInfo;
|
||||
@@ -683,7 +681,7 @@ void CPanel::SaveListViewInfo()
|
||||
PROPID sortPropID = _sortID;
|
||||
|
||||
_visibleProperties.Sort();
|
||||
for(i = 0; i < _visibleProperties.Size(); i++)
|
||||
for (i = 0; i < _visibleProperties.Size(); i++)
|
||||
{
|
||||
const CItemProperty &prop = _visibleProperties[i];
|
||||
CColumnInfo columnInfo;
|
||||
@@ -692,7 +690,7 @@ void CPanel::SaveListViewInfo()
|
||||
columnInfo.Width = prop.Width;
|
||||
viewInfo.Columns.Add(columnInfo);
|
||||
}
|
||||
for(i = 0; i < _properties.Size(); i++)
|
||||
for (i = 0; i < _properties.Size(); i++)
|
||||
{
|
||||
const CItemProperty &prop = _properties[i];
|
||||
if (!prop.IsVisible)
|
||||
@@ -719,7 +717,7 @@ void CPanel::SaveListViewInfo()
|
||||
|
||||
bool CPanel::OnRightClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActiveate, LRESULT &result)
|
||||
{
|
||||
if(itemActiveate->hdr.hwndFrom == HWND(_listView))
|
||||
if (itemActiveate->hdr.hwndFrom == HWND(_listView))
|
||||
return false;
|
||||
POINT point;
|
||||
::GetCursorPos(&point);
|
||||
@@ -737,7 +735,7 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
|
||||
menu.CreatePopup();
|
||||
|
||||
const int kCommandStart = 100;
|
||||
for(int i = 0; i < _properties.Size(); i++)
|
||||
for (int i = 0; i < _properties.Size(); i++)
|
||||
{
|
||||
const CItemProperty &prop = _properties[i];
|
||||
UINT flags = MF_STRING;
|
||||
@@ -785,7 +783,9 @@ void CPanel::ShowColumnsContextMenu(int x, int y)
|
||||
|
||||
void CPanel::OnReload()
|
||||
{
|
||||
RefreshListCtrlSaveFocused();
|
||||
HRESULT res = RefreshListCtrlSaveFocused();
|
||||
if (res != S_OK)
|
||||
MessageBoxError(res);
|
||||
OnRefreshStatusBar();
|
||||
}
|
||||
|
||||
|
||||
@@ -149,9 +149,10 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
|
||||
if (needRead)
|
||||
*/
|
||||
|
||||
if (_folder->GetProperty(realIndex, propID, &prop) != S_OK)
|
||||
throw 2723407;
|
||||
|
||||
HRESULT res = _folder->GetProperty(realIndex, propID, &prop);
|
||||
if (res != S_OK)
|
||||
s = UString(L"Error: ") + HResultToMessage(res);
|
||||
else
|
||||
if ((prop.vt == VT_UI8 || prop.vt == VT_UI4) && (
|
||||
propID == kpidSize ||
|
||||
propID == kpidPackSize ||
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
|
||||
HRESULT Result;
|
||||
|
||||
CThreadFolderOperations(EFolderOpType opType): OpType(opType), Result(E_FAIL) {};
|
||||
CThreadFolderOperations(EFolderOpType opType): OpType(opType), Result(E_FAIL) {}
|
||||
HRESULT DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError);
|
||||
};
|
||||
|
||||
@@ -72,7 +72,7 @@ HRESULT CThreadFolderOperations::ProcessVirt()
|
||||
Result = E_FAIL;
|
||||
}
|
||||
return Result;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError)
|
||||
|
||||
@@ -941,7 +941,7 @@ void CProgressDialog::ProcessWasFinished()
|
||||
PostMessage(kCloseMessage);
|
||||
else
|
||||
_needClose = true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
HRESULT CProgressThreadVirt::Create(const UString &title, HWND parentWindow)
|
||||
|
||||
@@ -72,7 +72,7 @@ void CRootFolder::Init()
|
||||
_names[ROOT_INDEX_VOLUMES] = kVolPrefix;
|
||||
_iconIndices[ROOT_INDEX_VOLUMES] = GetIconIndexForCSIDL(CSIDL_DRIVES);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
STDMETHODIMP CRootFolder::LoadItems()
|
||||
{
|
||||
|
||||
@@ -115,7 +115,7 @@ enum EMethodID
|
||||
kBZip2,
|
||||
kDeflate,
|
||||
kDeflate64,
|
||||
kPPMdZip,
|
||||
kPPMdZip
|
||||
};
|
||||
|
||||
static const LPCWSTR kMethodsNames[] =
|
||||
@@ -244,7 +244,7 @@ static bool IsMethodSupportedBySfx(int methodID)
|
||||
if (methodID == g_7zSfxMethods[i])
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
static UInt64 GetMaxRamSizeForProgram()
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace NCompressDialog
|
||||
kAdd,
|
||||
kUpdate,
|
||||
kFresh,
|
||||
kSynchronize,
|
||||
kSynchronize
|
||||
};
|
||||
}
|
||||
struct CInfo
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user