This commit is contained in:
Igor Pavlov
2015-01-03 00:00:00 +00:00
committed by Kornel Lesiński
parent 7e021179cd
commit 0713a3ab80
153 changed files with 2744 additions and 1485 deletions

View File

@@ -1,9 +1,9 @@
#define MY_VER_MAJOR 9
#define MY_VER_MINOR 36
#define MY_VER_MINOR 38
#define MY_VER_BUILD 00
#define MY_VERSION "9.36 beta"
// #define MY_7ZIP_VERSION "9.36"
#define MY_DATE "2014-12-26"
#define MY_VERSION "9.38 beta"
// #define MY_7ZIP_VERSION "9.38"
#define MY_DATE "2015-01-03"
#undef MY_COPYRIGHT
#undef MY_VERSION_COPYRIGHT_DATE
#define MY_COPYRIGHT ": Igor Pavlov : Public domain"

View File

@@ -1,5 +1,5 @@
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
2013-11-12 : Igor Pavlov : Public domain */
2014-12-29 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -457,9 +457,8 @@ static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE HashThreadFunc2(void *p) { Has
static THREAD_FUNC_RET_TYPE THREAD_FUNC_CALL_TYPE BtThreadFunc2(void *p)
{
Byte allocaDummy[0x180];
int i = 0;
for (i = 0; i < 16; i++)
allocaDummy[i] = (Byte)i;
allocaDummy[0] = 0;
allocaDummy[1] = allocaDummy[0];
BtThreadFunc((CMatchFinderMt *)p);
return 0;
}

View File

@@ -1,5 +1,5 @@
/* LzmaDec.c -- LZMA Decoder
2011-09-03 : Igor Pavlov : Public domain */
2015-01-01 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -195,7 +195,7 @@ static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte
}
else
{
unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
unsigned matchByte = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)];
unsigned offs = 0x100;
state -= (state < 10) ? 3 : 6;
symbol = 1;

View File

