This commit is contained in:
Igor Pavlov
2010-10-04 00:00:00 +00:00
committed by Kornel Lesiński
parent 044e4bb741
commit 2eb60a0598
105 changed files with 868 additions and 466 deletions

View File

@@ -1,7 +1,7 @@
#define MY_VER_MAJOR 9 #define MY_VER_MAJOR 9
#define MY_VER_MINOR 16 #define MY_VER_MINOR 17
#define MY_VER_BUILD 0 #define MY_VER_BUILD 0
#define MY_VERSION "9.16 beta" #define MY_VERSION "9.17 beta"
#define MY_DATE "2010-09-08" #define MY_DATE "2010-10-04"
#define MY_COPYRIGHT ": Igor Pavlov : Public domain" #define MY_COPYRIGHT ": Igor Pavlov : Public domain"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE

View File

@@ -1,5 +1,5 @@
/* Lzma2Enc.c -- LZMA2 Encoder /* Lzma2Enc.c -- LZMA2 Encoder
2010-04-16 : Igor Pavlov : Public domain */ 2010-09-24 : Igor Pavlov : Public domain */
/* #include <stdio.h> */ /* #include <stdio.h> */
#include <string.h> #include <string.h>
@@ -269,7 +269,7 @@ static SRes Lzma2Enc_EncodeMt1(CLzma2EncInt *p, CLzma2Enc *mainEncoder,
if (mainEncoder->outBuf == 0) 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) if (mainEncoder->outBuf == 0)
return SZ_ERROR_MEM; return SZ_ERROR_MEM;
} }

View File

@@ -1,5 +1,5 @@
/* MtCoder.c -- Multi-thread Coder /* MtCoder.c -- Multi-thread Coder
2010-03-24 : Igor Pavlov : Public domain */ 2010-09-24 : Igor Pavlov : Public domain */
#include <stdio.h> #include <stdio.h>
@@ -148,7 +148,7 @@ static void CMtThread_Destruct(CMtThread *p)
#define MY_BUF_ALLOC(buf, size, newSize) \ #define MY_BUF_ALLOC(buf, size, newSize) \
if (buf == 0 || size != newSize) \ if (buf == 0 || size != newSize) \
{ IAlloc_Free(p->mtCoder->alloc, buf); \ { 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; } if (buf == 0) return SZ_ERROR_MEM; }
static SRes CMtThread_Prepare(CMtThread *p) static SRes CMtThread_Prepare(CMtThread *p)

View File

@@ -1,7 +1,5 @@
/* Sort.c -- Sort functions /* Sort.c -- Sort functions
2008-08-17 2010-09-17 : Igor Pavlov : Public domain */
Igor Pavlov
Public domain */
#include "Sort.h" #include "Sort.h"

View File

@@ -1,5 +1,5 @@
/* 7zMain.c - Test application for 7z Decoder /* 7zMain.c - Test application for 7z Decoder
2010-07-13 : Igor Pavlov : Public domain */ 2010-09-20 : Igor Pavlov : Public domain */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -179,7 +179,7 @@ static SRes PrintString(const UInt16 *s)
Buf_Init(&buf); Buf_Init(&buf);
res = Utf16_To_Char(&buf, s, 0); res = Utf16_To_Char(&buf, s, 0);
if (res == SZ_OK) if (res == SZ_OK)
printf("%s", buf.data); fputs((const char *)buf.data, stdout);
Buf_Free(&buf, &g_Alloc); Buf_Free(&buf, &g_Alloc);
return res; return res;
} }
@@ -407,9 +407,10 @@ int MY_CDECL main(int numargs, char *args[])
printf("\n"); printf("\n");
continue; continue;
} }
printf(testCommand ? fputs(testCommand ?
"Testing ": "Testing ":
"Extracting "); "Extracting ",
stdout);
res = PrintString(temp); res = PrintString(temp);
if (res != SZ_OK) if (res != SZ_OK)
break; break;

View File

@@ -1,5 +1,5 @@
/* LzmaUtil.c -- Test application for LZMA compression /* 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 #define _CRT_SECURE_NO_WARNINGS
@@ -249,6 +249,6 @@ int MY_CDECL main(int numArgs, const char *args[])
{ {
char rs[800] = { 0 }; char rs[800] = { 0 };
int res = main2(numArgs, args, rs); int res = main2(numArgs, args, rs);
printf(rs); fputs(rs, stdout);
return res; return res;
} }

12
C/Xz.h
View File

@@ -1,14 +1,12 @@
/* Xz.h - Xz interface /* Xz.h - Xz interface
2009-04-15 : Igor Pavlov : Public domain */ 2010-09-17 : Igor Pavlov : Public domain */
#ifndef __XZ_H #ifndef __XZ_H
#define __XZ_H #define __XZ_H
#include "Sha256.h" #include "Sha256.h"
#ifdef __cplusplus EXTERN_C_BEGIN
extern "C" {
#endif
#define XZ_ID_Subblock 1 #define XZ_ID_Subblock 1
#define XZ_ID_Delta 3 #define XZ_ID_Delta 3
@@ -140,7 +138,7 @@ typedef enum
CODER_STATUS_NOT_SPECIFIED, /* use main error code instead */ CODER_STATUS_NOT_SPECIFIED, /* use main error code instead */
CODER_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ CODER_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
CODER_STATUS_NOT_FINISHED, /* stream was not finished */ 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; } ECoderStatus;
typedef enum typedef enum
@@ -249,8 +247,6 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p); Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p);
#ifdef __cplusplus EXTERN_C_END
}
#endif
#endif #endif

View File

@@ -120,7 +120,7 @@ public:
kUnsupportedVersion = 0, kUnsupportedVersion = 0,
kUnsupported, kUnsupported,
kIncorrect, kIncorrect,
kEndOfData, kEndOfData
} Cause; } Cause;
CInArchiveException(CCauseType cause): Cause(cause) {}; CInArchiveException(CCauseType cause): Cause(cause) {};
}; };

View File

