mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-06 21:14:58 -06:00
4.56 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
b67ffe691b
commit
acd742622d
@@ -299,7 +299,8 @@ STDMETHODIMP CAgent::DoOperation(
|
||||
RINOK(CopyBlock(sfxStream, outStream));
|
||||
}
|
||||
|
||||
return outArchive->UpdateItems(outStream, updatePairs2.Size(),updateCallback);
|
||||
RINOK(outArchive->UpdateItems(outStream, updatePairs2.Size(),updateCallback));
|
||||
return outStreamSpec->Close();
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgent::DoOperation2(
|
||||
@@ -362,7 +363,8 @@ HRESULT CAgent::CommonUpdate(
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return outArchive->UpdateItems(outStream, numUpdateItems, updateCallback);
|
||||
RINOK(outArchive->UpdateItems(outStream, numUpdateItems, updateCallback));
|
||||
return outStreamSpec->Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -79,6 +79,13 @@ void PrintStringLn(const AString &s)
|
||||
PrintNewLine();
|
||||
}
|
||||
|
||||
void PrintError(const AString &s)
|
||||
{
|
||||
PrintNewLine();
|
||||
PrintString(s);
|
||||
PrintNewLine();
|
||||
}
|
||||
|
||||
static HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propID, bool &result)
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
@@ -141,7 +148,7 @@ STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password)
|
||||
// You can ask real password here from user
|
||||
// Password = GetPassword(OutStream);
|
||||
// PasswordIsDefined = true;
|
||||
PrintStringLn("Password is not defined");
|
||||
PrintError("Password is not defined");
|
||||
return E_ABORT;
|
||||
}
|
||||
CMyComBSTR tempName(Password);
|
||||
@@ -396,8 +403,12 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
|
||||
}
|
||||
}
|
||||
|
||||
if(_outFileStream != NULL && _processedFileInfo.UTCLastWriteTimeIsDefined)
|
||||
_outFileStreamSpec->SetLastWriteTime(&_processedFileInfo.UTCLastWriteTime);
|
||||
if (_outFileStream != NULL)
|
||||
{
|
||||
if (_processedFileInfo.UTCLastWriteTimeIsDefined)
|
||||
_outFileStreamSpec->SetLastWriteTime(&_processedFileInfo.UTCLastWriteTime);
|
||||
RINOK(_outFileStreamSpec->Close());
|
||||
}
|
||||
_outFileStream.Release();
|
||||
if (_extractMode && _processedFileInfo.AttributesAreDefined)
|
||||
NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attributes);
|
||||
@@ -413,7 +424,7 @@ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
|
||||
// You can ask real password here from user
|
||||
// Password = GetPassword(OutStream);
|
||||
// PasswordIsDefined = true;
|
||||
PrintStringLn("Password is not defined");
|
||||
PrintError("Password is not defined");
|
||||
return E_ABORT;
|
||||
}
|
||||
CMyComBSTR tempName(Password);
|
||||
@@ -603,7 +614,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream
|
||||
// if (systemError == ERROR_SHARING_VIOLATION)
|
||||
{
|
||||
PrintNewLine();
|
||||
PrintStringLn("WARNING: can't open file");
|
||||
PrintError("WARNING: can't open file");
|
||||
// PrintString(NError::MyFormatMessageW(systemError));
|
||||
return S_FALSE;
|
||||
}
|
||||
@@ -658,7 +669,7 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef
|
||||
// You can ask real password here from user
|
||||
// Password = GetPassword(OutStream);
|
||||
// PasswordIsDefined = true;
|
||||
PrintStringLn("Password is not defined");
|
||||
PrintError("Password is not defined");
|
||||
return E_ABORT;
|
||||
}
|
||||
}
|
||||
@@ -695,13 +706,13 @@ main(int argc, char* argv[])
|
||||
NWindows::NDLL::CLibrary library;
|
||||
if (!library.Load(TEXT(kDllName)))
|
||||
{
|
||||
PrintStringLn("Can not load library");
|
||||
PrintError("Can not load library");
|
||||
return 1;
|
||||
}
|
||||
CreateObjectFunc createObjectFunc = (CreateObjectFunc)library.GetProcAddress("CreateObject");
|
||||
if (createObjectFunc == 0)
|
||||
{
|
||||
PrintStringLn("Can not get CreateObject");
|
||||
PrintError("Can not get CreateObject");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -742,14 +753,14 @@ main(int argc, char* argv[])
|
||||
CMyComPtr<IOutStream> outFileStream = outFileStreamSpec;
|
||||
if (!outFileStreamSpec->Create(archiveName, false))
|
||||
{
|
||||
PrintStringLn("can't create archive file");
|
||||
PrintError("can't create archive file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
CMyComPtr<IOutArchive> outArchive;
|
||||
if (createObjectFunc(&CLSID_CFormat7z, &IID_IOutArchive, (void **)&outArchive) != S_OK)
|
||||
{
|
||||
PrintStringLn("Can not get class object");
|
||||
PrintError("Can not get class object");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -763,7 +774,7 @@ main(int argc, char* argv[])
|
||||
updateCallbackSpec->Finilize();
|
||||
if (result != S_OK)
|
||||
{
|
||||
PrintStringLn("Update Error");
|
||||
PrintError("Update Error");
|
||||
return 1;
|
||||
}
|
||||
for (i = 0; i < updateCallbackSpec->FailedFiles.Size(); i++)
|
||||
@@ -789,14 +800,14 @@ main(int argc, char* argv[])
|
||||
listCommand = false;
|
||||
else
|
||||
{
|
||||
PrintStringLn("incorrect command");
|
||||
PrintError("incorrect command");
|
||||
return 1;
|
||||
}
|
||||
|
||||
CMyComPtr<IInArchive> archive;
|
||||
if (createObjectFunc(&CLSID_CFormat7z, &IID_IInArchive, (void **)&archive) != S_OK)
|
||||
{
|
||||
PrintStringLn("Can not get class object");
|
||||
PrintError("Can not get class object");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -805,7 +816,7 @@ main(int argc, char* argv[])
|
||||
|
||||
if (!fileSpec->Open(archiveName))
|
||||
{
|
||||
PrintStringLn("Can not open archive file");
|
||||
PrintError("Can not open archive file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -818,7 +829,7 @@ main(int argc, char* argv[])
|
||||
|
||||
if (archive->Open(file, 0, openCallback) != S_OK)
|
||||
{
|
||||
PrintStringLn("Can not open archive");
|
||||
PrintError("Can not open archive");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -857,7 +868,12 @@ main(int argc, char* argv[])
|
||||
extractCallbackSpec->PasswordIsDefined = false;
|
||||
// extractCallbackSpec->PasswordIsDefined = true;
|
||||
// extractCallbackSpec->Password = L"1";
|
||||
archive->Extract(NULL, (UInt32)(Int32)(-1), false, extractCallback);
|
||||
HRESULT result = archive->Extract(NULL, (UInt32)(Int32)(-1), false, extractCallback);
|
||||
if (result != S_OK)
|
||||
{
|
||||
PrintError("Extract Error");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -434,6 +434,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
|
||||
(WriteAccessed && _processedFileInfo.IsLastAccessTimeDefined) ? &_processedFileInfo.LastAccessTime : NULL,
|
||||
(WriteModified && _processedFileInfo.IsLastWriteTimeDefined) ? &_processedFileInfo.LastWriteTime : &_utcLastWriteTimeDefault);
|
||||
_curSize = _outFileStreamSpec->ProcessedSize;
|
||||
RINOK(_outFileStreamSpec->Close());
|
||||
_outFileStream.Release();
|
||||
}
|
||||
UnpackSize += _curSize;
|
||||
|
||||
@@ -93,7 +93,8 @@ typedef UInt32 (WINAPI *GetNumberOfMethodsFunc)(UInt32 *numMethods);
|
||||
typedef UInt32 (WINAPI *GetNumberOfFormatsFunc)(UInt32 *numFormats);
|
||||
typedef UInt32 (WINAPI *GetHandlerPropertyFunc)(PROPID propID, PROPVARIANT *value);
|
||||
typedef UInt32 (WINAPI *GetHandlerPropertyFunc2)(UInt32 index, PROPID propID, PROPVARIANT *value);
|
||||
typedef UINT32 (WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *iid, void **outObject);
|
||||
typedef UInt32 (WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *iid, void **outObject);
|
||||
typedef UInt32 (WINAPI *SetLargePageModeFunc)();
|
||||
|
||||
|
||||
static HRESULT GetCoderClass(GetMethodPropertyFunc getMethodProperty, UInt32 index,
|
||||
@@ -332,6 +333,13 @@ int CCodecLib::FindIconIndex(const UString &ext) const
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
extern "C"
|
||||
{
|
||||
extern SIZE_T g_LargePageSize;
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT CCodecs::LoadDll(const CSysString &dllPath)
|
||||
{
|
||||
{
|
||||
@@ -351,6 +359,16 @@ HRESULT CCodecs::LoadDll(const CSysString &dllPath)
|
||||
#ifdef NEW_FOLDER_INTERFACE
|
||||
lib.LoadIcons();
|
||||
#endif
|
||||
|
||||
#ifdef _7ZIP_LARGE_PAGES
|
||||
if (g_LargePageSize != 0)
|
||||
{
|
||||
SetLargePageModeFunc setLargePageMode = (SetLargePageModeFunc)lib.Lib.GetProcAddress("SetLargePageMode");
|
||||
if (setLargePageMode != 0)
|
||||
setLargePageMode();
|
||||
}
|
||||
#endif
|
||||
|
||||
lib.CreateObject = (CreateObjectFunc)lib.Lib.GetProcAddress("CreateObject");
|
||||
if (lib.CreateObject != 0)
|
||||
{
|
||||
|
||||
@@ -67,6 +67,7 @@ class COutMultiVolStream:
|
||||
|
||||
struct CSubStreamInfo
|
||||
{
|
||||
COutFileStream *StreamSpec;
|
||||
CMyComPtr<IOutStream> Stream;
|
||||
UString Name;
|
||||
UInt64 Pos;
|
||||
@@ -87,6 +88,8 @@ public:
|
||||
_length = 0;
|
||||
}
|
||||
|
||||
HRESULT Close();
|
||||
|
||||
MY_UNKNOWN_IMP1(IOutStream)
|
||||
|
||||
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
|
||||
@@ -96,6 +99,22 @@ public:
|
||||
|
||||
// static NSynchronization::CCriticalSection g_TempPathsCS;
|
||||
|
||||
HRESULT COutMultiVolStream::Close()
|
||||
{
|
||||
HRESULT res = S_OK;
|
||||
for (int i = 0; i < Streams.Size(); i++)
|
||||
{
|
||||
CSubStreamInfo &s = Streams[i];
|
||||
if (s.StreamSpec)
|
||||
{
|
||||
HRESULT res2 = s.StreamSpec->Close();
|
||||
if (res2 != S_OK)
|
||||
res = res2;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
STDMETHODIMP COutMultiVolStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
if(processedSize != NULL)
|
||||
@@ -112,9 +131,9 @@ STDMETHODIMP COutMultiVolStream::Write(const void *data, UInt32 size, UInt32 *pr
|
||||
while (res.Length() < 3)
|
||||
res = UString(L'0') + res;
|
||||
UString name = Prefix + res;
|
||||
COutFileStream *streamSpec = new COutFileStream;
|
||||
subStream.Stream = streamSpec;
|
||||
if(!streamSpec->Create(name, false))
|
||||
subStream.StreamSpec = new COutFileStream;
|
||||
subStream.Stream = subStream.StreamSpec;
|
||||
if(!subStream.StreamSpec->Create(name, false))
|
||||
return ::GetLastError();
|
||||
{
|
||||
// NSynchronization::CCriticalSectionLock lock(g_TempPathsCS);
|
||||
@@ -362,13 +381,17 @@ static HRESULT Compress(
|
||||
throw 1417161;
|
||||
NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
|
||||
}
|
||||
|
||||
COutFileStream *outStreamSpec = NULL;
|
||||
COutMultiVolStream *volStreamSpec = NULL;
|
||||
|
||||
if (volumesSizes.Size() == 0)
|
||||
{
|
||||
if (stdOutMode)
|
||||
outStream = new CStdOutFileStream;
|
||||
else
|
||||
{
|
||||
COutFileStream *outStreamSpec = new COutFileStream;
|
||||
outStreamSpec = new COutFileStream;
|
||||
outStream = outStreamSpec;
|
||||
bool isOK = false;
|
||||
UString realPath;
|
||||
@@ -410,7 +433,7 @@ static HRESULT Compress(
|
||||
{
|
||||
if (stdOutMode)
|
||||
return E_FAIL;
|
||||
COutMultiVolStream *volStreamSpec = new COutMultiVolStream;
|
||||
volStreamSpec = new COutMultiVolStream;
|
||||
outStream = volStreamSpec;
|
||||
volStreamSpec->Sizes = volumesSizes;
|
||||
volStreamSpec->Prefix = archivePath.GetFinalPath() + UString(L".");
|
||||
@@ -440,11 +463,12 @@ static HRESULT Compress(
|
||||
}
|
||||
|
||||
CMyComPtr<ISequentialOutStream> sfxOutStream;
|
||||
COutFileStream *outStreamSpec = NULL;
|
||||
if (volumesSizes.Size() == 0)
|
||||
sfxOutStream = outStream;
|
||||
else
|
||||
{
|
||||
COutFileStream *outStreamSpec = new COutFileStream;
|
||||
outStreamSpec = new COutFileStream;
|
||||
sfxOutStream = outStreamSpec;
|
||||
UString realPath = archivePath.GetFinalPath();
|
||||
if (!outStreamSpec->Create(realPath, false))
|
||||
@@ -456,10 +480,19 @@ static HRESULT Compress(
|
||||
}
|
||||
}
|
||||
RINOK(CopyBlock(sfxStream, sfxOutStream));
|
||||
if (outStreamSpec)
|
||||
{
|
||||
RINOK(outStreamSpec->Close());
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT result = outArchive->UpdateItems(outStream, updatePairs2.Size(), updateCallback);
|
||||
callback->Finilize();
|
||||
RINOK(result);
|
||||
if (outStreamSpec)
|
||||
result = outStreamSpec->Close();
|
||||
else if (volStreamSpec)
|
||||
result = volStreamSpec->Close();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -407,15 +407,9 @@ int Main2(
|
||||
result = E_FAIL;
|
||||
}
|
||||
|
||||
stdStream << endl << endl << "Total:" << endl;
|
||||
stdStream << endl;
|
||||
if (ecs->NumArchives > 1)
|
||||
stdStream << "Archives: " << ecs->NumArchives << endl;
|
||||
{
|
||||
stdStream << "Folders: " << stat.NumFolders << endl;
|
||||
stdStream << "Files: " << stat.NumFiles << endl;
|
||||
stdStream << "Size: " << stat.UnpackSize << endl;
|
||||
stdStream << "Compressed: " << stat.PackSize << endl;
|
||||
}
|
||||
if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
|
||||
{
|
||||
if (ecs->NumArchives > 1)
|
||||
@@ -432,6 +426,13 @@ int Main2(
|
||||
}
|
||||
if (result != S_OK)
|
||||
throw CSystemException(result);
|
||||
if (stat.NumFolders != 0)
|
||||
stdStream << "Folders: " << stat.NumFolders << endl;
|
||||
if (stat.NumFiles != 1 || stat.NumFolders != 0)
|
||||
stdStream << "Files: " << stat.NumFiles << endl;
|
||||
stdStream
|
||||
<< "Size: " << stat.UnpackSize << endl
|
||||
<< "Compressed: " << stat.PackSize << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -185,7 +185,6 @@ bool CFSFolder::LoadComments()
|
||||
file.Read(p, (UInt32)length, processedSize);
|
||||
p[length] = 0;
|
||||
s.ReleaseBuffer();
|
||||
s.Replace("\r\n", "\n");
|
||||
if (processedSize != length)
|
||||
return false;
|
||||
file.Close();
|
||||
@@ -218,7 +217,6 @@ bool CFSFolder::SaveComments()
|
||||
Byte bom [] = { 0xEF, 0xBB, 0xBF, 0x0D, 0x0A };
|
||||
file.Write(bom , sizeof(bom), processedSize);
|
||||
}
|
||||
utfString.Replace("\n", "\r\n");
|
||||
file.Write(utfString, utfString.Length(), processedSize);
|
||||
_commentsAreLoaded = false;
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "ProgressDialog2Res.h"
|
||||
#include "../../GuiCommon.rc"
|
||||
|
||||
#define xSize2 300
|
||||
#define xSize2 320
|
||||
#define ySize2 98
|
||||
|
||||
#define xSize (xSize2 + marg + marg)
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#define x0Size 90
|
||||
#define x1 (marg + x0Size)
|
||||
#define x1Size 40
|
||||
#define x1Size 70
|
||||
|
||||
#define x3Size 40
|
||||
#define x3 (xSize - marg - x3Size)
|
||||
|
||||
@@ -22,6 +22,11 @@ static bool IsSeparatorChar(wchar_t c)
|
||||
return (c == kSpaceChar || c == kTabChar);
|
||||
}
|
||||
|
||||
void RemoveCr(UString &s)
|
||||
{
|
||||
s.Replace(L"\x0D", L"");
|
||||
}
|
||||
|
||||
static UString GetIDString(const wchar_t *srcString, int &finishPos)
|
||||
{
|
||||
UString result;
|
||||
@@ -42,6 +47,7 @@ static UString GetIDString(const wchar_t *srcString, int &finishPos)
|
||||
result += c;
|
||||
}
|
||||
result.Trim();
|
||||
RemoveCr(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -59,34 +65,28 @@ static UString GetValueString(const wchar_t *srcString, int &finishPos)
|
||||
result += c;
|
||||
}
|
||||
result.Trim();
|
||||
RemoveCr(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool GetTextPairs(const UString &srcString, CObjectVector<CTextPair> &pairs)
|
||||
{
|
||||
pairs.Clear();
|
||||
UString srcString2 = srcString;
|
||||
srcString2.Replace(L"\x0D", L"");
|
||||
|
||||
pairs.Clear();
|
||||
int pos = 0;
|
||||
|
||||
/////////////////////
|
||||
// read strings
|
||||
|
||||
if (srcString2.Length() > 0)
|
||||
if (srcString.Length() > 0)
|
||||
{
|
||||
if (srcString2[0] == kBOM)
|
||||
if (srcString[0] == kBOM)
|
||||
pos++;
|
||||
}
|
||||
while (pos < srcString2.Length())
|
||||
while (pos < srcString.Length())
|
||||
{
|
||||
int finishPos;
|
||||
UString id = GetIDString((const wchar_t *)srcString2 + pos, finishPos);
|
||||
UString id = GetIDString((const wchar_t *)srcString + pos, finishPos);
|
||||
pos += finishPos;
|
||||
if (id.IsEmpty())
|
||||
continue;
|
||||
UString value = GetValueString((const wchar_t *)srcString2 + pos, finishPos);
|
||||
UString value = GetValueString((const wchar_t *)srcString + pos, finishPos);
|
||||
pos += finishPos;
|
||||
if (!id.IsEmpty())
|
||||
{
|
||||
@@ -195,7 +195,7 @@ bool CPairsStorage::ReadFromString(const UString &text)
|
||||
Sort();
|
||||
else
|
||||
Pairs.Clear();
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
void CPairsStorage::SaveToString(UString &text)
|
||||
@@ -211,6 +211,7 @@ void CPairsStorage::SaveToString(UString &text)
|
||||
text += L'\"';
|
||||
text += L' ';
|
||||
text += pair.Value;
|
||||
text += L'\x0D';
|
||||
text += L'\n';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user