@@ -1,5 +1,5 @@
/* LzmaEnc.c -- LZMA Encoder
2012-11-20 : Igor Pavlov : Public domain */
2014-12-29 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -20,7 +20,7 @@
#endif
#ifdef SHOW_STAT
static int ttt = 0;
static unsigned g_STAT_OFFSET = 0;
#endif
#define kBlockSizeMax ((1 << LZMA_NUM_BLOCK_SIZE_BITS) - 1)
@@ -518,7 +518,7 @@ static void RangeEnc_FlushStream(CRangeEnc *p)
static void MY_FAST_CALL RangeEnc_ShiftLow(CRangeEnc *p)
{
if ((UInt32)p->low < (UInt32)0xFF000000 || (int)(p->low >> 32) != 0)
if ((UInt32)p->low < (UInt32)0xFF000000 || (unsigned)(p->low >> 32) != 0)
{
Byte temp = p->cache;
do
@@ -544,7 +544,7 @@ static void RangeEnc_FlushData(CRangeEnc *p)
RangeEnc_ShiftLow(p);
}
static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, int numBits)
static void RangeEnc_EncodeDirectBits(CRangeEnc *p, UInt32 value, unsigned numBits)
{
do
{
@@ -813,9 +813,10 @@ static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, UInt32 symbol, UInt32
static void MovePos(CLzmaEnc *p, UInt32 num)
{
#ifdef SHOW_STAT
ttt += num;
g_STAT_OFFSET += num;
printf("\n MovePos %d", num);
#endif
if (num != 0)
{
p->additionalOffset += num;
@@ -828,15 +829,17 @@ static UInt32 ReadMatchDistances(CLzmaEnc *p, UInt32 *numDistancePairsRes)
UInt32 lenRes = 0, numPairs;
p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches);
#ifdef SHOW_STAT
printf("\n i = %d numPairs = %d ", ttt, numPairs / 2);
ttt++;
printf("\n i = %d numPairs = %d ", g_STAT_OFFSET, numPairs / 2);
g_STAT_OFFSET++;
{
UInt32 i;
for (i = 0; i < numPairs; i += 2)
printf("%2d %6d | ", p->matches[i], p->matches[i + 1]);
}
#endif
if (numPairs > 0)
{
lenRes = p->matches[numPairs - 2];
@@ -1907,12 +1910,10 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, Bool useLimits, UInt32 maxPackSize
static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
{
UInt32 beforeSize = kNumOpts;
Bool btMode;
if (!RangeEnc_Alloc(&p->rc, alloc))
return SZ_ERROR_MEM;
btMode = (p->matchFinderBase.btMode != 0);
#ifndef _7ZIP_ST
p->mtMode = (p->multiThread && !p->fastMode && btMode);
p->mtMode = (p->multiThread && !p->fastMode && (p->matchFinderBase.btMode != 0));
#endif
{
@@ -2167,9 +2168,8 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
#ifndef _7ZIP_ST
Byte allocaDummy[0x300];
int i = 0;
for (i = 0; i < 16; i++)
allocaDummy[i] = (Byte)i;
allocaDummy[0] = 0;
allocaDummy[1] = allocaDummy[0];
#endif
for (;;)

View File

@@ -1,5 +1,5 @@
/* 7zMain.c - Test application for 7z Decoder
2014-06-17 : Igor Pavlov : Public domain */
2015-01-02 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -281,7 +281,7 @@ static void ConvertFileTimeToString(const CNtfsFileTime *nt, char *s)
UIntToStr_2(s, sec); s[2] = 0;
}
void PrintError(char *sz)
void PrintError(const char *sz)
{
printf("\nERROR: %s\n", sz);
}
@@ -368,11 +368,11 @@ int MY_CDECL main(int numargs, char *args[])
if (res == SZ_OK)
{
char *command = args[1];
int listCommand = 0, testCommand = 0, extractCommand = 0, fullPaths = 0;
int listCommand = 0, testCommand = 0, fullPaths = 0;
if (strcmp(command, "l") == 0) listCommand = 1;
else if (strcmp(command, "t") == 0) testCommand = 1;
else if (strcmp(command, "e") == 0) extractCommand = 1;
else if (strcmp(command, "x") == 0) { extractCommand = 1; fullPaths = 1; }
else if (strcmp(command, "e") == 0) { }
else if (strcmp(command, "x") == 0) { fullPaths = 1; }
else
{
PrintError("incorrect command");

View File

@@ -1,5 +1,5 @@
/* LzmaUtil.c -- Test application for LZMA compression
2014-06-17 : Igor Pavlov : Public domain */
2014-12-31 : Igor Pavlov : Public domain */
#include "../../Precomp.h"
@@ -92,7 +92,7 @@ static SRes Decode2(CLzmaDec *state, ISeqOutStream *outStream, ISeqInStream *inS
outPos = 0;
if (res != SZ_OK || thereIsSize && unpackSize == 0)
if (res != SZ_OK || (thereIsSize && unpackSize == 0))
return res;
if (inProcessed == 0 && outProcessed == 0)

8
C/Xz.h
View File

@@ -1,5 +1,5 @@
/* Xz.h - Xz interface
2013-11-19 : Igor Pavlov : Public domain */
2014-12-30 : Igor Pavlov : Public domain */
#ifndef __XZ_H
#define __XZ_H
@@ -229,8 +229,8 @@ void XzUnpacker_Free(CXzUnpacker *p);
/*
finishMode:
It has meaning only if the decoding reaches output limit (*destLen).
LZMA_FINISH_ANY - use smallest number of input bytes
LZMA_FINISH_END - read EndOfStream marker after decoding
CODER_FINISH_ANY - use smallest number of input bytes
CODER_FINISH_END - read EndOfStream marker after decoding
Returns:
SZ_OK
@@ -255,7 +255,7 @@ Returns:
SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
const Byte *src, SizeT *srcLen, /* int srcWasFinished, */ int finishMode,
const Byte *src, SizeT *srcLen, ECoderFinishMode finishMode,
ECoderStatus *status);
Bool XzUnpacker_IsStreamWasFinished(CXzUnpacker *p);

View File

@@ -1,5 +1,5 @@
/* XzDec.c -- Xz Decode
2014-05-09 : Igor Pavlov : Public domain */
2014-12-30 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -209,7 +209,7 @@ SRes BraState_SetFromMethod(IStateCoder *p, UInt64 id, int encodeMode, ISzAlloc
id != XZ_ID_SPARC)
return SZ_ERROR_UNSUPPORTED;
p->p = 0;
decoder = alloc->Alloc(alloc, sizeof(CBraState));
decoder = (CBraState *)alloc->Alloc(alloc, sizeof(CBraState));
if (decoder == 0)
return SZ_ERROR_MEM;
decoder->methodId = (UInt32)id;
@@ -315,7 +315,7 @@ static SRes Lzma2State_Code(void *pp, Byte *dest, SizeT *destLen, const Byte *sr
static SRes Lzma2State_SetFromMethod(IStateCoder *p, ISzAlloc *alloc)
{
CLzma2Dec *decoder = alloc->Alloc(alloc, sizeof(CLzma2Dec));
CLzma2Dec *decoder = (CLzma2Dec *)alloc->Alloc(alloc, sizeof(CLzma2Dec));
p->p = decoder;
if (decoder == 0)
return SZ_ERROR_MEM;
@@ -400,7 +400,7 @@ SRes MixCoder_Code(CMixCoder *p, Byte *dest, SizeT *destLen,
if (p->buf == 0)
{
p->buf = p->alloc->Alloc(p->alloc, CODER_BUF_SIZE * (MIXCODER_NUM_FILTERS_MAX - 1));
p->buf = (Byte *)p->alloc->Alloc(p->alloc, CODER_BUF_SIZE * (MIXCODER_NUM_FILTERS_MAX - 1));
if (p->buf == 0)
return SZ_ERROR_MEM;
}
@@ -624,7 +624,7 @@ void XzUnpacker_Free(CXzUnpacker *p)
}
SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen,
const Byte *src, SizeT *srcLen, int finishMode, ECoderStatus *status)
const Byte *src, SizeT *srcLen, ECoderFinishMode finishMode, ECoderStatus *status)
{
SizeT destLenOrig = *destLen;
SizeT srcLenOrig = *srcLen;

View File

@@ -1,5 +1,5 @@
/* XzEnc.c -- Xz Encode
2013-11-12 : Igor Pavlov : Public domain */
2014-12-30 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -134,7 +134,7 @@ SRes Xz_AddIndexRecord(CXzStream *p, UInt64 unpackSize, UInt64 totalSize, ISzAll
CXzBlockSizes *blocks;
if (newSize / sizeof(CXzBlockSizes) != num)
return SZ_ERROR_MEM;
blocks = alloc->Alloc(alloc, newSize);
blocks = (CXzBlockSizes *)alloc->Alloc(alloc, newSize);
if (blocks == 0)
return SZ_ERROR_MEM;
if (p->numBlocks != 0)

View File

@@ -1,5 +1,5 @@
/* XzIn.c - Xz input
2013-11-12 : Igor Pavlov : Public domain */
2014-12-30 : Igor Pavlov : Public domain */
#include "Precomp.h"
@@ -72,7 +72,7 @@ SRes XzBlock_ReadFooter(CXzBlock *p, CXzStreamFlags f, ISeqInStream *inStream)
static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *alloc)
{
size_t i, numBlocks, crcStartPos, pos = 1;
size_t i, numBlocks, pos = 1;
UInt32 crc;
if (size < 5 || buf[0] != 0)
@@ -91,7 +91,6 @@ static SRes Xz_ReadIndex2(CXzStream *p, const Byte *buf, size_t size, ISzAlloc *
return SZ_ERROR_ARCHIVE;
}
crcStartPos = pos;
Xz_Free(p, alloc);
if (numBlocks != 0)
{
@@ -292,7 +291,8 @@ SRes Xzs_ReadBackward(CXzs *p, ILookInStream *stream, Int64 *startOffset, ICompr
if (data == 0)
return SZ_ERROR_MEM;
p->numAllocated = newNum;
memcpy(data, p->streams, p->num * sizeof(CXzStream));
if (p->num != 0)
memcpy(data, p->streams, p->num * sizeof(CXzStream));
alloc->Free(alloc, p->streams);
p->streams = (CXzStream *)data;
}

View File

@@ -321,13 +321,13 @@ STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data
if (/* _db.IsTree && propID == kpidName ||
!_db.IsTree && */ propID == kpidPath)
{
const wchar_t *name = _db.GetName(index);
if (name)
if (_db.NameOffsets && _db.NamesBuf)
{
size_t size = (_db.NameOffsets[index + 1] - _db.NameOffsets[index]) * 2;
size_t offset = _db.NameOffsets[index];
size_t size = (_db.NameOffsets[index + 1] - offset) * 2;
if (size < ((UInt32)1 << 31))
{
*data = (void *)name;
*data = (const void *)(_db.NamesBuf + offset * 2);
*dataSize = (UInt32)size;
*propType = NPropDataType::kUtf16z;
}
@@ -607,7 +607,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
}
*/
case kpidPath: return _db.GetPath(index, value);
case kpidPath: return _db.GetPath_Prop(index, value);
#ifndef _SFX
case kpidMethod: return SetMethodToProp(_db.FileIndexToFolderIndexMap[index2], value);
case kpidBlock:

View File

@@ -102,7 +102,7 @@ class CHandler:
{
public:
MY_QUERYINTERFACE_BEGIN2(IInArchive)
// MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps)
MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps)
#ifdef __7Z_SET_PROPERTIES
MY_QUERYINTERFACE_ENTRY(ISetProperties)
#endif

View File

@@ -301,10 +301,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
const CFileItem &fi = db->Files[ui.IndexInArchive];
if (!ui.NewProps)
{
NCOM::CPropVariant prop;
RINOK(_db.GetPath(ui.IndexInArchive, &prop));
if (prop.vt == VT_BSTR)
name = prop.bstrVal;
_db.GetPath(ui.IndexInArchive, name);
}
ui.IsDir = fi.IsDir;
ui.Size = fi.Size;

View File

@@ -2,6 +2,12 @@
#include "StdAfx.h"
#ifdef _WIN32
#include <wchar.h>
#else
#include <ctype.h>
#endif
#include "../../../../C/7zCrc.h"
#include "../../../../C/CpuArch.h"
@@ -496,26 +502,83 @@ void CFolders::ParseFolderInfo(unsigned folderIndex, CFolder &folder) const
}
HRESULT CDatabase::GetPath(unsigned index, PROPVARIANT *path) const
void CDatabase::GetPath(unsigned index, UString &path) const
{
path.Empty();
if (!NameOffsets || !NamesBuf)
return;
size_t offset = NameOffsets[index];
size_t size = NameOffsets[index + 1] - offset - 1;
if (size >= (1 << 20))
return;
wchar_t *s = path.GetBuffer((unsigned)size);
const Byte *p = ((const Byte *)NamesBuf + offset * 2);
#if defined(_WIN32) && defined(MY_CPU_LE)
wmemcpy(s, (const wchar_t *)p, size);
#else
for (size_t i = 0; i < size; i++)
{
*s = Get16(p);
p += 2;
s++;
}
#endif
path.ReleaseBuffer((unsigned)size);
}
HRESULT CDatabase::GetPath_Prop(unsigned index, PROPVARIANT *path) const throw()
{
PropVariant_Clear(path);
if (!NameOffsets || !NamesBuf)
return S_OK;
size_t offset = NameOffsets[index];
size_t size = NameOffsets[index + 1] - offset;
if (size >= (1 << 14))
return S_OK;
RINOK(PropVarEm_Alloc_Bstr(path, (unsigned)size - 1));
wchar_t *s = path->bstrVal;
const Byte *p = ((const Byte *)NamesBuf + offset * 2);
for (size_t i = 0; i < size; i++)
{
wchar_t c = Get16(p);
p += 2;
#if WCHAR_PATH_SEPARATOR != L'/'
if (c == L'/')
c = WCHAR_PATH_SEPARATOR;
#endif
*s++ = c;
}
return S_OK;
/*
unsigned cur = index;
unsigned size = 0;
// for (int i = 0;; i++)
for (int i = 0;; i++)
{
size_t len = NameOffsets[cur + 1] - NameOffsets[cur];
size += (unsigned)len;
if (/* i > 256 || */ len > (1 << 12) || size > (1 << 14))
if (i > 256 || len > (1 << 14) || size > (1 << 14))
return PropVarEm_Set_Str(path, "[TOO-LONG]");
/*
cur = Files[cur].Parent;
if (cur < 0)
break;
*/
}
size--;
@@ -539,16 +602,13 @@ HRESULT CDatabase::GetPath(unsigned index, PROPVARIANT *path) const
*s = c;
}
while (--len);
/*
const CFileItem &file = Files[cur];
cur = file.Parent;
if (cur < 0)
*/
return S_OK;
/*
*(--s) = (file.IsAltStream ? ':' : WCHAR_PATH_SEPARATOR);
*/
}
*/
}
void CInArchive::WaitId(UInt64 id)

View File

@@ -111,7 +111,7 @@ struct CDatabase: public CFolders
*/
CByteBuffer NamesBuf;
CObjArray<size_t> NameOffsets; // numFiles + 1, conatins offsets of UINt16 symbols.
CObjArray<size_t> NameOffsets; // numFiles + 1, offsets of utf-16 symbols
/*
void ClearSecure()
@@ -148,14 +148,15 @@ struct CDatabase: public CFolders
bool IsItemAnti(unsigned index) const { return (index < IsAnti.Size() && IsAnti[index]); }
// bool IsItemAux(unsigned index) const { return (index < IsAux.Size() && IsAux[index]); }
const wchar_t * GetName(unsigned index) const
const void * GetName(unsigned index) const
{
if (!NameOffsets || !NamesBuf)
return NULL;
return (const wchar_t *)(const Byte *)NamesBuf + NameOffsets[index];
return (const void *)((const Byte *)NamesBuf + NameOffsets[index] * 2);
};
HRESULT GetPath(unsigned index, PROPVARIANT *path) const;
void GetPath(unsigned index, UString &path) const;
HRESULT GetPath_Prop(unsigned index, PROPVARIANT *path) const throw();
};
struct CInArchiveInfo

View File

@@ -1018,7 +1018,7 @@ HRESULT Update(
else
{
GetFile(*db, ui.IndexInArchive, file, file2);
name = db->GetName(ui.IndexInArchive);
db->GetPath(ui.IndexInArchive, name);
}
/*
@@ -1152,7 +1152,8 @@ HRESULT Update(
CFileItem file;
CFileItem2 file2;
GetFile(*db, fi, file, file2);
UString name = db->GetName(fi);
UString name;
db->GetPath(fi, name);
if (file.HasStream)
{
indexInFolder++;
@@ -1278,7 +1279,7 @@ HRESULT Update(
else
{
GetFile(*db, ui.IndexInArchive, file, file2);
name = db->GetName(ui.IndexInArchive);
db->GetPath(ui.IndexInArchive, name);
}
if (file2.IsAnti || file.IsDir)
return E_FAIL;

View File

@@ -114,6 +114,7 @@ API_FUNC_static_IsArc IsArc_Apm(const Byte *p, size_t size)
return k_IsArc_Res_NO;
return k_IsArc_Res_YES;
}
}
HRESULT CHandler::ReadTables(IInStream *stream)
{

View File

@@ -15,7 +15,7 @@ static unsigned g_NumArcs = 0;
static unsigned g_DefaultArcIndex = 0;
static const CArcInfo *g_Arcs[kNumArcsMax];
void RegisterArc(const CArcInfo *arcInfo)
void RegisterArc(const CArcInfo *arcInfo) throw()
{
if (g_NumArcs < kNumArcsMax)
{

View File

@@ -160,6 +160,7 @@ API_FUNC_static_IsArc IsArc_Arj(const Byte *p, size_t size)
return k_IsArc_Res_YES;
}
}
static HRESULT ReadString(const Byte *p, unsigned &size, AString &res)
{

View File

@@ -131,6 +131,7 @@ API_FUNC_static_IsArc IsArc_BZip2(const Byte *p, size_t size)
return k_IsArc_Res_YES;
return k_IsArc_Res_NO;
}
}
STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *)
{

View File

@@ -15,14 +15,19 @@ class CMultiStream:
UInt64 _pos;
UInt64 _totalLength;
unsigned _streamIndex;
public:
struct CSubStreamInfo
{
CMyComPtr<IInStream> Stream;
UInt64 Size;
UInt64 GlobalOffset;
UInt64 LocalPos;
CSubStreamInfo(): Size(0), GlobalOffset(0), LocalPos(0) {}
};
CObjectVector<CSubStreamInfo> Streams;
HRESULT Init()

View File

@@ -120,10 +120,10 @@ struct CItem
UInt64 HeaderPos;
bool IsBin() const { return Type == k_Type_BinLe || Type == k_Type_BinBe; }
bool IsCrcFormat() const { return Type == k_Type_HexCrc; };
bool IsCrcFormat() const { return Type == k_Type_HexCrc; }
bool IsDir() const { return (Mode & 0170000) == 0040000; }
bool IsTrailer() const { return strcmp(Name, kName_TRAILER) == 0; }
UInt64 GetDataPosition() const { return HeaderPos + HeaderSize; };
UInt64 GetDataPosition() const { return HeaderPos + HeaderSize; }
};
enum EErrorType
@@ -273,6 +273,7 @@ API_FUNC_static_IsArc IsArc_Cpio(const Byte *p, size_t size)
return k_IsArc_Res_NO;
return k_IsArc_Res_YES;
}
}
#define READ_STREAM(_dest_, _size_) \
{ size_t processed = (_size_); RINOK(Read(_dest_, &processed)); \

View File

@@ -2,6 +2,10 @@
#include "StdAfx.h"
#if defined(_7ZIP_LARGE_PAGES)
#include "../../../C/Alloc.h"
#endif
#include "../../Common/MyInitGuid.h"
#include "../../Common/ComTry.h"
@@ -40,7 +44,7 @@ STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
STDAPI SetLargePageMode()
{
#if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
#if defined(_7ZIP_LARGE_PAGES)
SetLargePageSize();
#endif
return S_OK;

View File

@@ -4,7 +4,7 @@
#include "../../Common/MyInitGuid.h"
#if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
#if defined(_7ZIP_LARGE_PAGES)
#include "../../../C/Alloc.h"
#endif
@@ -67,7 +67,7 @@ STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
STDAPI SetLargePageMode()
{
#if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
#if defined(_7ZIP_LARGE_PAGES)
SetLargePageSize();
#endif
return S_OK;

View File

@@ -641,8 +641,8 @@ static const STATPROPSTG kProps[] =
{ NULL, kpidVa, VT_UI8 },
{ NULL, kpidType, VT_BSTR },
{ NULL, kpidCharacts, VT_BSTR }
, { L"Link Section", kpidLinkSection, VT_BSTR}
, { L"Info Section", kpidInfoSection, VT_BSTR}
, { (LPOLESTR)L"Link Section", kpidLinkSection, VT_BSTR}
, { (LPOLESTR)L"Info Section", kpidInfoSection, VT_BSTR}
};
IMP_IInArchive_Props_WITH_NAME

View File

@@ -118,6 +118,7 @@ API_FUNC_static_IsArc IsArc_Fat(const Byte *p, size_t size)
CHeader h;
return h.Parse(p) ? k_IsArc_Res_YES : k_IsArc_Res_NO;
}
}
bool CHeader::Parse(const Byte *p)
{
@@ -801,12 +802,12 @@ static const STATPROPSTG kArcProps[] =
{ NULL, kpidMTime, VT_FILETIME},
{ NULL, kpidVolumeName, VT_BSTR},
{ L"FATs", kpidNumFats, VT_UI4},
{ (LPOLESTR)L"FATs", kpidNumFats, VT_UI4},
{ NULL, kpidSectorSize, VT_UI4},
{ NULL, kpidId, VT_UI4},
// { L"OEM Name", kpidOemName, VT_BSTR},
// { L"Volume Name", kpidVolName, VT_BSTR},
// { L"File System Type", kpidFileSysType, VT_BSTR}
// { (LPOLESTR)L"OEM Name", kpidOemName, VT_BSTR},
// { (LPOLESTR)L"Volume Name", kpidVolName, VT_BSTR},
// { (LPOLESTR)L"File System Type", kpidFileSysType, VT_BSTR}
// { NULL, kpidSectorsPerTrack, VT_UI4},
// { NULL, kpidNumHeads, VT_UI4},
// { NULL, kpidHiddenSectors, VT_UI4}

View File

@@ -318,6 +318,7 @@ API_FUNC_static_IsArc IsArc_Gz(const Byte *p, size_t size)
return Is_Deflate(p, size);
}
}
HRESULT CItem::ReadHeader(NDecoder::CCOMCoder *stream)
{

View File

@@ -183,17 +183,26 @@ Notes:
Some IInArchive handlers will work incorrectly in that case.
*/
/* MSVC allows the code where there is throw() in declaration of function,
but there is no throw() in definition of function. */
#ifdef _MSC_VER
#define MY_NO_THROW_DECL_ONLY throw()
#else
#define MY_NO_THROW_DECL_ONLY
#endif
#define INTERFACE_IInArchive(x) \
STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openCallback) throw() x; \
STDMETHOD(Close)() throw() x; \
STDMETHOD(GetNumberOfItems)(UInt32 *numItems) throw() x; \
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) throw() x; \
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback) throw() x; \
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) throw() x; \
STDMETHOD(GetNumberOfProperties)(UInt32 *numProps) throw() x; \
STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) throw() x; \
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProps) throw() x; \
STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) throw() x;
STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openCallback) MY_NO_THROW_DECL_ONLY x; \
STDMETHOD(Close)() MY_NO_THROW_DECL_ONLY x; \
STDMETHOD(GetNumberOfItems)(UInt32 *numItems) MY_NO_THROW_DECL_ONLY x; \
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) MY_NO_THROW_DECL_ONLY x; \
STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback) MY_NO_THROW_DECL_ONLY x; \
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) MY_NO_THROW_DECL_ONLY x; \
STDMETHOD(GetNumberOfProperties)(UInt32 *numProps) MY_NO_THROW_DECL_ONLY x; \
STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) MY_NO_THROW_DECL_ONLY x; \
STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProps) MY_NO_THROW_DECL_ONLY x; \
STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) MY_NO_THROW_DECL_ONLY x;
ARCHIVE_INTERFACE(IInArchive, 0x60)
{
@@ -444,7 +453,7 @@ ARCHIVE_INTERFACE(IArchiveAllowTail, 0x05)
// #define k_IsArc_Res_YES_LOW_PROB 3
#define API_FUNC_IsArc EXTERN_C UInt32 WINAPI
#define API_FUNC_static_IsArc EXTERN_C static UInt32 WINAPI
#define API_FUNC_static_IsArc extern "C" { static UInt32 WINAPI
extern "C"
{

View File

@@ -219,6 +219,7 @@ API_FUNC_static_IsArc IsArc_Ihex(const Byte *p, size_t size)
return k_IsArc_Res_YES;
}
}
STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *)
{

View File

@@ -88,7 +88,7 @@ static void AddString(AString &s, const char *name, const Byte *p, unsigned size
}
}
#define ADD_STRING(n, v) AddString(s, n, vol. ## v, sizeof(vol. ## v))
#define ADD_STRING(n, v) AddString(s, n, vol. v, sizeof(vol. v))
static void AddErrorMessage(AString &s, const char *message)
{

View File

@@ -73,6 +73,7 @@ API_FUNC_static_IsArc IsArc_Lzh(const Byte *p, size_t size)
return k_IsArc_Res_NO;
return k_IsArc_Res_YES;
}
}
struct CItem
{

View File

@@ -332,6 +332,7 @@ API_FUNC_static_IsArc IsArc_Lzma(const Byte *p, size_t size)
return k_IsArc_Res_NO;
return k_IsArc_Res_YES;
}
}
API_FUNC_static_IsArc IsArc_Lzma86(const Byte *p, size_t size)
{
@@ -342,6 +343,7 @@ API_FUNC_static_IsArc IsArc_Lzma86(const Byte *p, size_t size)
return k_IsArc_Res_NO;
return IsArc_Lzma(p + 1, size - 1);
}
}
STDMETHODIMP CHandler::Open(IInStream *inStream, const UInt64 *, IArchiveOpenCallback *)
{

View File

@@ -342,9 +342,9 @@ static const STATPROPSTG kProps[] =
{ NULL, kpidSize, VT_UI8},
{ NULL, kpidFileSystem, VT_BSTR},
{ NULL, kpidOffset, VT_UI8},
{ L"Primary", kpidPrimary, VT_BOOL},
{ L"Begin CHS", kpidBegChs, VT_BSTR},
{ L"End CHS", kpidEndChs, VT_BSTR}
{ (LPOLESTR)L"Primary", kpidPrimary, VT_BOOL},
{ (LPOLESTR)L"Begin CHS", kpidBegChs, VT_BSTR},
{ (LPOLESTR)L"End CHS", kpidEndChs, VT_BSTR}
};
IMP_IInArchive_Props_WITH_NAME