@@ -19,32 +19,33 @@ struct CPropMap
CPropMap kPropMap[] = CPropMap kPropMap[] =
{ {
{ NID::kName, NULL, kpidPath, VT_BSTR}, { NID::kName, { NULL, kpidPath, VT_BSTR } },
{ NID::kSize, NULL, kpidSize, VT_UI8}, { NID::kSize, { NULL, kpidSize, VT_UI8 } },
{ NID::kPackInfo, NULL, kpidPackSize, VT_UI8}, { NID::kPackInfo, { NULL, kpidPackSize, VT_UI8 } },
#ifdef _MULTI_PACK #ifdef _MULTI_PACK
{ 100, L"Pack0", kpidPackedSize0, VT_UI8}, { 100, { L"Pack0", kpidPackedSize0, VT_UI8 } },
{ 101, L"Pack1", kpidPackedSize1, VT_UI8}, { 101, { L"Pack1", kpidPackedSize1, VT_UI8 } },
{ 102, L"Pack2", kpidPackedSize2, VT_UI8}, { 102, { L"Pack2", kpidPackedSize2, VT_UI8 } },
{ 103, L"Pack3", kpidPackedSize3, VT_UI8}, { 103, { L"Pack3", kpidPackedSize3, VT_UI8 } },
{ 104, L"Pack4", kpidPackedSize4, VT_UI8}, { 104, { L"Pack4", kpidPackedSize4, VT_UI8 } },
#endif #endif
{ NID::kCTime, NULL, kpidCTime, VT_FILETIME}, { NID::kCTime, { NULL, kpidCTime, VT_FILETIME } },
{ NID::kMTime, NULL, kpidMTime, VT_FILETIME}, { NID::kMTime, { NULL, kpidMTime, VT_FILETIME } },
{ NID::kATime, NULL, kpidATime, VT_FILETIME}, { NID::kATime, { NULL, kpidATime, VT_FILETIME } },
{ NID::kWinAttributes, NULL, kpidAttrib, VT_UI4}, { NID::kWinAttributes, { NULL, kpidAttrib, VT_UI4 } },
{ NID::kStartPos, NULL, kpidPosition, 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 #ifndef _SFX
{ 97, NULL, kpidEncrypted, VT_BOOL}, ,
{ 98, NULL, kpidMethod, VT_BSTR}, { 97, { NULL,kpidEncrypted, VT_BOOL } },
{ 99, NULL, kpidBlock, VT_UI4} { 98, { NULL,kpidMethod, VT_BSTR } },
{ 99, { NULL,kpidBlock, VT_UI4 } }
#endif #endif
}; };

View File

@@ -264,7 +264,7 @@ struct CInArchiveException
{ {
kUnexpectedEndOfArchive = 0, kUnexpectedEndOfArchive = 0,
kCRCError, kCRCError,
kIncorrectArchive, kIncorrectArchive
} }
Cause; Cause;
CInArchiveException(CCauseType cause): Cause(cause) {}; CInArchiveException(CCauseType cause): Cause(cause) {};

View File

@@ -9,18 +9,15 @@
#include "ChmIn.h" #include "ChmIn.h"
namespace NArchive{ namespace NArchive {
namespace NChm{ namespace NChm {
// define CHM_LOW, if you want to see low level items // define CHM_LOW, if you want to see low level items
// #define CHM_LOW // #define CHM_LOW
static const GUID kChmLzxGuid = static const GUID kChmLzxGuid = { 0x7FC28940, 0x9D31, 0x11D0, { 0x9B, 0x27, 0x00, 0xA0, 0xC9, 0x1E, 0x9C, 0x7C } };
{ 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 kHelp2LzxGuid = static const GUID kDesGuid = { 0x67F6E4A2, 0x60BF, 0x11D3, { 0x85, 0x40, 0x00, 0xC0, 0x4F, 0x58, 0xC3, 0xCF } };
{ 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) static bool AreGuidsEqual(REFGUID g1, REFGUID g2)
{ {

View File

@@ -3,8 +3,8 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "Common/ComTry.h" #include "Common/ComTry.h"
#include "Common/StringToInt.h"
#include "Common/StringConvert.h" #include "Common/StringConvert.h"
#include "Common/StringToInt.h"
#include "Windows/PropVariant.h" #include "Windows/PropVariant.h"
#include "Windows/Time.h" #include "Windows/Time.h"
@@ -25,10 +25,10 @@ namespace NFileHeader
{ {
namespace NMagic namespace NMagic
{ {
extern const char *kMagic1 = "070701"; const char *kMagic1 = "070701";
extern const char *kMagic2 = "070702"; const char *kMagic2 = "070702";
extern const char *kMagic3 = "070707"; const char *kMagic3 = "070707";
extern const char *kEndName = "TRAILER!!!"; const char *kEndName = "TRAILER!!!";
const Byte kMagicForRecord2[2] = { 0xC7, 0x71 }; const Byte kMagicForRecord2[2] = { 0xC7, 0x71 };
} }

View File

@@ -378,7 +378,7 @@ static const char *GetOS(Byte osId)
if (g_OsPairs[i].Id == osId) if (g_OsPairs[i].Id == osId)
return g_OsPairs[i].Name; return g_OsPairs[i].Name;
return kUnknownOS; return kUnknownOS;
}; }
static STATPROPSTG kProps[] = static STATPROPSTG kProps[] =
{ {
@@ -400,7 +400,7 @@ public:
static UInt16 Table[256]; static UInt16 Table[256];
static void InitTable(); static void InitTable();
CCRC(): _value(0){}; CCRC(): _value(0) {}
void Init() { _value = 0; } void Init() { _value = 0; }
void Update(const void *data, size_t size); void Update(const void *data, size_t size);
UInt16 GetDigest() const { return _value; } UInt16 GetDigest() const { return _value; }
@@ -460,7 +460,6 @@ public:
void ReleaseStream() { _stream.Release(); } void ReleaseStream() { _stream.Release(); }
UInt32 GetCRC() const { return _crc.GetDigest(); } UInt32 GetCRC() const { return _crc.GetDigest(); }
void InitCRC() { _crc.Init(); } void InitCRC() { _crc.Init(); }
}; };
STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *processedSize) STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *processedSize)

View File

@@ -332,7 +332,7 @@ enum
{ {
kpidPrimary = kpidUserDefined, kpidPrimary = kpidUserDefined,
kpidBegChs, kpidBegChs,
kpidEndChs, kpidEndChs
}; };
STATPROPSTG kProps[] = STATPROPSTG kProps[] =

View File

@@ -156,7 +156,7 @@ struct CMftRef
#define ATNAME(n) ATTR_TYPE_ ## n #define ATNAME(n) ATTR_TYPE_ ## n
#define DEF_ATTR_TYPE(v, n) ATNAME(n) = v #define DEF_ATTR_TYPE(v, n) ATNAME(n) = v
typedef enum enum
{ {
DEF_ATTR_TYPE(0x00, UNUSED), DEF_ATTR_TYPE(0x00, UNUSED),
DEF_ATTR_TYPE(0x10, STANDARD_INFO), DEF_ATTR_TYPE(0x10, STANDARD_INFO),
@@ -873,7 +873,7 @@ STDMETHODIMP CByteBufStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPo
return S_OK; 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) int attrIndex, int attrIndexLim, UInt64 numPhysClusters, CRecordVector<CExtent> &Extents)
{ {
CExtent e; CExtent e;
@@ -969,6 +969,7 @@ struct CMftRec
void ParseDataNames(); void ParseDataNames();
HRESULT GetStream(IInStream *mainStream, int dataIndex, HRESULT GetStream(IInStream *mainStream, int dataIndex,
int clusterSizeLog, UInt64 numPhysClusters, IInStream **stream) const; 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(); } 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; 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, bool CMftRec::Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNumber,
CObjectVector<CAttr> *attrs) CObjectVector<CAttr> *attrs)
{ {
@@ -1425,7 +1455,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
COM_TRY_END COM_TRY_END
} }
STATPROPSTG kProps[] = static const STATPROPSTG kProps[] =
{ {
{ NULL, kpidPath, VT_BSTR}, { NULL, kpidPath, VT_BSTR},
{ NULL, kpidIsDir, VT_BOOL}, { NULL, kpidIsDir, VT_BOOL},
@@ -1435,10 +1465,11 @@ STATPROPSTG kProps[] =
{ NULL, kpidCTime, VT_FILETIME}, { NULL, kpidCTime, VT_FILETIME},
{ NULL, kpidATime, VT_FILETIME}, { NULL, kpidATime, VT_FILETIME},
{ NULL, kpidAttrib, VT_UI4}, { 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, kpidVolumeName, VT_BSTR},
{ NULL, kpidFileSystem, 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 kpidLinks: prop = rec.MyNumNameLinks; break;
case kpidSize: if (data) prop = data->GetSize(); break; case kpidSize: if (data) prop = data->GetSize(); break;
case kpidPackSize: if (data) prop = data->GetPackSize(); 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); prop.Detach(value);
return S_OK; return S_OK;

View File

@@ -98,7 +98,7 @@ void CDirLink::Parse(const Byte *p)
{ {
Va = Get32(p); Va = Get32(p);
Size = Get32(p + 4); Size = Get32(p + 4);
}; }
enum enum
{ {
@@ -991,7 +991,7 @@ bool CBitmapInfoHeader::Parse(const Byte *p, size_t size)
Compression = Get32(p + 16); Compression = Get32(p + 16);
SizeImage = Get32(p + 20); SizeImage = Get32(p + 20);
return true; return true;
}; }
static UInt32 GetImageSize(UInt32 xSize, UInt32 ySize, UInt32 bitCount) static UInt32 GetImageSize(UInt32 xSize, UInt32 ySize, UInt32 bitCount)
{ {

View File

@@ -35,4 +35,3 @@ public:
}} }}
#endif #endif

View File

@@ -202,7 +202,7 @@ enum EDescriptorType
DESC_TYPE_UnallocatedSpace = 263, DESC_TYPE_UnallocatedSpace = 263,
DESC_TYPE_SpaceBitmap = 264, DESC_TYPE_SpaceBitmap = 264,
DESC_TYPE_PartitionIntegrity = 265, DESC_TYPE_PartitionIntegrity = 265,
DESC_TYPE_ExtendedFile = 266, DESC_TYPE_ExtendedFile = 266
}; };

View File

@@ -55,6 +55,7 @@ static STATPROPSTG kArcProps[] =
{ NULL, kpidCTime, VT_FILETIME}, { NULL, kpidCTime, VT_FILETIME},
{ NULL, kpidMTime, VT_FILETIME}, { NULL, kpidMTime, VT_FILETIME},
{ NULL, kpidComment, VT_BSTR}, { NULL, kpidComment, VT_BSTR},
{ NULL, kpidUnpackVer, VT_BSTR},
{ NULL, kpidIsVolume, VT_BOOL}, { NULL, kpidIsVolume, VT_BOOL},
{ NULL, kpidVolume, VT_UI4}, { NULL, kpidVolume, VT_UI4},
{ NULL, kpidNumVolumes, VT_UI4} { NULL, kpidNumVolumes, VT_UI4}
@@ -226,6 +227,28 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
} }
break; 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: case kpidIsVolume:
if (_xmls.Size() > 0) if (_xmls.Size() > 0)
{ {
@@ -303,8 +326,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
prop = _db.GetItemPath(realIndex); prop = _db.GetItemPath(realIndex);
else else
{ {
char sz[32]; char sz[16];
ConvertUInt64ToString(item.StreamIndex, sz); ConvertUInt32ToString(item.StreamIndex, sz);
AString s = sz; AString s = sz;
while (s.Length() < _nameLenForStreams) while (s.Length() < _nameLenForStreams)
s = '0' + s; s = '0' + s;
@@ -342,8 +365,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
{ {
case kpidPath: case kpidPath:
{ {
char sz[32]; char sz[16];
ConvertUInt64ToString(_xmls[index].VolIndex, sz); ConvertUInt32ToString(_xmls[index].VolIndex, sz);
prop = (AString)"[" + (AString)sz + "].xml"; prop = (AString)"[" + (AString)sz + "].xml";
break; break;
} }
@@ -379,8 +402,8 @@ public:
UString GetNextName(UInt32 index) UString GetNextName(UInt32 index)
{ {
wchar_t s[32]; wchar_t s[16];
ConvertUInt64ToString((index), s); ConvertUInt32ToString(index, s);
return _before + (UString)s + _after; return _before + (UString)s + _after;
} }
}; };
@@ -426,6 +449,8 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
continue; continue;
return res; return res;
} }
_version = header.Version;
_isOldVersion = header.IsOldVersion();
if (firstVolumeIndex >= 0) if (firstVolumeIndex >= 0)
if (!header.AreFromOnArchive(_volumes[firstVolumeIndex].Header)) if (!header.AreFromOnArchive(_volumes[firstVolumeIndex].Header))
break; break;
@@ -481,8 +506,8 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
_db.DetectPathMode(); _db.DetectPathMode();
RINOK(_db.Sort(_db.SkipRoot)); RINOK(_db.Sort(_db.SkipRoot));
wchar_t sz[32]; wchar_t sz[16];
ConvertUInt64ToString(_db.Streams.Size(), sz); ConvertUInt32ToString(_db.Streams.Size(), sz);
_nameLenForStreams = MyStringLen(sz); _nameLenForStreams = MyStringLen(sz);
_xmlInComments = (_xmls.Size() == 1 && !_db.ShowImageNumber); _xmlInComments = (_xmls.Size() == 1 && !_db.ShowImageNumber);

View File

@@ -51,6 +51,8 @@ class CHandler:
public CMyUnknownImp public CMyUnknownImp
{ {
CDatabase _db; CDatabase _db;
UInt32 _version;
bool _isOldVersion;
CObjectVector<CVolume> _volumes; CObjectVector<CVolume> _volumes;
CObjectVector<CXml> _xmls; CObjectVector<CXml> _xmls;
int _nameLenForStreams; int _nameLenForStreams;

View File

@@ -264,9 +264,8 @@ static void GetStream(bool oldVersion, const Byte *p, CStreamInfo &s)
if (oldVersion) if (oldVersion)
{ {
s.PartNumber = 1; s.PartNumber = 1;
s.RefCount = 1; s.Id = Get32(p + 24);
// UInt32 id = Get32(p + 24); s.RefCount = Get32(p + 28);
// UInt32 unknown = Get32(p + 28);
memcpy(s.Hash, p + 32, kHashSize); memcpy(s.Hash, p + 32, kHashSize);
} }
else else
@@ -384,31 +383,48 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent)
DirProcessed += 8; DirProcessed += 8;
return S_OK; 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; return S_FALSE;
DirProcessed += (size_t)len; DirProcessed += (size_t)len;
if (DirProcessed > DirSize) if (DirProcessed > DirSize)
return S_FALSE; 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) if (prevIndex == -1)
return S_FALSE; return S_FALSE;
UInt32 fileNameLen = Get16(p + extraOffset);
UInt32 fileNameLen = Get16(p + 0x24);
if ((fileNameLen & 1) != 0) if ((fileNameLen & 1) != 0)
return S_FALSE; return S_FALSE;
/* Probably different versions of ImageX can use different number of /* Probably different versions of ImageX can use different number of
additional ZEROs. So we don't use exact check. */ additional ZEROs. So we don't use exact check. */
UInt32 fileNameLen2 = (fileNameLen == 0 ? fileNameLen : fileNameLen + 2); UInt32 fileNameLen2 = (fileNameLen == 0 ? fileNameLen : fileNameLen + 2);
if (((0x26 + fileNameLen2 + 6) & ~7) > len) if (((extraOffset + 2 + fileNameLen2 + 6) & ~7) > len)
return S_FALSE; return S_FALSE;
UString name; UString name;
RINOK(ReadName(p + 0x26, fileNameLen, name)); RINOK(ReadName(p + extraOffset + 2, fileNameLen, name));
CItem &prevItem = Items[prevIndex]; CItem &prevItem = Items[prevIndex];
if (name.IsEmpty() && !prevItem.HasStream()) if (name.IsEmpty() && !prevItem.HasStream())
{
if (IsOldVersion)
prevItem.Id = Get32(p + 8);
else
memcpy(prevItem.Hash, p + 0x10, kHashSize); memcpy(prevItem.Hash, p + 0x10, kHashSize);
}
else else
{ {
CItem item; CItem item;
@@ -416,6 +432,12 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent)
item.CTime = prevItem.CTime; item.CTime = prevItem.CTime;
item.ATime = prevItem.ATime; item.ATime = prevItem.ATime;
item.MTime = prevItem.MTime; item.MTime = prevItem.MTime;
if (IsOldVersion)
{
item.Id = Get32(p + 8);
memset(item.Hash, 0, kHashSize);
}
else
memcpy(item.Hash, p + 0x10, kHashSize); memcpy(item.Hash, p + 0x10, kHashSize);
item.Attrib = 0; item.Attrib = 0;
item.Order = Order++; item.Order = Order++;
@@ -425,30 +447,41 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent)
pos += (size_t)len; pos += (size_t)len;
continue; continue;
} }
if (len < kDirRecordSize)
UInt32 dirRecordSize = IsOldVersion ? kDirRecordSizeOld : kDirRecordSize;
if (len < dirRecordSize)
return S_FALSE; return S_FALSE;
CItem item; CItem item;
item.Attrib = Get32(p + 8); item.Attrib = Get32(p + 8);
// item.SecurityId = Get32(p + 0xC); // item.SecurityId = Get32(p + 0xC);
UInt64 subdirOffset = Get64(p + 0x10); UInt64 subdirOffset = Get64(p + 0x10);
GetFileTimeFromMem(p + 0x28, &item.CTime); UInt32 timeOffset = IsOldVersion ? 0x18: 0x28;
GetFileTimeFromMem(p + 0x30, &item.ATime); GetFileTimeFromMem(p + timeOffset, &item.CTime);
GetFileTimeFromMem(p + 0x38, &item.MTime); 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); 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) if ((shortNameLen & 1) != 0 || (fileNameLen & 1) != 0)
return S_FALSE; return S_FALSE;
UInt32 shortNameLen2 = (shortNameLen == 0 ? shortNameLen : shortNameLen + 2); UInt32 shortNameLen2 = (shortNameLen == 0 ? shortNameLen : shortNameLen + 2);
UInt32 fileNameLen2 = (fileNameLen == 0 ? fileNameLen : fileNameLen + 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; return S_FALSE;
p += dirRecordSize;
p += kDirRecordSize;
RINOK(ReadName(p, fileNameLen, item.Name)); RINOK(ReadName(p, fileNameLen, item.Name));
RINOK(ReadName(p + fileNameLen2, shortNameLen, item.ShortName)); RINOK(ReadName(p + fileNameLen2, shortNameLen, item.ShortName));
@@ -458,9 +491,9 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent)
/* /*
// there are some extra data for some files. // there are some extra data for some files.
p -= kDirRecordSize; p -= dirRecordSize;
p += ((kDirRecordSize + fileNameLen2 + shortNameLen2 + 6) & ~7); p += ((dirRecordSize + fileNameLen2 + shortNameLen2 + 6) & ~7);
if (((kDirRecordSize + fileNameLen2 + shortNameLen2 + 6) & ~7) != len) if (((dirRecordSize + fileNameLen2 + shortNameLen2 + 6) & ~7) != len)
p = p; p = p;
*/ */
@@ -496,6 +529,29 @@ HRESULT CDatabase::ParseImageDirs(const CByteBuffer &buf, int parent)
return S_FALSE; return S_FALSE;
const Byte *p = DirData; const Byte *p = DirData;
UInt32 totalLength = Get32(p); 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); // UInt32 numEntries = Get32(p + 4);
pos += 8; pos += 8;
{ {
@@ -511,7 +567,7 @@ HRESULT CDatabase::ParseImageDirs(const CByteBuffer &buf, int parent)
sum += len; sum += len;
pos += 8; pos += 8;
} }
pos += sum; // skip security descriptors pos += (size_t)sum; // skip security descriptors
while ((pos & 7) != 0) while ((pos & 7) != 0)
pos++; pos++;
if (pos != totalLength) if (pos != totalLength)
@@ -524,6 +580,7 @@ HRESULT CDatabase::ParseImageDirs(const CByteBuffer &buf, int parent)
else else
pos = totalLength; pos = totalLength;
} }
}
DirStartOffset = DirProcessed = pos; DirStartOffset = DirProcessed = pos;
RINOK(ParseDirItem(pos, parent)); RINOK(ParseDirItem(pos, parent));
if (DirProcessed == DirSize) if (DirProcessed == DirSize)
@@ -580,8 +637,6 @@ HRESULT CHeader::Parse(const Byte *p)
BootIndex = Get32(p + 0x48); BootIndex = Get32(p + 0x48);
IntegrityResource.Parse(p + offset + 0x4C); IntegrityResource.Parse(p + offset + 0x4C);
} }
if (IsOldVersion())
return S_FALSE;
return S_OK; return S_OK;
} }
@@ -612,9 +667,18 @@ static HRESULT ReadStreams(bool oldVersion, IInStream *inStream, const CHeader &
return (i == offsetBuf.GetCapacity()) ? S_OK : S_FALSE; 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) HRESULT CDatabase::Open(IInStream *inStream, const CHeader &h, CByteBuffer &xml, IArchiveOpenCallback *openCallback)
{ {
OpenCallback = openCallback; OpenCallback = openCallback;
IsOldVersion = h.IsOldVersion();
RINOK(UnpackData(inStream, h.XmlResource, h.IsLzxMode(), xml, NULL)); RINOK(UnpackData(inStream, h.XmlResource, h.IsLzxMode(), xml, NULL));
RINOK(ReadStreams(h.IsOldVersion(), inStream, h, *this)); RINOK(ReadStreams(h.IsOldVersion(), inStream, h, *this));
bool needBootMetadata = !h.MetadataResource.IsEmpty(); bool needBootMetadata = !h.MetadataResource.IsEmpty();
@@ -631,7 +695,8 @@ HRESULT CDatabase::Open(IInStream *inStream, const CHeader &h, CByteBuffer &xml,
Byte hash[kHashSize]; Byte hash[kHashSize];
CByteBuffer metadata; CByteBuffer metadata;
RINOK(UnpackData(inStream, si.Resource, h.IsLzxMode(), metadata, hash)); 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; return S_FALSE;
NumImages++; NumImages++;
RINOK(ParseImageDirs(metadata, -(int)(++imageIndex))); RINOK(ParseImageDirs(metadata, -(int)(++imageIndex)));
@@ -660,12 +725,37 @@ static int CompareStreamsByPos(const CStreamInfo *p1, const CStreamInfo *p2, voi
return MyCompare(p1->Resource.Offset, p2->Resource.Offset); 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) static int CompareHashRefs(const int *p1, const int *p2, void *param)
{ {
const CRecordVector<CStreamInfo> &streams = *(const CRecordVector<CStreamInfo> *)param; const CRecordVector<CStreamInfo> &streams = *(const CRecordVector<CStreamInfo> *)param;
return memcmp(streams[*p1].Hash, streams[*p2].Hash, kHashSize); 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, static int FindHash(const CRecordVector<CStreamInfo> &streams,
const CIntVector &sortedByHash, const Byte *hash) const CIntVector &sortedByHash, const Byte *hash)
{ {
@@ -712,6 +802,9 @@ HRESULT CDatabase::Sort(bool skipRootDir)
{ {
for (int i = 0; i < Streams.Size(); i++) for (int i = 0; i < Streams.Size(); i++)
sortedByHash.Add(i); sortedByHash.Add(i);
if (IsOldVersion)
sortedByHash.Sort(CompareIDs, &Streams);
else
sortedByHash.Sort(CompareHashRefs, &Streams); sortedByHash.Sort(CompareHashRefs, &Streams);
} }
@@ -720,6 +813,9 @@ HRESULT CDatabase::Sort(bool skipRootDir)
CItem &item = Items[i]; CItem &item = Items[i];
item.StreamIndex = -1; item.StreamIndex = -1;
if (item.HasStream()) if (item.HasStream())
if (IsOldVersion)
item.StreamIndex = FindId(Streams, sortedByHash, item.Id);
else
item.StreamIndex = FindHash(Streams, sortedByHash, item.Hash); item.StreamIndex = FindHash(Streams, sortedByHash, item.Hash);
} }
} }

View File

@@ -155,8 +155,8 @@ struct CHeader
bool IsSupported() const { return (!IsCompressed() || (Flags & NHeaderFlags::kLZX) != 0 || (Flags & NHeaderFlags::kXPRESS) != 0 ) ; } bool IsSupported() const { return (!IsCompressed() || (Flags & NHeaderFlags::kLZX) != 0 || (Flags & NHeaderFlags::kXPRESS) != 0 ) ; }
bool IsLzxMode() const { return (Flags & NHeaderFlags::kLZX) != 0; } bool IsLzxMode() const { return (Flags & NHeaderFlags::kLZX) != 0; }
bool IsSpanned() const { return (!IsCompressed() || (Flags & NHeaderFlags::kSpanned) != 0); } bool IsSpanned() const { return (!IsCompressed() || (Flags & NHeaderFlags::kSpanned) != 0); }
bool IsOldVersion() const { return (Version == 0x010A00); } bool IsOldVersion() const { return (Version <= 0x010A00); }
bool IsNewVersion()const { return (Version > 0x010C00); } bool IsNewVersion() const { return (Version > 0x010C00); }
bool AreFromOnArchive(const CHeader &h) bool AreFromOnArchive(const CHeader &h)
{ {
@@ -172,11 +172,13 @@ struct CStreamInfo
CResource Resource; CResource Resource;
UInt16 PartNumber; UInt16 PartNumber;
UInt32 RefCount; UInt32 RefCount;
UInt32 Id;
BYTE Hash[kHashSize]; BYTE Hash[kHashSize];
void WriteTo(Byte *p) const; void WriteTo(Byte *p) const;
}; };
const UInt32 kDirRecordSizeOld = 62;
const UInt32 kDirRecordSize = 102; const UInt32 kDirRecordSize = 102;
struct CItem struct CItem
@@ -186,25 +188,25 @@ struct CItem
UInt32 Attrib; UInt32 Attrib;
// UInt32 SecurityId; // UInt32 SecurityId;
BYTE Hash[kHashSize]; BYTE Hash[kHashSize];
UInt32 Id;
FILETIME CTime; FILETIME CTime;
FILETIME ATime; FILETIME ATime;
FILETIME MTime; FILETIME MTime;
// UInt32 ReparseTag; // UInt32 ReparseTag;
// UInt64 HardLink; // UInt64 HardLink;
// UInt16 NumStreams; // UInt16 NumStreams;
// UInt16 ShortNameLen;
int StreamIndex; int StreamIndex;
int Parent; int Parent;
unsigned Order; unsigned Order;
bool HasMetadata; bool HasMetadata;
CItem(): HasMetadata(true), StreamIndex(-1) {} CItem(): HasMetadata(true), StreamIndex(-1), Id(0) {}
bool IsDir() const { return HasMetadata && ((Attrib & 0x10) != 0); } bool IsDir() const { return HasMetadata && ((Attrib & 0x10) != 0); }
bool HasStream() const bool HasStream() const
{ {
for (unsigned i = 0; i < kHashSize; i++) for (unsigned i = 0; i < kHashSize; i++)
if (Hash[i] != 0) if (Hash[i] != 0)
return true; return true;
return false; return Id != 0;
} }
}; };
@@ -228,6 +230,8 @@ public:
bool SkipRoot; bool SkipRoot;
bool ShowImageNumber; bool ShowImageNumber;
bool IsOldVersion;
UInt64 GetUnpackSize() const UInt64 GetUnpackSize() const
{ {
UInt64 res = 0; UInt64 res = 0;
@@ -253,6 +257,7 @@ public:
SkipRoot = true; SkipRoot = true;
ShowImageNumber = true; ShowImageNumber = true;
IsOldVersion = false;
} }
UString GetItemPath(int index) const; UString GetItemPath(int index) const;

