mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-11 00:07:09 -06:00
Merge branch 'pr/1'
This commit is contained in:
@@ -33,7 +33,7 @@ HINSTANCE g_hInstance = 0;
|
||||
|
||||
// Tou can find the list of all GUIDs in Guid.txt file.
|
||||
// use another CLSIDs, if you want to support other formats (zip, rar, ...).
|
||||
// {23170F69-0803-278A-1000-000110070000}
|
||||
// {23170F69-40C1-278A-1000-000110070000}
|
||||
|
||||
DEFINE_GUID(CLSID_CFormat7z,
|
||||
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "../../../Common/StringConvert.h"
|
||||
#include "../../../Common/StringToInt.h"
|
||||
|
||||
#include "../../../Windows/ErrorMsg.h"
|
||||
#include "../../../Windows/FileDir.h"
|
||||
#include "../../../Windows/FileName.h"
|
||||
#ifdef _WIN32
|
||||
@@ -39,7 +40,9 @@
|
||||
extern bool g_CaseSensitive;
|
||||
extern bool g_PathTrailReplaceMode;
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
bool g_LargePagesMode = false;
|
||||
#endif
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
||||
@@ -410,8 +413,19 @@ static void AddToCensorFromListFile(
|
||||
UStringVector names;
|
||||
if (!NFind::DoesFileExist(us2fs(fileName)))
|
||||
throw CArcCmdLineException(kCannotFindListFile, fileName);
|
||||
if (!ReadNamesFromListFile(us2fs(fileName), names, codePage))
|
||||
DWORD lastError = 0;
|
||||
if (!ReadNamesFromListFile2(us2fs(fileName), names, codePage, lastError))
|
||||
{
|
||||
if (lastError != 0)
|
||||
{
|
||||
UString m;
|
||||
m = "The file operation error for listfile";
|
||||
m.Add_LF();
|
||||
m += NError::MyFormatMessage(lastError);
|
||||
throw CArcCmdLineException(m, fileName);
|
||||
}
|
||||
throw CArcCmdLineException(kIncorrectListFile, fileName);
|
||||
}
|
||||
if (renamePairs)
|
||||
{
|
||||
if ((names.Size() & 1) != 0)
|
||||
|
||||
@@ -1182,7 +1182,9 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
bool needDelete = true;
|
||||
if (needDelete)
|
||||
{
|
||||
if (NFind::DoesFileExist(fullProcessedPath))
|
||||
if (!DeleteFileAlways(fullProcessedPath))
|
||||
if (GetLastError() != ERROR_FILE_NOT_FOUND)
|
||||
{
|
||||
RINOK(SendMessageError_with_LastError(kCantDeleteOutputFile, fullProcessedPath));
|
||||
return S_OK;
|
||||
@@ -1368,13 +1370,35 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
// UInt64 ticks = GetCpuTicks();
|
||||
bool res = _outFileStreamSpec->File.SetLength(_curSize);
|
||||
_fileLengthWasSet = res;
|
||||
_outFileStreamSpec->File.SeekToBegin();
|
||||
|
||||
// ticks = GetCpuTicks() - ticks;
|
||||
// printf("\nticks = %10d\n", (unsigned)ticks);
|
||||
if (!res)
|
||||
{
|
||||
RINOK(SendMessageError_with_LastError(kCantSetFileLen, fullProcessedPath));
|
||||
}
|
||||
|
||||
/*
|
||||
_outFileStreamSpec->File.Close();
|
||||
ticks = GetCpuTicks() - ticks;
|
||||
printf("\nticks = %10d\n", (unsigned)ticks);
|
||||
return S_FALSE;
|
||||
*/
|
||||
|
||||
/*
|
||||
File.SetLength() on FAT (xp64): is fast, but then File.Close() can be slow,
|
||||
if we don't write any data.
|
||||
File.SetLength() for remote share file (exFAT) can be slow in some cases,
|
||||
and the Windows can return "network error" after 1 minute,
|
||||
while remote file still can grow.
|
||||
We need some way to detect such bad cases and disable PreAllocateOutFile mode.
|
||||
*/
|
||||
|
||||
res = _outFileStreamSpec->File.SeekToBegin();
|
||||
if (!res)
|
||||
{
|
||||
RINOK(SendMessageError_with_LastError("Can not seek to begin of file", fullProcessedPath));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_ALT_STREAMS
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/Wildcard.h"
|
||||
|
||||
#include "../../../Windows/FileDir.h"
|
||||
#include "../../../Windows/FileName.h"
|
||||
|
||||
@@ -11,7 +13,7 @@
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
|
||||
UString CreateArchiveName(const NFind::CFileInfo &fi, bool keepName)
|
||||
static UString CreateArchiveName(const NFind::CFileInfo &fi, bool keepName)
|
||||
{
|
||||
FString resultName = fi.Name;
|
||||
if (!fi.IsDir() && !keepName)
|
||||
@@ -72,7 +74,82 @@ static FString CreateArchiveName2(const FString &path, bool fromPrev, bool keepN
|
||||
return resultName;
|
||||
}
|
||||
|
||||
UString CreateArchiveName(const UString &path, bool fromPrev, bool keepName)
|
||||
|
||||
UString CreateArchiveName(const UStringVector &paths, const NFind::CFileInfo *fi)
|
||||
{
|
||||
return Get_Correct_FsFile_Name(fs2us(CreateArchiveName2(us2fs(path), fromPrev, keepName)));
|
||||
bool keepName = false;
|
||||
/*
|
||||
if (paths.Size() == 1)
|
||||
{
|
||||
const UString &name = paths[0];
|
||||
if (name.Len() > 4)
|
||||
if (CompareFileNames(name.RightPtr(4), L".tar") == 0)
|
||||
keepName = true;
|
||||
}
|
||||
*/
|
||||
|
||||
UString name;
|
||||
if (fi)
|
||||
name = CreateArchiveName(*fi, keepName);
|
||||
else
|
||||
{
|
||||
if (paths.IsEmpty())
|
||||
return L"archive";
|
||||
bool fromPrev = (paths.Size() > 1);
|
||||
name = Get_Correct_FsFile_Name(fs2us(CreateArchiveName2(us2fs(paths.Front()), fromPrev, keepName)));
|
||||
}
|
||||
|
||||
UStringVector names;
|
||||
|
||||
{
|
||||
FOR_VECTOR (i, paths)
|
||||
{
|
||||
NFind::CFileInfo fi2;
|
||||
const NFind::CFileInfo *fp;
|
||||
if (fi && paths.Size() == 1)
|
||||
fp = fi;
|
||||
else
|
||||
{
|
||||
if (!fi2.Find(us2fs(paths[i])))
|
||||
continue;
|
||||
fp = &fi2;
|
||||
}
|
||||
names.Add(fs2us(fp->Name));
|
||||
}
|
||||
}
|
||||
|
||||
UString postfix;
|
||||
UInt32 index = 1;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// we don't want cases when we include archive to itself.
|
||||
// so we find first available name for archive
|
||||
const UString name2 = name + postfix;
|
||||
const UString name2_zip = name2 + L".zip";
|
||||
const UString name2_7z = name2 + L".7z";
|
||||
const UString name2_tar = name2 + L".tar";
|
||||
const UString name2_wim = name2 + L".wim";
|
||||
|
||||
unsigned i = 0;
|
||||
|
||||
for (i = 0; i < names.Size(); i++)
|
||||
{
|
||||
const UString &fname = names[i];
|
||||
if ( 0 == CompareFileNames(fname, name2_zip)
|
||||
|| 0 == CompareFileNames(fname, name2_7z)
|
||||
|| 0 == CompareFileNames(fname, name2_tar)
|
||||
|| 0 == CompareFileNames(fname, name2_wim))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == names.Size())
|
||||
break;
|
||||
index++;
|
||||
postfix = "_";
|
||||
postfix.Add_UInt32(index);
|
||||
}
|
||||
|
||||
name += postfix;
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,8 @@
|
||||
#ifndef __ARCHIVE_NAME_H
|
||||
#define __ARCHIVE_NAME_H
|
||||
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
#include "../../../Windows/FileFind.h"
|
||||
|
||||
UString CreateArchiveName(const UString &path, bool fromPrev, bool keepName);
|
||||
UString CreateArchiveName(const NWindows::NFile::NFind::CFileInfo &fileInfo, bool keepName);
|
||||
UString CreateArchiveName(const UStringVector &paths, const NWindows::NFile::NFind::CFileInfo *fi = NULL);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -102,7 +102,14 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre
|
||||
// if (!allowAbsVolPaths)
|
||||
if (!IsSafePath(name2))
|
||||
return S_FALSE;
|
||||
|
||||
|
||||
// #ifdef _WIN32
|
||||
// we don't want to support wildcards in names here here
|
||||
if (name2.Find(L'?') >= 0 ||
|
||||
name2.Find(L'*') >= 0)
|
||||
return S_FALSE;
|
||||
// #endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#endif
|
||||
|
||||
#include "../../../../C/7zCrc.h"
|
||||
#include "../../../../C/Alloc.h"
|
||||
#include "../../../../C/CpuArch.h"
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
@@ -47,6 +46,7 @@
|
||||
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/MyBuffer2.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
#include "../../../Common/StringToInt.h"
|
||||
|
||||
@@ -94,80 +94,33 @@ static const UInt32 kAdditionalSize = (1 << 16);
|
||||
static const UInt32 kCompressedAdditionalSize = (1 << 10);
|
||||
static const UInt32 kMaxLzmaPropSize = 5;
|
||||
|
||||
|
||||
|
||||
#define ALLOC_WITH_HRESULT(_buffer_, _size_) \
|
||||
(_buffer_)->Alloc(_size_); \
|
||||
if (!(_buffer_)->IsAllocated()) return E_OUTOFMEMORY;
|
||||
|
||||
|
||||
class CBaseRandomGenerator
|
||||
{
|
||||
UInt32 A1;
|
||||
UInt32 A2;
|
||||
UInt32 Salt;
|
||||
public:
|
||||
CBaseRandomGenerator() { Init(); }
|
||||
CBaseRandomGenerator(UInt32 salt = 0): Salt(salt) { Init(); }
|
||||
void Init() { A1 = 362436069; A2 = 521288629;}
|
||||
UInt32 GetRnd()
|
||||
{
|
||||
return
|
||||
return Salt ^
|
||||
(
|
||||
((A1 = 36969 * (A1 & 0xffff) + (A1 >> 16)) << 16) +
|
||||
((A2 = 18000 * (A2 & 0xffff) + (A2 >> 16)) );
|
||||
((A2 = 18000 * (A2 & 0xffff) + (A2 >> 16)) )
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static const unsigned kBufferAlignment = 1 << 4;
|
||||
|
||||
struct CBenchBuffer
|
||||
{
|
||||
size_t BufferSize;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
Byte *Buffer;
|
||||
|
||||
CBenchBuffer(): BufferSize(0), Buffer(NULL) {}
|
||||
~CBenchBuffer() { ::MidFree(Buffer); }
|
||||
|
||||
void AllocAlignedMask(size_t size, size_t)
|
||||
{
|
||||
::MidFree(Buffer);
|
||||
BufferSize = 0;
|
||||
Buffer = (Byte *)::MidAlloc(size);
|
||||
if (Buffer)
|
||||
BufferSize = size;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
Byte *Buffer;
|
||||
Byte *_bufBase;
|
||||
|
||||
CBenchBuffer(): BufferSize(0), Buffer(NULL), _bufBase(NULL){}
|
||||
~CBenchBuffer() { ::MidFree(_bufBase); }
|
||||
|
||||
void AllocAlignedMask(size_t size, size_t alignMask)
|
||||
{
|
||||
::MidFree(_bufBase);
|
||||
Buffer = NULL;
|
||||
BufferSize = 0;
|
||||
_bufBase = (Byte *)::MidAlloc(size + alignMask);
|
||||
|
||||
if (_bufBase)
|
||||
{
|
||||
// Buffer = (Byte *)(((uintptr_t)_bufBase + alignMask) & ~(uintptr_t)alignMask);
|
||||
Buffer = (Byte *)(((ptrdiff_t)_bufBase + alignMask) & ~(ptrdiff_t)alignMask);
|
||||
BufferSize = size;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool Alloc(size_t size)
|
||||
{
|
||||
if (Buffer && BufferSize == size)
|
||||
return true;
|
||||
AllocAlignedMask(size, kBufferAlignment - 1);
|
||||
return (Buffer != NULL || size == 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CBenchRandomGenerator: public CBenchBuffer
|
||||
class CBenchRandomGenerator: public CAlignedBuffer
|
||||
{
|
||||
static UInt32 GetVal(UInt32 &res, unsigned numBits)
|
||||
{
|
||||
@@ -184,23 +137,22 @@ class CBenchRandomGenerator: public CBenchBuffer
|
||||
|
||||
public:
|
||||
|
||||
void GenerateSimpleRandom(CBaseRandomGenerator *_RG_)
|
||||
void GenerateSimpleRandom(UInt32 salt)
|
||||
{
|
||||
CBaseRandomGenerator rg = *_RG_;
|
||||
const size_t bufSize = BufferSize;
|
||||
Byte *buf = Buffer;
|
||||
CBaseRandomGenerator rg(salt);
|
||||
const size_t bufSize = Size();
|
||||
Byte *buf = (Byte *)*this;
|
||||
for (size_t i = 0; i < bufSize; i++)
|
||||
buf[i] = (Byte)rg.GetRnd();
|
||||
*_RG_ = rg;
|
||||
}
|
||||
|
||||
void GenerateLz(unsigned dictBits, CBaseRandomGenerator *_RG_)
|
||||
void GenerateLz(unsigned dictBits, UInt32 salt)
|
||||
{
|
||||
CBaseRandomGenerator rg = *_RG_;
|
||||
CBaseRandomGenerator rg(salt);
|
||||
UInt32 pos = 0;
|
||||
UInt32 rep0 = 1;
|
||||
const size_t bufSize = BufferSize;
|
||||
Byte *buf = Buffer;
|
||||
const size_t bufSize = Size();
|
||||
Byte *buf = (Byte *)*this;
|
||||
unsigned posBits = 1;
|
||||
|
||||
while (pos < bufSize)
|
||||
@@ -255,8 +207,6 @@ public:
|
||||
*dest++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
*_RG_ = rg;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -297,7 +247,7 @@ STDMETHODIMP CBenchmarkInStream::Read(void *data, UInt32 size, UInt32 *processed
|
||||
|
||||
class CBenchmarkOutStream:
|
||||
public ISequentialOutStream,
|
||||
public CBenchBuffer,
|
||||
public CAlignedBuffer,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
// bool _overflow;
|
||||
@@ -325,13 +275,13 @@ public:
|
||||
|
||||
STDMETHODIMP CBenchmarkOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
size_t curSize = BufferSize - Pos;
|
||||
size_t curSize = Size() - Pos;
|
||||
if (curSize > size)
|
||||
curSize = size;
|
||||
if (curSize != 0)
|
||||
{
|
||||
if (RealCopy)
|
||||
memcpy(Buffer + Pos, data, curSize);
|
||||
memcpy(((Byte *)*this) + Pos, data, curSize);
|
||||
if (CalcCrc)
|
||||
Crc = CrcUpdate(Crc, data, curSize);
|
||||
Pos += curSize;
|
||||
@@ -522,10 +472,9 @@ class CBenchProgressInfo:
|
||||
{
|
||||
public:
|
||||
CBenchProgressStatus *Status;
|
||||
HRESULT Res;
|
||||
IBenchCallback *Callback;
|
||||
|
||||
CBenchProgressInfo(): Callback(0) {}
|
||||
CBenchProgressInfo(): Callback(NULL) {}
|
||||
MY_UNKNOWN_IMP
|
||||
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
|
||||
};
|
||||
@@ -687,20 +636,39 @@ UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt
|
||||
return props.GetDecompressRating(elapsedTime, freq, outSize, inSize, numIterations);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
struct CBenchSyncCommon
|
||||
{
|
||||
bool ExitMode;
|
||||
NSynchronization::CManualResetEvent StartEvent;
|
||||
|
||||
CBenchSyncCommon(): ExitMode(false) {}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
struct CEncoderInfo;
|
||||
|
||||
struct CEncoderInfo
|
||||
{
|
||||
#ifndef _7ZIP_ST
|
||||
NWindows::CThread thread[2];
|
||||
NSynchronization::CManualResetEvent ReadyEvent;
|
||||
UInt32 NumDecoderSubThreads;
|
||||
CBenchSyncCommon *Common;
|
||||
#endif
|
||||
|
||||
CMyComPtr<ICompressCoder> _encoder;
|
||||
CMyComPtr<ICompressFilter> _encoderFilter;
|
||||
CBenchProgressInfo *progressInfoSpec[2];
|
||||
CMyComPtr<ICompressProgressInfo> progressInfo[2];
|
||||
UInt64 NumIterations;
|
||||
|
||||
UInt32 Salt;
|
||||
|
||||
#ifdef USE_ALLOCA
|
||||
size_t AllocaSize;
|
||||
#endif
|
||||
@@ -739,26 +707,29 @@ struct CEncoderInfo
|
||||
const Byte *fileData;
|
||||
CBenchRandomGenerator rg;
|
||||
|
||||
CBenchBuffer rgCopy; // it must be 16-byte aligned !!!
|
||||
CAlignedBuffer rgCopy; // it must be 16-byte aligned !!!
|
||||
CBenchmarkOutStream *propStreamSpec;
|
||||
CMyComPtr<ISequentialOutStream> propStream;
|
||||
|
||||
// for decode
|
||||
unsigned generateDictBits;
|
||||
COneMethodInfo _method;
|
||||
|
||||
// for decode
|
||||
size_t _uncompressedDataSize;
|
||||
|
||||
HRESULT Init(
|
||||
const COneMethodInfo &method,
|
||||
unsigned generateDictBits,
|
||||
CBaseRandomGenerator *rg);
|
||||
HRESULT Generate();
|
||||
HRESULT Encode();
|
||||
HRESULT Decode(UInt32 decoderIndex);
|
||||
|
||||
CEncoderInfo():
|
||||
#ifndef _7ZIP_ST
|
||||
Common(NULL),
|
||||
#endif
|
||||
Salt(0),
|
||||
fileData(NULL),
|
||||
CheckCrc_Enc(true),
|
||||
CheckCrc_Dec(true),
|
||||
outStreamSpec(0), callback(0), printCallback(0), propStreamSpec(0) {}
|
||||
outStreamSpec(NULL), callback(NULL), printCallback(NULL), propStreamSpec(NULL) {}
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
|
||||
@@ -773,14 +744,15 @@ struct CEncoderInfo
|
||||
#endif
|
||||
|
||||
res = encoder->Encode();
|
||||
encoder->Results[0] = res;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
res = E_FAIL;
|
||||
}
|
||||
encoder->Results[0] = res;
|
||||
if (res != S_OK)
|
||||
encoder->progressInfoSpec[0]->Status->SetResult(res);
|
||||
encoder->ReadyEvent.Set();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -799,7 +771,12 @@ struct CEncoderInfo
|
||||
|
||||
HRESULT CreateEncoderThread()
|
||||
{
|
||||
return thread[0].Create(EncodeThreadFunction, this);
|
||||
WRes res = 0;
|
||||
if (!ReadyEvent.IsCreated())
|
||||
res = ReadyEvent.Create();
|
||||
if (res == 0)
|
||||
res = thread[0].Create(EncodeThreadFunction, this);
|
||||
return HRESULT_FROM_WIN32(res);
|
||||
}
|
||||
|
||||
HRESULT CreateDecoderThread(unsigned index, bool callbackMode
|
||||
@@ -824,11 +801,10 @@ struct CEncoderInfo
|
||||
};
|
||||
|
||||
|
||||
HRESULT CEncoderInfo::Init(
|
||||
const COneMethodInfo &method,
|
||||
unsigned generateDictBits,
|
||||
CBaseRandomGenerator *rgLoc)
|
||||
HRESULT CEncoderInfo::Generate()
|
||||
{
|
||||
const COneMethodInfo &method = _method;
|
||||
|
||||
// we need extra space, if input data is already compressed
|
||||
const size_t kCompressedBufferSize =
|
||||
kCompressedAdditionalSize +
|
||||
@@ -842,40 +818,39 @@ HRESULT CEncoderInfo::Init(
|
||||
|
||||
if (!fileData)
|
||||
{
|
||||
if (!rg.Alloc(kBufferSize))
|
||||
return E_OUTOFMEMORY;
|
||||
ALLOC_WITH_HRESULT(&rg, kBufferSize);
|
||||
|
||||
// DWORD ttt = GetTickCount();
|
||||
if (generateDictBits == 0)
|
||||
rg.GenerateSimpleRandom(rgLoc);
|
||||
rg.GenerateSimpleRandom(Salt);
|
||||
else
|
||||
rg.GenerateLz(generateDictBits, rgLoc);
|
||||
rg.GenerateLz(generateDictBits, Salt);
|
||||
// printf("\n%d\n ", GetTickCount() - ttt);
|
||||
|
||||
crc = CrcCalc(rg.Buffer, rg.BufferSize);
|
||||
uncompressedDataPtr = rg.Buffer;
|
||||
crc = CrcCalc((const Byte *)rg, rg.Size());
|
||||
uncompressedDataPtr = (const Byte *)rg;
|
||||
}
|
||||
|
||||
if (_encoderFilter)
|
||||
{
|
||||
if (!rgCopy.Alloc(kBufferSize))
|
||||
return E_OUTOFMEMORY;
|
||||
ALLOC_WITH_HRESULT(&rgCopy, kBufferSize);
|
||||
}
|
||||
|
||||
|
||||
outStreamSpec = new CBenchmarkOutStream;
|
||||
outStream = outStreamSpec;
|
||||
if (!outStreamSpec->Alloc(kCompressedBufferSize))
|
||||
return E_OUTOFMEMORY;
|
||||
if (!outStream)
|
||||
{
|
||||
outStreamSpec = new CBenchmarkOutStream;
|
||||
outStream = outStreamSpec;
|
||||
}
|
||||
|
||||
ALLOC_WITH_HRESULT(outStreamSpec, kCompressedBufferSize)
|
||||
|
||||
propStreamSpec = 0;
|
||||
if (!propStream)
|
||||
{
|
||||
propStreamSpec = new CBenchmarkOutStream;
|
||||
propStream = propStreamSpec;
|
||||
}
|
||||
if (!propStreamSpec->Alloc(kMaxLzmaPropSize))
|
||||
return E_OUTOFMEMORY;
|
||||
ALLOC_WITH_HRESULT(propStreamSpec, kMaxLzmaPropSize);
|
||||
propStreamSpec->Init(true, false);
|
||||
|
||||
|
||||
@@ -962,6 +937,28 @@ static void My_FilterBench(ICompressFilter *filter, Byte *data, size_t size)
|
||||
|
||||
HRESULT CEncoderInfo::Encode()
|
||||
{
|
||||
RINOK(Generate());
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
if (Common)
|
||||
{
|
||||
Results[0] = S_OK;
|
||||
WRes wres = ReadyEvent.Set();
|
||||
if (wres == 0)
|
||||
wres = Common->StartEvent.Lock();
|
||||
if (wres != 0)
|
||||
return HRESULT_FROM_WIN32(wres);
|
||||
if (Common->ExitMode)
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
CBenchProgressInfo *bpi = progressInfoSpec[0];
|
||||
bpi->SetStartTime();
|
||||
}
|
||||
|
||||
|
||||
CBenchInfo &bi = progressInfoSpec[0]->BenchInfo;
|
||||
bi.UnpackSize = 0;
|
||||
bi.PackSize = 0;
|
||||
@@ -998,10 +995,10 @@ HRESULT CEncoderInfo::Encode()
|
||||
|
||||
if (_encoderFilter)
|
||||
{
|
||||
memcpy(rgCopy.Buffer, uncompressedDataPtr, kBufferSize);
|
||||
memcpy((Byte *)rgCopy, uncompressedDataPtr, kBufferSize);
|
||||
_encoderFilter->Init();
|
||||
My_FilterBench(_encoderFilter, rgCopy.Buffer, kBufferSize);
|
||||
RINOK(WriteStream(outStream, rgCopy.Buffer, kBufferSize));
|
||||
My_FilterBench(_encoderFilter, (Byte *)rgCopy, kBufferSize);
|
||||
RINOK(WriteStream(outStream, (const Byte *)rgCopy, kBufferSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1079,7 +1076,7 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex)
|
||||
|
||||
if (setDecProps)
|
||||
{
|
||||
RINOK(setDecProps->SetDecoderProperties2(propStreamSpec->Buffer, (UInt32)propStreamSpec->Pos));
|
||||
RINOK(setDecProps->SetDecoderProperties2((const Byte *)*propStreamSpec, (UInt32)propStreamSpec->Pos));
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1107,7 +1104,7 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex)
|
||||
prev = pi->BenchInfo.UnpackSize;
|
||||
}
|
||||
|
||||
inStreamSpec->Init(outStreamSpec->Buffer, compressedSize);
|
||||
inStreamSpec->Init((const Byte *)*outStreamSpec, compressedSize);
|
||||
crcOutStreamSpec->Init();
|
||||
|
||||
UInt64 outSize = kBufferSize;
|
||||
@@ -1115,12 +1112,12 @@ HRESULT CEncoderInfo::Decode(UInt32 decoderIndex)
|
||||
|
||||
if (_decoderFilter)
|
||||
{
|
||||
if (compressedSize > rgCopy.BufferSize)
|
||||
if (compressedSize > rgCopy.Size())
|
||||
return E_FAIL;
|
||||
memcpy(rgCopy.Buffer, outStreamSpec->Buffer, compressedSize);
|
||||
memcpy((Byte *)rgCopy, (const Byte *)*outStreamSpec, compressedSize);
|
||||
_decoderFilter->Init();
|
||||
My_FilterBench(_decoderFilter, rgCopy.Buffer, compressedSize);
|
||||
RINOK(WriteStream(crcOutStream, rgCopy.Buffer, compressedSize));
|
||||
My_FilterBench(_decoderFilter, (Byte *)rgCopy, compressedSize);
|
||||
RINOK(WriteStream(crcOutStream, (const Byte *)rgCopy, compressedSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1144,7 +1141,7 @@ static const UInt32 kNumThreadsMax = (1 << 12);
|
||||
struct CBenchEncoders
|
||||
{
|
||||
CEncoderInfo *encoders;
|
||||
CBenchEncoders(UInt32 num): encoders(0) { encoders = new CEncoderInfo[num]; }
|
||||
CBenchEncoders(UInt32 num): encoders(NULL) { encoders = new CEncoderInfo[num]; }
|
||||
~CBenchEncoders() { delete []encoders; }
|
||||
};
|
||||
|
||||
@@ -1158,6 +1155,57 @@ static UInt64 GetNumIterations(UInt64 numCommands, UInt64 complexInCommands)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
|
||||
// ---------- CBenchThreadsFlusher ----------
|
||||
|
||||
struct CBenchThreadsFlusher
|
||||
{
|
||||
CBenchEncoders *EncodersSpec;
|
||||
CBenchSyncCommon Common;
|
||||
unsigned NumThreads;
|
||||
bool NeedClose;
|
||||
|
||||
CBenchThreadsFlusher(): NumThreads(0), NeedClose(false) {}
|
||||
|
||||
~CBenchThreadsFlusher()
|
||||
{
|
||||
StartAndWait(true);
|
||||
}
|
||||
|
||||
WRes StartAndWait(bool exitMode = false);
|
||||
};
|
||||
|
||||
|
||||
WRes CBenchThreadsFlusher::StartAndWait(bool exitMode)
|
||||
{
|
||||
if (!NeedClose)
|
||||
return 0;
|
||||
|
||||
Common.ExitMode = exitMode;
|
||||
WRes res = Common.StartEvent.Set();
|
||||
|
||||
for (unsigned i = 0; i < NumThreads; i++)
|
||||
{
|
||||
NWindows::CThread &t = EncodersSpec->encoders[i].thread[0];
|
||||
if (t.IsCreated())
|
||||
{
|
||||
WRes res2 = t.Wait();
|
||||
if (res2 == 0)
|
||||
res2 = t.Close();
|
||||
if (res == S_OK)
|
||||
res = res2;
|
||||
}
|
||||
}
|
||||
NeedClose = false;
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static HRESULT MethodBench(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
UInt64 complexInCommands,
|
||||
@@ -1209,6 +1257,8 @@ static HRESULT MethodBench(
|
||||
numSubDecoderThreads = 2;
|
||||
}
|
||||
}
|
||||
|
||||
bool mtEncMode = (numEncoderThreads > 1);
|
||||
#endif
|
||||
|
||||
CBenchEncoders encodersSpec(numEncoderThreads);
|
||||
@@ -1248,9 +1298,6 @@ static HRESULT MethodBench(
|
||||
}
|
||||
}
|
||||
|
||||
CBaseRandomGenerator rg;
|
||||
rg.Init();
|
||||
|
||||
UInt32 crc = 0;
|
||||
if (fileData)
|
||||
crc = CrcCalc(fileData, uncompressedDataSize);
|
||||
@@ -1259,22 +1306,38 @@ static HRESULT MethodBench(
|
||||
{
|
||||
CEncoderInfo &encoder = encoders[i];
|
||||
encoder._method = method;
|
||||
encoder.generateDictBits = generateDictBits;
|
||||
encoder._uncompressedDataSize = uncompressedDataSize;
|
||||
encoder.kBufferSize = uncompressedDataSize;
|
||||
encoder.fileData = fileData;
|
||||
encoder.crc = crc;
|
||||
|
||||
RINOK(encoders[i].Init(method, generateDictBits, &rg));
|
||||
}
|
||||
|
||||
CBenchProgressStatus status;
|
||||
status.Res = S_OK;
|
||||
status.EncodeMode = true;
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
CBenchThreadsFlusher encoderFlusher;
|
||||
if (mtEncMode)
|
||||
{
|
||||
WRes wres = encoderFlusher.Common.StartEvent.Create();
|
||||
if (wres != 0)
|
||||
return HRESULT_FROM_WIN32(wres);
|
||||
encoderFlusher.NumThreads = numEncoderThreads;
|
||||
encoderFlusher.EncodersSpec = &encodersSpec;
|
||||
encoderFlusher.NeedClose = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (i = 0; i < numEncoderThreads; i++)
|
||||
{
|
||||
CEncoderInfo &encoder = encoders[i];
|
||||
encoder.NumIterations = GetNumIterations(benchProps->GeComprCommands(uncompressedDataSize), complexInCommands);
|
||||
encoder.Salt = g_CrcTable[i & 0xFF];
|
||||
encoder.Salt ^= (g_CrcTable[(i >> 8) & 0xFF] << 3);
|
||||
// (g_CrcTable[0] == 0), and (encoder.Salt == 0) for first thread
|
||||
// printf(" %8x", encoder.Salt);
|
||||
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
@@ -1289,30 +1352,50 @@ static HRESULT MethodBench(
|
||||
CBenchProgressInfo *bpi = encoder.progressInfoSpec[0];
|
||||
bpi->Callback = callback;
|
||||
bpi->BenchInfo.NumIterations = numEncoderThreads;
|
||||
bpi->SetStartTime();
|
||||
}
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
if (numEncoderThreads > 1)
|
||||
if (mtEncMode)
|
||||
{
|
||||
#ifdef USE_ALLOCA
|
||||
encoder.AllocaSize = (i * 16 * 21) & 0x7FF;
|
||||
#endif
|
||||
|
||||
encoder.Common = &encoderFlusher.Common;
|
||||
RINOK(encoder.CreateEncoderThread())
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
RINOK(encoder.Encode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (printCallback)
|
||||
{
|
||||
RINOK(printCallback->CheckBreak());
|
||||
}
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
if (numEncoderThreads > 1)
|
||||
if (mtEncMode)
|
||||
{
|
||||
for (i = 0; i < numEncoderThreads; i++)
|
||||
encoders[i].thread[0].Wait();
|
||||
{
|
||||
CEncoderInfo &encoder = encoders[i];
|
||||
WRes wres = encoder.ReadyEvent.Lock();
|
||||
if (wres != 0)
|
||||
return HRESULT_FROM_WIN32(wres);
|
||||
RINOK(encoder.Results[0]);
|
||||
}
|
||||
|
||||
CBenchProgressInfo *bpi = encoders[0].progressInfoSpec[0];
|
||||
bpi->SetStartTime();
|
||||
|
||||
WRes wres = encoderFlusher.StartAndWait();
|
||||
if (status.Res == 0 && wres != 0)
|
||||
return HRESULT_FROM_WIN32(wres);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
RINOK(encoders[0].Encode());
|
||||
}
|
||||
|
||||
RINOK(status.Res);
|
||||
|
||||
@@ -1328,11 +1411,16 @@ static HRESULT MethodBench(
|
||||
CEncoderInfo &encoder = encoders[i];
|
||||
info.UnpackSize += encoder.kBufferSize;
|
||||
info.PackSize += encoder.compressedSize;
|
||||
// printf("\n%7d\n", encoder.compressedSize);
|
||||
}
|
||||
|
||||
RINOK(callback->SetEncodeResult(info, true));
|
||||
|
||||
|
||||
|
||||
|
||||
// ---------- Decode ----------
|
||||
|
||||
status.Res = S_OK;
|
||||
status.EncodeMode = false;
|
||||
|
||||
@@ -1545,7 +1633,7 @@ struct CFreqThreads
|
||||
CFreqInfo *Items;
|
||||
UInt32 NumThreads;
|
||||
|
||||
CFreqThreads(): Items(0), NumThreads(0) {}
|
||||
CFreqThreads(): Items(NULL), NumThreads(0) {}
|
||||
void WaitAll()
|
||||
{
|
||||
for (UInt32 i = 0; i < NumThreads; i++)
|
||||
@@ -1603,7 +1691,7 @@ struct CCrcThreads
|
||||
CCrcInfo *Items;
|
||||
UInt32 NumThreads;
|
||||
|
||||
CCrcThreads(): Items(0), NumThreads(0) {}
|
||||
CCrcThreads(): Items(NULL), NumThreads(0) {}
|
||||
void WaitAll()
|
||||
{
|
||||
for (UInt32 i = 0; i < NumThreads; i++)
|
||||
@@ -1619,21 +1707,21 @@ struct CCrcThreads
|
||||
|
||||
#endif
|
||||
|
||||
static UInt32 CrcCalc1(const Byte *buf, UInt32 size)
|
||||
static UInt32 CrcCalc1(const Byte *buf, size_t size)
|
||||
{
|
||||
UInt32 crc = CRC_INIT_VAL;;
|
||||
for (UInt32 i = 0; i < size; i++)
|
||||
for (size_t i = 0; i < size; i++)
|
||||
crc = CRC_UPDATE_BYTE(crc, buf[i]);
|
||||
return CRC_GET_DIGEST(crc);
|
||||
}
|
||||
|
||||
static void RandGen(Byte *buf, UInt32 size, CBaseRandomGenerator &RG)
|
||||
static void RandGen(Byte *buf, size_t size, CBaseRandomGenerator &RG)
|
||||
{
|
||||
for (UInt32 i = 0; i < size; i++)
|
||||
for (size_t i = 0; i < size; i++)
|
||||
buf[i] = (Byte)RG.GetRnd();
|
||||
}
|
||||
|
||||
static UInt32 RandGenCrc(Byte *buf, UInt32 size, CBaseRandomGenerator &RG)
|
||||
static UInt32 RandGenCrc(Byte *buf, size_t size, CBaseRandomGenerator &RG)
|
||||
{
|
||||
RandGen(buf, size, RG);
|
||||
return CrcCalc1(buf, size);
|
||||
@@ -1641,14 +1729,15 @@ static UInt32 RandGenCrc(Byte *buf, UInt32 size, CBaseRandomGenerator &RG)
|
||||
|
||||
bool CrcInternalTest()
|
||||
{
|
||||
CBenchBuffer buffer;
|
||||
const UInt32 kBufferSize0 = (1 << 8);
|
||||
const UInt32 kBufferSize1 = (1 << 10);
|
||||
const UInt32 kCheckSize = (1 << 5);
|
||||
if (!buffer.Alloc(kBufferSize0 + kBufferSize1))
|
||||
CAlignedBuffer buffer;
|
||||
const size_t kBufferSize0 = (1 << 8);
|
||||
const size_t kBufferSize1 = (1 << 10);
|
||||
const unsigned kCheckSize = (1 << 5);
|
||||
buffer.Alloc(kBufferSize0 + kBufferSize1);
|
||||
if (!buffer.IsAllocated())
|
||||
return false;
|
||||
Byte *buf = buffer.Buffer;
|
||||
UInt32 i;
|
||||
Byte *buf = (Byte *)buffer;
|
||||
size_t i;
|
||||
for (i = 0; i < kBufferSize0; i++)
|
||||
buf[i] = (Byte)i;
|
||||
UInt32 crc1 = CrcCalc1(buf, kBufferSize0);
|
||||
@@ -1657,7 +1746,7 @@ bool CrcInternalTest()
|
||||
CBaseRandomGenerator RG;
|
||||
RandGen(buf + kBufferSize0, kBufferSize1, RG);
|
||||
for (i = 0; i < kBufferSize0 + kBufferSize1 - kCheckSize; i++)
|
||||
for (UInt32 j = 0; j < kCheckSize; j++)
|
||||
for (unsigned j = 0; j < kCheckSize; j++)
|
||||
if (CrcCalc1(buf + i, j) != CrcCalc(buf + i, j))
|
||||
return false;
|
||||
return true;
|
||||
@@ -1885,8 +1974,55 @@ AString GetProcessThreadsInfo(const NSystem::CProcessAffinity &ti)
|
||||
}
|
||||
|
||||
|
||||
static void PrintSize(AString &s, UInt64 v)
|
||||
{
|
||||
char c = 0;
|
||||
if ((v & 0x3FF) == 0) { v >>= 10; c = 'K';
|
||||
if ((v & 0x3FF) == 0) { v >>= 10; c = 'M';
|
||||
if ((v & 0x3FF) == 0) { v >>= 10; c = 'G';
|
||||
if ((v & 0x3FF) == 0) { v >>= 10; c = 'T';
|
||||
}}}}
|
||||
else
|
||||
{
|
||||
PrintHex(s, v);
|
||||
return;
|
||||
}
|
||||
char temp[32];
|
||||
ConvertUInt64ToString(v, temp);
|
||||
s += temp;
|
||||
if (c)
|
||||
s += c;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
|
||||
extern bool g_LargePagesMode;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern SIZE_T g_LargePageSize;
|
||||
}
|
||||
|
||||
void Add_LargePages_String(AString &s)
|
||||
{
|
||||
if (g_LargePagesMode || g_LargePageSize != 0)
|
||||
{
|
||||
s += " (LP-";
|
||||
PrintSize(s, g_LargePageSize);
|
||||
#ifdef MY_CPU_X86_OR_AMD64
|
||||
if (CPU_IsSupported_PageGB())
|
||||
s += "-1G";
|
||||
#endif
|
||||
if (!g_LargePagesMode)
|
||||
s += "-NA";
|
||||
s += ")";
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString,
|
||||
bool size_Defined, UInt64 size, const char *threadsString, UInt32 numThreads)
|
||||
@@ -1898,8 +2034,15 @@ static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString,
|
||||
else
|
||||
f.Print(" ?");
|
||||
f.Print(" MB");
|
||||
if (g_LargePagesMode)
|
||||
f.Print(" LP");
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
{
|
||||
AString s;
|
||||
Add_LargePages_String(s);
|
||||
f.Print(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
f.Print(", # ");
|
||||
f.Print(threadsString);
|
||||
PrintNumber(f, numThreads, 3);
|
||||
@@ -2189,14 +2332,13 @@ static HRESULT CrcBench(
|
||||
methodName, hashID))
|
||||
return E_NOTIMPL;
|
||||
|
||||
CBenchBuffer buffer;
|
||||
CAlignedBuffer buffer;
|
||||
size_t totalSize = (size_t)bufferSize * numThreads;
|
||||
if (totalSize / numThreads != bufferSize)
|
||||
return E_OUTOFMEMORY;
|
||||
if (!buffer.Alloc(totalSize))
|
||||
return E_OUTOFMEMORY;
|
||||
ALLOC_WITH_HRESULT(&buffer, totalSize)
|
||||
|
||||
Byte *buf = buffer.Buffer;
|
||||
Byte *buf = (Byte *)buffer;
|
||||
CBaseRandomGenerator RG;
|
||||
UInt32 bsize = (bufferSize == 0 ? 1 : bufferSize);
|
||||
UInt64 numIterations = complexInCommands * 256 / complexity / bsize;
|
||||
@@ -2539,26 +2681,7 @@ static const char * const k_PF[] =
|
||||
#endif
|
||||
|
||||
|
||||
static void PrintSize(AString &s, UInt64 v)
|
||||
{
|
||||
char c = 0;
|
||||
if ((v & 0x3FF) == 0) { v >>= 10; c = 'K';
|
||||
if ((v & 0x3FF) == 0) { v >>= 10; c = 'M';
|
||||
if ((v & 0x3FF) == 0) { v >>= 10; c = 'G';
|
||||
if ((v & 0x3FF) == 0) { v >>= 10; c = 'T';
|
||||
}}}}
|
||||
else
|
||||
{
|
||||
PrintHex(s, v);
|
||||
return;
|
||||
}
|
||||
char temp[32];
|
||||
ConvertUInt64ToString(v, temp);
|
||||
s += temp;
|
||||
if (c)
|
||||
s += c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void PrintPage(AString &s, UInt32 v)
|
||||
{
|
||||
@@ -2707,8 +2830,9 @@ void GetCpuName(AString &s)
|
||||
|
||||
#endif
|
||||
|
||||
if (g_LargePagesMode)
|
||||
s += " (LP)";
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
Add_LargePages_String(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -2762,7 +2886,7 @@ HRESULT Bench(
|
||||
bool multiDict)
|
||||
{
|
||||
if (!CrcInternalTest())
|
||||
return S_FALSE;
|
||||
return E_FAIL;
|
||||
|
||||
UInt32 numCPUs = 1;
|
||||
UInt64 ramSize = (UInt64)(sizeof(size_t)) << 29;
|
||||
@@ -2791,7 +2915,7 @@ HRESULT Bench(
|
||||
|
||||
COneMethodInfo method;
|
||||
|
||||
CBenchBuffer fileDataBuffer;
|
||||
CAlignedBuffer fileDataBuffer;
|
||||
|
||||
{
|
||||
unsigned i;
|
||||
@@ -2816,10 +2940,9 @@ HRESULT Bench(
|
||||
return E_FAIL;
|
||||
if (len >= ((UInt32)1 << 31) || len == 0)
|
||||
return E_INVALIDARG;
|
||||
if (!fileDataBuffer.Alloc((size_t)len))
|
||||
return E_OUTOFMEMORY;
|
||||
ALLOC_WITH_HRESULT(&fileDataBuffer, (size_t)len);
|
||||
UInt32 processedSize;
|
||||
file.Read(fileDataBuffer.Buffer, (UInt32)len, processedSize);
|
||||
file.Read((Byte *)fileDataBuffer, (UInt32)len, processedSize);
|
||||
if (processedSize != len)
|
||||
return E_FAIL;
|
||||
if (printCallback)
|
||||
@@ -2968,6 +3091,9 @@ HRESULT Bench(
|
||||
UInt64 start = ::GetTimeCount();
|
||||
UInt32 sum = (UInt32)start;
|
||||
sum = CountCpuFreq(sum, (UInt32)(numMilCommands * 1000000 / kNumFreqCommands), g_BenchCpuFreqTemp);
|
||||
if (sum == 0xF1541213)
|
||||
if (printCallback)
|
||||
printCallback->Print("");
|
||||
const UInt64 realDelta = ::GetTimeCount() - start;
|
||||
start = realDelta;
|
||||
if (start == 0)
|
||||
@@ -2984,7 +3110,7 @@ HRESULT Bench(
|
||||
else
|
||||
{
|
||||
// PrintNumber(*printCallback, start, 0);
|
||||
PrintNumber(*printCallback, mipsVal, 5 + ((sum == 0xF1541213) ? 1 : 0));
|
||||
PrintNumber(*printCallback, mipsVal, 5);
|
||||
}
|
||||
}
|
||||
/*
|
||||
@@ -3032,7 +3158,7 @@ HRESULT Bench(
|
||||
complexInCommands,
|
||||
true, numThreadsSpecified,
|
||||
method,
|
||||
uncompressedDataSize, fileDataBuffer.Buffer,
|
||||
uncompressedDataSize, (const Byte *)fileDataBuffer,
|
||||
kOldLzmaDictBits, printCallback, benchCallback, &benchProps);
|
||||
}
|
||||
|
||||
@@ -3344,9 +3470,9 @@ HRESULT Bench(
|
||||
{
|
||||
res = TotalBench(EXTERNAL_CODECS_LOC_VARS
|
||||
complexInCommands, numThreads,
|
||||
dictIsDefined || fileDataBuffer.Buffer, // forceUnpackSize
|
||||
fileDataBuffer.Buffer ? fileDataBuffer.BufferSize : dict,
|
||||
fileDataBuffer.Buffer,
|
||||
dictIsDefined || fileDataBuffer.IsAllocated(), // forceUnpackSize
|
||||
fileDataBuffer.IsAllocated() ? fileDataBuffer.Size() : dict,
|
||||
(const Byte *)fileDataBuffer,
|
||||
printCallback, &callback);
|
||||
RINOK(res);
|
||||
}
|
||||
@@ -3436,9 +3562,9 @@ HRESULT Bench(
|
||||
}
|
||||
|
||||
size_t uncompressedDataSize;
|
||||
if (fileDataBuffer.Buffer)
|
||||
if (fileDataBuffer.IsAllocated())
|
||||
{
|
||||
uncompressedDataSize = fileDataBuffer.BufferSize;
|
||||
uncompressedDataSize = fileDataBuffer.Size();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3452,7 +3578,7 @@ HRESULT Bench(
|
||||
complexInCommands,
|
||||
true, numThreads,
|
||||
method2,
|
||||
uncompressedDataSize, fileDataBuffer.Buffer,
|
||||
uncompressedDataSize, (const Byte *)fileDataBuffer,
|
||||
kOldLzmaDictBits, printCallback, &callback, &callback.BenchProps);
|
||||
f.NewLine();
|
||||
RINOK(res);
|
||||
|
||||
@@ -68,5 +68,10 @@ void GetSysInfo(AString &s1, AString &s2);
|
||||
void GetCpuName(AString &s);
|
||||
void GetCpuFeatures(AString &s);
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
void Add_LargePages_String(AString &s);
|
||||
#else
|
||||
// #define Add_LargePages_String
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1084,3 +1084,13 @@ CMessagePathException::CMessagePathException(const char *a, const wchar_t *u)
|
||||
(*this) += u;
|
||||
}
|
||||
}
|
||||
|
||||
CMessagePathException::CMessagePathException(const wchar_t *a, const wchar_t *u)
|
||||
{
|
||||
(*this) += a;
|
||||
if (u)
|
||||
{
|
||||
Add_LF();
|
||||
(*this) += u;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ HRESULT EnumerateItems(
|
||||
struct CMessagePathException: public UString
|
||||
{
|
||||
CMessagePathException(const char *a, const wchar_t *u = NULL);
|
||||
CMessagePathException(const wchar_t *a, const wchar_t *u = NULL);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ HRESULT HashCalc(
|
||||
unsigned i;
|
||||
CHashBundle hb;
|
||||
RINOK(hb.SetMethods(EXTERNAL_CODECS_LOC_VARS options.Methods));
|
||||
hb.Init();
|
||||
// hb.Init();
|
||||
|
||||
hb.NumErrors = dirItems.Stat.NumErrors;
|
||||
|
||||
|
||||
@@ -51,9 +51,13 @@ struct CHashBundle: public IHashCalc
|
||||
|
||||
UInt64 CurSize;
|
||||
|
||||
UString MainName;
|
||||
UString FirstFileName;
|
||||
|
||||
HRESULT SetMethods(DECL_EXTERNAL_CODECS_LOC_VARS const UStringVector &methods);
|
||||
|
||||
void Init()
|
||||
// void Init() {}
|
||||
CHashBundle()
|
||||
{
|
||||
NumDirs = NumFiles = NumAltStreams = FilesSize = AltStreamsSize = NumErrors = 0;
|
||||
}
|
||||
@@ -76,7 +80,7 @@ struct CHashBundle: public IHashCalc
|
||||
virtual HRESULT GetStream(const wchar_t *name, bool isFolder) x; \
|
||||
virtual HRESULT OpenFileError(const FString &path, DWORD systemError) x; \
|
||||
virtual HRESULT SetOperationResult(UInt64 fileSize, const CHashBundle &hb, bool showHash) x; \
|
||||
virtual HRESULT AfterLastFile(const CHashBundle &hb) x; \
|
||||
virtual HRESULT AfterLastFile(CHashBundle &hb) x; \
|
||||
|
||||
struct IHashCallbackUI: public IDirItemsCallback
|
||||
{
|
||||
|
||||
@@ -563,6 +563,8 @@ HRESULT CArc::GetItemPathToParent(UInt32 index, UInt32 parent, UStringVector &pa
|
||||
UInt32 parentType = 0;
|
||||
RINOK(GetRawProps->GetParent(curIndex, &curParent, &parentType));
|
||||
|
||||
// 18.06: fixed : we don't want to split name to parts
|
||||
/*
|
||||
if (parentType != NParentType::kAltStream)
|
||||
{
|
||||
for (;;)
|
||||
@@ -576,6 +578,7 @@ HRESULT CArc::GetItemPathToParent(UInt32 index, UInt32 parent, UStringVector &pa
|
||||
s.DeleteFrom(pos);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
parts.Insert(0, s);
|
||||
|
||||
@@ -2014,7 +2017,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op)
|
||||
}
|
||||
else
|
||||
{
|
||||
const CArcInfoEx &ai = op.codecs->Formats[formatIndex];
|
||||
const CArcInfoEx &ai = op.codecs->Formats[(unsigned)formatIndex];
|
||||
if (ai.FindExtension(extension) >= 0)
|
||||
{
|
||||
if (ai.Flags_FindSignature() && searchMarkerInHandler)
|
||||
|
||||
@@ -288,29 +288,27 @@ void CArchivePath::ParseFromPath(const UString &path, EArcNameMode mode)
|
||||
|
||||
if (mode == k_ArcNameMode_Add)
|
||||
return;
|
||||
if (mode == k_ArcNameMode_Exact)
|
||||
{
|
||||
BaseExtension.Empty();
|
||||
return;
|
||||
}
|
||||
|
||||
int dotPos = Name.ReverseFind_Dot();
|
||||
if (dotPos < 0)
|
||||
return;
|
||||
if ((unsigned)dotPos == Name.Len() - 1)
|
||||
if (mode != k_ArcNameMode_Exact)
|
||||
{
|
||||
Name.DeleteBack();
|
||||
BaseExtension.Empty();
|
||||
return;
|
||||
int dotPos = Name.ReverseFind_Dot();
|
||||
if (dotPos < 0)
|
||||
return;
|
||||
if ((unsigned)dotPos == Name.Len() - 1)
|
||||
Name.DeleteBack();
|
||||
else
|
||||
{
|
||||
const UString ext = Name.Ptr(dotPos + 1);
|
||||
if (BaseExtension.IsEqualTo_NoCase(ext))
|
||||
{
|
||||
BaseExtension = ext;
|
||||
Name.DeleteFrom(dotPos);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
const UString ext = Name.Ptr(dotPos + 1);
|
||||
if (BaseExtension.IsEqualTo_NoCase(ext))
|
||||
{
|
||||
BaseExtension = ext;
|
||||
Name.DeleteFrom(dotPos);
|
||||
}
|
||||
else
|
||||
BaseExtension.Empty();
|
||||
|
||||
BaseExtension.Empty();
|
||||
}
|
||||
|
||||
UString CArchivePath::GetFinalPath() const
|
||||
@@ -327,6 +325,7 @@ UString CArchivePath::GetFinalPath() const
|
||||
UString CArchivePath::GetFinalVolPath() const
|
||||
{
|
||||
UString path = GetPathWithoutExt();
|
||||
// if BaseExtension is empty, we must ignore VolExtension also.
|
||||
if (!BaseExtension.IsEmpty())
|
||||
{
|
||||
path += '.';
|
||||
@@ -1166,7 +1165,7 @@ HRESULT UpdateArchive(
|
||||
{
|
||||
errorInfo.SystemError = ERROR_ACCESS_DENIED;
|
||||
errorInfo.Message = "The file is read-only";
|
||||
errorInfo.FileNames.Add(arcPath);
|
||||
errorInfo.FileNames.Add(us2fs(arcPath));
|
||||
return errorInfo.Get_HRESULT_Error();
|
||||
}
|
||||
|
||||
@@ -1377,6 +1376,31 @@ HRESULT UpdateArchive(
|
||||
|
||||
unsigned ci;
|
||||
|
||||
|
||||
// self including protection
|
||||
if (options.DeleteAfterCompressing)
|
||||
{
|
||||
for (ci = 0; ci < options.Commands.Size(); ci++)
|
||||
{
|
||||
CArchivePath &ap = options.Commands[ci].ArchivePath;
|
||||
const FString path = us2fs(ap.GetFinalPath());
|
||||
// maybe we must compare absolute paths path here
|
||||
FOR_VECTOR (i, dirItems.Items)
|
||||
{
|
||||
const FString phyPath = dirItems.GetPhyPath(i);
|
||||
if (phyPath == path)
|
||||
{
|
||||
UString s;
|
||||
s = "It is not allowed to include archive to itself";
|
||||
s.Add_LF();
|
||||
s += path;
|
||||
throw s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (ci = 0; ci < options.Commands.Size(); ci++)
|
||||
{
|
||||
CArchivePath &ap = options.Commands[ci].ArchivePath;
|
||||
@@ -1562,26 +1586,39 @@ HRESULT UpdateArchive(
|
||||
}
|
||||
|
||||
CCurrentDirRestorer curDirRestorer;
|
||||
|
||||
AStringVector paths;
|
||||
AStringVector names;
|
||||
|
||||
for (i = 0; i < fullPaths.Size(); i++)
|
||||
{
|
||||
const UString arcPath2 = fs2us(fullPaths[i]);
|
||||
const UString fileName = ExtractFileNameFromPath(arcPath2);
|
||||
const AString path (GetAnsiString(arcPath2));
|
||||
const AString name (GetAnsiString(fileName));
|
||||
paths.Add(GetAnsiString(arcPath2));
|
||||
names.Add(GetAnsiString(fileName));
|
||||
// const AString path (GetAnsiString(arcPath2));
|
||||
// const AString name (GetAnsiString(fileName));
|
||||
// Warning!!! MAPISendDocuments function changes Current directory
|
||||
// fnSend(0, ";", (LPSTR)(LPCSTR)path, (LPSTR)(LPCSTR)name, 0);
|
||||
}
|
||||
|
||||
MapiFileDesc f;
|
||||
CRecordVector<MapiFileDesc> files;
|
||||
files.ClearAndSetSize(paths.Size());
|
||||
|
||||
for (i = 0; i < paths.Size(); i++)
|
||||
{
|
||||
MapiFileDesc &f = files[i];
|
||||
memset(&f, 0, sizeof(f));
|
||||
f.nPosition = 0xFFFFFFFF;
|
||||
f.lpszPathName = (char *)(const char *)path;
|
||||
f.lpszFileName = (char *)(const char *)name;
|
||||
|
||||
f.lpszPathName = (char *)(const char *)paths[i];
|
||||
f.lpszFileName = (char *)(const char *)names[i];
|
||||
}
|
||||
|
||||
{
|
||||
MapiMessage m;
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.nFileCount = 1;
|
||||
m.lpFiles = &f;
|
||||
m.nFileCount = files.Size();
|
||||
m.lpFiles = &files.Front();
|
||||
|
||||
const AString addr (GetAnsiString(options.EMailAddress));
|
||||
MapiRecipDesc rec;
|
||||
|
||||
@@ -417,6 +417,10 @@ SOURCE=..\..\..\Common\MyBuffer.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyBuffer2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Common\MyCom.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@@ -843,6 +847,15 @@ SOURCE=..\..\..\..\C\CpuArch.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\DllSecur.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\DllSecur.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Sort.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
MY_CONSOLE = 1
|
||||
|
||||
!IFNDEF UNDER_CE
|
||||
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -D_7ZIP_LARGE_PAGES -DSUPPORT_DEVICE_FILE
|
||||
!ENDIF
|
||||
|
||||
CONSOLE_OBJS = \
|
||||
$O\BenchCon.obj \
|
||||
$O\ConsoleClose.obj \
|
||||
@@ -33,4 +39,5 @@ UI_COMMON_OBJS = \
|
||||
$O\UpdatePair.obj \
|
||||
$O\UpdateProduce.obj \
|
||||
|
||||
#
|
||||
C_OBJS = $(C_OBJS) \
|
||||
$O\DllSecur.obj \
|
||||
|
||||
@@ -332,7 +332,7 @@ void CHashCallbackConsole::PrintProperty(const char *name, UInt64 value)
|
||||
*_so << name << s << endl;
|
||||
}
|
||||
|
||||
HRESULT CHashCallbackConsole::AfterLastFile(const CHashBundle &hb)
|
||||
HRESULT CHashCallbackConsole::AfterLastFile(CHashBundle &hb)
|
||||
{
|
||||
ClosePercents2();
|
||||
|
||||
|
||||
@@ -1072,18 +1072,24 @@ HRESULT ListArchives(CCodecs *codecs,
|
||||
errorCode = ERROR_FILE_NOT_FOUND;
|
||||
lastError = HRESULT_FROM_WIN32(lastError);;
|
||||
g_StdOut.Flush();
|
||||
*g_ErrStream << endl << kError << NError::MyFormatMessage(errorCode) << endl;
|
||||
g_ErrStream->NormalizePrint_UString(arcPath);
|
||||
*g_ErrStream << endl << endl;
|
||||
if (g_ErrStream)
|
||||
{
|
||||
*g_ErrStream << endl << kError << NError::MyFormatMessage(errorCode) << endl;
|
||||
g_ErrStream->NormalizePrint_UString(arcPath);
|
||||
*g_ErrStream << endl << endl;
|
||||
}
|
||||
numErrors++;
|
||||
continue;
|
||||
}
|
||||
if (fi.IsDir())
|
||||
{
|
||||
g_StdOut.Flush();
|
||||
*g_ErrStream << endl << kError;
|
||||
g_ErrStream->NormalizePrint_UString(arcPath);
|
||||
*g_ErrStream << " is not a file" << endl << endl;
|
||||
if (g_ErrStream)
|
||||
{
|
||||
*g_ErrStream << endl << kError;
|
||||
g_ErrStream->NormalizePrint_UString(arcPath);
|
||||
*g_ErrStream << " is not a file" << endl << endl;
|
||||
}
|
||||
numErrors++;
|
||||
continue;
|
||||
}
|
||||
@@ -1133,24 +1139,28 @@ HRESULT ListArchives(CCodecs *codecs,
|
||||
{
|
||||
if (result == E_ABORT)
|
||||
return result;
|
||||
g_StdOut.Flush();
|
||||
*g_ErrStream << endl << kError;
|
||||
g_ErrStream->NormalizePrint_UString(arcPath);
|
||||
*g_ErrStream << " : ";
|
||||
if (result == S_FALSE)
|
||||
{
|
||||
Print_OpenArchive_Error(*g_ErrStream, codecs, arcLink);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result != S_FALSE)
|
||||
lastError = result;
|
||||
*g_ErrStream << "opening : ";
|
||||
if (result == E_OUTOFMEMORY)
|
||||
*g_ErrStream << "Can't allocate required memory";
|
||||
g_StdOut.Flush();
|
||||
if (g_ErrStream)
|
||||
{
|
||||
*g_ErrStream << endl << kError;
|
||||
g_ErrStream->NormalizePrint_UString(arcPath);
|
||||
*g_ErrStream << " : ";
|
||||
if (result == S_FALSE)
|
||||
{
|
||||
Print_OpenArchive_Error(*g_ErrStream, codecs, arcLink);
|
||||
}
|
||||
else
|
||||
*g_ErrStream << NError::MyFormatMessage(result);
|
||||
{
|
||||
*g_ErrStream << "opening : ";
|
||||
if (result == E_OUTOFMEMORY)
|
||||
*g_ErrStream << "Can't allocate required memory";
|
||||
else
|
||||
*g_ErrStream << NError::MyFormatMessage(result);
|
||||
}
|
||||
*g_ErrStream << endl;
|
||||
}
|
||||
*g_ErrStream << endl;
|
||||
numErrors++;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "../../../Windows/TimeUtils.h"
|
||||
|
||||
#include "../Common/ArchiveCommandLine.h"
|
||||
#include "../Common/Bench.h"
|
||||
#include "../Common/ExitCode.h"
|
||||
#include "../Common/Extract.h"
|
||||
|
||||
@@ -56,8 +57,6 @@ using namespace NCommandLineParser;
|
||||
HINSTANCE g_hInstance = 0;
|
||||
#endif
|
||||
|
||||
extern bool g_LargePagesMode;
|
||||
|
||||
extern CStdOutStream *g_StdStream;
|
||||
extern CStdOutStream *g_ErrStream;
|
||||
|
||||
@@ -88,7 +87,7 @@ static const char * const kHelpString =
|
||||
"a"
|
||||
#endif
|
||||
#endif
|
||||
" <command> [<switches>...] <archive_name> [<file_names>...]\n"
|
||||
" <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]\n"
|
||||
"\n"
|
||||
"<Commands>\n"
|
||||
" a : Add files to archive\n"
|
||||
@@ -104,8 +103,7 @@ static const char * const kHelpString =
|
||||
" x : eXtract files with full paths\n"
|
||||
"\n"
|
||||
"<Switches>\n"
|
||||
" -- : Stop switches parsing\n"
|
||||
" @listfile : set path to listfile that contains file names\n"
|
||||
" -- : Stop switches and @listfile parsing\n"
|
||||
" -ai[r[-|0]]{@listfile|!wildcard} : Include archives\n"
|
||||
" -ax[r[-|0]]{@listfile|!wildcard} : eXclude archives\n"
|
||||
" -ao{a|s|t|u} : set Overwrite mode\n"
|
||||
@@ -236,7 +234,7 @@ static void PrintWarningsPaths(const CErrorPathCodes &pc, CStdOutStream &so)
|
||||
{
|
||||
FOR_VECTOR(i, pc.Paths)
|
||||
{
|
||||
so.NormalizePrint_UString(pc.Paths[i]);
|
||||
so.NormalizePrint_UString(fs2us(pc.Paths[i]));
|
||||
so << " : ";
|
||||
so << NError::MyFormatMessage(pc.Codes[i]) << endl;
|
||||
}
|
||||
@@ -376,8 +374,13 @@ static void PrintMemUsage(const char *s, UInt64 val)
|
||||
*g_StdStream << " " << s << " Memory =";
|
||||
PrintNum(SHIFT_SIZE_VALUE(val, 20), 7);
|
||||
*g_StdStream << " MB";
|
||||
if (g_LargePagesMode)
|
||||
*g_StdStream << " (LP)";
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
AString lp;
|
||||
Add_LargePages_String(lp);
|
||||
if (!lp.IsEmpty())
|
||||
*g_StdStream << lp;
|
||||
#endif
|
||||
}
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
@@ -911,7 +914,7 @@ int Main2(
|
||||
{
|
||||
hashCalc = &hb;
|
||||
ThrowException_if_Error(hb.SetMethods(EXTERNAL_CODECS_VARS_L options.HashMethods));
|
||||
hb.Init();
|
||||
// hb.Init();
|
||||
}
|
||||
|
||||
hresultMain = Extract(
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "../../../../C/DllSecur.h"
|
||||
#endif
|
||||
|
||||
#include "../../../Common/MyException.h"
|
||||
#include "../../../Common/StdOutStream.h"
|
||||
|
||||
@@ -63,6 +67,10 @@ int MY_CDECL main
|
||||
|
||||
try
|
||||
{
|
||||
#ifdef _WIN32
|
||||
My_SetDefaultDllDirectories();
|
||||
#endif
|
||||
|
||||
res = Main2(
|
||||
#ifndef _WIN32
|
||||
numArgs, args
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
PROG = 7z.exe
|
||||
MY_CONSOLE = 1
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-DEXTERNAL_CODECS \
|
||||
|
||||
!IFNDEF UNDER_CE
|
||||
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -D_7ZIP_LARGE_PAGES -DSUPPORT_DEVICE_FILE
|
||||
!ENDIF
|
||||
|
||||
COMMON_OBJS = \
|
||||
$O\CommandLineParser.obj \
|
||||
$O\CRC.obj \
|
||||
@@ -57,7 +52,7 @@ AR_COMMON_OBJS = \
|
||||
COMPRESS_OBJS = \
|
||||
$O\CopyCoder.obj \
|
||||
|
||||
C_OBJS = \
|
||||
C_OBJS = $(C_OBJS) \
|
||||
$O\Alloc.obj \
|
||||
$O\CpuArch.obj \
|
||||
$O\Sort.obj \
|
||||
|
||||
@@ -120,7 +120,11 @@ HRESULT CZipContextMenu::InitContextMenu(const wchar_t * /* folder */, const wch
|
||||
_isMenuForFM = true;
|
||||
_fileNames.Clear();
|
||||
for (UInt32 i = 0; i < numFiles; i++)
|
||||
{
|
||||
// MessageBoxW(0, names[i], NULL, 0);
|
||||
// OutputDebugStringW(names[i]);
|
||||
_fileNames.Add(names[i]);
|
||||
}
|
||||
_dropMode = false;
|
||||
return S_OK;
|
||||
}
|
||||
@@ -225,13 +229,13 @@ static const CHashCommand g_HashCommands[] =
|
||||
{ CZipContextMenu::kHash_CRC64, "CRC-64", "CRC64" },
|
||||
{ CZipContextMenu::kHash_XXH32, "XXH-32", "XXH32" },
|
||||
{ CZipContextMenu::kHash_XXH64, "XXH-64", "XXH64" },
|
||||
{ CZipContextMenu::kHash_MD5, "MD2", "MD2" },
|
||||
{ CZipContextMenu::kHash_MD5, "MD4", "MD4" },
|
||||
{ CZipContextMenu::kHash_MD2, "MD2", "MD2" },
|
||||
{ CZipContextMenu::kHash_MD4, "MD4", "MD4" },
|
||||
{ CZipContextMenu::kHash_MD5, "MD5", "MD5" },
|
||||
{ CZipContextMenu::kHash_SHA1, "SHA-1", "SHA1" },
|
||||
{ CZipContextMenu::kHash_SHA256, "SHA-256", "SHA256" },
|
||||
{ CZipContextMenu::kHash_SHA256, "SHA-384", "SHA384" },
|
||||
{ CZipContextMenu::kHash_SHA256, "SHA-512", "SHA512" },
|
||||
{ CZipContextMenu::kHash_SHA384, "SHA-384", "SHA384" },
|
||||
{ CZipContextMenu::kHash_SHA512, "SHA-512", "SHA512" },
|
||||
{ CZipContextMenu::kHash_BLAKE2sp, "BLAKE2sp", "BLAKE2sp" },
|
||||
{ CZipContextMenu::kHash_All, "*", "*" }
|
||||
};
|
||||
@@ -436,6 +440,13 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
{
|
||||
// OutputDebugStringA("QueryContextMenu");
|
||||
|
||||
/*
|
||||
for (UInt32 i = 0; i < _fileNames.Size(); i++)
|
||||
{
|
||||
OutputDebugStringW(_fileNames[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
LoadLangOneTime();
|
||||
if (_fileNames.Size() == 0)
|
||||
return E_FAIL;
|
||||
@@ -595,7 +606,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
}
|
||||
}
|
||||
|
||||
const UString &fileName = _fileNames.Front();
|
||||
// const UString &fileName = _fileNames.Front();
|
||||
|
||||
if (needExtract)
|
||||
{
|
||||
@@ -652,12 +663,8 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
}
|
||||
}
|
||||
|
||||
UString arcName;
|
||||
if (_fileNames.Size() == 1)
|
||||
arcName = CreateArchiveName(fi0, false);
|
||||
else
|
||||
arcName = CreateArchiveName(fileName, _fileNames.Size() > 1, false);
|
||||
|
||||
const UString arcName = CreateArchiveName(_fileNames, _fileNames.Size() == 1 ? &fi0 : NULL);
|
||||
|
||||
UString arcName7z = arcName;
|
||||
arcName7z += ".7z";
|
||||
UString arcNameZip = arcName;
|
||||
|
||||
@@ -25,21 +25,17 @@
|
||||
|
||||
#include "ContextMenu.h"
|
||||
|
||||
static LPCTSTR const k_ShellExtName = TEXT("7-Zip-Zstandard Shell Extension");
|
||||
static LPCTSTR const k_ShellExtName = TEXT("7-Zip ZS Shell Extension");
|
||||
static LPCTSTR const k_Approved = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
|
||||
|
||||
// {23170F69-40C1-278A-1000-000100020000}
|
||||
#ifdef NEED_7ZIP_GUID
|
||||
static LPCTSTR const k_Clsid = TEXT("{23170F69-40C1-278A-1000-000100020001}");
|
||||
#else
|
||||
static LPCTSTR const k_Clsid = TEXT("{23170F69-0803-278A-1000-000100020001}");
|
||||
#endif
|
||||
static LPCTSTR const k_Clsid = TEXT("{23170F69-20BB-278A-1000-000100020000}");
|
||||
|
||||
DEFINE_GUID(CLSID_CZipContextMenu,
|
||||
k_7zip_GUID_Data1,
|
||||
k_7zip_GUID_Data2,
|
||||
k_7zip_GUID_Data2_ZS,
|
||||
k_7zip_GUID_Data3_Common,
|
||||
0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01);
|
||||
0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
|
||||
@@ -286,6 +286,15 @@ SOURCE=..\FileManager\RegistryUtils.h
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\CpuArch.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\CpuArch.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Threads.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
|
||||
@@ -17,10 +17,10 @@ using namespace NRegistry;
|
||||
// CLISID (and Approved ?) items are separated for 32-bit and 64-bit code.
|
||||
// shellex items shared by 32-bit and 64-bit code?
|
||||
|
||||
#define k_Clsid_A "{23170F69-0803-278A-1000-000100020001}"
|
||||
#define k_Clsid_A "{23170F69-20BB-278A-1000-000100020000}"
|
||||
|
||||
static LPCTSTR const k_Clsid = TEXT(k_Clsid_A);
|
||||
static LPCTSTR const k_ShellExtName = TEXT("7-Zip Shell Extension");
|
||||
static LPCTSTR const k_ShellExtName = TEXT("7-Zip ZS Shell Extension");
|
||||
|
||||
static LPCTSTR const k_Approved = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
|
||||
static LPCTSTR const k_Inproc = TEXT("InprocServer32");
|
||||
|
||||
@@ -68,6 +68,7 @@ FM_OBJS = \
|
||||
$O\RegistryUtils.obj \
|
||||
|
||||
C_OBJS = \
|
||||
$O\CpuArch.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
!include "../../7zip.mak"
|
||||
|
||||
@@ -327,7 +327,7 @@ HRESULT OpenArchive(const CSysString &fileName,
|
||||
}
|
||||
*/
|
||||
|
||||
static HANDLE MyOpenFilePluginW(const wchar_t *name)
|
||||
static HANDLE MyOpenFilePluginW(const wchar_t *name, bool isAbortCodeSupported)
|
||||
{
|
||||
FString normalizedName = us2fs(name);
|
||||
normalizedName.Trim();
|
||||
@@ -373,7 +373,12 @@ static HANDLE MyOpenFilePluginW(const wchar_t *name)
|
||||
archiverInfoResult, defaultName, openArchiveCallback);
|
||||
*/
|
||||
if (result == E_ABORT)
|
||||
return (HANDLE)-2;
|
||||
{
|
||||
// fixed 18.06:
|
||||
// OpenFilePlugin() is allowed to return (HANDLE)-2 as abort code
|
||||
// OpenPlugin() is not allowed to return (HANDLE)-2.
|
||||
return isAbortCodeSupported ? (HANDLE)-2 : INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
UString errorMessage = agent->GetErrorMessage();
|
||||
if (!errorMessage.IsEmpty())
|
||||
@@ -403,7 +408,7 @@ static HANDLE MyOpenFilePluginW(const wchar_t *name)
|
||||
return (HANDLE)(plugin);
|
||||
}
|
||||
|
||||
static HANDLE MyOpenFilePlugin(const char *name)
|
||||
static HANDLE MyOpenFilePlugin(const char *name, bool isAbortCodeSupported)
|
||||
{
|
||||
UINT codePage =
|
||||
#ifdef UNDER_CE
|
||||
@@ -411,7 +416,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
|
||||
#else
|
||||
::AreFileApisANSI() ? CP_ACP : CP_OEMCP;
|
||||
#endif
|
||||
return MyOpenFilePluginW(GetUnicodeString(name, codePage));
|
||||
return MyOpenFilePluginW(GetUnicodeString(name, codePage), isAbortCodeSupported);
|
||||
}
|
||||
|
||||
EXTERN_C HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char * /* data */, int /* dataSize */)
|
||||
@@ -423,7 +428,7 @@ EXTERN_C HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char * /* data
|
||||
// if (!Opt.ProcessShiftF1)
|
||||
return(INVALID_HANDLE_VALUE);
|
||||
}
|
||||
return MyOpenFilePlugin(name);
|
||||
return MyOpenFilePlugin(name, true); // isAbortCodeSupported
|
||||
MY_TRY_END2("OpenFilePlugin", INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
@@ -458,7 +463,7 @@ EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, INT_PTR item)
|
||||
fileName.DeleteBack();
|
||||
fileName.DeleteFrontal(1);
|
||||
}
|
||||
return MyOpenFilePlugin(fileName);
|
||||
return MyOpenFilePlugin(fileName, false); // isAbortCodeSupported
|
||||
}
|
||||
|
||||
if (openFrom == OPEN_PLUGINSMENU)
|
||||
@@ -470,7 +475,7 @@ EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, INT_PTR item)
|
||||
PluginPanelItem pluginPanelItem;
|
||||
if (!g_StartupInfo.ControlGetActivePanelCurrentItemInfo(pluginPanelItem))
|
||||
throw 142134;
|
||||
return MyOpenFilePlugin(pluginPanelItem.FindData.cFileName);
|
||||
return MyOpenFilePlugin(pluginPanelItem.FindData.cFileName, false); // isAbortCodeSupported
|
||||
}
|
||||
|
||||
case 1:
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <richedit.h>
|
||||
#include "AboutDialogRes.h"
|
||||
#include "..\..\GuiCommon.rc"
|
||||
#include "..\..\MyVersion.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
#include "../../MyVersion.h"
|
||||
|
||||
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
|
||||
#define xc 216
|
||||
#define yc 144
|
||||
|
||||
IDI_LOGO ICON "7zipLogo.ico"
|
||||
#define y 93
|
||||
|
||||
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 224, 132
|
||||
STYLE WS_POPUP|DS_MODALFRAME|DS_CENTER|WS_CAPTION|WS_SYSMENU
|
||||
IDI_LOGO ICON "../../UI/FileManager/7zipLogo.ico"
|
||||
|
||||
#ifndef SS_REALSIZEIMAGE
|
||||
#define SS_REALSIZEIMAGE 0x800
|
||||
#endif
|
||||
|
||||
IDD_ABOUT DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT
|
||||
CAPTION "About 7-Zip"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
{
|
||||
CONTROL "OK", IDOK, "Button", BS_DEFPUSHBUTTON|WS_TABSTOP, 4, 112, 64, 16
|
||||
CONTROL "www.7-zip.org", IDB_ABOUT_HOMEPAGE, "Button", WS_TABSTOP, 72, 112, 64, 16
|
||||
CONTROL IDI_LOGO, -1, "Static", SS_ICON|SS_REALSIZEIMAGE, 8, 8, 32, 32
|
||||
CONTROL "", IDT_ABOUT_VERSION, "Static", WS_GROUP, 8, 54, 208, 8
|
||||
CONTROL "", IDT_ABOUT_DATE, "Static", WS_GROUP, 8, 67, 208, 8
|
||||
CONTROL MY_COPYRIGHT_CR, -1, "Static", WS_GROUP, 8, 80, 208, 8
|
||||
CONTROL "7-Zip is free software", IDT_ABOUT_INFO, "Static", WS_GROUP, 8, 93, 208, 19
|
||||
CONTROL "7-Zip ZS Homepage", IDB_ABOUT_HOMEPAGE2, "Button", WS_TABSTOP, 140, 112, 76, 16
|
||||
DEFPUSHBUTTON "OK", IDOK, bx3-10, by, bxs, bys
|
||||
PUSHBUTTON "www.7-zip.org", IDB_ABOUT_HOMEPAGE, bx2-10, by, bxs, bys
|
||||
PUSHBUTTON "7-Zip ZS Hompeage", IDB_ABOUT_HOMEPAGE2, bx1-10, by, bxs+10, bys
|
||||
ICON IDI_LOGO, -1, m, m, 32, 32, SS_REALSIZEIMAGE,
|
||||
LTEXT "", IDT_ABOUT_VERSION, m, 54, xc, 8
|
||||
LTEXT "", IDT_ABOUT_DATE, m, 67, xc, 8
|
||||
LTEXT MY_COPYRIGHT_CR, -1, m, 80, xc, 8
|
||||
LTEXT "7-Zip is free software", IDT_ABOUT_INFO, m, y, xc, (by - y - 1)
|
||||
}
|
||||
|
||||
|
||||
@@ -468,7 +468,7 @@ static HRESULT UpdateFile(NFsFolder::CCopyStateIO &state, CFSTR inPath, CFSTR ou
|
||||
{
|
||||
if (NFind::DoesFileOrDirExist(outPath))
|
||||
{
|
||||
RINOK(SendMessageError(callback, NError::MyFormatMessage(ERROR_ALREADY_EXISTS), outPath));
|
||||
RINOK(SendMessageError(callback, NError::MyFormatMessage(ERROR_ALREADY_EXISTS), FString(outPath)));
|
||||
CFileInfo fi;
|
||||
if (fi.Find(inPath))
|
||||
{
|
||||
|
||||
@@ -759,11 +759,15 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
|
||||
destPathResultTemp = fs2us(destPathSys);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (NFind::DoesFileExist(destPathSys))
|
||||
if (!NDir::DeleteFileAlways(destPathSys))
|
||||
if (GetLastError() != ERROR_FILE_NOT_FOUND)
|
||||
{
|
||||
RINOK(MessageError("can not delete output file", destPathSys));
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
}
|
||||
*writeAnswer = BoolToInt(true);
|
||||
return StringToBstr(destPathResultTemp, destPathResult);
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include "../../../../C/Alloc.h"
|
||||
#ifdef _WIN32
|
||||
#include "../../../../C/DllSecur.h"
|
||||
#endif
|
||||
|
||||
#include "../../../Common/StringConvert.h"
|
||||
#include "../../../Common/StringToInt.h"
|
||||
@@ -660,6 +663,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
||||
{
|
||||
try
|
||||
{
|
||||
#ifdef _WIN32
|
||||
My_SetDefaultDllDirectories();
|
||||
#endif
|
||||
return WinMain2(nCmdShow);
|
||||
}
|
||||
catch (...)
|
||||
|
||||
@@ -712,10 +712,24 @@ SOURCE=..\..\..\..\C\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\CpuArch.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\CpuArch.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\DllSecur.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\DllSecur.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Sort.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-DLANG \
|
||||
-DNEW_FOLDER_INTERFACE \
|
||||
|
||||
!IFDEF UNDER_CE
|
||||
LIBS = $(LIBS) ceshell.lib Commctrl.lib
|
||||
!ELSE
|
||||
LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib
|
||||
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -DSUPPORT_DEVICE_FILE
|
||||
LFLAGS = $(LFLAGS) /DELAYLOAD:mpr.dll
|
||||
LIBS = $(LIBS) delayimp.lib
|
||||
!ENDIF
|
||||
|
||||
FM_OBJS = \
|
||||
$O\App.obj \
|
||||
$O\BrowseDialog.obj \
|
||||
@@ -73,6 +86,9 @@ WIN_OBJS = $(WIN_OBJS) \
|
||||
|
||||
!ENDIF
|
||||
|
||||
C_OBJS = $(C_OBJS) \
|
||||
$O\DllSecur.obj \
|
||||
|
||||
AGENT_OBJS = \
|
||||
$O\Agent.obj \
|
||||
$O\AgentOut.obj \
|
||||
|
||||
@@ -532,9 +532,8 @@ STDMETHODIMP CFSFolder::GetNumRawProps(UInt32 *numProps)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CFSFolder::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *propID)
|
||||
STDMETHODIMP CFSFolder::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID)
|
||||
{
|
||||
index = index;
|
||||
*name = NULL;
|
||||
*propID = kpidNtReparse;
|
||||
return S_OK;
|
||||
|
||||
@@ -161,8 +161,6 @@ static DWORD CALLBACK CopyProgressRoutine(
|
||||
LPVOID lpData // from CopyFileEx
|
||||
)
|
||||
{
|
||||
TotalFileSize = TotalFileSize;
|
||||
// TotalBytesTransferred = TotalBytesTransferred;
|
||||
// StreamSize = StreamSize;
|
||||
// StreamBytesTransferred = StreamBytesTransferred;
|
||||
// dwStreamNumber = dwStreamNumber;
|
||||
|
||||
@@ -213,6 +213,12 @@ void CListViewDialog::ShowItemInfo()
|
||||
if (index < Values.Size())
|
||||
dlg.Text = Values[index];
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (dlg.Text.Find(L'\r') < 0)
|
||||
dlg.Text.Replace(L"\n", L"\r\n");
|
||||
#endif
|
||||
|
||||
dlg.Create(*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -879,8 +879,9 @@ void CPanel::AddToArchive()
|
||||
|
||||
FOR_VECTOR (i, indices)
|
||||
names.Add(curPrefix + GetItemRelPath2(indices[i]));
|
||||
bool fromPrev = (names.Size() > 1);
|
||||
const UString arcName = CreateArchiveName(names.Front(), fromPrev, false);
|
||||
|
||||
const UString arcName = CreateArchiveName(names);
|
||||
|
||||
HRESULT res = CompressFiles(destCurDirPrefix, arcName, L"",
|
||||
true, // addExtension
|
||||
names, false, true, false);
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
CMyComPtr<IFolderOperationsExtractCallback> ExtractCallback;
|
||||
|
||||
CHashBundle Hash;
|
||||
UString FirstFilePath;
|
||||
// UString FirstFilePath;
|
||||
|
||||
HRESULT Result;
|
||||
|
||||
@@ -48,7 +48,7 @@ void CPanelCopyThread::ShowFinalResults(HWND hwnd)
|
||||
if (!ResultsWereShown)
|
||||
{
|
||||
ResultsWereShown = true;
|
||||
ShowHashResults(Hash, fs2us(FirstFilePath), hwnd);
|
||||
ShowHashResults(Hash, hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ HRESULT CPanelCopyThread::ProcessVirt()
|
||||
else if (options->testMode)
|
||||
{
|
||||
CProgressMessageBoxPair &pair = GetMessagePair(false); // GetMessagePair(ExtractCallbackSpec->Hash.NumErrors != 0);
|
||||
AddHashBundleRes(pair.Message, Hash, FirstFilePath);
|
||||
AddHashBundleRes(pair.Message, Hash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,10 @@ HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &ind
|
||||
|
||||
|
||||
if (indices.Size() == 1)
|
||||
extracter.FirstFilePath = GetItemRelPath(indices[0]);
|
||||
{
|
||||
extracter.Hash.FirstFileName = GetItemRelPath(indices[0]);
|
||||
extracter.Hash.MainName = extracter.Hash.FirstFileName;
|
||||
}
|
||||
|
||||
if (options.VirtFileSystem)
|
||||
{
|
||||
@@ -186,7 +189,7 @@ HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &ind
|
||||
extracter.ExtractCallbackSpec->SetHashCalc(&extracter.Hash);
|
||||
}
|
||||
|
||||
extracter.Hash.Init();
|
||||
// extracter.Hash.Init();
|
||||
|
||||
UString title;
|
||||
{
|
||||
|
||||
@@ -147,7 +147,7 @@ class CThreadCrc: public CProgressThreadVirt
|
||||
public:
|
||||
CDirEnumerator Enumerator;
|
||||
CHashBundle Hash;
|
||||
FString FirstFilePath;
|
||||
// FString FirstFilePath;
|
||||
|
||||
void SetStatus(const UString &s);
|
||||
void AddErrorMessage(DWORD systemError, const FChar *name);
|
||||
@@ -165,7 +165,7 @@ void CThreadCrc::ShowFinalResults(HWND hwnd)
|
||||
if (!ResultsWereShown)
|
||||
{
|
||||
ResultsWereShown = true;
|
||||
ShowHashResults(Hash, fs2us(FirstFilePath), hwnd);
|
||||
ShowHashResults(Hash, hwnd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ void CThreadCrc::SetStatus(const UString &s2)
|
||||
|
||||
HRESULT CThreadCrc::ProcessVirt()
|
||||
{
|
||||
Hash.Init();
|
||||
// Hash.Init();
|
||||
|
||||
CMyBuffer buf;
|
||||
if (!buf.Allocate(kBufSize))
|
||||
@@ -289,7 +289,7 @@ HRESULT CThreadCrc::ProcessVirt()
|
||||
}
|
||||
if (isFirstFile)
|
||||
{
|
||||
FirstFilePath = path;
|
||||
Hash.FirstFileName = path;
|
||||
isFirstFile = false;
|
||||
}
|
||||
sync.Set_FilePath(fs2us(path));
|
||||
@@ -370,9 +370,13 @@ HRESULT CApp::CalculateCrc2(const UString &methodName)
|
||||
methods.Add(methodName);
|
||||
RINOK(t.Hash.SetMethods(EXTERNAL_CODECS_VARS_G methods));
|
||||
}
|
||||
|
||||
FOR_VECTOR (i, indices)
|
||||
t.Enumerator.FilePaths.Add(us2fs(srcPanel.GetItemRelPath(indices[i])));
|
||||
|
||||
if (t.Enumerator.FilePaths.Size() == 1)
|
||||
t.Hash.MainName = t.Enumerator.FilePaths[0];
|
||||
|
||||
UString basePrefix = srcPanel.GetFsPath();
|
||||
UString basePrefix2 = basePrefix;
|
||||
if (basePrefix2.Back() == ':')
|
||||
|
||||
@@ -940,8 +940,10 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo
|
||||
if (IsFolderInTemp(folderPath2F))
|
||||
folderPath2 = ROOT_FS_FOLDER;
|
||||
}
|
||||
const UString archiveName = CreateArchiveName(fileNames.Front(), (fileNames.Size() > 1), false);
|
||||
CompressFiles(folderPath2, archiveName, L"",
|
||||
|
||||
const UString arcName = CreateArchiveName(fileNames);
|
||||
|
||||
CompressFiles(folderPath2, arcName, L"",
|
||||
true, // addExtension
|
||||
fileNames,
|
||||
false, // email
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
PROG = 7zFM.exe
|
||||
CFLAGS = $(CFLAGS) \
|
||||
-DLANG \
|
||||
-DNEW_FOLDER_INTERFACE \
|
||||
-DEXTERNAL_CODECS \
|
||||
|
||||
!IFDEF UNDER_CE
|
||||
LIBS = $(LIBS) ceshell.lib Commctrl.lib
|
||||
!ELSE
|
||||
LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib
|
||||
CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -DSUPPORT_DEVICE_FILE
|
||||
!ENDIF
|
||||
|
||||
!include "FM.mak"
|
||||
|
||||
COMMON_OBJS = \
|
||||
@@ -102,8 +93,9 @@ GUI_OBJS = \
|
||||
COMPRESS_OBJS = \
|
||||
$O\CopyCoder.obj \
|
||||
|
||||
C_OBJS = \
|
||||
C_OBJS = $(C_OBJS) \
|
||||
$O\Alloc.obj \
|
||||
$O\CpuArch.obj \
|
||||
$O\Sort.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
|
||||
@@ -324,7 +324,6 @@ static void PrintSize_MB(UString &s, UInt64 size)
|
||||
s += kMB;
|
||||
}
|
||||
|
||||
extern bool g_LargePagesMode;
|
||||
|
||||
UInt32 CBenchmarkDialog::OnChangeDictionary()
|
||||
{
|
||||
@@ -338,8 +337,14 @@ UInt32 CBenchmarkDialog::OnChangeDictionary()
|
||||
s += " / ";
|
||||
PrintSize_MB(s, ramSize);
|
||||
}
|
||||
if (g_LargePagesMode)
|
||||
s += " LP";
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
{
|
||||
AString s2;
|
||||
Add_LargePages_String(s2);
|
||||
s += s2;
|
||||
}
|
||||
#endif
|
||||
|
||||
SetItemText(IDT_BENCH_MEMORY_VAL, s);
|
||||
|
||||
|
||||
@@ -99,8 +99,10 @@ HRESULT CThreadExtracting::ProcessVirt()
|
||||
CDecompressStat Stat;
|
||||
|
||||
#ifndef _SFX
|
||||
/*
|
||||
if (HashBundle)
|
||||
HashBundle->Init();
|
||||
*/
|
||||
#endif
|
||||
|
||||
HRESULT res = Extract(codecs,
|
||||
@@ -119,7 +121,7 @@ HRESULT CThreadExtracting::ProcessVirt()
|
||||
{
|
||||
AddValuePair(Pairs, IDS_ARCHIVES_COLON, Stat.NumArchives);
|
||||
AddSizeValuePair(Pairs, IDS_PROP_PACKED_SIZE, Stat.PackSize);
|
||||
AddHashBundleRes(Pairs, *HashBundle, UString());
|
||||
AddHashBundleRes(Pairs, *HashBundle);
|
||||
}
|
||||
else if (Options->TestMode)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "../../../../C/DllSecur.h"
|
||||
#endif
|
||||
|
||||
#include "../../../Common/MyWindows.h"
|
||||
|
||||
#include <shlwapi.h>
|
||||
@@ -372,6 +376,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
||||
// setlocale(LC_COLLATE, ".ACP");
|
||||
try
|
||||
{
|
||||
#ifdef _WIN32
|
||||
My_SetDefaultDllDirectories();
|
||||
#endif
|
||||
|
||||
return Main2();
|
||||
}
|
||||
catch(const CNewException &)
|
||||
|
||||
@@ -810,6 +810,15 @@ SOURCE=..\..\..\..\C\CpuArch.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\DllSecur.c
|
||||
# SUBTRACT CPP /YX /Yc /Yu
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\DllSecur.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\..\C\Sort.c
|
||||
|
||||
!IF "$(CFG)" == "GUI - Win32 Release"
|
||||
|
||||
@@ -27,6 +27,7 @@ class CHashCallbackGUI: public CProgressThreadVirt, public IHashCallbackUI
|
||||
UInt64 NumFiles;
|
||||
bool _curIsFolder;
|
||||
UString FirstFileName;
|
||||
// UString MainPath;
|
||||
|
||||
CPropNameValPairs PropNameValPairs;
|
||||
|
||||
@@ -71,9 +72,9 @@ void AddSizeValue(UString &s, UInt64 value)
|
||||
if (value >= (1 << 10))
|
||||
{
|
||||
char c;
|
||||
if (value >= ((UInt64)10 << 30)) { value >>= 30; c = 'G'; }
|
||||
if (value >= (10 << 20)) { value >>= 20; c = 'M'; }
|
||||
else { value >>= 10; c = 'K'; }
|
||||
if (value >= ((UInt64)10 << 30)) { value >>= 30; c = 'G'; }
|
||||
else if (value >= (10 << 20)) { value >>= 20; c = 'M'; }
|
||||
else { value >>= 10; c = 'K'; }
|
||||
char sz[32];
|
||||
ConvertUInt64ToString(value, sz);
|
||||
s += " (";
|
||||
@@ -192,19 +193,25 @@ static void AddHashResString(CPropNameValPairs &s, const CHasherState &h, unsign
|
||||
}
|
||||
|
||||
|
||||
void AddHashBundleRes(CPropNameValPairs &s, const CHashBundle &hb, const UString &firstFileName)
|
||||
void AddHashBundleRes(CPropNameValPairs &s, const CHashBundle &hb)
|
||||
{
|
||||
if (hb.NumErrors != 0)
|
||||
AddValuePair(s, IDS_PROP_NUM_ERRORS, hb.NumErrors);
|
||||
|
||||
if (hb.NumFiles == 1 && hb.NumDirs == 0 && !firstFileName.IsEmpty())
|
||||
|
||||
if (hb.NumFiles == 1 && hb.NumDirs == 0 && !hb.FirstFileName.IsEmpty())
|
||||
{
|
||||
CProperty &pair = s.AddNew();
|
||||
LangString(IDS_PROP_NAME, pair.Name);
|
||||
pair.Value = firstFileName;
|
||||
pair.Value = hb.FirstFileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!hb.MainName.IsEmpty())
|
||||
{
|
||||
CProperty &pair = s.AddNew();
|
||||
LangString(IDS_PROP_NAME, pair.Name);
|
||||
pair.Value = hb.MainName;
|
||||
}
|
||||
if (hb.NumDirs != 0)
|
||||
AddValuePair(s, IDS_PROP_FOLDERS, hb.NumDirs);
|
||||
AddValuePair(s, IDS_PROP_FILES, hb.NumFiles);
|
||||
@@ -240,10 +247,10 @@ void AddHashBundleRes(CPropNameValPairs &s, const CHashBundle &hb, const UString
|
||||
}
|
||||
|
||||
|
||||
void AddHashBundleRes(UString &s, const CHashBundle &hb, const UString &firstFileName)
|
||||
void AddHashBundleRes(UString &s, const CHashBundle &hb)
|
||||
{
|
||||
CPropNameValPairs pairs;
|
||||
AddHashBundleRes(pairs, hb, firstFileName);
|
||||
AddHashBundleRes(pairs, hb);
|
||||
|
||||
FOR_VECTOR (i, pairs)
|
||||
{
|
||||
@@ -263,9 +270,11 @@ void AddHashBundleRes(UString &s, const CHashBundle &hb, const UString &firstFil
|
||||
}
|
||||
|
||||
|
||||
HRESULT CHashCallbackGUI::AfterLastFile(const CHashBundle &hb)
|
||||
HRESULT CHashCallbackGUI::AfterLastFile(CHashBundle &hb)
|
||||
{
|
||||
AddHashBundleRes(PropNameValPairs, hb, FirstFileName);
|
||||
hb.FirstFileName = FirstFileName;
|
||||
// MainPath
|
||||
AddHashBundleRes(PropNameValPairs, hb);
|
||||
|
||||
CProgressSync &sync = Sync;
|
||||
sync.Set_NumFilesCur(hb.NumFiles);
|
||||
@@ -335,10 +344,10 @@ void ShowHashResults(const CPropNameValPairs &propPairs, HWND hwnd)
|
||||
}
|
||||
|
||||
|
||||
void ShowHashResults(const CHashBundle &hb, const UString &firstFileName, HWND hwnd)
|
||||
void ShowHashResults(const CHashBundle &hb, HWND hwnd)
|
||||
{
|
||||
CPropNameValPairs propPairs;
|
||||
AddHashBundleRes(propPairs, hb, firstFileName);
|
||||
AddHashBundleRes(propPairs, hb);
|
||||
ShowHashResults(propPairs, hwnd);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ void AddValuePair(CPropNameValPairs &pairs, UINT resourceID, UInt64 value);
|
||||
void AddSizeValue(UString &s, UInt64 value);
|
||||
void AddSizeValuePair(CPropNameValPairs &pairs, UINT resourceID, UInt64 value);
|
||||
|
||||
void AddHashBundleRes(CPropNameValPairs &s, const CHashBundle &hb, const UString &firstFileName);
|
||||
void AddHashBundleRes(UString &s, const CHashBundle &hb, const UString &firstFileName);
|
||||
void AddHashBundleRes(CPropNameValPairs &s, const CHashBundle &hb);
|
||||
void AddHashBundleRes(UString &s, const CHashBundle &hb);
|
||||
|
||||
void ShowHashResults(const CPropNameValPairs &propPairs, HWND hwnd);
|
||||
void ShowHashResults(const CHashBundle &hb, const UString &firstFileName, HWND hwnd);
|
||||
void ShowHashResults(const CHashBundle &hb, HWND hwnd);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -134,6 +134,7 @@ COMPRESS_OBJS = \
|
||||
C_OBJS = \
|
||||
$O\Alloc.obj \
|
||||
$O\CpuArch.obj \
|
||||
$O\DllSecur.obj \
|
||||
$O\Sort.obj \
|
||||
$O\Threads.obj \
|
||||
|
||||
|
||||
Reference in New Issue
Block a user