View File

@@ -63,7 +63,7 @@ public:
}
HRESULT CDecoder::SetToPos(UInt64 pos, ICompressProgressInfo *progress); // for solid
HRESULT SetToPos(UInt64 pos, ICompressProgressInfo *progress); // for solid
HRESULT Decode(CByteBuffer *outBuf, bool unpackSizeDefined, UInt32 unpackSize,
ISequentialOutStream *realOutStream, ICompressProgressInfo *progress,
UInt32 &packSizeRes, UInt32 &unpackSizeRes);

View File

@@ -582,13 +582,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
if (!dataError)
{
UInt32 unpackSize = 0;
bool unpackSize_Defined = false;
// UInt32 unpackSize = 0;
// bool unpackSize_Defined = false;
bool writeToTemp1 = writeToTemp;
if (item.IsUninstaller)
{
unpackSize = item.PatchSize;
unpackSize_Defined = true;
// unpackSize = item.PatchSize;
// unpackSize_Defined = true;
if (!readFromTemp)
writeToTemp = true;
writeToTemp1 = writeToTemp;

View File

@@ -3777,7 +3777,7 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
for (UInt32 j = i - 1; j >= kkk + 3; j--)
{
const Byte *pCmd = p - kCmdSize * (kkk - j);
const Byte *pCmd = p + kCmdSize * (j - kkk);
AddParam(GET_CMD_PARAM(pCmd, 0));
}
NewLine();

View File

@@ -97,11 +97,11 @@ bool CHeader::Parse(const Byte *p)
if (p[0x1FE] != 0x55 || p[0x1FF] != 0xAA)
return false;
int codeOffset = 0;
// int codeOffset = 0;
switch (p[0])
{
case 0xE9: codeOffset = 3 + (Int16)Get16(p + 1); break;
case 0xEB: if (p[2] != 0x90) return false; codeOffset = 2 + (int)(signed char)p[1]; break;
case 0xE9: /* codeOffset = 3 + (Int16)Get16(p + 1); */ break;
case 0xEB: if (p[2] != 0x90) return false; /* codeOffset = 2 + (int)(signed char)p[1]; */ break;
default: return false;
}
unsigned sectorsPerClusterLog;
@@ -2175,20 +2175,20 @@ static const STATPROPSTG kProps[] =
// { NULL, kpidLink, VT_BSTR},
// { L"Link 2", kpidLink2, VT_BSTR},
// { L"Link Type", kpidLinkType, VT_UI2},
// { (LPOLESTR)L"Link 2", kpidLink2, VT_BSTR},
// { (LPOLESTR)L"Link Type", kpidLinkType, VT_UI2},
{ NULL, kpidINode, VT_UI8},
{ NULL, kpidMTime, VT_FILETIME},
{ NULL, kpidCTime, VT_FILETIME},
{ NULL, kpidATime, VT_FILETIME},
// { L"Record Modified", kpidRecMTime, VT_FILETIME},
// { (LPOLESTR)L"Record Modified", kpidRecMTime, VT_FILETIME},
// { L"Modified 2", kpidMTime2, VT_FILETIME},
// { L"Created 2", kpidCTime2, VT_FILETIME},
// { L"Accessed 2", kpidATime2, VT_FILETIME},
// { L"Record Modified 2", kpidRecMTime2, VT_FILETIME},
// { (LPOLESTR)L"Modified 2", kpidMTime2, VT_FILETIME},
// { (LPOLESTR)L"Created 2", kpidCTime2, VT_FILETIME},
// { (LPOLESTR)L"Accessed 2", kpidATime2, VT_FILETIME},
// { (LPOLESTR)L"Record Modified 2", kpidRecMTime2, VT_FILETIME},
{ NULL, kpidAttrib, VT_UI4},
{ NULL, kpidNumBlocks, VT_UI4},
@@ -2223,7 +2223,7 @@ static const STATPROPSTG kArcProps[] =
{ NULL, kpidFileSystem, VT_BSTR},
{ NULL, kpidClusterSize, VT_UI4},
{ NULL, kpidSectorSize, VT_UI4},
{ L"Record Size", kpidRecordSize, VT_UI4},
{ (LPOLESTR)L"Record Size", kpidRecordSize, VT_UI4},
{ NULL, kpidHeadersSize, VT_UI8},
{ NULL, kpidCTime, VT_FILETIME},
{ NULL, kpidId, VT_UI8},

View File

@@ -784,27 +784,27 @@ static const STATPROPSTG kArcProps[] =
{ NULL, kpidChecksum, VT_UI4},
{ NULL, kpidName, VT_BSTR},
{ L"Image Size", kpidImageSize, VT_UI4},
{ L"Section Alignment", kpidSectAlign, VT_UI4},
{ L"File Alignment", kpidFileAlign, VT_UI4},
{ L"Code Size", kpidCodeSize, VT_UI4},
{ L"Initialized Data Size", kpidInitDataSize, VT_UI4},
{ L"Uninitialized Data Size", kpidUnInitDataSize, VT_UI4},
{ L"Linker Version", kpidLinkerVer, VT_BSTR},
{ L"OS Version", kpidOsVer, VT_BSTR},
{ L"Image Version", kpidImageVer, VT_BSTR},
{ L"Subsystem Version", kpidSubsysVer, VT_BSTR},
{ L"Subsystem", kpidSubSystem, VT_BSTR},
{ L"DLL Characteristics", kpidDllCharacts, VT_BSTR},
{ L"Stack Reserve", kpidStackReserve, VT_UI8},
{ L"Stack Commit", kpidStackCommit, VT_UI8},
{ L"Heap Reserve", kpidHeapReserve, VT_UI8},
{ L"Heap Commit", kpidHeapCommit, VT_UI8},
{ L"Image Base", kpidImageBase, VT_UI8},
{ (LPOLESTR)L"Image Size", kpidImageSize, VT_UI4},
{ (LPOLESTR)L"Section Alignment", kpidSectAlign, VT_UI4},
{ (LPOLESTR)L"File Alignment", kpidFileAlign, VT_UI4},
{ (LPOLESTR)L"Code Size", kpidCodeSize, VT_UI4},
{ (LPOLESTR)L"Initialized Data Size", kpidInitDataSize, VT_UI4},
{ (LPOLESTR)L"Uninitialized Data Size", kpidUnInitDataSize, VT_UI4},
{ (LPOLESTR)L"Linker Version", kpidLinkerVer, VT_BSTR},
{ (LPOLESTR)L"OS Version", kpidOsVer, VT_BSTR},
{ (LPOLESTR)L"Image Version", kpidImageVer, VT_BSTR},
{ (LPOLESTR)L"Subsystem Version", kpidSubsysVer, VT_BSTR},
{ (LPOLESTR)L"Subsystem", kpidSubSystem, VT_BSTR},
{ (LPOLESTR)L"DLL Characteristics", kpidDllCharacts, VT_BSTR},
{ (LPOLESTR)L"Stack Reserve", kpidStackReserve, VT_UI8},
{ (LPOLESTR)L"Stack Commit", kpidStackCommit, VT_UI8},
{ (LPOLESTR)L"Heap Reserve", kpidHeapReserve, VT_UI8},
{ (LPOLESTR)L"Heap Commit", kpidHeapCommit, VT_UI8},
{ (LPOLESTR)L"Image Base", kpidImageBase, VT_UI8},
{ NULL, kpidComment, VT_BSTR},
// { L"Address Of Entry Point", kpidAddressOfEntryPoint, VT_UI8},
// { L"Base Of Code", kpidBaseOfCode, VT_UI8},
// { L"Base Of Data", kpidBaseOfData32, VT_UI8},
// { (LPOLESTR)L"Address Of Entry Point", kpidAddressOfEntryPoint, VT_UI8},
// { (LPOLESTR)L"Base Of Code", kpidBaseOfCode, VT_UI8},
// { (LPOLESTR)L"Base Of Data", kpidBaseOfData32, VT_UI8},
};
static const Byte kProps[] =
@@ -2089,6 +2089,7 @@ API_FUNC_static_IsArc IsArc_Pe(const Byte *p, size_t size)
return k_IsArc_Res_NO;
return k_IsArc_Res_YES;
}
}
HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
{
@@ -2719,6 +2720,7 @@ API_FUNC_static_IsArc IsArc_Te(const Byte *p, size_t size)
return k_IsArc_Res_NO;
return k_IsArc_Res_YES;
}
}
struct CSection
@@ -2799,8 +2801,8 @@ static const STATPROPSTG kArcProps[] =
{
// { NULL, kpidHeadersSize, VT_UI4 },
{ NULL, kpidCpu, VT_BSTR},
{ L"Subsystem", kpidSubSystem, VT_BSTR },
// { L"Image Base", kpidImageBase, VT_UI8 }
{ (LPOLESTR)L"Subsystem", kpidSubSystem, VT_BSTR },
// { (LPOLESTR)L"Image Base", kpidImageBase, VT_UI8 }
};
IMP_IInArchive_Props

View File

@@ -359,7 +359,7 @@ static int ReadTime(const Byte *p, unsigned size, Byte mask, CRarTime &rarTime)
#define READ_TIME_2(_mask_, _def_, _ttt_) \
_def_ = ((_mask_ & 8) != 0); if (_def_) \
{ if (size < 4) return false; \
_ttt_ ## .DosTime = Get32(p); p += 4; size -= 4; \
_ttt_ .DosTime = Get32(p); p += 4; size -= 4; \
READ_TIME(_mask_, _ttt_); } \
bool CInArchive::ReadHeaderReal(const Byte *p, unsigned size, CItem &item)

View File

@@ -801,6 +801,8 @@ struct CItem
int Node;
int Parent;
UInt32 Ptr;
CItem(): Node(-1), Parent(-1), Ptr(0) {}
};
struct CData
@@ -1198,7 +1200,7 @@ HRESULT CHandler::Decompress(ISequentialOutStream *outStream, Byte *outBuf, bool
{
ECoderStatus status;
XzUnpacker_Init(&_xz);
SRes res = XzUnpacker_Code(&_xz, dest, &destLen, _inputBuffer, &srcLen, LZMA_FINISH_END, &status);
SRes res = XzUnpacker_Code(&_xz, dest, &destLen, _inputBuffer, &srcLen, CODER_FINISH_END, &status);
if (res != 0)
return SResToHRESULT(res);
if (status != CODER_STATUS_NEEDS_MORE_INPUT || !XzUnpacker_IsStreamWasFinished(&_xz))

View File

@@ -61,6 +61,7 @@ API_FUNC_static_IsArc IsArc_Swf(const Byte *p, size_t size)
return k_IsArc_Res_NO;
return k_IsArc_Res_YES;
}
}
API_FUNC_static_IsArc IsArc_Swfc(const Byte *p, size_t size)
{
@@ -100,6 +101,7 @@ API_FUNC_static_IsArc IsArc_Swfc(const Byte *p, size_t size)
return k_IsArc_Res_YES;
}
}
struct CItem
{

View File

@@ -226,6 +226,7 @@ STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream)
{
Close();
_seqStream = stream;
_isArc = true;
return S_OK;
}