View File

@@ -146,6 +146,7 @@ HRESULT CAddCommon::Compress(
opRes.ExtractVersion = NFileHeader::NCompressionMethod::kExtractVersion_Default; opRes.ExtractVersion = NFileHeader::NCompressionMethod::kExtractVersion_Default;
if (inCrcStreamSpec != 0) if (inCrcStreamSpec != 0)
RINOK(inCrcStreamSpec->Seek(0, STREAM_SEEK_SET, NULL)); RINOK(inCrcStreamSpec->Seek(0, STREAM_SEEK_SET, NULL));
RINOK(outStream->SetSize(0));
RINOK(outStream->Seek(0, STREAM_SEEK_SET, NULL)); RINOK(outStream->Seek(0, STREAM_SEEK_SET, NULL));
if (_options.PasswordIsDefined) if (_options.PasswordIsDefined)
{ {
@@ -218,7 +219,7 @@ HRESULT CAddCommon::Compress(
_options.Algo, _options.Algo,
_options.DicSize, _options.DicSize,
_options.NumFastBytes, _options.NumFastBytes,
(BSTR)(const wchar_t *)_options.MatchFinder, const_cast<BSTR>((const wchar_t *)_options.MatchFinder),
_options.NumMatchFinderCycles _options.NumMatchFinderCycles
}; };
PROPID propIDs[] = PROPID propIDs[] =
@@ -373,7 +374,7 @@ HRESULT CAddCommon::Compress(
RINOK(outStream->Seek(0, STREAM_SEEK_CUR, &opRes.PackSize)); RINOK(outStream->Seek(0, STREAM_SEEK_CUR, &opRes.PackSize));
} }
opRes.Method = method; opRes.Method = method;
return outStream->SetSize(opRes.PackSize); return S_OK;
} }
}} }}

