Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/CPP
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-10-24 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:55 +0300
commitacd742622d1e0daf50ae815bec4ddb2143bafbf5 (patch)
tree9726a4b8de0935af6c892a2b8d632284f37570c4 /CPP
parentb67ffe691bddceb89b47dd09a60203b77a2b72ed (diff)
4.56 beta
Diffstat (limited to 'CPP')
-rwxr-xr-xCPP/7zip/Archive/7z/7zExtract.cpp2
-rwxr-xr-xCPP/7zip/Archive/7z/7zFolderInStream.cpp9
-rwxr-xr-xCPP/7zip/Archive/7z/7zFolderOutStream.cpp9
-rwxr-xr-xCPP/7zip/Archive/7z/7zFolderOutStream.h5
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandler.cpp2
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandler.h4
-rwxr-xr-xCPP/7zip/Archive/Archive2.def1
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmIn.cpp18
-rwxr-xr-xCPP/7zip/Archive/Common/HandlerOut.cpp9
-rwxr-xr-xCPP/7zip/Archive/Common/HandlerOut.h2
-rwxr-xr-xCPP/7zip/Archive/DllExports.cpp10
-rwxr-xr-xCPP/7zip/Archive/DllExports2.cpp10
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp3
-rwxr-xr-xCPP/7zip/Common/FileStreams.cpp5
-rwxr-xr-xCPP/7zip/Common/FileStreams.h2
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateEncoder.cpp4
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMAEncoder.cpp58
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp19
-rwxr-xr-xCPP/7zip/MyVersion.h8
-rwxr-xr-xCPP/7zip/UI/Agent/AgentOut.cpp6
-rwxr-xr-xCPP/7zip/UI/Client7z/Client7z.cpp48
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveExtractCallback.cpp1
-rwxr-xr-xCPP/7zip/UI/Common/LoadCodecs.cpp20
-rwxr-xr-xCPP/7zip/UI/Common/Update.cpp45
-rwxr-xr-xCPP/7zip/UI/Console/Main.cpp15
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolder.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2.rc4
-rwxr-xr-xCPP/7zip/UI/FileManager/TextPairs.cpp27
-rwxr-xr-xCPP/Common/C_FileIO.cpp5
-rwxr-xr-xCPP/Common/C_FileIO.h1
30 files changed, 244 insertions, 110 deletions
diff --git a/CPP/7zip/Archive/7z/7zExtract.cpp b/CPP/7zip/Archive/7z/7zExtract.cpp
index 65f9c9eb..42977097 100755
--- a/CPP/7zip/Archive/7z/7zExtract.cpp
+++ b/CPP/7zip/Archive/7z/7zExtract.cpp
@@ -195,7 +195,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
0,
#endif
startIndex,
- &efi.ExtractStatuses, extractCallback, testMode);
+ &efi.ExtractStatuses, extractCallback, testMode, _crcSize != 0);
RINOK(result);
diff --git a/CPP/7zip/Archive/7z/7zFolderInStream.cpp b/CPP/7zip/Archive/7z/7zFolderInStream.cpp
index fb1cfd3a..f60a7177 100755
--- a/CPP/7zip/Archive/7z/7zFolderInStream.cpp
+++ b/CPP/7zip/Archive/7z/7zFolderInStream.cpp
@@ -113,13 +113,14 @@ STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSiz
STDMETHODIMP CFolderInStream::GetSubStreamSize(UInt64 subStream, UInt64 *value)
{
*value = 0;
- if (subStream < Sizes.Size())
+ int subStreamIndex = (int)subStream;
+ if (subStreamIndex < 0 || subStream > Sizes.Size())
+ return E_FAIL;
+ if (subStreamIndex < Sizes.Size())
{
- *value= Sizes[(int)(size_t)subStream];
+ *value= Sizes[subStreamIndex];
return S_OK;
}
- if (subStream > Sizes.Size())
- return E_FAIL;
if (!_currentSizeIsDefined)
return S_FALSE;
*value = _currentSize;
diff --git a/CPP/7zip/Archive/7z/7zFolderOutStream.cpp b/CPP/7zip/Archive/7z/7zFolderOutStream.cpp
index 93bed3d9..6206ffec 100755
--- a/CPP/7zip/Archive/7z/7zFolderOutStream.cpp
+++ b/CPP/7zip/Archive/7z/7zFolderOutStream.cpp
@@ -19,7 +19,8 @@ HRESULT CFolderOutStream::Init(
UInt32 startIndex,
const CBoolVector *extractStatuses,
IArchiveExtractCallback *extractCallback,
- bool testMode)
+ bool testMode,
+ bool checkCrc)
{
_archiveDatabase = archiveDatabase;
_ref2Offset = ref2Offset;
@@ -29,6 +30,8 @@ HRESULT CFolderOutStream::Init(
_extractCallback = extractCallback;
_testMode = testMode;
+ _checkCrc = checkCrc;
+
_currentIndex = 0;
_fileIsOpen = false;
return WriteEmptyFiles();
@@ -49,7 +52,7 @@ HRESULT CFolderOutStream::OpenFile()
RINOK(_extractCallback->GetStream(_ref2Offset + index, &realOutStream, askMode));
_outStreamWithHashSpec->SetStream(realOutStream);
- _outStreamWithHashSpec->Init();
+ _outStreamWithHashSpec->Init(_checkCrc);
if (askMode == NArchive::NExtract::NAskMode::kExtract &&
(!realOutStream))
{
@@ -100,7 +103,7 @@ STDMETHODIMP CFolderOutStream::Write(const void *data,
if (_filePos == fileSize)
{
bool digestsAreEqual;
- if (fileInfo.IsFileCRCDefined)
+ if (fileInfo.IsFileCRCDefined && _checkCrc)
digestsAreEqual = fileInfo.FileCRC == _outStreamWithHashSpec->GetCRC();
else
digestsAreEqual = true;
diff --git a/CPP/7zip/Archive/7z/7zFolderOutStream.h b/CPP/7zip/Archive/7z/7zFolderOutStream.h
index c132c79a..8ca91e64 100755
--- a/CPP/7zip/Archive/7z/7zFolderOutStream.h
+++ b/CPP/7zip/Archive/7z/7zFolderOutStream.h
@@ -36,6 +36,8 @@ private:
bool _testMode;
bool _fileIsOpen;
+
+ bool _checkCrc;
UInt64 _filePos;
HRESULT OpenFile();
@@ -47,7 +49,8 @@ public:
UInt32 startIndex,
const CBoolVector *extractStatuses,
IArchiveExtractCallback *extractCallback,
- bool testMode);
+ bool testMode,
+ bool checkCrc);
HRESULT FlushCorrupted(Int32 resultEOperationResult);
HRESULT WasWritingFinished();
};
diff --git a/CPP/7zip/Archive/7z/7zHandler.cpp b/CPP/7zip/Archive/7z/7zHandler.cpp
index d5dc8720..bbef1ea5 100755
--- a/CPP/7zip/Archive/7z/7zHandler.cpp
+++ b/CPP/7zip/Archive/7z/7zHandler.cpp
@@ -33,6 +33,8 @@ namespace N7z {
CHandler::CHandler()
{
+ _crcSize = 4;
+
#ifdef EXTRACT_ONLY
#ifdef COMPRESS_MT
_numThreads = NWindows::NSystem::GetNumberOfProcessors();
diff --git a/CPP/7zip/Archive/7z/7zHandler.h b/CPP/7zip/Archive/7z/7zHandler.h
index 1006f204..ad4df41f 100755
--- a/CPP/7zip/Archive/7z/7zHandler.h
+++ b/CPP/7zip/Archive/7z/7zHandler.h
@@ -110,7 +110,9 @@ private:
#ifdef COMPRESS_MT
UInt32 _numThreads;
#endif
-
+
+ UInt32 _crcSize;
+
#else
CRecordVector<CBind> _binds;
diff --git a/CPP/7zip/Archive/Archive2.def b/CPP/7zip/Archive/Archive2.def
index 78ec1dd7..885d39d1 100755
--- a/CPP/7zip/Archive/Archive2.def
+++ b/CPP/7zip/Archive/Archive2.def
@@ -6,3 +6,4 @@ EXPORTS
CreateObject PRIVATE
GetNumberOfMethods PRIVATE
GetMethodProperty PRIVATE
+ SetLargePageMode PRIVATE
diff --git a/CPP/7zip/Archive/Chm/ChmIn.cpp b/CPP/7zip/Archive/Chm/ChmIn.cpp
index 8c56ec91..5e13f54b 100755
--- a/CPP/7zip/Archive/Chm/ChmIn.cpp
+++ b/CPP/7zip/Archive/Chm/ChmIn.cpp
@@ -759,9 +759,23 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
li.ResetInterval = ReadUInt32();
li.WindowSize = ReadUInt32();
li.CacheSize = ReadUInt32();
- if (li.ResetInterval != 2 && li.ResetInterval != 4)
+ if (
+ li.ResetInterval != 1 &&
+ li.ResetInterval != 2 &&
+ li.ResetInterval != 4 &&
+ li.ResetInterval != 8 &&
+ li.ResetInterval != 16 &&
+ li.ResetInterval != 32 &&
+ li.ResetInterval != 64)
return S_FALSE;
- if (li.WindowSize != 2 && li.WindowSize != 4)
+ if (
+ li.WindowSize != 1 &&
+ li.WindowSize != 2 &&
+ li.WindowSize != 4 &&
+ li.WindowSize != 8 &&
+ li.WindowSize != 16 &&
+ li.WindowSize != 32 &&
+ li.WindowSize != 64)
return S_FALSE;
numDWORDS -= 5;
while (numDWORDS-- != 0)
diff --git a/CPP/7zip/Archive/Common/HandlerOut.cpp b/CPP/7zip/Archive/Common/HandlerOut.cpp
index 7c214c3c..0dcf449e 100755
--- a/CPP/7zip/Archive/Common/HandlerOut.cpp
+++ b/CPP/7zip/Archive/Common/HandlerOut.cpp
@@ -468,6 +468,7 @@ void COutHandler::Init()
_level = 5;
_autoFilter = true;
_volumeMode = false;
+ _crcSize = 4;
InitSolid();
}
@@ -481,6 +482,7 @@ void COutHandler::BeforeSetProperty()
mainDicSize = 0xFFFFFFFF;
mainDicMethodIndex = 0xFFFFFFFF;
minNumber = 0;
+ _crcSize = 4;
}
HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &value)
@@ -507,6 +509,13 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
return SetSolidSettings(name);
}
+ if (name == L"CRC")
+ {
+ _crcSize = 4;
+ name.Delete(0, 3);
+ return ParsePropValue(name, value, _crcSize);
+ }
+
UInt32 number;
int index = ParseStringToUInt32(name, number);
UString realName = name.Mid(index);
diff --git a/CPP/7zip/Archive/Common/HandlerOut.h b/CPP/7zip/Archive/Common/HandlerOut.h
index eded0786..ab925cc3 100755
--- a/CPP/7zip/Archive/Common/HandlerOut.h
+++ b/CPP/7zip/Archive/Common/HandlerOut.h
@@ -26,6 +26,8 @@ public:
UInt32 _numThreads;
#endif
+ UInt32 _crcSize;
+
CObjectVector<COneMethodInfo> _methods;
bool _removeSfxBlock;
diff --git a/CPP/7zip/Archive/DllExports.cpp b/CPP/7zip/Archive/DllExports.cpp
index 58daedb4..dae2698f 100755
--- a/CPP/7zip/Archive/DllExports.cpp
+++ b/CPP/7zip/Archive/DllExports.cpp
@@ -33,9 +33,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
#endif
- #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
- SetLargePageSize();
- #endif
}
return TRUE;
}
@@ -50,3 +47,10 @@ STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
return CreateArchiver(clsid, iid, outObject);
}
+STDAPI SetLargePageMode()
+{
+ #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
+ SetLargePageSize();
+ #endif
+ return S_OK;
+}
diff --git a/CPP/7zip/Archive/DllExports2.cpp b/CPP/7zip/Archive/DllExports2.cpp
index 216afdb1..d3b15f06 100755
--- a/CPP/7zip/Archive/DllExports2.cpp
+++ b/CPP/7zip/Archive/DllExports2.cpp
@@ -43,9 +43,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
g_IsNT = IsItWindowsNT();
#endif
#endif
- #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
- SetLargePageSize();
- #endif
}
return TRUE;
}
@@ -76,3 +73,10 @@ STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
// COM_TRY_END
}
+STDAPI SetLargePageMode()
+{
+ #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
+ SetLargePageSize();
+ #endif
+ return S_OK;
+}
diff --git a/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp
index aaeae468..5d56a9e7 100755
--- a/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp
+++ b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp
@@ -240,7 +240,10 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 resultEOperationResul
}
}
if(_outFileStream != NULL)
+ {
_outFileStreamSpec->SetLastWriteTime(&_processedFileInfo.UTCLastWriteTime);
+ RINOK(_outFileStreamSpec->Close());
+ }
_outFileStream.Release();
if (_extractMode)
NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attributes);
diff --git a/CPP/7zip/Common/FileStreams.cpp b/CPP/7zip/Common/FileStreams.cpp
index 27fb0e81..bebcf14c 100755
--- a/CPP/7zip/Common/FileStreams.cpp
+++ b/CPP/7zip/Common/FileStreams.cpp
@@ -145,6 +145,11 @@ STDMETHODIMP CInFileStream::GetSize(UInt64 *size)
//////////////////////////
// COutFileStream
+HRESULT COutFileStream::Close()
+{
+ return ConvertBoolToHRESULT(File.Close());
+}
+
STDMETHODIMP COutFileStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
{
#ifdef USE_WIN_FILE
diff --git a/CPP/7zip/Common/FileStreams.h b/CPP/7zip/Common/FileStreams.h
index 94cd1daf..715801d8 100755
--- a/CPP/7zip/Common/FileStreams.h
+++ b/CPP/7zip/Common/FileStreams.h
@@ -103,6 +103,8 @@ public:
}
#endif
#endif
+
+ HRESULT Close();
UInt64 ProcessedSize;
diff --git a/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp b/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp
index ac68ff35..2f72fded 100755
--- a/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp
+++ b/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp
@@ -282,10 +282,10 @@ NO_INLINE void CCoder::GetMatches()
{
UInt32 numAvail = Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) + 1;
const Byte *pby = Inline_MatchFinder_GetPointerToCurrentPos(&_lzInWindow) - 1;
- UInt32 distance = distanceTmp[numPairs - 1] + 1;
+ const Byte *pby2 = pby - (distanceTmp[numPairs - 1] + 1);
if (numAvail > m_MatchMaxLen)
numAvail = m_MatchMaxLen;
- for (; len < numAvail && pby[len] == pby[(size_t)len - distance]; len++);
+ for (; len < numAvail && pby[len] == pby2[len]; len++);
m_MatchDistances[i - 1] = (UInt16)len;
}
}
diff --git a/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp b/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp
index c2e2acbe..021099d8 100755
--- a/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp
+++ b/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp
@@ -610,15 +610,14 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
for(i = 0; i < kNumRepDistances; i++)
{
reps[i] = _repDistances[i];
- UInt32 backOffset = reps[i] + 1;
- if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])
+ const Byte *data2 = data - (reps[i] + 1);
+ if (data[0] != data2[0] || data[1] != data2[1])
{
repLens[i] = 0;
continue;
}
UInt32 lenTest;
- for (lenTest = 2; lenTest < numAvailableBytes &&
- data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);
+ for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data2[lenTest]; lenTest++);
repLens[i] = lenTest;
if (lenTest > repLens[repMaxIndex])
repMaxIndex = i;
@@ -639,7 +638,7 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
return lenMain;
}
Byte currentByte = *data;
- Byte matchByte = data[(size_t)0 - reps[0] - 1];
+ Byte matchByte = *(data - (reps[0] + 1));
if(lenMain < 2 && currentByte != matchByte && repLens[repMaxIndex] < 2)
{
@@ -821,13 +820,13 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
UInt32 curPrice = curOptimum.Price;
const Byte *data = _matchFinder.GetPointerToCurrentPos(_matchFinderObj) - 1;
const Byte currentByte = *data;
- const Byte matchByte = data[(size_t)0 - reps[0] - 1];
+ const Byte matchByte = *(data - (reps[0] + 1));
UInt32 posState = (position & _posStateMask);
UInt32 curAnd1Price = curPrice +
_isMatch[state.Index][posState].GetPrice0() +
- _literalEncoder.GetSubCoder(position, data[(size_t)0 - 1])->GetPrice(!state.IsCharState(), matchByte, currentByte);
+ _literalEncoder.GetSubCoder(position, *(data - 1))->GetPrice(!state.IsCharState(), matchByte, currentByte);
COptimal &nextOptimum = _optimum[cur + 1];
@@ -870,11 +869,10 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
if (!nextIsChar && matchByte != currentByte) // speed optimization
{
// try Literal + rep0
- UInt32 backOffset = reps[0] + 1;
+ const Byte *data2 = data - (reps[0] + 1);
UInt32 limit = MyMin(numAvailableBytesFull, _numFastBytes + 1);
UInt32 temp;
- for (temp = 1; temp < limit &&
- data[temp] == data[(size_t)temp - backOffset]; temp++);
+ for (temp = 1; temp < limit && data[temp] == data2[temp]; temp++);
UInt32 lenTest2 = temp - 1;
if (lenTest2 >= 2)
{
@@ -908,13 +906,11 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
for(UInt32 repIndex = 0; repIndex < kNumRepDistances; repIndex++)
{
// UInt32 repLen = _matchFinder.GetMatchLen(0 - 1, reps[repIndex], newLen); // test it;
- UInt32 backOffset = reps[repIndex] + 1;
- if (data[0] != data[(size_t)0 - backOffset] ||
- data[1] != data[(size_t)1 - backOffset])
+ const Byte *data2 = data - (reps[repIndex] + 1);
+ if (data[0] != data2[0] || data[1] != data2[1])
continue;
UInt32 lenTest;
- for (lenTest = 2; lenTest < numAvailableBytes &&
- data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);
+ for (lenTest = 2; lenTest < numAvailableBytes && data[lenTest] == data2[lenTest]; lenTest++);
while(lenEnd < cur + lenTest)
_optimum[++lenEnd].Price = kIfinityPrice;
UInt32 lenTestTemp = lenTest;
@@ -941,8 +937,7 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
{
UInt32 lenTest2 = lenTest + 1;
UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
- for (; lenTest2 < limit &&
- data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);
+ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
lenTest2 -= lenTest + 1;
if (lenTest2 >= 2)
{
@@ -952,8 +947,8 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
UInt32 curAndLenCharPrice =
price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState) +
_isMatch[state2.Index][posStateNext].GetPrice0() +
- _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice(
- true, data[(size_t)lenTest - backOffset], data[lenTest]);
+ _literalEncoder.GetSubCoder(position + lenTest, data[lenTest - 1])->GetPrice(
+ true, data2[lenTest], data[lenTest]);
state2.UpdateChar();
posStateNext = (position + lenTest + 1) & _posStateMask;
UInt32 nextRepMatchPrice = curAndLenCharPrice +
@@ -1025,11 +1020,10 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
if (/*_maxMode && */lenTest == matchDistances[offs])
{
// Try Match + Literal + Rep0
- UInt32 backOffset = curBack + 1;
+ const Byte *data2 = data - (curBack + 1);
UInt32 lenTest2 = lenTest + 1;
UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
- for (; lenTest2 < limit &&
- data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);
+ for (; lenTest2 < limit && data[lenTest2] == data2[lenTest2]; lenTest2++);
lenTest2 -= lenTest + 1;
if (lenTest2 >= 2)
{
@@ -1038,8 +1032,8 @@ UInt32 CEncoder::GetOptimum(UInt32 position, UInt32 &backRes)
UInt32 posStateNext = (position + lenTest) & _posStateMask;
UInt32 curAndLenCharPrice = curAndLenPrice +
_isMatch[state2.Index][posStateNext].GetPrice0() +
- _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice(
- true, data[(size_t)lenTest - backOffset], data[lenTest]);
+ _literalEncoder.GetSubCoder(position + lenTest, data[lenTest - 1])->GetPrice(
+ true, data2[lenTest], data[lenTest]);
state2.UpdateChar();
posStateNext = (posStateNext + 1) & _posStateMask;
UInt32 nextRepMatchPrice = curAndLenCharPrice +
@@ -1105,7 +1099,9 @@ UInt32 CEncoder::ReadMatchDistances(UInt32 &numDistancePairs)
UInt32 distance = _matchDistances[numDistancePairs - 1] + 1;
if (numAvail > kMatchMaxLen)
numAvail = kMatchMaxLen;
- for (; lenRes < numAvail && pby[lenRes] == pby[(size_t)lenRes - distance]; lenRes++);
+
+ const Byte *pby2 = pby - distance;
+ for (; lenRes < numAvail && pby[lenRes] == pby2[lenRes]; lenRes++);
}
}
_additionalOffset++;
@@ -1141,14 +1137,14 @@ UInt32 CEncoder::GetOptimumFast(UInt32 &backRes)
for(UInt32 i = 0; i < kNumRepDistances; i++)
{
- UInt32 backOffset = _repDistances[i] + 1;
- if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])
+ const Byte *data2 = data - (_repDistances[i] + 1);
+ if (data[0] != data2[0] || data[1] != data2[1])
{
repLens[i] = 0;
continue;
}
UInt32 len;
- for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);
+ for (len = 2; len < numAvailableBytes && data[len] == data2[len]; len++);
if(len >= _numFastBytes)
{
backRes = i;
@@ -1216,14 +1212,14 @@ UInt32 CEncoder::GetOptimumFast(UInt32 &backRes)
data = _matchFinder.GetPointerToCurrentPos(_matchFinderObj) - 1;
for(UInt32 i = 0; i < kNumRepDistances; i++)
{
- UInt32 backOffset = _repDistances[i] + 1;
- if (data[1] != data[(size_t)1 - backOffset] || data[2] != data[(size_t)2 - backOffset])
+ const Byte *data2 = data - (_repDistances[i] + 1);
+ if (data[1] != data2[1] || data[2] != data2[2])
{
repLens[i] = 0;
continue;
}
UInt32 len;
- for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);
+ for (len = 2; len < numAvailableBytes && data[len] == data2[len]; len++);
if (len + 1 >= lenMain)
{
_longestMatchWasFound = true;
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
index 923c014c..0e83f576 100755
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
@@ -159,7 +159,7 @@ int main2(int n, const char *args[])
g_IsNT = IsItWindowsNT();
#endif
- fprintf(stderr, "\nLZMA 4.54 Copyright (c) 1999-2007 Igor Pavlov 2007-09-04\n");
+ fprintf(stderr, "\nLZMA 4.56 Copyright (c) 1999-2007 Igor Pavlov 2007-10-19\n");
if (n == 1)
{
@@ -276,6 +276,7 @@ int main2(int n, const char *args[])
}
CMyComPtr<ISequentialOutStream> outStream;
+ COutFileStream *outStreamSpec = NULL;
if (stdOutMode)
{
outStream = new CStdOutFileStream;
@@ -286,7 +287,7 @@ int main2(int n, const char *args[])
if (paramIndex >= nonSwitchStrings.Size())
IncorrectCommand();
const UString &outputName = nonSwitchStrings[paramIndex++];
- COutFileStream *outStreamSpec = new COutFileStream;
+ outStreamSpec = new COutFileStream;
outStream = outStreamSpec;
if (!outStreamSpec->Create(GetSystemString(outputName), true))
{
@@ -368,8 +369,7 @@ int main2(int n, const char *args[])
UInt64 fileSize;
if (encodeMode)
{
- NCompress::NLZMA::CEncoder *encoderSpec =
- new NCompress::NLZMA::CEncoder;
+ NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder;
CMyComPtr<ICompressCoder> encoder = encoderSpec;
if (!dictionaryIsDefined)
@@ -483,8 +483,7 @@ int main2(int n, const char *args[])
}
else
{
- NCompress::NLZMA::CDecoder *decoderSpec =
- new NCompress::NLZMA::CDecoder;
+ NCompress::NLZMA::CDecoder *decoderSpec = new NCompress::NLZMA::CDecoder;
CMyComPtr<ICompressCoder> decoder = decoderSpec;
const UInt32 kPropertiesSize = 5;
Byte properties[kPropertiesSize];
@@ -526,6 +525,14 @@ int main2(int n, const char *args[])
return 1;
}
}
+ if (outStreamSpec != NULL)
+ {
+ if (outStreamSpec->Close() != S_OK)
+ {
+ fprintf(stderr, "File closing error");
+ return 1;
+ }
+ }
return 0;
}
diff --git a/CPP/7zip/MyVersion.h b/CPP/7zip/MyVersion.h
index 3d5c5267..f9ba7a3b 100755
--- a/CPP/7zip/MyVersion.h
+++ b/CPP/7zip/MyVersion.h
@@ -1,8 +1,8 @@
#define MY_VER_MAJOR 4
-#define MY_VER_MINOR 55
+#define MY_VER_MINOR 56
#define MY_VER_BUILD 0
-#define MY_VERSION "4.55 beta"
-#define MY_7ZIP_VERSION "7-Zip 4.55 beta"
-#define MY_DATE "2007-09-05"
+#define MY_VERSION "4.56 beta"
+#define MY_7ZIP_VERSION "7-Zip 4.56 beta"
+#define MY_DATE "2007-10-24"
#define MY_COPYRIGHT "Copyright (c) 1999-2007 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE
diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp
index 956b0bbd..4c6ba1a1 100755
--- a/CPP/7zip/UI/Agent/AgentOut.cpp
+++ b/CPP/7zip/UI/Agent/AgentOut.cpp
@@ -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();
}
diff --git a/CPP/7zip/UI/Client7z/Client7z.cpp b/CPP/7zip/UI/Client7z/Client7z.cpp
index 8d448258..fce1c4f6 100755
--- a/CPP/7zip/UI/Client7z/Client7z.cpp
+++ b/CPP/7zip/UI/Client7z/Client7z.cpp
@@ -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;
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
index 9e679e57..c3913e1c 100755
--- a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
+++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
@@ -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;
diff --git a/CPP/7zip/UI/Common/LoadCodecs.cpp b/CPP/7zip/UI/Common/LoadCodecs.cpp
index a6c97aed..087340a1 100755
--- a/CPP/7zip/UI/Common/LoadCodecs.cpp
+++ b/CPP/7zip/UI/Common/LoadCodecs.cpp
@@ -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)
{
diff --git a/CPP/7zip/UI/Common/Update.cpp b/CPP/7zip/UI/Common/Update.cpp
index e4857225..ec5ebc80 100755
--- a/CPP/7zip/UI/Common/Update.cpp
+++ b/CPP/7zip/UI/Common/Update.cpp
@@ -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;
}
diff --git a/CPP/7zip/UI/Console/Main.cpp b/CPP/7zip/UI/Console/Main.cpp
index bbee32e9..de496530 100755
--- a/CPP/7zip/UI/Console/Main.cpp
+++ b/CPP/7zip/UI/Console/Main.cpp
@@ -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
{
diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp
index f6994066..aeb3b333 100755
--- a/CPP/7zip/UI/FileManager/FSFolder.cpp
+++ b/CPP/7zip/UI/FileManager/FSFolder.cpp
@@ -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;
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.rc b/CPP/7zip/UI/FileManager/ProgressDialog2.rc
index 5818dfb3..d505033f 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.rc
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.rc
@@ -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)
diff --git a/CPP/7zip/UI/FileManager/TextPairs.cpp b/CPP/7zip/UI/FileManager/TextPairs.cpp
index 76c97b8c..a149fe37 100755
--- a/CPP/7zip/UI/FileManager/TextPairs.cpp
+++ b/CPP/7zip/UI/FileManager/TextPairs.cpp
@@ -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';
}
}
diff --git a/CPP/Common/C_FileIO.cpp b/CPP/Common/C_FileIO.cpp
index 28a1378c..3c7f82d9 100755
--- a/CPP/Common/C_FileIO.cpp
+++ b/CPP/Common/C_FileIO.cpp
@@ -75,6 +75,11 @@ bool COutFile::Create(const char *name, bool createAlways)
return OpenBinary(name, O_CREAT | O_EXCL | O_WRONLY);
}
+bool COutFile::Open(const char *name, DWORD creationDisposition)
+{
+ return Create(name, false);
+}
+
ssize_t COutFile::Write(const void *data, size_t size)
{
return write(_handle, data, size);
diff --git a/CPP/Common/C_FileIO.h b/CPP/Common/C_FileIO.h
index 29378dfa..27aa5686 100755
--- a/CPP/Common/C_FileIO.h
+++ b/CPP/Common/C_FileIO.h
@@ -38,6 +38,7 @@ class COutFile: public CFileBase
{
public:
bool Create(const char *name, bool createAlways);
+ bool Open(const char *name, DWORD creationDisposition);
ssize_t Write(const void *data, size_t size);
};