View File

@@ -556,7 +556,7 @@ struct CCapsuleHeader
UInt32 OffsetToLongDescription;
UInt32 OffsetToApplicableDevices;
void Clear() { memset(this, 0, sizeof(this)); }
void Clear() { memset(this, 0, sizeof(*this)); }
void Parse(const Byte *p)
{

View File

@@ -612,10 +612,10 @@ static const STATPROPSTG kArcProps[] =
{ NULL, kpidCTime, VT_FILETIME},
{ NULL, kpidClusterSize, VT_UI8},
{ NULL, kpidMethod, VT_BSTR},
{ L"Parent", kpidParent, VT_BSTR},
{ (LPOLESTR)L"Parent", kpidParent, VT_BSTR},
{ NULL, kpidCreatorApp, VT_BSTR},
{ NULL, kpidHostOS, VT_BSTR},
{ L"Saved State", kpidSavedState, VT_BOOL},
{ (LPOLESTR)L"Saved State", kpidSavedState, VT_BOOL},
{ NULL, kpidId, VT_BSTR}
};

View File

@@ -63,8 +63,8 @@ static const STATPROPSTG kArcProps[] =
{ NULL, kpidIsVolume, VT_BOOL},
{ NULL, kpidVolume, VT_UI4},
{ NULL, kpidNumVolumes, VT_UI4},
{ L"Images", kpidNumImages, VT_UI4},
{ L"Boot Image", kpidBootImage, VT_UI4}
{ (LPOLESTR)L"Images", kpidNumImages, VT_UI4},
{ (LPOLESTR)L"Boot Image", kpidBootImage, VT_UI4}
};
static const char *kMethodLZX = "LZX";

View File