View File

@@ -544,7 +544,17 @@ HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
UInt64 curPos = endPosition - bufSize + i; UInt64 curPos = endPosition - bufSize + i;
UInt64 cdEnd = cdInfo.Size + cdInfo.Offset; UInt64 cdEnd = cdInfo.Size + cdInfo.Offset;
if (curPos != cdEnd) 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; ArcInfo.Base = curPos - cdEnd;
}
return S_OK; return S_OK;
} }
} }

View File

@@ -2,6 +2,8 @@
#include "StdAfx.h" #include "StdAfx.h"
#include "../../../../C/Alloc.h"
#include "Common/AutoPtr.h" #include "Common/AutoPtr.h"
#include "Common/Defs.h" #include "Common/Defs.h"
#include "Common/StringConvert.h" #include "Common/StringConvert.h"
@@ -16,6 +18,7 @@
#ifndef _7ZIP_ST #ifndef _7ZIP_ST
#include "../../Common/ProgressMt.h" #include "../../Common/ProgressMt.h"
#endif #endif
#include "../../Common/StreamUtils.h"
#include "../../Compress/CopyCoder.h" #include "../../Compress/CopyCoder.h"
@@ -798,6 +801,216 @@ static HRESULT Update2(
#endif #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( HRESULT Update(
DECL_EXTERNAL_CODECS_LOC_VARS DECL_EXTERNAL_CODECS_LOC_VARS
const CObjectVector<CItemEx> &inputItems, const CObjectVector<CItemEx> &inputItems,
@@ -808,9 +1021,17 @@ HRESULT Update(
IArchiveUpdateCallback *updateCallback) IArchiveUpdateCallback *updateCallback)
{ {
CMyComPtr<IOutStream> outStream; 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; return E_NOTIMPL;
CCacheOutStream *cacheStream = new CCacheOutStream();
outStream = cacheStream;
if (!cacheStream->Allocate())
return E_OUTOFMEMORY;
RINOK(cacheStream->Init(outStreamReal));
}
if (inArchive) if (inArchive)
{ {

View File

@@ -88,7 +88,7 @@ static const int kNumSwitches = sizeof(kSwitchForms) / sizeof(kSwitchForms[0]);
static void PrintMessage(const char *s) static void PrintMessage(const char *s)
{ {
fprintf(stderr, s); fputs(s, stderr);
} }
static void PrintHelp() static void PrintHelp()
@@ -425,7 +425,7 @@ int main2(int numArgs, const char *args[])
props[5].ulVal = (UInt32)fb; props[5].ulVal = (UInt32)fb;
props[6].vt = VT_BSTR; 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].vt = VT_BOOL;
props[7].boolVal = eos ? VARIANT_TRUE : VARIANT_FALSE; props[7].boolVal = eos ? VARIANT_TRUE : VARIANT_FALSE;

View File

@@ -353,7 +353,7 @@ STDMETHODIMP COutFileStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPo
#endif #endif
} }
STDMETHODIMP COutFileStream::SetSize(Int64 newSize) STDMETHODIMP COutFileStream::SetSize(UInt64 newSize)
{ {
#ifdef USE_WIN_FILE #ifdef USE_WIN_FILE
UInt64 currentPos; UInt64 currentPos;
@@ -418,4 +418,5 @@ STDMETHODIMP CStdOutFileStream::Write(const void *data, UInt32 size, UInt32 *pro
return S_OK; return S_OK;
#endif #endif
} }
#endif #endif

View File

@@ -127,7 +127,7 @@ public:
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
STDMETHOD(SetSize)(Int64 newSize); STDMETHOD(SetSize)(UInt64 newSize);
}; };
class CStdOutFileStream: class CStdOutFileStream:

View File

@@ -92,7 +92,7 @@ STDMETHODIMP CFilterCoder::ReleaseOutStream()
{ {
_outStream.Release(); _outStream.Release();
return S_OK; return S_OK;
}; }
STDMETHODIMP CFilterCoder::Write(const void *data, UInt32 size, UInt32 *processedSize) STDMETHODIMP CFilterCoder::Write(const void *data, UInt32 size, UInt32 *processedSize)
@@ -164,7 +164,7 @@ STDMETHODIMP CFilterCoder::ReleaseInStream()
{ {
_inStream.Release(); _inStream.Release();
return S_OK; return S_OK;
}; }
STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize) STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize)
{ {

View File

@@ -29,7 +29,7 @@ STDMETHODIMP COffsetOutStream::Seek(Int64 offset, UInt32 seekOrigin,
return result; return result;
} }
STDMETHODIMP COffsetOutStream::SetSize(Int64 newSize) STDMETHODIMP COffsetOutStream::SetSize(UInt64 newSize)
{ {
return _stream->SetSize(_offset + newSize); return _stream->SetSize(_offset + newSize);
} }

View File

@@ -19,7 +19,7 @@ public:
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
STDMETHOD(SetSize)(Int64 newSize); STDMETHOD(SetSize)(UInt64 newSize);
}; };
#endif #endif

View File

@@ -129,7 +129,7 @@ STDMETHODIMP COutMemStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPos
return S_OK; return S_OK;
} }
STDMETHODIMP COutMemStream::SetSize(Int64 newSize) STDMETHODIMP COutMemStream::SetSize(UInt64 newSize)
{ {
if (_realStreamMode) if (_realStreamMode)
{ {

View File

@@ -90,7 +90,7 @@ public:
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
STDMETHOD(SetSize)(Int64 newSize); STDMETHOD(SetSize)(UInt64 newSize);
}; };
#endif #endif

View File

@@ -10,7 +10,8 @@
namespace NCompress { namespace NCompress {
namespace NBZip2 { namespace NBZip2 {
#define NO_INLINE MY_FAST_CALL #undef NO_INLINE
#define NO_INLINE
static const UInt32 kNumThreadsMax = 4; static const UInt32 kNumThreadsMax = 4;
@@ -422,7 +423,7 @@ CDecoder::CDecoder()
m_States = 0; m_States = 0;
m_NumThreadsPrev = 0; m_NumThreadsPrev = 0;
NumThreads = 1; NumThreads = 1;
#endif; #endif
_needInStreamInit = true; _needInStreamInit = true;
} }

View File

@@ -9,8 +9,10 @@
#include "DeflateEncoder.h" #include "DeflateEncoder.h"
#if _MSC_VER >= 1300 #undef NO_INLINE
#define NO_INLINE __declspec(noinline)
#ifdef _MSC_VER
#define NO_INLINE MY_NO_INLINE
#else #else
#define NO_INLINE #define NO_INLINE
#endif #endif
@@ -580,7 +582,7 @@ NO_INLINE UInt32 Huffman_GetPrice(const UInt32 *freqs, const Byte *lens, UInt32
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
price += lens[i] * freqs[i]; price += lens[i] * freqs[i];
return price; return price;
}; }
NO_INLINE UInt32 Huffman_GetPrice_Spec(const UInt32 *freqs, const Byte *lens, UInt32 num, const Byte *extraBits, UInt32 extraBase) NO_INLINE UInt32 Huffman_GetPrice_Spec(const UInt32 *freqs, const Byte *lens, UInt32 num, const Byte *extraBits, UInt32 extraBase)
{ {

View File

@@ -164,7 +164,7 @@ void CDecoder::ClearPrevLevels()
m_LastMainLevels[i] = 0; m_LastMainLevels[i] = 0;
for (i = 0; i < kNumLenSymbols; i++) for (i = 0; i < kNumLenSymbols; i++)
m_LastLenLevels[i] = 0; m_LastLenLevels[i] = 0;
}; }
HRESULT CDecoder::CodeSpec(UInt32 curSize) HRESULT CDecoder::CodeSpec(UInt32 curSize)

View File

@@ -778,13 +778,13 @@ struct StandardFilterSignature
} }
kStdFilters[]= kStdFilters[]=
{ {
53, 0xad576887, SF_E8, { 53, 0xad576887, SF_E8 },
57, 0x3cd7e57e, SF_E8E9, { 57, 0x3cd7e57e, SF_E8E9 },
120, 0x3769893f, SF_ITANIUM, { 120, 0x3769893f, SF_ITANIUM },
29, 0x0e06077d, SF_DELTA, { 29, 0x0e06077d, SF_DELTA },
149, 0x1c2c5dc8, SF_RGB, { 149, 0x1c2c5dc8, SF_RGB },
216, 0xbc85e701, SF_AUDIO, { 216, 0xbc85e701, SF_AUDIO },
40, 0x46b9c560, SF_UPCASE { 40, 0x46b9c560, SF_UPCASE }
}; };
static int FindStandardFilter(const Byte *code, UInt32 codeSize) static int FindStandardFilter(const Byte *code, UInt32 codeSize)

View File

@@ -106,9 +106,9 @@ void CDecoder::Calculate()
unsigned i; unsigned i;
for (i = 0; i < kNumRounds; 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) }; 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) if (i % (kNumRounds / 16) == 0)
{ {
NSha1::CContext shaTemp = sha; NSha1::CContext shaTemp = sha;

View File

@@ -112,11 +112,29 @@ void CContextBase::PrepareBlock(UInt32 *block, unsigned size) const
block[curBufferPos++] = (UInt32)(lenInBits); 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; bool returnRes = false;
unsigned curBufferPos = _count2; unsigned curBufferPos = _count2;
while (size-- > 0) while (size--)
{ {
int pos = (int)(curBufferPos & 3); int pos = (int)(curBufferPos & 3);
if (pos == 0) if (pos == 0)
@@ -179,7 +197,7 @@ void CContext::Final(Byte *digest)
void CContext32::Update(const UInt32 *data, size_t size) void CContext32::Update(const UInt32 *data, size_t size)
{ {
while (size-- > 0) while (size--)
{ {
_buffer[_count2++] = *data++; _buffer[_count2++] = *data++;
if (_count2 == kBlockSizeInWords) if (_count2 == kBlockSizeInWords)

View File

@@ -51,8 +51,8 @@ public:
class CContext: public CContextBase2 class CContext: public CContextBase2
{ {
public: public:
void Update(Byte *data, size_t size, bool rar350Mode = false); void Update(const Byte *data, size_t size);
void Update(const Byte *data, size_t size) { Update((Byte *)data, size, false); } void UpdateRar(Byte *data, size_t size, bool rar350Mode);
void Final(Byte *digest); void Final(Byte *digest);
}; };

View File

@@ -42,7 +42,7 @@ STREAM_INTERFACE_SUB(IInStream, ISequentialInStream, 0x03)
STREAM_INTERFACE_SUB(IOutStream, ISequentialOutStream, 0x04) STREAM_INTERFACE_SUB(IOutStream, ISequentialOutStream, 0x04)
{ {
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE; STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;
STDMETHOD(SetSize)(Int64 newSize) PURE; STDMETHOD(SetSize)(UInt64 newSize) PURE;
}; };
STREAM_INTERFACE(IStreamGetSize, 0x06) STREAM_INTERFACE(IStreamGetSize, 0x06)

View File

@@ -1,8 +1,8 @@
#define MY_VER_MAJOR 9 #define MY_VER_MAJOR 9
#define MY_VER_MINOR 16 #define MY_VER_MINOR 17
#define MY_VER_BUILD 0 #define MY_VER_BUILD 0
#define MY_VERSION "9.16" #define MY_VERSION "9.17 beta"
#define MY_7ZIP_VERSION "7-Zip 9.16 beta" #define MY_7ZIP_VERSION "7-Zip 9.17 beta"
#define MY_DATE "2010-09-08" #define MY_DATE "2010-10-04"
#define MY_COPYRIGHT "Copyright (c) 1999-2010 Igor Pavlov" #define MY_COPYRIGHT "Copyright (c) 1999-2010 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE

View File

@@ -86,7 +86,7 @@ enum Enum
kTechMode, kTechMode,
kShareForWrite, kShareForWrite,
kCaseSensitive, 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) static void ThrowException(const char *errorMessage)
{ {
throw CArchiveCommandLineException(errorMessage); throw CArchiveCommandLineException(errorMessage);
}; }
static void ThrowUserErrorException() static void ThrowUserErrorException()
{ {
ThrowException(kUserErrorMessage); ThrowException(kUserErrorMessage);
}; }
// --------------------------- // ---------------------------

View File

@@ -82,7 +82,7 @@ public:
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
STDMETHOD(SetSize)(Int64 newSize); STDMETHOD(SetSize)(UInt64 newSize);
}; };
// static NSynchronization::CCriticalSection g_TempPathsCS; // static NSynchronization::CCriticalSection g_TempPathsCS;
@@ -204,7 +204,7 @@ STDMETHODIMP COutMultiVolStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *n
return S_OK; return S_OK;
} }
STDMETHODIMP COutMultiVolStream::SetSize(Int64 newSize) STDMETHODIMP COutMultiVolStream::SetSize(UInt64 newSize)
{ {
if (newSize < 0) if (newSize < 0)
return E_INVALIDARG; return E_INVALIDARG;
@@ -905,4 +905,3 @@ HRESULT UpdateArchive(
#endif #endif
return S_OK; return S_OK;
} }

View File

@@ -7,7 +7,7 @@
namespace NUpdateArchive { namespace NUpdateArchive {
const CActionSet kAddActionSet = const CActionSet kAddActionSet =
{ {{
NPairAction::kCopy, NPairAction::kCopy,
NPairAction::kCopy, NPairAction::kCopy,
NPairAction::kCompress, NPairAction::kCompress,
@@ -15,10 +15,10 @@ const CActionSet kAddActionSet =
NPairAction::kCompress, NPairAction::kCompress,
NPairAction::kCompress, NPairAction::kCompress,
NPairAction::kCompress NPairAction::kCompress
}; }};
const CActionSet kUpdateActionSet = const CActionSet kUpdateActionSet =
{ {{
NPairAction::kCopy, NPairAction::kCopy,
NPairAction::kCopy, NPairAction::kCopy,
NPairAction::kCompress, NPairAction::kCompress,
@@ -26,10 +26,10 @@ const CActionSet kUpdateActionSet =
NPairAction::kCompress, NPairAction::kCompress,
NPairAction::kCopy, NPairAction::kCopy,
NPairAction::kCompress NPairAction::kCompress
}; }};
const CActionSet kFreshActionSet = const CActionSet kFreshActionSet =
{ {{
NPairAction::kCopy, NPairAction::kCopy,
NPairAction::kCopy, NPairAction::kCopy,
NPairAction::kIgnore, NPairAction::kIgnore,
@@ -37,10 +37,10 @@ const CActionSet kFreshActionSet =
NPairAction::kCompress, NPairAction::kCompress,
NPairAction::kCopy, NPairAction::kCopy,
NPairAction::kCompress NPairAction::kCompress
}; }};
const CActionSet kSynchronizeActionSet = const CActionSet kSynchronizeActionSet =
{ {{
NPairAction::kCopy, NPairAction::kCopy,
NPairAction::kIgnore, NPairAction::kIgnore,
NPairAction::kCompress, NPairAction::kCompress,
@@ -48,10 +48,10 @@ const CActionSet kSynchronizeActionSet =
NPairAction::kCompress, NPairAction::kCompress,
NPairAction::kCopy, NPairAction::kCopy,
NPairAction::kCompress, NPairAction::kCompress,
}; }};
const CActionSet kDeleteActionSet = const CActionSet kDeleteActionSet =
{ {{
NPairAction::kCopy, NPairAction::kCopy,
NPairAction::kIgnore, NPairAction::kIgnore,
NPairAction::kIgnore, NPairAction::kIgnore,
@@ -59,6 +59,6 @@ const CActionSet kDeleteActionSet =
NPairAction::kIgnore, NPairAction::kIgnore,
NPairAction::kIgnore, NPairAction::kIgnore,
NPairAction::kIgnore NPairAction::kIgnore
}; }};
} }

View File

@@ -19,6 +19,7 @@ namespace NUpdateArchive {
kUnknowNewerFiles kUnknowNewerFiles
}; };
} }
namespace NPairAction namespace NPairAction
{ {
enum EEnum enum EEnum
@@ -29,6 +30,7 @@ namespace NUpdateArchive {
kCompressAsAnti kCompressAsAnti
}; };
} }
struct CActionSet struct CActionSet
{ {
NPairAction::EEnum StateActions[NPairState::kNumValues]; NPairAction::EEnum StateActions[NPairState::kNumValues];
@@ -44,14 +46,12 @@ namespace NUpdateArchive {
return false; return false;
} }
}; };
extern const CActionSet kAddActionSet; extern const CActionSet kAddActionSet;
extern const CActionSet kUpdateActionSet; extern const CActionSet kUpdateActionSet;
extern const CActionSet kFreshActionSet; extern const CActionSet kFreshActionSet;
extern const CActionSet kSynchronizeActionSet; extern const CActionSet kSynchronizeActionSet;
extern const CActionSet kDeleteActionSet; extern const CActionSet kDeleteActionSet;
}; }
#endif #endif