@@ -100,6 +100,7 @@ API_FUNC_static_IsArc IsArc_Z(const Byte *p, size_t size)
return k_IsArc_Res_NO;
return k_IsArc_Res_YES;
}
}
STDMETHODIMP CHandler::Open(IInStream *stream,
const UInt64 * /* maxCheckStartPosition */,

View File

@@ -462,6 +462,10 @@ SOURCE=..\..\..\Windows\FileIO.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\FileLink.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\FileName.cpp
# End Source File
# Begin Source File

View File

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "Alone"=.\Alone.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@@ -1,24 +1,42 @@
PROG = lzma
CXX = g++ -O2 -Wall
CXX_C = gcc -O2 -Wall
LIB = -lm
RM = rm -f
CFLAGS = -c -D_7ZIP_ST
CXX = g++ -O2
# -Wall -Werror -Wno-delete-non-virtual-dtor
CXX_C = gcc -O2 -Wall -Werror
ifdef SystemDrive
IS_MINGW = 1
endif
ifdef IS_MINGW
RM = del
CFLAGS = -c
LIB2 = -loleaut32 -luuid
LDFLAGS = -s
FILE_IO =FileIO
FILE_IO_2 =Windows/$(FILE_IO)
LIB2 = -luuid
MT_FILES = \
System.o \
LzFindMt.o \
Threads.o \
else
RM = rm -f
CFLAGS = -c -D_7ZIP_ST
FILE_IO =C_FileIO
FILE_IO_2 =Common/$(FILE_IO)
endif
OBJS = \
$(MT_FILES) \
$(FILE_IO).o \
LzmaAlone.o \
Bench.o \
BenchCon.o \
@@ -32,7 +50,6 @@ OBJS = \
FilterCoder.o \
MethodProps.o \
StreamUtils.o \
$(FILE_IO).o \
CommandLineParser.o \
CRC.o \
CrcReg.o \
@@ -58,7 +75,7 @@ OBJS = \
all: $(PROG)
$(PROG): $(OBJS)
$(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB) $(LIB2)
$(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB2)
LzmaAlone.o: LzmaAlone.cpp
$(CXX) $(CFLAGS) LzmaAlone.cpp
@@ -133,6 +150,11 @@ StringToInt.o: ../../../Common/StringToInt.cpp
PropVariant.o: ../../../Windows/PropVariant.cpp
$(CXX) $(CFLAGS) ../../../Windows/PropVariant.cpp
ifdef MT_FILES
System.o: ../../../Windows/System.cpp
$(CXX) $(CFLAGS) ../../../Windows/System.cpp
endif
7zCrc.o: ../../../../C/7zCrc.c
$(CXX_C) $(CFLAGS) ../../../../C/7zCrc.c
@@ -151,6 +173,14 @@ CpuArch.o: ../../../../C/CpuArch.c
LzFind.o: ../../../../C/LzFind.c
$(CXX_C) $(CFLAGS) ../../../../C/LzFind.c
ifdef MT_FILES
LzFindMt.o: ../../../../C/LzFindMt.c
$(CXX_C) $(CFLAGS) ../../../../C/LzFindMt.c
Threads.o: ../../../../C/Threads.c
$(CXX_C) $(CFLAGS) ../../../../C/Threads.c
endif
LzmaDec.o: ../../../../C/LzmaDec.c
$(CXX_C) $(CFLAGS) ../../../../C/LzmaDec.c

View File

@@ -19,7 +19,7 @@ static SRes CompressProgress(void *pp, UInt64 inSize, UInt64 outSize) throw()
return (SRes)p->Res;
}
CCompressProgressWrap::CCompressProgressWrap(ICompressProgressInfo *progress)
CCompressProgressWrap::CCompressProgressWrap(ICompressProgressInfo *progress) throw()
{
p.Progress = CompressProgress;
Progress = progress;
@@ -69,14 +69,14 @@ static size_t MyWrite(void *object, const void *data, size_t size) throw()
return size;
}
CSeqInStreamWrap::CSeqInStreamWrap(ISequentialInStream *stream)
CSeqInStreamWrap::CSeqInStreamWrap(ISequentialInStream *stream) throw()
{
p.Read = MyRead;
Stream = stream;
Processed = 0;
}
CSeqOutStreamWrap::CSeqOutStreamWrap(ISequentialOutStream *stream)
CSeqOutStreamWrap::CSeqOutStreamWrap(ISequentialOutStream *stream) throw()
{
p.Write = MyWrite;
Stream = stream;
@@ -84,7 +84,7 @@ CSeqOutStreamWrap::CSeqOutStreamWrap(ISequentialOutStream *stream)
Processed = 0;
}
HRESULT SResToHRESULT(SRes res)
HRESULT SResToHRESULT(SRes res) throw()
{
switch(res)
{
@@ -124,7 +124,7 @@ static SRes InStreamWrap_Seek(void *pp, Int64 *offset, ESzSeek origin) throw()
return (p->Res == S_OK) ? SZ_OK : SZ_ERROR_READ;
}
CSeekInStreamWrap::CSeekInStreamWrap(IInStream *stream)
CSeekInStreamWrap::CSeekInStreamWrap(IInStream *stream) throw()
{
Stream = stream;
p.Read = InStreamWrap_Read;
@@ -135,13 +135,13 @@ CSeekInStreamWrap::CSeekInStreamWrap(IInStream *stream)
/* ---------- CByteInBufWrap ---------- */
void CByteInBufWrap::Free()
void CByteInBufWrap::Free() throw()
{
::MidFree(Buf);
Buf = 0;
}
bool CByteInBufWrap::Alloc(UInt32 size)
bool CByteInBufWrap::Alloc(UInt32 size) throw()
{
if (Buf == 0 || size != Size)
{
@@ -152,7 +152,7 @@ bool CByteInBufWrap::Alloc(UInt32 size)
return (Buf != 0);
}
Byte CByteInBufWrap::ReadByteFromNewBlock()
Byte CByteInBufWrap::ReadByteFromNewBlock() throw()
{
if (Res == S_OK)
{
@@ -184,13 +184,13 @@ CByteInBufWrap::CByteInBufWrap(): Buf(0)
/* ---------- CByteOutBufWrap ---------- */
void CByteOutBufWrap::Free()
void CByteOutBufWrap::Free() throw()
{
::MidFree(Buf);
Buf = 0;
}
bool CByteOutBufWrap::Alloc(size_t size)
bool CByteOutBufWrap::Alloc(size_t size) throw()
{
if (Buf == 0 || size != Size)
{
@@ -201,7 +201,7 @@ bool CByteOutBufWrap::Alloc(size_t size)
return (Buf != 0);
}
HRESULT CByteOutBufWrap::Flush()
HRESULT CByteOutBufWrap::Flush() throw()
{
if (Res == S_OK)
{
@@ -224,7 +224,7 @@ static void Wrap_WriteByte(void *pp, Byte b) throw()
p->Flush();
}
CByteOutBufWrap::CByteOutBufWrap(): Buf(0)
CByteOutBufWrap::CByteOutBufWrap() throw(): Buf(0)
{
p.Write = Wrap_WriteByte;
}

View File

@@ -90,7 +90,7 @@ HRESULT CExternalCodecs::LoadCodecs()
}
if (GetHashers)
{
UInt32 num = num = GetHashers->GetNumHashers();
UInt32 num = GetHashers->GetNumHashers();
for (UInt32 i = 0; i < num; i++)
{
CHasherInfoEx info;
@@ -226,7 +226,6 @@ HRESULT CreateCoder(
CMyComPtr<ICompressCoder2> &coder2,
bool encode, bool onlyCoder)
{
bool created = false;
UInt32 i;
for (i = 0; i < g_NumCodecs; i++)
{
@@ -241,7 +240,6 @@ HRESULT CreateCoder(
if (codec.IsFilter) filter = (ICompressFilter *)p;
else if (codec.NumInStreams == 1) coder = (ICompressCoder *)p;
else coder2 = (ICompressCoder2 *)p;
created = (p != 0);
break;
}
}
@@ -252,14 +250,13 @@ HRESULT CreateCoder(
if (codec.IsFilter) filter = (ICompressFilter *)p;
else if (codec.NumInStreams == 1) coder = (ICompressCoder *)p;
else coder2 = (ICompressCoder2 *)p;
created = (p != 0);
break;
}
}
}
#ifdef EXTERNAL_CODECS
if (!created && __externalCodecs)
if (!filter && !coder && !coder2 && __externalCodecs)
for (i = 0; i < (UInt32)__externalCodecs->Codecs.Size(); i++)
{
const CCodecInfoEx &codec = __externalCodecs->Codecs[i];

View File

@@ -1,4 +1,4 @@
/ FileStreams.cpp
// FileStreams.cpp
#include "StdAfx.h"

View File

@@ -6,7 +6,7 @@
#include "InBuffer.h"
CInBufferBase::CInBufferBase():
CInBufferBase::CInBufferBase() throw():
_buf(0),
_bufLim(0),
_bufBase(0),
@@ -17,7 +17,7 @@ CInBufferBase::CInBufferBase():
NumExtraBytes(0)
{}
bool CInBuffer::Create(size_t bufSize)
bool CInBuffer::Create(size_t bufSize) throw()
{
const unsigned kMinBlockSize = 1;
if (bufSize < kMinBlockSize)
@@ -30,13 +30,13 @@ bool CInBuffer::Create(size_t bufSize)
return (_bufBase != 0);
}
void CInBuffer::Free()
void CInBuffer::Free() throw()
{
::MidFree(_bufBase);
_bufBase = 0;
}
void CInBufferBase::Init()
void CInBufferBase::Init() throw()
{
_processedSize = 0;
_buf = _bufBase;

View File

@@ -1,222 +0,0 @@
// InMemStream.cpp
#include "StdAfx.h"
#include <stdio.h>
#include "Windows/Thread.h"
#include "InMemStream.h"
#include "../../Common/Defs.h"
void CStreamInfo::Free(IInMemStreamMtCallback *callback)
{
for (int i = 0; i < Blocks.Size(); i++)
{
callback->FreeBlock(Blocks[i]);
Blocks[i] = 0;
}
}
bool CInMemStreamMt::Create(int numSubStreams, UInt64 subStreamSize)
{
Free();
_subStreamSize = subStreamSize;
size_t blockSize = Callback->GetBlockSize();
for (int i = 0; i < numSubStreams; i++)
{
_streams.Add(CStreamInfo());
CStreamInfo &blocks = _streams.Back();
blocks.Create();
for (UInt64 j = 0; (UInt64)j * blockSize < _subStreamSize; j++)
blocks.Blocks.Add(0);
}
if (!_streamIndexAllocator.AllocateList(numSubStreams))
return false;
return true;
}
void CInMemStreamMt::Free()
{
while(_streams.Size() > 0)
{
_streams.Back().Free(Callback);
_streams.DeleteBack();
}
}
HRESULT CInMemStreamMt::Read()
{
for (;;)
{
// printf("\n_streamIndexAllocator.AllocateItem\n");
int index = _streamIndexAllocator.AllocateItem();
/*
if (_stopReading)
return E_ABORT;
*/
// printf("\nread Index = %d\n", index);
CStreamInfo &blocks = _streams[index];
blocks.Init();
Callback->AddStreamIndexToQueue(index);
for (;;)
{
const Byte *p = (const Byte *)blocks.Blocks[blocks.LastBlockIndex];
if (p == 0)
{
void **pp = &blocks.Blocks[blocks.LastBlockIndex];
HRESULT res = Callback->AllocateBlock(pp);
p = (const Byte *)*pp;
RINOK(res);
if (p == 0)
return E_FAIL;
}
size_t blockSize = Callback->GetBlockSize();
UInt32 curSize = (UInt32)(blockSize - blocks.LastBlockPos);
UInt32 realProcessedSize;
UInt64 pos64 = (UInt64)blocks.LastBlockIndex * blockSize + blocks.LastBlockPos;
if (curSize > _subStreamSize - pos64)
curSize = (UInt32)(_subStreamSize - pos64);
RINOK(_stream->Read((void *)(p + blocks.LastBlockPos), curSize, &realProcessedSize));
blocks.Cs->Enter();
if (realProcessedSize == 0)
{
blocks.StreamWasFinished = true;
blocks.CanReadEvent->Set();
blocks.Cs->Leave();
Callback->AddStreamIndexToQueue(-1);
return S_OK;
}
blocks.LastBlockPos += realProcessedSize;
if (blocks.LastBlockPos == blockSize)
{
blocks.LastBlockPos = 0;
blocks.LastBlockIndex++;
}
pos64 += realProcessedSize;
if (pos64 >= _subStreamSize)
blocks.StreamWasFinished = true;
blocks.CanReadEvent->Set();
blocks.Cs->Leave();
if (pos64 >= _subStreamSize)
break;
}
}
}
static THREAD_FUNC_DECL CoderThread(void *threadCoderInfo)
{
((CInMemStreamMt *)threadCoderInfo)->ReadResult = ((CInMemStreamMt *)threadCoderInfo)->Read();
return 0;
}
HRes CInMemStreamMt::StartReadThread()
{
// _stopReading = false;
NWindows::CThread Thread;
return Thread.Create(CoderThread, this);
}
void CInMemStreamMt::FreeSubStream(int subStreamIndex)
{
// printf("\nFreeSubStream\n");
_streams[subStreamIndex].Free(Callback);
_streamIndexAllocator.FreeItem(subStreamIndex);
// printf("\nFreeSubStream end\n");
}
HRESULT CInMemStreamMt::ReadSubStream(int subStreamIndex, void *data, UInt32 size, UInt32 *processedSize, bool keepData)
{
if (processedSize != NULL)
*processedSize = 0;
CStreamInfo &blocks = _streams[subStreamIndex];
while (size > 0)
{
if (blocks.CurBlockPos == Callback->GetBlockSize())
{
blocks.CurBlockPos = 0;
blocks.CurBlockIndex++;
}
UInt32 curSize;
UInt32 curPos = blocks.CurBlockPos;
blocks.Cs->Enter();
if (blocks.CurBlockIndex == blocks.LastBlockIndex)
{
curSize = blocks.LastBlockPos - curPos;
if (curSize == 0)
{
if (blocks.StreamWasFinished)
{
blocks.Cs->Leave();
void *p = blocks.Blocks[blocks.CurBlockIndex];
if (p != 0 && !keepData)
{
Callback->FreeBlock(p);
blocks.Blocks[blocks.CurBlockIndex] = 0;
}
return S_OK;
}
blocks.CanReadEvent->Reset();
blocks.Cs->Leave();
// printf("\nBlock Lock\n");
blocks.CanReadEvent->Lock();
// printf("\nAfter Lock\n");
if (blocks.ExitResult != S_OK)
return blocks.ExitResult;
continue;
}
}
else
curSize = Callback->GetBlockSize() - curPos;
blocks.Cs->Leave();
if (curSize > size)
curSize = size;
void *p = blocks.Blocks[blocks.CurBlockIndex];
memcpy(data, (const Byte *)p + curPos, curSize);
data = (void *)((Byte *)data + curSize);
size -= curSize;
if (processedSize != NULL)
*processedSize += curSize;
curPos += curSize;
bool needFree = false;
blocks.CurBlockPos = curPos;
if (curPos == Callback->GetBlockSize())
needFree = true;
blocks.Cs->Enter();
if (blocks.CurBlockIndex == blocks.LastBlockIndex &&
blocks.CurBlockPos == blocks.LastBlockPos &&
blocks.StreamWasFinished)
needFree = true;
blocks.Cs->Leave();
if (needFree && !keepData)
{
Callback->FreeBlock(p);
blocks.Blocks[blocks.CurBlockIndex] = 0;
}
return S_OK;
}
return S_OK;
}
STDMETHODIMP CInMemStream::Read(void *data, UInt32 size, UInt32 *processedSize)
{
UInt32 realProcessedSize;
HRESULT result = mtStream->ReadSubStream(Index, data, size, &realProcessedSize, _keepData);
if (processedSize != NULL)
*processedSize = realProcessedSize;
if (realProcessedSize != 0)
{
// printf("\ns = %d\n", Index);
}
_size += realProcessedSize;
return result;
}

View File

@@ -1,284 +0,0 @@
// InMemStream.h
#ifndef __IN_MEM_STREAM_H
#define __IN_MEM_STREAM_H
#include <stdio.h>
#include "../../../C/Alloc.h"
#include "../../Common/MyCom.h"
#include "MemBlocks.h"
class CIntListCheck
{
protected:
int *_data;
public:
CIntListCheck(): _data(0) {}
~CIntListCheck() { FreeList(); }
bool AllocateList(int numItems)
{
FreeList();
if (numItems == 0)
return true;
_data = (int *)::MyAlloc(numItems * sizeof(int));
return (_data != 0);
}
void FreeList()
{
::MyFree(_data);
_data = 0;
}
};
class CResourceList : public CIntListCheck
{
int _headFree;
public:
CResourceList(): _headFree(-1) {}
bool AllocateList(int numItems)
{
FreeList();
if (numItems == 0)
return true;
if (!CIntListCheck::AllocateList(numItems))
return false;
for (int i = 0; i < numItems; i++)
_data[i] = i + 1;
_data[numItems - 1] = -1;
_headFree = 0;
return true;
}
void FreeList()
{
CIntListCheck::FreeList();
_headFree = -1;
}
int AllocateItem()
{
int res = _headFree;
if (res >= 0)
_headFree = _data[res];
return res;
}
void FreeItem(int index)
{
if (index < 0)
return;
_data[index] = _headFree;
_headFree = index;
}
};
class CResourceListMt: public CResourceList
{
NWindows::NSynchronization::CCriticalSection _criticalSection;
public:
NWindows::NSynchronization::CSemaphore Semaphore;
HRes AllocateList(int numItems)
{
if (!CResourceList::AllocateList(numItems))
return E_OUTOFMEMORY;
Semaphore.Close();
return Semaphore.Create(numItems, numItems);
}
int AllocateItem()
{
Semaphore.Lock();
_criticalSection.Enter();
int res = CResourceList::AllocateItem();
_criticalSection.Leave();
return res;
}
void FreeItem(int index)
{
if (index < 0)
return;
_criticalSection.Enter();
CResourceList::FreeItem(index);
_criticalSection.Leave();
Semaphore.Release();
}
};
class CIntQueueMt: public CIntListCheck
{
int _numItems;
int _head;
int _cur;
public:
CIntQueueMt(): _numItems(0), _head(0), _cur(0) {}
NWindows::NSynchronization::CSemaphore Semaphore;
HRes AllocateList(int numItems)
{
FreeList();
if (numItems == 0)
return S_OK;
if (!CIntListCheck::AllocateList(numItems))
return E_OUTOFMEMORY;
_numItems = numItems;
return Semaphore.Create(0, numItems);
}
void FreeList()
{
CIntListCheck::FreeList();
_numItems = 0;
_head = 0;
_cur = 0;
}
void AddItem(int value)
{
_data[_head++] = value;
if (_head == _numItems)
_head = 0;
Semaphore.Release();
// printf("\nRelease prev = %d\n", previousCount);
}
int GetItem()
{
// Semaphore.Lock();
int res = _data[_cur++];
if (_cur == _numItems)
_cur = 0;
return res;
}
};
struct IInMemStreamMtCallback
{
// must be same for all calls
virtual size_t GetBlockSize() = 0;
// Out:
// result != S_OK stops Reading
// if *p = 0, result must be != S_OK;
// Locking is allowed
virtual HRESULT AllocateBlock(void **p) = 0;
virtual void FreeBlock(void *p) = 0;
// It must allow to add at least numSubStreams + 1 ,
// where numSubStreams is value from CInMemStreamMt::Create
// value -1 means End of stream
// Locking is not allowed
virtual void AddStreamIndexToQueue(int index) = 0;
};
struct CStreamInfo
{
CRecordVector<void *> Blocks;
int LastBlockIndex;
size_t LastBlockPos;
bool StreamWasFinished;
int CurBlockIndex;
size_t CurBlockPos;
NWindows::NSynchronization::CCriticalSection *Cs;
NWindows::NSynchronization::CManualResetEvent *CanReadEvent;
HRESULT ExitResult;
CStreamInfo(): Cs(0), CanReadEvent(0), StreamWasFinished(false) { }
~CStreamInfo()
{
delete Cs;
delete CanReadEvent;
// Free();
}
void Create()
{
Cs = new NWindows::NSynchronization::CCriticalSection;
CanReadEvent = new NWindows::NSynchronization::CManualResetEvent;
}
void Free(IInMemStreamMtCallback *callback);
void Init()
{
LastBlockIndex = CurBlockIndex = 0;
CurBlockPos = LastBlockPos = 0;
StreamWasFinished = false;
ExitResult = S_OK;
}
// res must be != S_OK
void Exit(HRESULT res)
{
ExitResult = res;
CanReadEvent->Set();
}
};
class CInMemStreamMt
{
CMyComPtr<ISequentialInStream> _stream;
NWindows::NSynchronization::CCriticalSection CS;
CObjectVector<CStreamInfo> _streams;
int _nextFreeStreamIndex;
int _currentStreamIndex;
UInt64 _subStreamSize;
CResourceListMt _streamIndexAllocator;
// bool _stopReading;
public:
HRESULT Read();
HRESULT ReadResult;
IInMemStreamMtCallback *Callback;
void FreeSubStream(int subStreamIndex);
HRESULT ReadSubStream(int subStreamIndex, void *data, UInt32 size, UInt32 *processedSize, bool keepData);
// numSubStreams: min = 1, good min = numThreads
bool Create(int numSubStreams, UInt64 subStreamSize);
~CInMemStreamMt() { Free(); }
void SetStream(ISequentialInStream *stream) { _stream = stream; }
// to stop reading you must implement
// returning Error in IInMemStreamMtCallback::AllocateBlock
// and then you must free at least one substream
HRes StartReadThread();
void Free();
// you must free at least one substream after that function to unlock waiting.
// void StopReading() { _stopReading = true; }
};
class CInMemStream:
public ISequentialInStream,
public CMyUnknownImp
{
UInt64 _size;
bool _keepData;
public:
int Index;
CInMemStreamMt *mtStream;
void Init(bool keepData = false)
{
_size = 0; _keepData = keepData ;
}
MY_UNKNOWN_IMP
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
UInt64 GetSize() const { return _size; }
};
#endif

View File

@@ -6,7 +6,7 @@
#include "OutBuffer.h"
bool COutBuffer::Create(UInt32 bufSize)
bool COutBuffer::Create(UInt32 bufSize) throw()
{
const UInt32 kMinBlockSize = 1;
if (bufSize < kMinBlockSize)
@@ -19,13 +19,13 @@ bool COutBuffer::Create(UInt32 bufSize)
return (_buf != 0);
}
void COutBuffer::Free()
void COutBuffer::Free() throw()
{
::MidFree(_buf);
_buf = 0;
}
void COutBuffer::Init()
void COutBuffer::Init() throw()
{
_streamPos = 0;
_limitPos = _bufSize;
@@ -37,7 +37,7 @@ void COutBuffer::Init()
#endif
}
UInt64 COutBuffer::GetProcessedSize() const
UInt64 COutBuffer::GetProcessedSize() const throw()
{
UInt64 res = _processedSize + _pos - _streamPos;
if (_streamPos > _pos)
@@ -46,7 +46,7 @@ UInt64 COutBuffer::GetProcessedSize() const
}
HRESULT COutBuffer::FlushPart()
HRESULT COutBuffer::FlushPart() throw()
{
// _streamPos < _bufSize
UInt32 size = (_streamPos >= _pos) ? (_bufSize - _streamPos) : (_pos - _streamPos);
@@ -83,7 +83,7 @@ HRESULT COutBuffer::FlushPart()
return result;
}
HRESULT COutBuffer::Flush()
HRESULT COutBuffer::Flush() throw()
{
#ifdef _NO_EXCEPTIONS
if (ErrorCode != S_OK)

View File

@@ -65,14 +65,14 @@ void Create_BufInStream_WithNewBuf(const void *data, size_t size, ISequentialInS
*stream = streamTemp.Detach();
}
void CByteDynBuffer::Free()
void CByteDynBuffer::Free() throw()
{
free(_buf);
_buf = 0;
_capacity = 0;
}
bool CByteDynBuffer::EnsureCapacity(size_t cap)
bool CByteDynBuffer::EnsureCapacity(size_t cap) throw()
{
if (cap <= _capacity)
return true;
@@ -147,7 +147,7 @@ STDMETHODIMP CSequentialOutStreamSizeCount::Write(const void *data, UInt32 size,
static const UInt64 kEmptyTag = (UInt64)(Int64)-1;
void CCachedInStream::Free()
void CCachedInStream::Free() throw()
{
MyFree(_tags);
_tags = 0;
@@ -155,7 +155,7 @@ void CCachedInStream::Free()
_data = 0;
}
bool CCachedInStream::Alloc(unsigned blockSizeLog, unsigned numBlocksLog)
bool CCachedInStream::Alloc(unsigned blockSizeLog, unsigned numBlocksLog) throw()
{
unsigned sizeLog = blockSizeLog + numBlocksLog;
if (sizeLog >= sizeof(size_t) * 8)
@@ -181,7 +181,7 @@ bool CCachedInStream::Alloc(unsigned blockSizeLog, unsigned numBlocksLog)
return true;
}
void CCachedInStream::Init(UInt64 size)
void CCachedInStream::Init(UInt64 size) throw()
{
_size = size;
_pos = 0;

View File

@@ -6,7 +6,7 @@
static const UInt32 kBlockSize = ((UInt32)1 << 31);
HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSize)
HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSize) throw()
{
size_t size = *processedSize;
*processedSize = 0;
@@ -25,21 +25,21 @@ HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSiz
return S_OK;
}
HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size)
HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size) throw()
{
size_t processedSize = size;
RINOK(ReadStream(stream, data, &processedSize));
return (size == processedSize) ? S_OK : S_FALSE;
}
HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size)
HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size) throw()
{
size_t processedSize = size;
RINOK(ReadStream(stream, data, &processedSize));
return (size == processedSize) ? S_OK : E_FAIL;
}
HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size)
HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size) throw()
{
while (size != 0)
{

View File

@@ -121,12 +121,12 @@ public:
void AlignToByte() { MovePos((32 - this->_bitPos) & 7); }
Byte ReadDirectByte() { return _stream.ReadByte(); }
Byte ReadDirectByte() { return this->_stream.ReadByte(); }
Byte ReadAlignedByte()
{
if (this->_bitPos == kNumBigValueBits)
return _stream.ReadByte();
return this->_stream.ReadByte();
Byte b = (Byte)(_normalValue & 0xFF);
MovePos(8);
return b;

View File

@@ -11,7 +11,7 @@
static const unsigned kNumCodecsMax = 48;
unsigned g_NumCodecs = 0;
const CCodecInfo *g_Codecs[kNumCodecsMax];
void RegisterCodec(const CCodecInfo *codecInfo)
void RegisterCodec(const CCodecInfo *codecInfo) throw()
{
if (g_NumCodecs < kNumCodecsMax)
g_Codecs[g_NumCodecs++] = codecInfo;

View File

@@ -4,7 +4,7 @@
#include "LzOutWindow.h"
void CLzOutWindow::Init(bool solid)
void CLzOutWindow::Init(bool solid) throw()
{
if (!solid)
COutBuffer::Init();

View File

@@ -39,7 +39,7 @@ public:
{
if (Symbol >= 0)
return (UInt32)Symbol;
return DecodeSymbol(bitStream);
return this->DecodeSymbol(bitStream);
}
};

View File

@@ -69,8 +69,6 @@ Byte CFilter::Decode(int &channelDelta, Byte deltaByte)
}
}
static const char *kNumberErrorMessage = "Number error";
static const UInt32 kHistorySize = 1 << 20;
static const int kNumStats = 11;

View File

@@ -14,31 +14,59 @@
STREAM_INTERFACE(ISequentialInStream, 0x01)
{
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) PURE;
/*
Out: if size != 0, return_value = S_OK and (*processedSize == 0),
then there are no more bytes in stream.
if (size > 0) && there are bytes in stream,
this function must read at least 1 byte.
This function is allowed to read less than number of remaining bytes in stream.
You must call Read function in loop, if you need exact amount of data
The requirement for caller: (processedSize != NULL).
The callee can allow (processedSize == NULL) for compatibility reasons.
if (size == 0), this function returns S_OK and (*processedSize) is set to 0.
If seek pointer before Read() function call was changed to position past the
end of stream, the Read() function returns S_OK and *processedSize is set to 0.
if (size != 0)
{
Partial read is allowed: (*processedSize <= avail_size && *processedSize <= size),
where (avail_size) is the size of remaining bytes in stream.
If (avail_size != 0), this function must read at least 1 byte: (*processedSize > 0).
You must call Read() in loop, if you need to read exact amount of data.
}
If seek pointer before Read() call was changed to position past the end of stream:
if (seek_pointer >= stream_size), this function returns S_OK and (*processedSize) is set to 0.
ERROR CASES:
If the function returns error code, then (*processedSize) is size of
data written to (data) buffer (it can be data before error or data with errors).
The recommended way for callee to work with reading errors:
1) write part of data before error to (data) buffer and return S_OK.
2) return error code for further calls of Read().
*/
};
STREAM_INTERFACE(ISequentialOutStream, 0x02)
{
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) PURE;
/*
if (size > 0) this function must write at least 1 byte.
This function is allowed to write less than "size".
You must call Write function in loop, if you need to write exact amount of data
The requirement for caller: (processedSize != NULL).
The callee can allow (processedSize == NULL) for compatibility reasons.
if (size != 0)
{
Partial write is allowed: (*processedSize <= size),
but this function must write at least 1 byte: (*processedSize > 0).
You must call Write() in loop, if you need to write exact amount of data.
}
ERROR CASES:
If the function returns error code, then (*processedSize) is size of
data written from (data) buffer.
*/
};
#ifdef __HRESULT_FROM_WIN32
#define HRESULT_WIN32_ERROR_NEGATIVE_SEEK __HRESULT_FROM_WIN32(ERROR_NEGATIVE_SEEK)
#else
#define HRESULT_WIN32_ERROR_NEGATIVE_SEEK HRESULT_FROM_WIN32(ERROR_NEGATIVE_SEEK)
#endif
/* Seek() Function
If you seek before the beginning of the stream, Seek() function returns error code:

View File

@@ -106,7 +106,7 @@ enum
kpidUserDefined = 0x10000
};
Byte k7z_PROPID_To_VARTYPE[]; // VARTYPE
extern Byte k7z_PROPID_To_VARTYPE[kpid_NUM_DEFINED]; // VARTYPE
const UInt32 kpv_ErrorFlags_IsNotArc = 1 << 0;
const UInt32 kpv_ErrorFlags_HeadersError = 1 << 1;

View File

@@ -492,8 +492,8 @@ HRESULT CProxyArchive2::Load(const CArc &arc, IProgress *progress)
{
file.Name = (const wchar_t *)p;
file.NameSize = 0;
if (size >= 2)
file.NameSize = size / 2 - 1;
if (size >= sizeof(wchar_t))
file.NameSize = size / sizeof(wchar_t) - 1;
}
else
#endif

View File

@@ -0,0 +1,8 @@
// StdAfx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include "../../../Common/Common.h"
#endif

View File

@@ -236,8 +236,8 @@ static const int kCommandIndex = 0;
// static const char *kUserErrorMessage = "Incorrect command line";
static const char *kCannotFindListFile = "Cannot find listfile";
static const char *kIncorrectListFile = "Incorrect item in listfile.\nCheck charset encoding and -scs switch.";
static const char *kIncorrectWildcardInListFile = "Incorrect wildcard in listfile";
static const char *kIncorrectWildcardInCommandLine = "Incorrect wildcard in command line";
// static const char *kIncorrectWildcardInListFile = "Incorrect wildcard in listfile";
// static const char *kIncorrectWildcardInCommandLine = "Incorrect wildcard in command line";
static const char *kTerminalOutError = "I won't write compressed data to a terminal";
static const char *kSameTerminalError = "I won't write data and program's messages to same terminal";
static const char *kEmptyFilePath = "Empty file path";

View File

@@ -370,7 +370,7 @@ STDMETHODIMP CGetProp::GetProp(PROPID propID, PROPVARIANT *value)
if (propID == kpidName)
{
COM_TRY_BEGIN
NCOM::CPropVariant prop = Name;
NCOM::CPropVariant prop = Name.Ptr();
prop.Detach(value);
return S_OK;
COM_TRY_END
@@ -1059,7 +1059,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
SECURITY_INFORMATION securInfo = DACL_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION;
if (_saclEnabled)
securInfo |= SACL_SECURITY_INFORMATION;
::SetFileSecurityW(fs2us(_diskFilePath), securInfo, (void *)data);
::SetFileSecurityW(fs2us(_diskFilePath), securInfo, (PSECURITY_DESCRIPTOR)(void *)data);
}
}
}

View File

@@ -1316,9 +1316,8 @@ UInt32 g_BenchCpuFreqTemp = 1;
#define YY7 YY5 YY5 YY5 YY5
static const UInt32 kNumFreqCommands = 128;
static UInt32 CountCpuFreq(UInt32 num, UInt32 val)
static UInt32 CountCpuFreq(UInt32 sum, UInt32 num, UInt32 val)
{
UInt32 sum = 0;
for (UInt32 i = 0; i < num; i++)
{
YY7
@@ -1354,7 +1353,7 @@ static THREAD_FUNC_DECL FreqThreadFunction(void *param)
p->CallbackRes = p->Callback->CheckBreak();
if (p->CallbackRes != S_OK)
return 0;
sum = CountCpuFreq(p->Size, sum);
sum = CountCpuFreq(sum, p->Size, g_BenchCpuFreqTemp);
}
p->ValRes = sum;
return 0;
@@ -1653,7 +1652,7 @@ static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString, UI
{
f.Print("RAM ");
f.Print(sizeString);
PrintNumber(f, (size >> 20), 5);
PrintNumber(f, (size >> 20), 6);
f.Print(" MB, # ");
f.Print(threadsString);
PrintNumber(f, numThreads, 3);
@@ -1858,7 +1857,7 @@ static HRESULT FreqBench(
for (UInt64 k = numIterations; k > 0; k--)
{
RINOK(_file->CheckBreak());
sum = CountCpuFreq(bufferSize, sum);
sum = CountCpuFreq(sum, bufferSize, g_BenchCpuFreqTemp);
}
res += sum;
}
@@ -2164,17 +2163,17 @@ HRESULT Bench(
{
UInt64 start = ::GetTimeCount();
UInt32 sum = (UInt32)start;
sum += CountCpuFreq((UInt32)(numMilCommands * 1000000 / kNumFreqCommands), g_BenchCpuFreqTemp);
sum = CountCpuFreq(sum, (UInt32)(numMilCommands * 1000000 / kNumFreqCommands), g_BenchCpuFreqTemp);
start = ::GetTimeCount() - start;
if (start == 0)
start = 1;
UInt64 freq = GetFreq();
UInt64 mips = numMilCommands * freq / start;
UInt64 mipsVal = numMilCommands * freq / start;
if (printCallback)
PrintNumber(*printCallback, mips, 5 + ((sum >> 31) & 1));
PrintNumber(*printCallback, mipsVal, 5 + ((sum >> 31) & 1));
if (jj >= 3)
{
SetComplexCommands(testTime, mips * 1000000, complexInCommands);
SetComplexCommands(testTime, mipsVal * 1000000, complexInCommands);
if (jj >= 8 || start >= freq)
break;
// break; // change it

View File

@@ -124,7 +124,7 @@ void CDirItems::AddSecurityItem(const FString &path, int &secureIndex)
DWORD errorCode = 0;
DWORD secureSize;
BOOL res = ::GetFileSecurityW(fs2us(path), securInfo, TempSecureBuf, (DWORD)TempSecureBuf.Size(), &secureSize);
BOOL res = ::GetFileSecurityW(fs2us(path), securInfo, (PSECURITY_DESCRIPTOR)(Byte *)TempSecureBuf, (DWORD)TempSecureBuf.Size(), &secureSize);
if (res)
{
if (secureSize == 0)
@@ -142,7 +142,7 @@ void CDirItems::AddSecurityItem(const FString &path, int &secureIndex)
else
{
TempSecureBuf.Alloc(secureSize);
res = ::GetFileSecurityW(fs2us(path), securInfo, TempSecureBuf, (DWORD)TempSecureBuf.Size(), &secureSize);
res = ::GetFileSecurityW(fs2us(path), securInfo, (PSECURITY_DESCRIPTOR)(Byte *)TempSecureBuf, (DWORD)TempSecureBuf.Size(), &secureSize);
if (res)
{
if (secureSize != TempSecureBuf.Size())

View File

@@ -169,7 +169,7 @@ static HRESULT DecompressArchive(
}
else
result = archive->Extract(&realIndices.Front(), realIndices.Size(), testMode, ecs);
if (result == S_OK)
if (result == S_OK && !options.StdInMode)
result = ecs->SetDirsTimes();
return callback->ExtractResult(result);
}

View File

@@ -81,7 +81,7 @@ static const unsigned kNumArcsMax = 48;
static unsigned g_NumArcs = 0;
static const CArcInfo *g_Arcs[kNumArcsMax];
void RegisterArc(const CArcInfo *arcInfo)
void RegisterArc(const CArcInfo *arcInfo) throw()
{
if (g_NumArcs < kNumArcsMax)
{

View File

@@ -446,7 +446,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
#endif
HRESULT Archive_GetItemBoolProp(IInArchive *arc, UInt32 index, PROPID propID, bool &result)
HRESULT Archive_GetItemBoolProp(IInArchive *arc, UInt32 index, PROPID propID, bool &result) throw()
{
NCOM::CPropVariant prop;
result = false;
@@ -458,22 +458,22 @@ HRESULT Archive_GetItemBoolProp(IInArchive *arc, UInt32 index, PROPID propID, bo
return S_OK;
}
HRESULT Archive_IsItem_Folder(IInArchive *arc, UInt32 index, bool &result)
HRESULT Archive_IsItem_Folder(IInArchive *arc, UInt32 index, bool &result) throw()
{
return Archive_GetItemBoolProp(arc, index, kpidIsDir, result);
}
HRESULT Archive_IsItem_Aux(IInArchive *arc, UInt32 index, bool &result)
HRESULT Archive_IsItem_Aux(IInArchive *arc, UInt32 index, bool &result) throw()
{
return Archive_GetItemBoolProp(arc, index, kpidIsAux, result);
}
HRESULT Archive_IsItem_AltStream(IInArchive *arc, UInt32 index, bool &result)
HRESULT Archive_IsItem_AltStream(IInArchive *arc, UInt32 index, bool &result) throw()
{
return Archive_GetItemBoolProp(arc, index, kpidIsAltStream, result);
}
HRESULT Archive_IsItem_Deleted(IInArchive *arc, UInt32 index, bool &result)
HRESULT Archive_IsItem_Deleted(IInArchive *arc, UInt32 index, bool &result) throw()
{
return Archive_GetItemBoolProp(arc, index, kpidIsDeleted, result);
}
@@ -590,12 +590,15 @@ HRESULT CArc::GetItemPath(UInt32 index, UString &result) const
{
wchar_t c = GetUi16(p);
p = (const void *)((const Byte *)p + 2);
if (c == '/')
#if WCHAR_PATH_SEPARATOR != L'/'
if (c == L'/')
c = WCHAR_PATH_SEPARATOR;
#endif
*s++ = c;
}
result.ReleaseBuffer(len);
return S_OK;
if (len != 0)
return S_OK;
}
}
/*
@@ -2633,6 +2636,8 @@ HRESULT CArc::OpenStream(const COpenOptions &op)
return S_OK;
}
#ifdef _SFX
#ifdef _WIN32
static const wchar_t *k_ExeExt = L".exe";
static const unsigned k_ExeExt_Len = 4;
@@ -2641,6 +2646,8 @@ HRESULT CArc::OpenStream(const COpenOptions &op)
static const unsigned k_ExeExt_Len = 0;
#endif
#endif
HRESULT CArc::OpenStreamOrFile(COpenOptions &op)
{
CMyComPtr<IInStream> fileStream;

View File

@@ -52,7 +52,7 @@ void ConvertWinAttribToString(char *s, UInt32 wa)
static const char kPosixTypes[16] = { '0', 'p', 'c', '3', 'd', '5', 'b', '7', '-', '9', 'l', 'B', 's', 'D', 'E', 'F' };
#define MY_ATTR_CHAR(a, n, c) ((a) & (1 << (n))) ? c : '-';
void ConvertPropertyToShortString(char *dest, const PROPVARIANT &prop, PROPID propID, bool full)
void ConvertPropertyToShortString(char *dest, const PROPVARIANT &prop, PROPID propID, bool full) throw()
{
*dest = 0;
if (prop.vt == VT_FILETIME)
@@ -204,7 +204,7 @@ static const char *sidNames[] =
struct CSecID2Name
{
UInt32 n;
char *sz;
const char *sz;
};
const CSecID2Name sid_32_Names[] =
@@ -255,12 +255,12 @@ static const CSecID2Name sid_21_Names[] =
struct CServicesToName
{
UInt32 n[5];
char *sz;
const char *sz;
};
static const CServicesToName services_to_name[] =
{
{ { 956008885, 3418522649, 1831038044, 1853292631, 2271478464 } , "TrustedInstaller" }
{ { 0x38FB89B5, 0xCBC28419, 0x6D236C5C, 0x6E770057, 0x876402C0 } , "TrustedInstaller" }
};
static void ParseSid(AString &s, const Byte *p, UInt32 lim, UInt32 &sidSize)

View File

@@ -1103,10 +1103,12 @@ HRESULT UpdateArchive(
CDirItem parentDirItem;
CDirItem *parentDirItem_Ptr = NULL;
/*
FStringVector requestedPaths;
FStringVector *requestedPaths_Ptr = NULL;
if (options.DeleteAfterCompressing)
requestedPaths_Ptr = &requestedPaths;
*/
if (options.StdInMode)
{
@@ -1421,7 +1423,7 @@ HRESULT UpdateArchive(
m.lpRecips = &rec;
}
sendMail(NULL, 0, &m, MAPI_DIALOG, 0);
sendMail((LHANDLE)0, 0, &m, MAPI_DIALOG, 0);
}
}
#endif

View File

@@ -328,7 +328,6 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR
const CDirItem &di = DirItems->Items[up.DirIndex];
// if (di.IsDir())
{
di.ReparseData;
CReparseAttr attr;
if (attr.Parse(di.ReparseData, di.ReparseData.Size()))
{

View File

@@ -29,7 +29,16 @@ struct CUpdatePair2
bool ExistOnDisk() const { return DirIndex != -1; }
bool ExistInArchive() const { return ArcIndex != -1; }
CUpdatePair2(): IsAnti(false), UseArcProps(false), DirIndex(-1), ArcIndex(-1), NewNameIndex(-1) {}
CUpdatePair2():
NewData(false),
NewProps(false),
UseArcProps(false),
IsAnti(false),
DirIndex(-1),
ArcIndex(-1),
NewNameIndex(-1),
IsMainRenameItem(false)
{}
};
struct IUpdateProduceCallback

View File

@@ -187,7 +187,7 @@ static const CFieldInfoInit kStandardFieldTable[] =
};
const int kNumSpacesMax = 32; // it must be larger than max CFieldInfoInit.Width
static char *g_Spaces =
static const char *g_Spaces =
" " ;
static void PrintSpaces(int numSpaces)

View File

@@ -820,7 +820,7 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
// It's fix for bug: crashing in XP. See example in MSDN: "Creating Context Menu Handlers".
#ifndef UNDER_CE
#if !defined(UNDER_CE) && defined(_MSC_VER)
if (commandInfo->cbSize == sizeof(CMINVOKECOMMANDINFOEX) &&
(commandInfo->fMask & CMIC_MASK_UNICODE) != 0)
{

View File

@@ -367,14 +367,6 @@ SOURCE=..\..\..\Common\StringToInt.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\TextConfig.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\TextConfig.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Types.h
# End Source File
# Begin Source File

View File

@@ -1,71 +0,0 @@
// OptionsDialog.cpp
#include "StdAfx.h"
#include "Windows/Control/PropertyPage.h"
#include "../FileManager/DialogSize.h"
#include "../FileManager/LangUtils.h"
#include "FoldersPage.h"
#include "FoldersPageRes.h"
#include "OptionsDialog.h"
#include "MenuPage.h"
#include "MenuPageRes.h"
#include "resource.h"
using namespace NWindows;
static INT_PTR OptionsDialog(HWND hwndOwner)
{
CMenuPage systemPage;
CFoldersPage foldersPage;
UINT32 langIDs[] = { 0x01000300, 0x01000200};
BIG_DIALOG_SIZE(200, 200);
UINT pageIDs[] = { SIZED_DIALOG(IDD_MENU), SIZED_DIALOG(IDD_FOLDERS) };
NControl::CPropertyPage *pagePinters[] = { &systemPage, &foldersPage };
CObjectVector<NControl::CPageInfo> pages;
const int kNumPages = ARRAY_SIZE(langIDs);
for (int i = 0; i < kNumPages; i++)
{
NControl::CPageInfo page;
page.Title = LangString(langIDs[i]);
page.ID = pageIDs[i];
page.Page = pagePinters[i];
pages.Add(page);
}
return NControl::MyPropertySheet(pages, hwndOwner,
LangString(IDS_CONFIG_DIALOG_CAPTION, 0x01000000));
}
STDMETHODIMP CSevenZipOptions::PluginOptions(HWND hWnd,
IPluginOptionsCallback * /* callback */)
{
/*
CComBSTR programPath;
RINOK(callback->GetProgramPath(programName)));
*/
OptionsDialog(hWnd);
return S_OK;
}
STDMETHODIMP CSevenZipOptions::GetFileExtensions(BSTR * /* extensions */)
{
/*
UString extStrings;
CObjectVector<NZipRootRegistry::CArchiverInfo> formats;
NZipRootRegistry::ReadArchiverInfoList(formats);
for(int i = 0; i < formats.Size(); i++)
{
if (i != 0)
extStrings += L' ';
extStrings += formats[i].Extension;
}
CComBSTR valueTemp = extStrings;
*extensions = valueTemp.Detach();
return S_OK;
*/
return E_NOTIMPL;
}

View File

@@ -1,23 +0,0 @@
// OptionsDialog.h
#ifndef __SEVENZIP_OPTIONSDIALOG_H
#define __SEVENZIP_OPTIONSDIALOG_H
#include "../FileManager/PluginInterface.h"
#include "Common/MyCom.h"
// {23170F69-40C1-278D-1000-000100020000}
DEFINE_GUID(CLSID_CSevenZipOptions,
0x23170F69, 0x40C1, 0x278D, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
class CSevenZipOptions:
public IPluginOptions,
public CMyUnknownImp
{
public:
MY_UNKNOWN_IMP
STDMETHOD(PluginOptions)(HWND hWnd, IPluginOptionsCallback *callback);
STDMETHOD(GetFileExtensions)(BSTR *extensions);
};
#endif

View File

@@ -25,7 +25,6 @@ COMMON_OBJS = \
$O\Random.obj \
$O\StringConvert.obj \
$O\StringToInt.obj \
$O\TextConfig.obj \
$O\UTFConvert.obj \
$O\Wildcard.obj \

View File

@@ -1004,7 +1004,7 @@ STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *
STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress)
{
RINOK(progress->SetTotal(numItems));
int prevDeletedFileIndex = -1;
// int prevDeletedFileIndex = -1;
for (UInt32 i = 0; i < numItems; i++)
{
// Sleep(200);
@@ -1025,7 +1025,7 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress
{
const CDirItem &fi = Files[index];
const FString fullPath = _path + GetRelPath(fi);
prevDeletedFileIndex = index;
// prevDeletedFileIndex = index;
if (fi.IsDir())
result = RemoveDirWithSubItems(fullPath);
else

View File

@@ -260,7 +260,7 @@ static HRESULT FsCopyFile(
&writeAskResult));
if (IntToBool(writeAskResult))
{
FString destPathNew = us2fs(destPathResult);
FString destPathNew = us2fs((const wchar_t *)(BSTR)destPathResult);
RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
if (!FsCopyFile(srcPath, destPathNew, callback, completedSize))
{
@@ -351,7 +351,7 @@ static HRESULT FsMoveFile(
&writeAskResult));
if (IntToBool(writeAskResult))
{
FString destPathNew = us2fs(destPathResult);
FString destPathNew = us2fs((const wchar_t *)(BSTR)destPathResult);
RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
if (!FsMoveFile(srcPath, destPathNew, callback, completedSize))
{

View File

@@ -2,24 +2,28 @@
#include "StdAfx.h"
#include "HelpUtils.h"
#if defined(UNDER_CE) || !defined(_WIN32)
void ShowHelpWindow(HWND, LPCWSTR)
{
}
#else
#include <HtmlHelp.h>
#include "../../../Common/StringConvert.h"
#include "../../../Windows/DLL.h"
#include "HelpUtils.h"
static LPCWSTR kHelpFileName = L"7-zip.chm::/";
#ifdef UNDER_CE
void ShowHelpWindow(HWND, LPCWSTR)
{
}
#else
void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
{
FString path = NWindows::NDLL::GetModuleDirPrefix();
HtmlHelp(hwnd, GetSystemString(fs2us(path) + kHelpFileName + topicFile), HH_DISPLAY_TOPIC, NULL);
HtmlHelp(hwnd, GetSystemString(fs2us(path) + kHelpFileName + topicFile), HH_DISPLAY_TOPIC, 0);
}
#endif

View File

@@ -3,6 +3,8 @@
#ifndef __MY_WINDOWS_NEW_H
#define __MY_WINDOWS_NEW_H
#ifdef _MSC_VER
#include <ShObjIdl.h>
#ifndef __ITaskbarList3_INTERFACE_DEFINED__
@@ -70,3 +72,5 @@ struct ITaskbarList3: public ITaskbarList2
#endif
#endif
#endif

View File

@@ -577,6 +577,10 @@ public:
bool _processTimerMem;
CPanel &_panel;
CDisableTimerProcessing(const CDisableTimerProcessing &);
CDisableTimerProcessing& operator=(const CDisableTimerProcessing &);
public:
CDisableTimerProcessing(CPanel &panel): _panel(panel) { Disable(); }
@@ -590,7 +594,6 @@ public:
{
_panel._processTimer = _processTimerMem;
}
CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; }
};
class CDisableNotify
@@ -599,6 +602,10 @@ public:
bool _processStatusBarMem;
CPanel &_panel;
CDisableNotify(const CDisableNotify &);
CDisableNotify& operator=(const CDisableNotify &);
public:
CDisableNotify(CPanel &panel): _panel(panel) { Disable(); }
@@ -620,7 +627,6 @@ public:
_panel._processNotify = _processNotifyMem;
_panel._processStatusBar = _processStatusBarMem;
}
CDisableNotify& operator=(const CDisableNotify &) {; }
};
// bool _passwordIsDefined;

View File

@@ -1137,11 +1137,11 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
return;
CProcess process;
HRESULT res;
/* HRESULT res; */
if (editMode)
res = StartEditApplication(fs2us(tempFilePath), useEditor, (HWND)*this, process);
/* res = */ StartEditApplication(fs2us(tempFilePath), useEditor, (HWND)*this, process);
else
res = StartApplication(fs2us(tempDirNorm), fs2us(tempFilePath), (HWND)*this, process);
/* res = */ StartApplication(fs2us(tempDirNorm), fs2us(tempFilePath), (HWND)*this, process);
if ((HANDLE)process == 0)
return;

View File

@@ -91,12 +91,12 @@ HRESULT CPanel::InitColumns()
ReadListViewInfo();
PROPID sortID;
// PROPID sortID;
/*
if (_listViewInfo.SortIndex >= 0)
sortID = _listViewInfo.Columns[_listViewInfo.SortIndex].PropID;
*/
sortID = _listViewInfo.SortID;
// sortID = _listViewInfo.SortID;
_ascending = _listViewInfo.Ascending;

View File

@@ -640,6 +640,10 @@ bool CPanel::InvokePluginCommand(int id)
return InvokePluginCommand(id, _sevenZipContextMenu, _systemContextMenu);
}
#if defined(_MSC_VER) && !defined(UNDER_CE)
#define use_CMINVOKECOMMANDINFOEX
#endif
bool CPanel::InvokePluginCommand(int id,
IContextMenu *sevenZipContextMenu, IContextMenu *systemContextMenu)
{
@@ -650,7 +654,7 @@ bool CPanel::InvokePluginCommand(int id,
else
offset = id - kSevenZipStartMenuID;
#ifdef UNDER_CE
#ifndef use_CMINVOKECOMMANDINFOEXR
CMINVOKECOMMANDINFO
#else
CMINVOKECOMMANDINFOEX
@@ -659,7 +663,7 @@ bool CPanel::InvokePluginCommand(int id,
memset(&commandInfo, 0, sizeof(commandInfo));
commandInfo.cbSize = sizeof(commandInfo);
commandInfo.fMask = 0
#ifndef UNDER_CE
#ifdef use_CMINVOKECOMMANDINFOEXR
| CMIC_MASK_UNICODE
#endif
;
@@ -669,7 +673,7 @@ bool CPanel::InvokePluginCommand(int id,
CSysString currentFolderSys = GetSystemString(_currentFolderPrefix);
commandInfo.lpDirectory = (LPCSTR)(LPCTSTR)(currentFolderSys);
commandInfo.nShow = SW_SHOW;
#ifndef UNDER_CE
#ifdef use_CMINVOKECOMMANDINFOEXR
commandInfo.lpParametersW = NULL;
commandInfo.lpTitle = "";
commandInfo.lpVerbW = (LPCWSTR)(MAKEINTRESOURCEW(offset));

View File

@@ -194,15 +194,15 @@ void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin))
fo.fAnyOperationsAborted = FALSE;
fo.hNameMappings = 0;
fo.lpszProgressTitle = 0;
int res;
// int res;
#ifdef _UNICODE
res = ::SHFileOperationW(&fo);
/* res = */ ::SHFileOperationW(&fo);
#else
SHFileOperationWP shFileOperationW = (SHFileOperationWP)
::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHFileOperationW");
if (shFileOperationW == 0)
return;
res = shFileOperationW(&fo);
/* res = */ shFileOperationW(&fo);
#endif
}
}
@@ -529,7 +529,7 @@ void CPanel::ChangeComment()
LangString(IDS_COMMENT2, dlg.Static);
if (dlg.Create(GetParent()) != IDOK)
return;
NCOM::CPropVariant propVariant = dlg.Value;
NCOM::CPropVariant propVariant = (const wchar_t *)dlg.Value;
CDisableNotify disableNotify(*this);
HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL);

View File

@@ -97,7 +97,7 @@ void CPanel::SetSortRawStatus()
int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
{
if (lpData == NULL)
if (lpData == 0)
return 0;
CPanel *panel = (CPanel*)lpData;
@@ -189,7 +189,7 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
{
if (lpData == NULL) return 0;
if (lpData == 0) return 0;
if (lParam1 == kParentIndex) return -1;
if (lParam2 == kParentIndex) return 1;

View File

@@ -1,207 +0,0 @@
// PluginsPage.cpp
#include "StdAfx.h"
#include "Common/MyCom.h"
#include "Windows/DLL.h"
#include "HelpUtils.h"
#include "LangUtils.h"
#include "PluginsPage.h"
#include "PluginsPageRes.h"
#include "ProgramLocation.h"
#include "PluginInterface.h"
static const UInt32 kLangIDs[] =
{
IDT_PLUGINS_PLUGINS,
IDB_PLUGINS_OPTIONS
};
static LPCWSTR kPluginsTopic = L"FM/options.htm#plugins";
bool CPluginsPage::OnInit()
{
LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs));
_listView.Attach(GetItem(IDL_PLUGINS));
UINT32 newFlags = /* LVS_EX_CHECKBOXES | */ LVS_EX_FULLROWSELECT;
_listView.SetExtendedListViewStyle(newFlags, newFlags);
_listView.InsertColumn(0, L"Plugins", 50);
ReadFileFolderPluginInfoList(_plugins);
_listView.SetRedraw(false);
// _listView.DeleteAllItems();
for (int i = 0; i < _plugins.Size(); i++)
{
const CPluginInfo &p = _plugins[i];
if (!p.OptionsClassIDDefined)
continue;
LVITEMW item;
item.iItem = i;
item.mask = LVIF_TEXT | LVIF_STATE;
UString pluginName = p.Name;
item.pszText = (WCHAR *)(const WCHAR *)pluginName;
item.state = 0;
item.stateMask = UINT(-1);
item.iSubItem = 0;
_listView.InsertItem(&item);
_listView.SetCheckState(i, true);
}
_listView.SetRedraw(true);
if (_listView.GetItemCount() > 0)
{
UINT state = LVIS_SELECTED | LVIS_FOCUSED;
_listView.SetItemState(0, state, state);
}
_listView.SetColumnWidthAuto(0);
return CPropertyPage::OnInit();
}
LONG CPluginsPage::OnApply()
{
/*
int selectedIndex = m_Lang.GetCurSel();
int aPathIndex = m_Lang.GetItemData(selectedIndex);
SaveRegLang(m_Paths[aPathIndex]);
ReloadLang();
*/
return PSNRET_NOERROR;
}
void CPluginsPage::OnNotifyHelp()
{
ShowHelpWindow(NULL, kPluginsTopic);
}
bool CPluginsPage::OnButtonClicked(int buttonID, HWND buttonHWND)
{
switch(buttonID)
{
case IDB_PLUGINS_OPTIONS:
OnButtonOptions();
break;
default:
return CPropertyPage::OnButtonClicked(buttonID, buttonHWND);
}
return true;
}
class CPluginOptionsCallback:
public IPluginOptionsCallback,
public CMyUnknownImp
{
UString _pluginName;
public:
MY_UNKNOWN_IMP
STDMETHOD(GetProgramFolderPath)(BSTR *value);
STDMETHOD(GetProgramPath)(BSTR *Value);
STDMETHOD(GetRegistryCUPath)(BSTR *Value);
void Init(const UString &pluginName)
{ _pluginName = pluginName; }
};
STDMETHODIMP CPluginOptionsCallback::GetProgramFolderPath(BSTR *value)
{
*value = 0;
UString folder;
if (!::GetProgramFolderPath(folder))
return E_FAIL;
return StringToBstr(folder, value);
}
static UString GetDefaultProgramName()
{
return L"7zFM.exe";
}
STDMETHODIMP CPluginOptionsCallback::GetProgramPath(BSTR *value)
{
*value = 0;
UString folder;
if (!::GetProgramFolderPath(folder))
return E_FAIL;
return StringToBstr(folder + GetDefaultProgramName(), value);
}
STDMETHODIMP CPluginOptionsCallback::GetRegistryCUPath(BSTR *value)
{
return StringToBstr(UString(L"Software"
WSTRING_PATH_SEPARATOR L"7-Zip"
WSTRING_PATH_SEPARATOR L"FM"
WSTRING_PATH_SEPARATOR L"Plugins"
WSTRING_PATH_SEPARATOR) + _pluginName, value);
}
void CPluginsPage::OnButtonOptions()
{
int index = _listView.GetSelectionMark();
if (index < 0)
return;
CPluginInfo pluginInfo = _plugins[index];
if (!pluginInfo.OptionsClassIDDefined)
{
MessageBoxW(*this, L"There are no options", L"7-Zip", 0);
return;
}
NWindows::NDLL::CLibrary lib;
CMyComPtr<IPluginOptions> pluginOptions;
if (!lib.Load(pluginInfo.FilePath))
{
MessageBoxW(*this, L"Can't load plugin", L"7-Zip", 0);
return;
}
typedef UINT32 (WINAPI * CreateObjectPointer)(const GUID *clsID, const GUID *interfaceID, void **outObject);
CreateObjectPointer createObject = (CreateObjectPointer)lib.GetProc("CreateObject");
if (createObject == NULL)
{
MessageBoxW(*this, L"Incorrect plugin", L"7-Zip", 0);
return;
}
if (createObject(&pluginInfo.OptionsClassID, &IID_IPluginOptions, (void **)&pluginOptions) != S_OK)
{
MessageBoxW(*this, L"There are no options", L"7-Zip", 0);
return;
}
CPluginOptionsCallback *callbackSpec = new CPluginOptionsCallback;
CMyComPtr<IPluginOptionsCallback> callback(callbackSpec);
callbackSpec->Init(pluginInfo.Name);
pluginOptions->PluginOptions(*this, callback);
}
bool CPluginsPage::OnNotify(UINT controlID, LPNMHDR lParam)
{
if (lParam->hwndFrom == HWND(_listView) && lParam->code == LVN_ITEMCHANGED)
{
const NMLISTVIEW *aNMListView = (const NMLISTVIEW *)lParam;
if ((aNMListView->uChanged & LVIF_STATE) != 0)
{
UINT oldState = aNMListView->uOldState & LVIS_STATEIMAGEMASK;
UINT newState = aNMListView->uNewState & LVIS_STATEIMAGEMASK;
if (oldState != newState)
Changed();
}
return true;
}
return CPropertyPage::OnNotify(controlID, lParam);
}
/*
bool CPluginsPage::OnCommand(int code, int itemID, LPARAM lParam)
{
if (code == CBN_SELCHANGE && itemID == IDC_LANG_COMBO_LANG)
{
Changed();
return true;
}
return CPropertyPage::OnCommand(code, itemID, lParam);
}
*/

View File

@@ -1,26 +0,0 @@
// PluginsPage.h
#include "Windows/Control/ListView.h"
#ifndef __PLUGINSPAGE_H
#define __PLUGINSPAGE_H
#include "Windows/Control/PropertyPage.h"
#include "Windows/Control/ComboBox.h"
#include "RegistryPlugins.h"
class CPluginsPage: public NWindows::NControl::CPropertyPage
{
NWindows::NControl::CListView _listView;
CObjectVector<CPluginInfo> _plugins;
public:
virtual bool OnInit();
virtual void OnNotifyHelp();
virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
virtual void OnButtonOptions();
virtual LONG OnApply();
virtual bool OnNotify(UINT controlID, LPNMHDR lParam);
};
#endif

View File

@@ -1,15 +0,0 @@
#include "PluginsPageRes.h"
#include "../../GuiCommon.rc"
#define xc 96
#define yc 80
IDD_PLUGINS MY_PAGE
CAPTION "Plugins"
BEGIN
LTEXT "&Plugins:", IDC_PLUGINS_STATIC_PLUGINS, m, m, xc, 8
CONTROL "List1", IDC_PLUGINS_LIST, "SysListView32",
LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,
m, 20, xc, 40
PUSHBUTTON "Options...", IDC_PLUGINS_BUTTON_OPTIONS, m, by, bxs, bys
END

View File

@@ -1,4 +0,0 @@
#define IDD_PLUGINS 999
#define IDT_PLUGINS_PLUGINS 999
#define IDL_PLUGINS 999
#define IDB_PLUGINS_OPTIONS 999

View File

@@ -54,7 +54,7 @@ bool CProgressDialog::OnInit()
_dialogCreatedEvent.Set();
#ifdef LANG
LangSetDlgItemsText(*this, NULL, 0);
LangSetDlgItems(*this, NULL, 0);
#endif
m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));

Some files were not shown because too many files have changed in this diff Show More