View File

@@ -24,8 +24,8 @@
virtual HRESULT SetOperationResult(Int32 operationResult) x; \ virtual HRESULT SetOperationResult(Int32 operationResult) x; \
virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) x; \ virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) x; \
virtual HRESULT CryptoGetTextPassword(BSTR *password) x; \ virtual HRESULT CryptoGetTextPassword(BSTR *password) x; \
// virtual HRESULT ShowDeleteFile(const wchar_t *name) x; \ /* virtual HRESULT ShowDeleteFile(const wchar_t *name) x; */ \
// virtual HRESULT CloseProgress() { return S_OK; }; /* virtual HRESULT CloseProgress() { return S_OK; }; */
struct IUpdateCallbackUI struct IUpdateCallbackUI
{ {

View File

@@ -76,7 +76,7 @@ static void PrintNumber(FILE *f, UInt64 value, int size)
fprintf(f, " "); fprintf(f, " ");
for (int len = (int)strlen(s); len < size; len++) for (int len = (int)strlen(s); len < size; len++)
fprintf(f, " "); fprintf(f, " ");
fprintf(f, "%s", s); fputs(s, f);
} }
static void PrintRating(FILE *f, UInt64 rating) static void PrintRating(FILE *f, UInt64 rating)
@@ -134,7 +134,7 @@ HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
if (final) if (final)
{ {
UInt64 rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations); UInt64 rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations);
fprintf(f, kSep); fputs(kSep, f);
CBenchInfo info2 = info; CBenchInfo info2 = info;
info2.UnpackSize *= info2.NumIterations; info2.UnpackSize *= info2.NumIterations;
info2.PackSize *= info2.NumIterations; info2.PackSize *= info2.NumIterations;
@@ -191,14 +191,14 @@ HRESULT LzmaBenchCon(
{ {
fprintf(f, " Speed Usage R/U Rating"); fprintf(f, " Speed Usage R/U Rating");
if (j == 0) if (j == 0)
fprintf(f, kSep); fputs(kSep, f);
} }
fprintf(f, "\n "); fprintf(f, "\n ");
for (j = 0; j < 2; j++) for (j = 0; j < 2; j++)
{ {
fprintf(f, " KB/s %% MIPS MIPS"); fprintf(f, " KB/s %% MIPS MIPS");
if (j == 0) if (j == 0)
fprintf(f, kSep); fputs(kSep, f);
} }
fprintf(f, "\n\n"); fprintf(f, "\n\n");
for (UInt32 i = 0; i < numIterations; i++) for (UInt32 i = 0; i < numIterations; i++)

View File

@@ -1,8 +0,0 @@
// CLSIDConst.cpp
#include "StdAfx.h"
#include <initguid.h>
#include "../Agent/Agent.h"
#include "../../IPassword.h"

View File

@@ -57,20 +57,21 @@ STDMETHODIMP CExtractCallBackImp::AskOverwrite(
Int32 *answer) Int32 *answer)
{ {
NOverwriteDialog::CFileInfo oldFileInfo, newFileInfo; NOverwriteDialog::CFileInfo oldFileInfo, newFileInfo;
oldFileInfo.TimeIsDefined = (existTime != 0);
if (oldFileInfo.TimeIsDefined)
oldFileInfo.Time = *existTime; oldFileInfo.Time = *existTime;
oldFileInfo.SizeIsDefined = (existSize != NULL); oldFileInfo.SizeIsDefined = (existSize != NULL);
if (oldFileInfo.SizeIsDefined) if (oldFileInfo.SizeIsDefined)
oldFileInfo.Size = *existSize; oldFileInfo.Size = *existSize;
oldFileInfo.Name = GetSystemString(existName, m_CodePage); oldFileInfo.Name = existName;
newFileInfo.TimeIsDefined = (newTime != 0); newFileInfo.TimeIsDefined = (newTime != 0);
if (newFileInfo.TimeIsDefined) if (newFileInfo.TimeIsDefined)
newFileInfo.Time = *newTime; newFileInfo.Time = *newTime;
newFileInfo.SizeIsDefined = (newSize != NULL); newFileInfo.SizeIsDefined = (newSize != NULL);
if (newFileInfo.SizeIsDefined) if (newFileInfo.SizeIsDefined)
newFileInfo.Size = *newSize; newFileInfo.Size = *newSize;
newFileInfo.Name = GetSystemString(newName, m_CodePage); newFileInfo.Name = newName;
NOverwriteDialog::NResult::EEnum result = NOverwriteDialog::NResult::EEnum result =
NOverwriteDialog::Execute(oldFileInfo, newFileInfo); NOverwriteDialog::Execute(oldFileInfo, newFileInfo);

View File

@@ -1,20 +1,34 @@
; 7-ZipFar.def : Declares the module parameters for the DLL. ; 7-ZipFar.def : Declares the module parameters for the DLL.
LIBRARY "7-ZipFar" LIBRARY "7-ZipFar"
DESCRIPTION '7-ZipFar Windows Dynamic Link Library'
EXPORTS EXPORTS
SetStartupInfo = _SetStartupInfo@4 SetStartupInfo
OpenPlugin = _OpenPlugin@8 OpenPlugin
OpenFilePlugin = _OpenFilePlugin@12 OpenFilePlugin
ClosePlugin = _ClosePlugin@4 ClosePlugin
GetFindData = _GetFindData@16 GetFindData
FreeFindData = _FreeFindData@12 FreeFindData
SetDirectory = _SetDirectory@12 SetDirectory
GetPluginInfo = _GetPluginInfo@4 GetPluginInfo
Configure = _Configure@4 Configure
GetOpenPluginInfo = _GetOpenPluginInfo@8 GetOpenPluginInfo
GetFiles = _GetFiles@24 GetFiles
PutFiles = _PutFiles@20 PutFiles
DeleteFiles = _DeleteFiles@16 DeleteFiles
ProcessKey = _ProcessKey@12 ProcessKey
;SetStartupInfoW
;OpenPluginW
;OpenFilePluginW
;ClosePluginW
;GetFindDataW
;FreeFindDataW
;SetDirectoryW
;GetPluginInfoW
;ConfigureW
;GetOpenPluginInfoW
;GetFilesW
;PutFilesW
;DeleteFilesW
;ProcessKeyW

View File

@@ -53,7 +53,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe 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 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 # SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "Far - Win32 Debug" !ELSEIF "$(CFG)" == "Far - Win32 Debug"
@@ -80,7 +80,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe 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 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 !ENDIF
@@ -93,10 +93,6 @@ LINK32=link.exe
# PROP Default_Filter "" # PROP Default_Filter ""
# Begin Source File # Begin Source File
SOURCE=.\CLSIDConst.cpp
# End Source File
# Begin Source File
SOURCE=.\Far.def SOURCE=.\Far.def
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@@ -1,18 +1,37 @@
// FarPlugin.h // FarPlugin.h
#ifndef __FARPLUGIN_H // #include "plugin.hpp"
#define __FARPLUGIN_H
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) #if defined(__BORLANDC__) && (__BORLANDC <= 0x520)
#pragma option -a1 #pragma option -a1
#elif defined(__GNUC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1100)) #elif defined(__GNUC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1100))
#pragma pack(1) #pragma pack(1)
#else #else
#pragma pack(push,1) #pragma pack(push,1)
#endif
#endif
#if _MSC_VER #if _MSC_VER
#define _export #define _export
#endif #endif
#endif
#define NM 260 #define NM 260
@@ -41,8 +60,9 @@ struct PluginPanelItem
char *Owner; char *Owner;
char **CustomColumnData; char **CustomColumnData;
int CustomColumnNumber; int CustomColumnNumber;
DWORD UserData; DWORD_PTR UserData;
DWORD Reserved[3]; DWORD CRC32;
DWORD_PTR Reserved[2];
}; };
#define PPIF_PROCESSDESCR 0x80000000 #define PPIF_PROCESSDESCR 0x80000000
@@ -58,7 +78,7 @@ enum {
typedef int (WINAPI *FARAPIMENU)( typedef int (WINAPI *FARAPIMENU)(
int PluginNumber, INT_PTR PluginNumber,
int X, int X,
int Y, int Y,
int MaxHeight, int MaxHeight,
@@ -73,7 +93,7 @@ typedef int (WINAPI *FARAPIMENU)(
); );
typedef int (WINAPI *FARAPIDIALOG)( typedef int (WINAPI *FARAPIDIALOG)(
int PluginNumber, INT_PTR PluginNumber,
int X1, int X1,
int Y1, int Y1,
int X2, int X2,
@@ -92,7 +112,7 @@ enum {
}; };
typedef int (WINAPI *FARAPIMESSAGE)( typedef int (WINAPI *FARAPIMESSAGE)(
int PluginNumber, INT_PTR PluginNumber,
unsigned int Flags, unsigned int Flags,
char *HelpTopic, char *HelpTopic,
char **Items, char **Items,
@@ -101,7 +121,7 @@ typedef int (WINAPI *FARAPIMESSAGE)(
); );
typedef char* (WINAPI *FARAPIGETMSG)( typedef char* (WINAPI *FARAPIGETMSG)(
int PluginNumber, INT_PTR PluginNumber,
int MsgId int MsgId
); );
@@ -194,7 +214,8 @@ struct PanelInfo
char CurDir[NM]; char CurDir[NM];
int ShortNames; int ShortNames;
int SortMode; int SortMode;
DWORD Reserved[2]; DWORD Flags;
DWORD Reserved;
}; };
@@ -222,7 +243,7 @@ typedef int (WINAPI *FARAPIGETDIRLIST)(
); );
typedef int (WINAPI *FARAPIGETPLUGINDIRLIST)( typedef int (WINAPI *FARAPIGETPLUGINDIRLIST)(
int PluginNumber, INT_PTR PluginNumber,
HANDLE hPlugin, HANDLE hPlugin,
char *Dir, char *Dir,
struct PluginPanelItem **pPanelItem, struct PluginPanelItem **pPanelItem,
@@ -294,126 +315,11 @@ typedef int (WINAPI *FARAPIEDITORCONTROL)(
void *Param 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 struct PluginStartupInfo
{ {
int StructSize; int StructSize;
char ModuleName[NM]; char ModuleName[NM];
int ModuleNumber; INT_PTR ModuleNumber;
char *RootKey; char *RootKey;
FARAPIMENU Menu; FARAPIMENU Menu;
FARAPIDIALOG Dialog; FARAPIDIALOG Dialog;
@@ -456,8 +362,6 @@ struct PluginInfo
char *CommandPrefix; char *CommandPrefix;
}; };
const int kInfoPanelLineSize = 80;
struct InfoPanelLine struct InfoPanelLine
{ {
char Text[kInfoPanelLineSize]; char Text[kInfoPanelLineSize];
@@ -567,6 +471,7 @@ enum OPERATION_MODES {
OPM_DESCR=32 OPM_DESCR=32
}; };
#ifndef _WIN64
#if defined(__BORLANDC__) && (__BORLANDC <= 0x520) #if defined(__BORLANDC__) && (__BORLANDC <= 0x520)
#pragma option -a. #pragma option -a.
#elif defined(__GNUC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1100)) #elif defined(__GNUC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1100))
@@ -574,5 +479,41 @@ enum OPERATION_MODES {
#else #else
#pragma pack(pop) #pragma pack(pop)
#endif #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 #endif

View File

@@ -4,7 +4,10 @@
#include "Common/StringConvert.h" #include "Common/StringConvert.h"
#ifndef UNDER_CE
#include "Windows/Console.h" #include "Windows/Console.h"
#endif
#include "Windows/Defs.h"
#include "Windows/Error.h" #include "Windows/Error.h"
#include "FarUtils.h" #include "FarUtils.h"
@@ -417,6 +420,9 @@ void PrintErrorMessage(const char *message, const wchar_t *text)
bool WasEscPressed() bool WasEscPressed()
{ {
#ifdef UNDER_CE
return false;
#else
NConsole::CIn inConsole; NConsole::CIn inConsole;
HANDLE handle = ::GetStdHandle(STD_INPUT_HANDLE); HANDLE handle = ::GetStdHandle(STD_INPUT_HANDLE);
if(handle == INVALID_HANDLE_VALUE) if(handle == INVALID_HANDLE_VALUE)
@@ -438,16 +444,16 @@ bool WasEscPressed()
event.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) event.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE)
return true; return true;
} }
#endif
} }
void ShowErrorMessage(DWORD errorCode) void ShowErrorMessage(DWORD errorCode)
{ {
CSysString message; UString message;
NError::MyFormatMessage(errorCode, message); NError::MyFormatMessage(errorCode, message);
message.Replace(TEXT("\x0D"), TEXT("")); message.Replace(L"\x0D", L"");
message.Replace(TEXT("\x0A"), TEXT(" ")); message.Replace(L"\x0A", L" ");
g_StartupInfo.ShowMessage(SystemStringToOemString(message)); g_StartupInfo.ShowMessage(UnicodeStringToMultiByte(message, CP_OEMCP));
} }
void ShowLastErrorMessage() void ShowLastErrorMessage()

View File

@@ -21,8 +21,8 @@ using namespace NWindows;
using namespace NFar; using namespace NFar;
static const char *kCommandPrefix = "7-zip"; static const char *kCommandPrefix = "7-zip";
static const char *kRegisrtryMainKeyName = ""; static const TCHAR *kRegisrtryMainKeyName = TEXT("");
static const char *kRegisrtryValueNameEnabled = "UsedByDefault3"; static const TCHAR *kRegisrtryValueNameEnabled = TEXT("UsedByDefault3");
static const char *kHelpTopicConfig = "Config"; static const char *kHelpTopicConfig = "Config";
static bool kPluginEnabledDefault = true; static bool kPluginEnabledDefault = true;
@@ -30,11 +30,17 @@ HINSTANCE g_hInstance;
#define NT_CHECK_FAIL_ACTION return FALSE; #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) if (dwReason == DLL_PROCESS_ATTACH)
{ {
g_hInstance = hInstance; g_hInstance = (HINSTANCE)hInstance;
NT_CHECK NT_CHECK
} }
return TRUE; return TRUE;
@@ -45,9 +51,9 @@ static struct COptions
bool Enabled; bool Enabled;
} g_Options; } 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; MY_TRY_BEGIN;
g_StartupInfo.Init(*info, kPliginNameForRegestry); 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 = name;
UString normalizedName = GetUnicodeString(name, codePage);
normalizedName.Trim(); normalizedName.Trim();
UString fullName; UString fullName;
int fileNamePartStartIndex; int fileNamePartStartIndex;
@@ -344,7 +348,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
CMyComPtr<IInFolderArchive> archiveHandler; CMyComPtr<IInFolderArchive> archiveHandler;
// CArchiverInfo archiverInfoResult; // CArchiverInfo archiverInfoResult;
// ::OutputDebugString("before OpenArchive\n"); // ::OutputDebugStringA("before OpenArchive\n");
CScreenRestorer screenRestorer; CScreenRestorer screenRestorer;
{ {
@@ -360,7 +364,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
fullName.Left(fileNamePartStartIndex), fullName.Left(fileNamePartStartIndex),
fullName.Mid(fileNamePartStartIndex)); fullName.Mid(fileNamePartStartIndex));
// ::OutputDebugString("before OpenArchive\n"); // ::OutputDebugStringA("before OpenArchive\n");
archiveHandler = new CAgent; archiveHandler = new CAgent;
CMyComBSTR archiveType; CMyComBSTR archiveType;
@@ -377,7 +381,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
// ::OutputDebugString("after OpenArchive\n"); // ::OutputDebugStringA("after OpenArchive\n");
CPlugin *plugin = new CPlugin( CPlugin *plugin = new CPlugin(
fullName, fullName,
@@ -393,7 +397,18 @@ static HANDLE MyOpenFilePlugin(const char *name)
return (HANDLE)(plugin); 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; MY_TRY_BEGIN;
if (name == NULL || (!g_Options.Enabled)) 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); 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; MY_TRY_BEGIN;
if(openFrom == OPEN_COMMANDLINE) if(openFrom == OPEN_COMMANDLINE)
{ {
CSysString fileName = (const char *)(UINT_PTR)item; AString fileName = (const char *)item;
if(fileName.IsEmpty()) if(fileName.IsEmpty())
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
if (fileName.Length() >= 2 && if (fileName.Length() >= 2 &&
@@ -482,7 +512,7 @@ EXTERN_C int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
MY_TRY_END2("GetFiles", NFileOperationReturnCode::kError); 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; MY_TRY_BEGIN;
return(((CPlugin *)plugin)->SetDirectory(dir, opMode)); return(((CPlugin *)plugin)->SetDirectory(dir, opMode));

View File

@@ -22,8 +22,8 @@ namespace NOverwriteDialog {
struct CFileInfoStrings struct CFileInfoStrings
{ {
CSysString Size; AString Size;
CSysString Time; AString Time;
}; };
void SetFileInfoStrings(const CFileInfo &fileInfo, void SetFileInfoStrings(const CFileInfo &fileInfo,
@@ -51,7 +51,7 @@ void SetFileInfoStrings(const CFileInfo &fileInfo,
UString timeString = ConvertFileTimeToString(localFileTime); UString timeString = ConvertFileTimeToString(localFileTime);
fileInfoStrings.Time = g_StartupInfo.GetMsgString(NMessageID::kOverwriteModifiedOn); fileInfoStrings.Time = g_StartupInfo.GetMsgString(NMessageID::kOverwriteModifiedOn);
fileInfoStrings.Time += " "; 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(oldFileInfo, oldFileInfoStrings);
SetFileInfoStrings(newFileInfo, newFileInfoStrings); 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_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 }, { 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, 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, 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, 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, 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, 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 }, { 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 } { 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]; FarDialogItem aDialogItems[kNumDialogItems];
g_StartupInfo.InitDialogItems(anInitItems, aDialogItems, kNumDialogItems); g_StartupInfo.InitDialogItems(initItems, aDialogItems, kNumDialogItems);
int anAskCode = g_StartupInfo.ShowDialog(kXSize, kYSize, int anAskCode = g_StartupInfo.ShowDialog(kXSize, kYSize,
NULL, aDialogItems, kNumDialogItems); NULL, aDialogItems, kNumDialogItems);
const int kButtonStartPos = kNumDialogItems - 6; const int kButtonStartPos = kNumDialogItems - 6;

View File

@@ -4,6 +4,7 @@
#define OVERWRITEDIALOG_H #define OVERWRITEDIALOG_H
#include "Common/MyString.h" #include "Common/MyString.h"
#include "Common/Types.h"
namespace NOverwriteDialog { namespace NOverwriteDialog {
@@ -11,10 +12,11 @@ struct CFileInfo
{ {
bool SizeIsDefined; bool SizeIsDefined;
bool TimeIsDefined; bool TimeIsDefined;
UINT64 Size; UInt64 Size;
FILETIME Time; FILETIME Time;
CSysString Name; UString Name;
}; };
namespace NResult namespace NResult
{ {
enum EEnum enum EEnum
@@ -24,10 +26,11 @@ namespace NResult
kNo, kNo,
kNoToAll, kNoToAll,
kAutoRename, kAutoRename,
kCancel, kCancel
}; };
} }
NResult::EEnum Execute(const CFileInfo &anOldFileInfo, const CFileInfo &aNewFileInfo);
NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInfo);
} }

View File

@@ -72,7 +72,7 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
if (prop.vt != VT_BSTR) if (prop.vt != VT_BSTR)
throw 272340; throw 272340;
CSysString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP); AString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
if (oemString == "..") if (oemString == "..")
oemString = kDotsReplaceString; oemString = kDotsReplaceString;
@@ -133,9 +133,9 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
panelItem.CustomColumnData = NULL; panelItem.CustomColumnData = NULL;
panelItem.CustomColumnNumber = 0; panelItem.CustomColumnNumber = 0;
panelItem.CRC32 = 0;
panelItem.Reserved[0] = 0; panelItem.Reserved[0] = 0;
panelItem.Reserved[1] = 0; panelItem.Reserved[1] = 0;
panelItem.Reserved[2] = 0;
} }
int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opMode) int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opMode)
@@ -466,7 +466,7 @@ static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID)
AString s; AString s;
if (prop.vt == VT_BSTR) if (prop.vt == VT_BSTR)
s = GetSystemString(prop.bstrVal, CP_OEMCP); s = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
else if (prop.vt == VT_BOOL) else if (prop.vt == VT_BOOL)
{ {
int messageID = VARIANT_BOOLToBool(prop.boolVal) ? int messageID = VARIANT_BOOLToBool(prop.boolVal) ?
@@ -733,7 +733,7 @@ HRESULT CPlugin::ShowAttributesWindow()
if (strcmp(pluginPanelItem.FindData.cFileName, "..") == 0 && if (strcmp(pluginPanelItem.FindData.cFileName, "..") == 0 &&
NFile::NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes)) NFile::NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes))
return S_FALSE; return S_FALSE;
int itemIndex = pluginPanelItem.UserData; int itemIndex = (int)pluginPanelItem.UserData;
CObjectVector<CArchiveItemProperty> properties; CObjectVector<CArchiveItemProperty> properties;
UInt32 numProps; UInt32 numProps;
@@ -781,7 +781,7 @@ HRESULT CPlugin::ShowAttributesWindow()
NCOM::CPropVariant prop; NCOM::CPropVariant prop;
RINOK(_folder->GetProperty(itemIndex, property.ID, &prop)); RINOK(_folder->GetProperty(itemIndex, property.ID, &prop));
CSysString s = PropToString(prop, property.ID); AString s = PropToString(prop, property.ID);
values.Add(s); values.Add(s);
{ {

View File

@@ -82,8 +82,8 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
CRecordVector<UINT32> indices; CRecordVector<UINT32> indices;
indices.Reserve(numItems); indices.Reserve(numItems);
int i; int i;
for(i = 0; i < numItems; i++) for (i = 0; i < numItems; i++)
indices.Add(panelItems[i].UserData); indices.Add((UINT32)panelItems[i].UserData);
//////////////////////////// ////////////////////////////
// Save _folder; // Save _folder;
@@ -93,7 +93,7 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
CMyComPtr<IOutFolderArchive> outArchive; CMyComPtr<IOutFolderArchive> outArchive;
HRESULT result = m_ArchiveHandler.QueryInterface(IID_IOutFolderArchive, &outArchive); HRESULT result = m_ArchiveHandler.QueryInterface(IID_IOutFolderArchive, &outArchive);
if(result != S_OK) if (result != S_OK)
{ {
g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive); g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive);
return FALSE; return FALSE;
@@ -151,11 +151,11 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
{ {
CMyComPtr<IFolderFolder> newFolder; CMyComPtr<IFolderFolder> newFolder;
_folder->BindToFolder(pathVector[i], &newFolder); _folder->BindToFolder(pathVector[i], &newFolder);
if(!newFolder ) if (!newFolder)
break; break;
_folder = newFolder; _folder = newFolder;
} }
GetCurrentDir(); GetCurrentDir();
return(TRUE); return TRUE;
} }

View File

@@ -76,23 +76,25 @@ HRESULT CPlugin::ExtractFiles(
} }
NFileOperationReturnCode::EEnum CPlugin::GetFiles(struct PluginPanelItem *panelItems, 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, return GetFilesReal(panelItems, itemsNumber, move,
_aDestPath, opMode, (opMode & OPM_SILENT) == 0); destPath, opMode, (opMode & OPM_SILENT) == 0);
} }
NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *panelItems, 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); g_StartupInfo.ShowMessage(NMessageID::kMoveIsNotSupported);
return NFileOperationReturnCode::kError; return NFileOperationReturnCode::kError;
} }
CSysString destPath = _aDestPath; AString destPath = destPathLoc;
NFile::NName::NormalizeDirPathPrefix(destPath); UString destPathU = GetUnicodeString(destPath, CP_OEMCP);
NFile::NName::NormalizeDirPathPrefix(destPathU);
destPath = UnicodeStringToMultiByte(destPathU, CP_OEMCP);
bool extractSelectedFiles = true; bool extractSelectedFiles = true;
@@ -185,17 +187,22 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
if (askCode != kOkButtonIndex) if (askCode != kOkButtonIndex)
return NFileOperationReturnCode::kInterruptedByUser; return NFileOperationReturnCode::kInterruptedByUser;
destPath = dialogItems[kPathIndex].Data; destPath = dialogItems[kPathIndex].Data;
destPath.Trim(); destPathU = GetUnicodeString(destPath, CP_OEMCP);
if (destPath.IsEmpty()) destPathU.Trim();
if (destPathU.IsEmpty())
{ {
if(!NFile::NDirectory::MyGetCurrentDirectory(destPath)) #ifdef UNDER_CE
destPathU = L"\\";
#else
if (!NFile::NDirectory::MyGetCurrentDirectory(destPathU))
throw 318016; throw 318016;
NFile::NName::NormalizeDirPathPrefix(destPath); NFile::NName::NormalizeDirPathPrefix(destPathU);
#endif
break; break;
} }
else else
{ {
if(destPath[destPath.Length() - 1] == kDirDelimiter) if (destPathU.Back() == kDirDelimiter)
break; break;
} }
g_StartupInfo.ShowMessage("You must specify directory path"); g_StartupInfo.ShowMessage("You must specify directory path");
@@ -244,7 +251,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
passwordIsDefined = !password.IsEmpty(); passwordIsDefined = !password.IsEmpty();
} }
NFile::NDirectory::CreateComplexDirectory(destPath); NFile::NDirectory::CreateComplexDirectory(destPathU);
/* /*
vector<int> realIndices; vector<int> realIndices;
@@ -254,11 +261,11 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
CRecordVector<UINT32> indices; CRecordVector<UINT32> indices;
indices.Reserve(itemsNumber); indices.Reserve(itemsNumber);
for (int i = 0; i < itemsNumber; i++) 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, HRESULT result = ExtractFiles(decompressAllItems, &indices.Front(), itemsNumber,
!showBox, extractionInfo.PathMode, extractionInfo.OverwriteMode, !showBox, extractionInfo.PathMode, extractionInfo.OverwriteMode,
MultiByteToUnicodeString(destPath, CP_OEMCP), destPathU,
passwordIsDefined, password); passwordIsDefined, password);
// HRESULT result = ExtractFiles(decompressAllItems, realIndices, !showBox, // HRESULT result = ExtractFiles(decompressAllItems, realIndices, !showBox,
// extractionInfo, destPath, passwordIsDefined, password); // extractionInfo, destPath, passwordIsDefined, password);
@@ -270,9 +277,9 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
return NFileOperationReturnCode::kError; 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::kError;
// } // }
return NFileOperationReturnCode::kSuccess; return NFileOperationReturnCode::kSuccess;

View File

@@ -412,16 +412,17 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
for(i = 0; i < pluginPanelItems.Size(); i++) for(i = 0; i < pluginPanelItems.Size(); i++)
{ {
const PluginPanelItem &panelItem = pluginPanelItems[i]; const PluginPanelItem &panelItem = pluginPanelItems[i];
CSysString fullName; UString fullName;
if (strcmp(panelItem.FindData.cFileName, "..") == 0 && if (strcmp(panelItem.FindData.cFileName, "..") == 0 &&
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes)) NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
return E_FAIL; return E_FAIL;
if (strcmp(panelItem.FindData.cFileName, ".") == 0 && if (strcmp(panelItem.FindData.cFileName, ".") == 0 &&
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes)) NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
return E_FAIL; return E_FAIL;
if (!MyGetFullPathName(panelItem.FindData.cFileName, fullName)) UString fileNameUnicode = MultiByteToUnicodeString(panelItem.FindData.cFileName, CP_OEMCP);
if (!MyGetFullPathName(fileNameUnicode, fullName))
return E_FAIL; return E_FAIL;
fileNames.Add(MultiByteToUnicodeString(fullName, CP_OEMCP)); fileNames.Add(fullName);
} }
NCompression::CInfo compressionInfo; NCompression::CInfo compressionInfo;
@@ -496,7 +497,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex]; const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex];
char updateAddToArchiveString[512]; char updateAddToArchiveString[512];
const AString s = GetSystemString(arcInfo.Name, CP_OEMCP); const AString s = UnicodeStringToMultiByte(arcInfo.Name, CP_OEMCP);
sprintf(updateAddToArchiveString, sprintf(updateAddToArchiveString,
g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), (const char *)s); g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), (const char *)s);
@@ -777,4 +778,3 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
return S_OK; return S_OK;
} }

View File

@@ -1,11 +1,13 @@
PROG = 7-ZipFar.dll PROG = 7-ZipFar.dll
DEF_FILE = Far.def DEF_FILE = Far.def
CFLAGS = $(CFLAGS) -I ../../../ \ CFLAGS = $(CFLAGS) -I ../../../ \
-DWIN_LONG_PATH \
-DEXTERNAL_CODECS -DEXTERNAL_CODECS
!IFNDEF UNDER_CE
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH
!ENDIF
FAR_OBJS = \ FAR_OBJS = \
$O\CLSIDConst.obj \
$O\ExtractEngine.obj \ $O\ExtractEngine.obj \
$O\FarUtils.obj \ $O\FarUtils.obj \
$O\Main.obj \ $O\Main.obj \

View File

@@ -111,5 +111,4 @@ struct CAppState
} }
}; };
#endif #endif

View File

@@ -384,7 +384,7 @@ static const int kNumSwitches = 1;
namespace NKey { namespace NKey {
enum Enum enum Enum
{ {
kOpenArachive = 0, kOpenArachive = 0
}; };
} }

View File

@@ -920,7 +920,7 @@ HRESULT CThreadTest::ProcessVirt()
OkMessage = s; OkMessage = s;
} }
return S_OK; return S_OK;
}; }
/* /*
static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s)

View File

@@ -440,7 +440,7 @@ HRESULT CThreadCopyFrom::ProcessVirt()
fileNames.Add(Name); fileNames.Add(Name);
fileNamePointers.Add(fileNames[0]); fileNamePointers.Add(fileNames[0]);
return FolderOperations->CopyFrom(PathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), UpdateCallback); return FolderOperations->CopyFrom(PathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), UpdateCallback);
}; }
HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName, HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName,
bool usePassword, const UString &password) bool usePassword, const UString &password)

View File

@@ -166,7 +166,7 @@ void CPanel::InsertColumn(int index)
column.fmt = GetColumnAlign(prop.ID, prop.Type); column.fmt = GetColumnAlign(prop.ID, prop.Type);
column.iOrder = prop.Order; column.iOrder = prop.Order;
column.iSubItem = index; 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); _listView.InsertColumn(index, &column);
} }
@@ -337,7 +337,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
int subItem = 0; int subItem = 0;
item.iSubItem = subItem++; item.iSubItem = subItem++;
item.lParam = kParentIndex; 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; UInt32 attrib = FILE_ATTRIBUTE_DIRECTORY;
item.iImage = _extToIconMap.GetIconIndex(attrib, itemName); item.iImage = _extToIconMap.GetIconIndex(attrib, itemName);
if (item.iImage < 0) if (item.iImage < 0)
@@ -391,10 +391,10 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
pos = posNew; pos = posNew;
while (itemName[++pos] == ' '); while (itemName[++pos] == ' ');
} }
item.pszText = (wchar_t *)(const wchar_t *)correctedName; item.pszText = const_cast<wchar_t *>((const wchar_t *)correctedName);
} }
else else
item.pszText = (wchar_t *)(const wchar_t *)itemName; item.pszText = const_cast<wchar_t *>((const wchar_t *)itemName);
NCOM::CPropVariant prop; NCOM::CPropVariant prop;
RINOK(_folder->GetProperty(i, kpidAttrib, &prop)); RINOK(_folder->GetProperty(i, kpidAttrib, &prop));

View File

@@ -50,7 +50,7 @@ public:
HRESULT Result; 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); HRESULT DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError);
}; };
@@ -72,7 +72,7 @@ HRESULT CThreadFolderOperations::ProcessVirt()
Result = E_FAIL; Result = E_FAIL;
} }
return Result; return Result;
}; }
HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError) HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError)

View File

@@ -941,7 +941,7 @@ void CProgressDialog::ProcessWasFinished()
PostMessage(kCloseMessage); PostMessage(kCloseMessage);
else else
_needClose = true; _needClose = true;
}; }
HRESULT CProgressThreadVirt::Create(const UString &title, HWND parentWindow) HRESULT CProgressThreadVirt::Create(const UString &title, HWND parentWindow)

View File

@@ -72,7 +72,7 @@ void CRootFolder::Init()
_names[ROOT_INDEX_VOLUMES] = kVolPrefix; _names[ROOT_INDEX_VOLUMES] = kVolPrefix;
_iconIndices[ROOT_INDEX_VOLUMES] = GetIconIndexForCSIDL(CSIDL_DRIVES); _iconIndices[ROOT_INDEX_VOLUMES] = GetIconIndexForCSIDL(CSIDL_DRIVES);
#endif #endif
}; }
STDMETHODIMP CRootFolder::LoadItems() STDMETHODIMP CRootFolder::LoadItems()
{ {

View File

@@ -115,7 +115,7 @@ enum EMethodID
kBZip2, kBZip2,
kDeflate, kDeflate,
kDeflate64, kDeflate64,
kPPMdZip, kPPMdZip
}; };
static const LPCWSTR kMethodsNames[] = static const LPCWSTR kMethodsNames[] =
@@ -244,7 +244,7 @@ static bool IsMethodSupportedBySfx(int methodID)
if (methodID == g_7zSfxMethods[i]) if (methodID == g_7zSfxMethods[i])
return true; return true;
return false; return false;
}; }
static UInt64 GetMaxRamSizeForProgram() static UInt64 GetMaxRamSizeForProgram()
{ {

View File

@@ -22,7 +22,7 @@ namespace NCompressDialog
kAdd, kAdd,
kUpdate, kUpdate,
kFresh, kFresh,
kSynchronize, kSynchronize
}; };
} }
struct CInfo struct CInfo

View File

@@ -106,7 +106,7 @@ HRESULT CThreadExtracting::ProcessVirt()
} }
#endif #endif
return res; return res;
}; }
HRESULT ExtractGUI( HRESULT ExtractGUI(
CCodecs *codecs, CCodecs *codecs,

View File

@@ -172,7 +172,7 @@ HRESULT CUpdateCallbackGUI::CloseProgress()
{ {
ProgressDialog->MyClose(); ProgressDialog->MyClose();
return S_OK; return S_OK;
}; }
*/ */

View File

@@ -57,7 +57,7 @@ HRESULT CThreadUpdating::ProcessVirt()
if (ei.SystemError != S_OK && ei.SystemError != E_FAIL && ei.SystemError != E_ABORT) if (ei.SystemError != S_OK && ei.SystemError != E_FAIL && ei.SystemError != E_ABORT)
return ei.SystemError; return ei.SystemError;
return res; return res;
}; }
static void AddProp(CObjectVector<CProperty> &properties, const UString &name, const UString &value) static void AddProp(CObjectVector<CProperty> &properties, const UString &name, const UString &value)
{ {

View File

@@ -2,6 +2,7 @@ DIRS = \
Client7z\~ \ Client7z\~ \
Console\~ \ Console\~ \
Explorer\~ \ Explorer\~ \
Far\~ \
FileManager\~ \ FileManager\~ \
GUI\~ \ GUI\~ \

View File

@@ -10,8 +10,8 @@
#define COM_TRY_BEGIN try { #define COM_TRY_BEGIN try {
#define COM_TRY_END } catch(...) { return E_OUTOFMEMORY; } #define COM_TRY_END } catch(...) { return E_OUTOFMEMORY; }
// catch(const CNewException &) { return E_OUTOFMEMORY; }\ // catch(const CNewException &) { return E_OUTOFMEMORY; }
// catch(const CSystemException &e) { return e.ErrorCode; }\ // catch(const CSystemException &e) { return e.ErrorCode; }
// catch(...) { return E_FAIL; } // catch(...) { return E_FAIL; }
#endif #endif

View File

@@ -59,7 +59,7 @@ public:
struct CCommandForm struct CCommandForm
{ {
wchar_t *IDString; const wchar_t *IDString;
bool PostStringMode; bool PostStringMode;
}; };

View File

@@ -38,7 +38,7 @@ inline int operator!=(REFGUID g1, REFGUID g2) { return !(g1 == g2); }
#define MY_EXTERN_C extern #define MY_EXTERN_C extern
#endif #endif
#endif // GUID_DEFINED #endif
#ifdef DEFINE_GUID #ifdef DEFINE_GUID

View File

@@ -166,7 +166,7 @@ class CObjectVector: public CPointerVector
public: public:
CObjectVector() {}; CObjectVector() {};
~CObjectVector() { Clear(); }; ~CObjectVector() { Clear(); };
CObjectVector(const CObjectVector &v) { *this = v; } CObjectVector(const CObjectVector &v): CPointerVector() { *this = v; }
CObjectVector& operator=(const CObjectVector &v) CObjectVector& operator=(const CObjectVector &v)
{ {
Clear(); Clear();

View File

@@ -53,7 +53,7 @@ AString GUIDToStringA(REFGUID guid);
#define GUIDToString GUIDToStringW #define GUIDToString GUIDToStringW
#else #else
#define GUIDToString GUIDToStringA #define GUIDToString GUIDToStringA
#endif // !UNICODE #endif
HRESULT StringToGUIDW(const wchar_t *string, GUID &classID); HRESULT StringToGUIDW(const wchar_t *string, GUID &classID);
HRESULT StringToGUIDA(const char *string, GUID &classID); HRESULT StringToGUIDA(const char *string, GUID &classID);
@@ -61,7 +61,7 @@ HRESULT StringToGUIDA(const char *string, GUID &classID);
#define StringToGUID StringToGUIDW #define StringToGUID StringToGUIDW
#else #else
#define StringToGUID StringToGUIDA #define StringToGUID StringToGUIDA
#endif // !UNICODE #endif
}} }}

View File

@@ -4,7 +4,6 @@
#define __WINDOWS_CONTROL_EDIT_H #define __WINDOWS_CONTROL_EDIT_H
#include "Windows/Window.h" #include "Windows/Window.h"
#include "Windows/Defs.h"
namespace NWindows { namespace NWindows {
namespace NControl { namespace NControl {
@@ -12,8 +11,7 @@ namespace NControl {
class CEdit: public CWindow class CEdit: public CWindow
{ {
public: public:
void SetPasswordChar(WPARAM c) void SetPasswordChar(WPARAM c) { SendMessage(EM_SETPASSWORDCHAR, c); }
{ SendMessage(EM_SETPASSWORDCHAR, c); }
}; };
}} }}

View File

@@ -83,4 +83,3 @@ public:
}} }}
#endif #endif

View File

@@ -9,6 +9,4 @@ namespace NFile {
namespace NMapping { namespace NMapping {
}}} }}}

View File

@@ -8,7 +8,7 @@
#ifndef _UNICODE #ifndef _UNICODE
extern bool g_IsNT; extern bool g_IsNT;
#endif _UNICODE #endif
namespace NWindows { namespace NWindows {

View File

@@ -168,7 +168,7 @@ HRESULT CPropVariant::Copy(const PROPVARIANT* pSrc)
memmove((PROPVARIANT*)this, pSrc, sizeof(PROPVARIANT)); memmove((PROPVARIANT*)this, pSrc, sizeof(PROPVARIANT));
return S_OK; return S_OK;
} }
return ::VariantCopy((tagVARIANT *)this, (tagVARIANT *)(pSrc)); return ::VariantCopy((tagVARIANT *)this, (tagVARIANT *)const_cast<PROPVARIANT *>(pSrc));
} }

View File

@@ -399,7 +399,7 @@ FilesInfo
UINT64 DataIndex UINT64 DataIndex
[] []
for(Definded Items) for(Definded Items)
UINT32 Time UINT64 Time
[] []
kNames: (0x11) kNames: (0x11)

View File

@@ -10,8 +10,8 @@ AppName = "7-Zip"
InstallDir = %CE1%\%AppName% InstallDir = %CE1%\%AppName%
[Strings] [Strings]
AppVer = "9.16" AppVer = "9.17"
AppDate = "2010-09-07" AppDate = "2010-10-04"
[CEDevice] [CEDevice]
; ProcessorType = 2577 ; ARM ; ProcessorType = 2577 ; ARM

View File

@@ -2,7 +2,7 @@
;Defines ;Defines
!define VERSION_MAJOR 9 !define VERSION_MAJOR 9
!define VERSION_MINOR 16 !define VERSION_MINOR 17
!define VERSION_POSTFIX_FULL " beta" !define VERSION_POSTFIX_FULL " beta"
!ifdef WIN64 !ifdef WIN64
!ifdef IA64 !ifdef IA64

View File

@@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<?define VerMajor = "9" ?> <?define VerMajor = "9" ?>
<?define VerMinor = "16" ?> <?define VerMinor = "17" ?>
<?define VerBuild = "00" ?> <?define VerBuild = "00" ?>
<?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?> <?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?>
<?define MmHex = "0$(var.VerMajor)$(var.VerMinor)" ?> <?define MmHex = "0$(var.VerMajor)$(var.VerMinor)" ?>

View File

@@ -1,6 +1,14 @@
Sources history of the 7-Zip Sources history of the 7-Zip
---------------------------- ----------------------------
9.17 2010-10-04
-------------------------
- IStream.h::IOutStream::
STDMETHOD(SetSize)(Int64 newSize) PURE;
was changed to
STDMETHOD(SetSize)(UInt64 newSize) PURE;
9.09 2009-12-12 9.09 2009-12-12
------------------------- -------------------------
- The bug was fixed: - The bug was fixed:

View File

@@ -1,4 +1,4 @@
LZMA SDK 9.16 LZMA SDK 9.17
------------- -------------
LZMA SDK provides the documentation, samples, header files, libraries, LZMA SDK provides the documentation, samples, header files, libraries,

View File

@@ -1,4 +1,4 @@
7-Zip 9.16 Sources 7-Zip 9.17 Sources
------------------ ------------------
7-Zip is a file archiver for Windows. 7-Zip is a file archiver for Windows.