diff options
Diffstat (limited to 'CPP')
395 files changed, 14144 insertions, 7079 deletions
diff --git a/CPP/7zip/Archive/7z/7zEncode.cpp b/CPP/7zip/Archive/7z/7zEncode.cpp index c97f893b..86753acd 100755 --- a/CPP/7zip/Archive/7z/7zEncode.cpp +++ b/CPP/7zip/Archive/7z/7zEncode.cpp @@ -164,8 +164,7 @@ HRESULT CEncoder::Encode( } for (i = 1; i < _bindInfo.OutStreams.Size(); i++) { - CSequentialOutTempBufferImp *tempBufferSpec = - new CSequentialOutTempBufferImp; + CSequentialOutTempBufferImp *tempBufferSpec = new CSequentialOutTempBufferImp; CMyComPtr<ISequentialOutStream> tempBuffer = tempBufferSpec; tempBufferSpec->Init(&inOutTempBuffers[i - 1]); tempBuffers.Add(tempBuffer); @@ -260,9 +259,7 @@ HRESULT CEncoder::Encode( for (i = 1; i < _bindInfo.OutStreams.Size(); i++) { CInOutTempBuffer &inOutTempBuffer = inOutTempBuffers[i - 1]; - inOutTempBuffer.FlushWrite(); - inOutTempBuffer.InitReading(); - inOutTempBuffer.WriteToStream(outStream); + RINOK(inOutTempBuffer.WriteToStream(outStream)); packSizes.Add(inOutTempBuffer.GetDataSize()); } diff --git a/CPP/7zip/Archive/7z/7zExtract.cpp b/CPP/7zip/Archive/7z/7zExtract.cpp index 06e9ef97..1b0f9ea1 100755 --- a/CPP/7zip/Archive/7z/7zExtract.cpp +++ b/CPP/7zip/Archive/7z/7zExtract.cpp @@ -44,7 +44,7 @@ struct CExtractFolderInfo }; }; -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, Int32 testModeSpec, IArchiveExtractCallback *extractCallbackSpec) { COM_TRY_BEGIN @@ -52,7 +52,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec; UInt64 importantTotalUnpacked = 0; - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = #ifdef _7Z_VOL @@ -244,25 +244,25 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (result == S_FALSE) { - RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError)); + RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kDataError)); continue; } if (result == E_NOTIMPL) { - RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kUnSupportedMethod)); + RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kUnSupportedMethod)); continue; } if (result != S_OK) return result; if (folderOutStream->WasWritingFinished() != S_OK) { - RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError)); + RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kDataError)); continue; } } catch(...) { - RINOK(folderOutStream->FlushCorrupted(NArchive::NExtract::NOperationResult::kDataError)); + RINOK(folderOutStream->FlushCorrupted(NExtract::NOperationResult::kDataError)); continue; } } diff --git a/CPP/7zip/Archive/7z/7zFolderOutStream.cpp b/CPP/7zip/Archive/7z/7zFolderOutStream.cpp index 75505863..c5dbfa6d 100755 --- a/CPP/7zip/Archive/7z/7zFolderOutStream.cpp +++ b/CPP/7zip/Archive/7z/7zFolderOutStream.cpp @@ -37,9 +37,9 @@ HRESULT CFolderOutStream::Init( HRESULT CFolderOutStream::OpenFile() { Int32 askMode = ((*_extractStatuses)[_currentIndex]) ? (_testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract): - NArchive::NExtract::NAskMode::kSkip; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract) : + NExtract::NAskMode::kSkip; CMyComPtr<ISequentialOutStream> realOutStream; UInt32 index = _startIndex + _currentIndex; RINOK(_extractCallback->GetStream(_ref2Offset + index, &realOutStream, askMode)); @@ -48,9 +48,9 @@ HRESULT CFolderOutStream::OpenFile() _fileIsOpen = true; const CFileItem &fi = _db->Files[index]; _rem = fi.Size; - if (askMode == NArchive::NExtract::NAskMode::kExtract && !realOutStream && + if (askMode == NExtract::NAskMode::kExtract && !realOutStream && !_db->IsItemAnti(index) && !fi.IsDir) - askMode = NArchive::NExtract::NAskMode::kSkip; + askMode = NExtract::NAskMode::kSkip; return _extractCallback->PrepareOperation(askMode); } @@ -67,8 +67,8 @@ HRESULT CFolderOutStream::CloseFileAndSetResult() const CFileItem &fi = _db->Files[_startIndex + _currentIndex]; return CloseFileAndSetResult( (fi.IsDir || !fi.CrcDefined || !_checkCrc || fi.Crc == _crcStreamSpec->GetCRC()) ? - NArchive::NExtract::NOperationResult::kOK : - NArchive::NExtract::NOperationResult::kCRCError); + NExtract::NOperationResult::kOK : + NExtract::NOperationResult::kCRCError); } HRESULT CFolderOutStream::ProcessEmptyFiles() diff --git a/CPP/7zip/Archive/7z/7zHandler.cpp b/CPP/7zip/Archive/7z/7zHandler.cpp index 6f0cf6b2..136d0c5f 100755 --- a/CPP/7zip/Archive/7z/7zHandler.cpp +++ b/CPP/7zip/Archive/7z/7zHandler.cpp @@ -300,11 +300,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va else if (coder.MethodID == k_PPMD && coder.Props.GetCapacity() == 5) { Byte order = *(const Byte *)coder.Props; - methodsString += L'o'; - methodsString += ConvertUInt32ToString(order); - methodsString += L":mem"; + propsString = L'o'; + propsString += ConvertUInt32ToString(order); + propsString += L":mem"; UInt32 dicSize = GetUi32((const Byte *)coder.Props + 1); - propsString = GetStringForSizeValue(dicSize); + propsString += GetStringForSizeValue(dicSize); } else if (coder.MethodID == k_AES && coder.Props.GetCapacity() >= 1) { diff --git a/CPP/7zip/Archive/7z/7zHandlerOut.cpp b/CPP/7zip/Archive/7z/7zHandlerOut.cpp index e2c250ab..813510c8 100755 --- a/CPP/7zip/Archive/7z/7zHandlerOut.cpp +++ b/CPP/7zip/Archive/7z/7zHandlerOut.cpp @@ -27,7 +27,13 @@ static const wchar_t *kDefaultMethodName = kLZMAMethodName; static const UInt32 kLzmaAlgorithmX5 = 1; static const wchar_t *kLzmaMatchFinderForHeaders = L"BT2"; -static const UInt32 kDictionaryForHeaders = 1 << 20; +static const UInt32 kDictionaryForHeaders = + #ifdef UNDER_CE + 1 << 18 + #else + 1 << 20 + #endif +; static const UInt32 kNumFastBytesForHeaders = 273; static const UInt32 kAlgorithmForHeaders = kLzmaAlgorithmX5; diff --git a/CPP/7zip/Archive/7z/7zHeader.cpp b/CPP/7zip/Archive/7z/7zHeader.cpp index f232a23e..5b5f2fb3 100755 --- a/CPP/7zip/Archive/7z/7zHeader.cpp +++ b/CPP/7zip/Archive/7z/7zHeader.cpp @@ -1,4 +1,4 @@ -// 7z/Header.cpp +// 7zHeader.cpp #include "StdAfx.h" #include "7zHeader.h" @@ -6,22 +6,9 @@ namespace NArchive { namespace N7z { -Byte kSignature[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C}; +Byte kSignature[kSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; #ifdef _7Z_VOL -Byte kFinishSignature[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C + 1}; +Byte kFinishSignature[kSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C + 1}; #endif -class SignatureInitializer -{ -public: - SignatureInitializer() - { - kSignature[0]--; - #ifdef _7Z_VOL - kFinishSignature[0]--; - #endif - }; -} g_SignatureInitializer; - }} - diff --git a/CPP/7zip/Archive/7z/7zOut.cpp b/CPP/7zip/Archive/7z/7zOut.cpp index e897680e..8d241d74 100755 --- a/CPP/7zip/Archive/7z/7zOut.cpp +++ b/CPP/7zip/Archive/7z/7zOut.cpp @@ -541,16 +541,16 @@ void COutArchive::WriteUInt64DefVector(const CUInt64DefVector &v, Byte type) HRESULT COutArchive::EncodeStream( DECL_EXTERNAL_CODECS_LOC_VARS - CEncoder &encoder, const Byte *data, size_t dataSize, + CEncoder &encoder, const CByteBuffer &data, CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders) { - CSequentialInStreamImp *streamSpec = new CSequentialInStreamImp; + CBufInStream *streamSpec = new CBufInStream; CMyComPtr<ISequentialInStream> stream = streamSpec; - streamSpec->Init(data, dataSize); + streamSpec->Init(data, data.GetCapacity()); CFolder folderItem; folderItem.UnpackCRCDefined = true; - folderItem.UnpackCRC = CrcCalc(data, dataSize); - UInt64 dataSize64 = dataSize; + folderItem.UnpackCRC = CrcCalc(data, data.GetCapacity()); + UInt64 dataSize64 = data.GetCapacity(); RINOK(encoder.Encode( EXTERNAL_CODECS_LOC_VARS stream, NULL, &dataSize64, folderItem, SeqStream, packSizes, NULL)) @@ -558,16 +558,6 @@ HRESULT COutArchive::EncodeStream( return S_OK; } -HRESULT COutArchive::EncodeStream( - DECL_EXTERNAL_CODECS_LOC_VARS - CEncoder &encoder, const CByteBuffer &data, - CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders) -{ - return EncodeStream( - EXTERNAL_CODECS_LOC_VARS - encoder, data, data.GetCapacity(), packSizes, folders); -} - void COutArchive::WriteHeader( const CArchiveDatabase &db, const CHeaderOptions &headerOptions, @@ -804,8 +794,8 @@ HRESULT COutArchive::WriteDatabase( CObjectVector<CFolder> folders; RINOK(EncodeStream( EXTERNAL_CODECS_LOC_VARS - encoder, (const Byte *)buf, - _countSize, packSizes, folders)); + encoder, buf, + packSizes, folders)); _writeToStream = true; diff --git a/CPP/7zip/Archive/7z/7zOut.h b/CPP/7zip/Archive/7z/7zOut.h index 9d8ef308..7b1b528e 100755 --- a/CPP/7zip/Archive/7z/7zOut.h +++ b/CPP/7zip/Archive/7z/7zOut.h @@ -100,10 +100,6 @@ class COutArchive HRESULT EncodeStream( DECL_EXTERNAL_CODECS_LOC_VARS - CEncoder &encoder, const Byte *data, size_t dataSize, - CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders); - HRESULT EncodeStream( - DECL_EXTERNAL_CODECS_LOC_VARS CEncoder &encoder, const CByteBuffer &data, CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders); void WriteHeader( diff --git a/CPP/7zip/Archive/7z/7zRegister.cpp b/CPP/7zip/Archive/7z/7zRegister.cpp index e18c4d74..af59b644 100755 --- a/CPP/7zip/Archive/7z/7zRegister.cpp +++ b/CPP/7zip/Archive/7z/7zRegister.cpp @@ -5,14 +5,14 @@ #include "../../Common/RegisterArc.h" #include "7zHandler.h" -static IInArchive *CreateArc() { return new NArchive::N7z::CHandler; } +static IInArchive *CreateArc() { return new NArchive::N7z::CHandler; } #ifndef EXTRACT_ONLY -static IOutArchive *CreateArcOut() { return new NArchive::N7z::CHandler; } +static IOutArchive *CreateArcOut() { return new NArchive::N7z::CHandler; } #else #define CreateArcOut 0 #endif static CArcInfo g_ArcInfo = - { L"7z", L"7z", 0, 7, {'7' + 1 , 'z', 0xBC, 0xAF, 0x27, 0x1C}, 6, false, CreateArc, CreateArcOut }; + { L"7z", L"7z", 0, 7, {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}, 6, false, CreateArc, CreateArcOut }; REGISTER_ARC_DEC_SIG(7z) diff --git a/CPP/7zip/Archive/7z/7zUpdate.cpp b/CPP/7zip/Archive/7z/7zUpdate.cpp index 9506e8f7..d1082808 100755 --- a/CPP/7zip/Archive/7z/7zUpdate.cpp +++ b/CPP/7zip/Archive/7z/7zUpdate.cpp @@ -2,6 +2,8 @@ #include "StdAfx.h" +#include "../../../../C/CpuArch.h" + #include "../../Common/LimitedStreams.h" #include "../../Common/ProgressUtils.h" @@ -32,6 +34,10 @@ static const UInt32 kDictionaryForBCJ2_LZMA = 1 << 20; static const UInt32 kAlgorithmForBCJ2_LZMA = 1; static const UInt32 kNumFastBytesForBCJ2_LZMA = 64; +#ifdef MY_CPU_X86_OR_AMD64 +#define USE_86_FILTER +#endif + static HRESULT WriteRange(IInStream *inStream, ISequentialOutStream *outStream, UInt64 position, UInt64 size, ICompressProgressInfo *progress) { @@ -122,7 +128,7 @@ static int CompareFiles(const CFileItem &f1, const CFileItem &f2) } */ -const struct CFolderRepack +struct CFolderRepack { int FolderIndex; int Group; @@ -334,7 +340,9 @@ static bool IsExeExt(const UString &ext) return false; } -static void GetMethodFull(UInt64 methodID, UInt32 numInStreams, CMethodFull &methodResult) +#ifdef USE_86_FILTER + +static inline void GetMethodFull(UInt64 methodID, UInt32 numInStreams, CMethodFull &methodResult) { methodResult.Id = methodID; methodResult.NumInStreams = numInStreams; @@ -409,6 +417,8 @@ static void MakeExeMethod(const CCompressionMethodMode &method, } } +#endif + static void FromUpdateItemToFileItem(const CUpdateItem &ui, CFileItem &file, CFileItem2 &file2) { @@ -665,7 +675,9 @@ STDMETHODIMP CCryptoGetTextPassword::CryptoGetTextPassword(BSTR *password) static const int kNumGroupsMax = 4; +#ifdef USE_86_FILTER static bool Is86Group(int group) { return (group & 1) != 0; } +#endif static bool IsEncryptedGroup(int group) { return (group & 2) != 0; } static int GetGroupIndex(bool encrypted, int bcjFiltered) { return (encrypted ? 2 : 0) + (bcjFiltered ? 1 : 0); } @@ -865,9 +877,11 @@ HRESULT Update( const CSolidGroup &group = groups[groupIndex]; CCompressionMethodMode method; + #ifdef USE_86_FILTER if (Is86Group(groupIndex)) MakeExeMethod(*options.Method, options.MaxFilter, method); else + #endif method = *options.Method; if (IsEncryptedGroup(groupIndex)) diff --git a/CPP/7zip/Archive/7z/makefile b/CPP/7zip/Archive/7z/makefile index 4489f290..baedf862 100755 --- a/CPP/7zip/Archive/7z/makefile +++ b/CPP/7zip/Archive/7z/makefile @@ -4,8 +4,6 @@ CFLAGS = $(CFLAGS) -I ../../../ \ -DCOMPRESS_MT \ -DEXTERNAL_CODECS \ -LIBS = $(LIBS) oleaut32.lib user32.lib - AR_OBJS = \ $O\ArchiveExports.obj \ $O\DllExports.obj \ diff --git a/CPP/7zip/Archive/ArchiveExports.cpp b/CPP/7zip/Archive/ArchiveExports.cpp index f7bc9c69..5dcf9806 100755 --- a/CPP/7zip/Archive/ArchiveExports.cpp +++ b/CPP/7zip/Archive/ArchiveExports.cpp @@ -10,11 +10,17 @@ static const unsigned int kNumArcsMax = 48; static unsigned int g_NumArcs = 0; +static unsigned int g_DefaultArcIndex = 0; static const CArcInfo *g_Arcs[kNumArcsMax]; void RegisterArc(const CArcInfo *arcInfo) { if (g_NumArcs < kNumArcsMax) + { + const wchar_t *p = arcInfo->Name; + if (p[0] == '7' && p[1] == 'z' && p[2] == 0) + g_DefaultArcIndex = g_NumArcs; g_Arcs[g_NumArcs++] = arcInfo; + } } DEFINE_GUID(CLSID_CArchiveHandler, @@ -117,7 +123,7 @@ STDAPI GetHandlerProperty2(UInt32 formatIndex, PROPID propID, PROPVARIANT *value STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value) { - return GetHandlerProperty2(0, propID, value); + return GetHandlerProperty2(g_DefaultArcIndex, propID, value); } STDAPI GetNumberOfFormats(UINT32 *numFormats) diff --git a/CPP/7zip/Archive/ArjHandler.cpp b/CPP/7zip/Archive/ArjHandler.cpp index 66ad1677..0620ae84 100755 --- a/CPP/7zip/Archive/ArjHandler.cpp +++ b/CPP/7zip/Archive/ArjHandler.cpp @@ -652,13 +652,12 @@ STDMETHODIMP CHandler::Close() return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 testModeSpec, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (testModeSpec != 0); UInt64 totalUnpacked = 0, totalPacked = 0; - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _items.Size(); if (numItems == 0) @@ -714,7 +713,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, continue; } - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); @@ -789,7 +788,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, COM_TRY_END } -static IInArchive *CreateArc() { return new CHandler; } +static IInArchive *CreateArc() { return new CHandler; } static CArcInfo g_ArcInfo = { L"Arj", L"arj", 0, 4, { 0x60, 0xEA }, 2, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/Bz2Handler.cpp b/CPP/7zip/Archive/Bz2Handler.cpp index 9b2c4048..5d2620ba 100755 --- a/CPP/7zip/Archive/Bz2Handler.cpp +++ b/CPP/7zip/Archive/Bz2Handler.cpp @@ -154,28 +154,23 @@ STDMETHODIMP CHandler::Close() return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool allFilesMode = (numItems == (UInt32)-1); - if (!allFilesMode) - { - if (numItems == 0) - return S_OK; - if (numItems != 1 || indices[0] != 0) - return E_INVALIDARG; - } + if (numItems == 0) + return S_OK; + if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0)) + return E_INVALIDARG; - bool testMode = (_aTestMode != 0); if (_stream) extractCallback->SetTotal(_packSize); UInt64 currentTotalPacked = 0; RINOK(extractCallback->SetCompleted(¤tTotalPacked)); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; RINOK(extractCallback->GetStream(0, &realOutStream, askMode)); if (!testMode && !realOutStream) return S_OK; @@ -421,7 +416,7 @@ static IOutArchive *CreateArcOut() { return new CHandler; } #endif static CArcInfo g_ArcInfo = - { L"BZip2", L"bz2 bzip2 tbz2 tbz", L"* * .tar .tar", 2, { 'B', 'Z', 'h' }, 3, true, CreateArc, CreateArcOut }; + { L"bzip2", L"bz2 bzip2 tbz2 tbz", L"* * .tar .tar", 2, { 'B', 'Z', 'h' }, 3, true, CreateArc, CreateArcOut }; REGISTER_ARC(BZip2) diff --git a/CPP/7zip/Archive/Cab/CabHandler.cpp b/CPP/7zip/Archive/Cab/CabHandler.cpp index ad015aaf..480a9a8a 100755 --- a/CPP/7zip/Archive/Cab/CabHandler.cpp +++ b/CPP/7zip/Archive/Cab/CabHandler.cpp @@ -2,6 +2,7 @@ #include "StdAfx.h" +#include "Common/Buffer.h" #include "Common/ComTry.h" #include "Common/Defs.h" #include "Common/IntToString.h" @@ -12,6 +13,7 @@ #include "Windows/Time.h" #include "../../Common/ProgressUtils.h" +#include "../../Common/StreamUtils.h" #include "../../Compress/CopyCoder.h" #include "../../Compress/DeflateDecoder.h" @@ -30,6 +32,8 @@ namespace NCab { // #define _CAB_DETAILS +static const UInt32 kMaxTempBufSize = 1 << 20; + #ifdef _CAB_DETAILS enum { @@ -279,7 +283,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream, { const CInArchiveInfo &ai = m_Database.Volumes.Front().ArchiveInfo; if (ai.IsTherePrev()) - otherArchive = &ai.PreviousArchive; + otherArchive = &ai.PrevArc; else prevChecked = true; } @@ -287,7 +291,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream, { const CInArchiveInfo &ai = m_Database.Volumes.Back().ArchiveInfo; if (ai.IsThereNext()) - otherArchive = &ai.NextArchive; + otherArchive = &ai.NextArc; } if (!otherArchive) break; @@ -328,7 +332,7 @@ STDMETHODIMP CHandler::Close() return S_OK; } -class CCabFolderOutStream: +class CFolderOutStream: public ISequentialOutStream, public CMyUnknownImp { @@ -339,6 +343,12 @@ public: private: const CMvDatabaseEx *m_Database; const CRecordVector<bool> *m_ExtractStatuses; + + CByteBuffer TempBuf; + bool TempBufMode; + bool IsSupported; + UInt32 m_BufStartFolderOffset; + int m_StartIndex; int m_CurrentIndex; CMyComPtr<IArchiveExtractCallback> m_ExtractCallback; @@ -348,11 +358,12 @@ private: bool m_IsOk; bool m_FileIsOpen; - UInt64 m_RemainFileSize; + UInt32 m_RemainFileSize; UInt64 m_FolderSize; UInt64 m_PosInFolder; HRESULT OpenFile(); + HRESULT CloseFile(); HRESULT Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK); public: HRESULT WriteEmptyFiles(); @@ -371,7 +382,7 @@ public: UInt64 GetPosInFolder() const { return m_PosInFolder; } }; -void CCabFolderOutStream::Init( +void CFolderOutStream::Init( const CMvDatabaseEx *database, const CRecordVector<bool> *extractStatuses, int startIndex, @@ -391,25 +402,66 @@ void CCabFolderOutStream::Init( m_PosInFolder = 0; m_FileIsOpen = false; m_IsOk = true; + TempBufMode = false; +} + +HRESULT CFolderOutStream::CloseFile() +{ + m_RealOutStream.Release(); + HRESULT res = m_ExtractCallback->SetOperationResult(m_IsOk ? + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError); + m_FileIsOpen = false; + return res; } -HRESULT CCabFolderOutStream::OpenFile() +HRESULT CFolderOutStream::OpenFile() { Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? (m_TestMode ? NExtract::NAskMode::kTest : NExtract::NAskMode::kExtract) : NExtract::NAskMode::kSkip; + + if (!TempBufMode) + { + const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex]; + const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex]; + int curIndex = m_CurrentIndex + 1; + for (; curIndex < m_ExtractStatuses->Size(); curIndex++) + if ((*m_ExtractStatuses)[curIndex]) + { + const CMvItem &mvItem2 = m_Database->Items[m_StartIndex + curIndex]; + const CItem &item2 = m_Database->Volumes[mvItem2.VolumeIndex].Items[mvItem2.ItemIndex]; + if (item.Offset != item2.Offset || + item.Size != item2.Size || + item.Size == 0) + break; + } + if (curIndex > m_CurrentIndex + 1) + { + size_t oldCapacity = TempBuf.GetCapacity(); + IsSupported = (item.Size <= kMaxTempBufSize); + if (item.Size > oldCapacity && IsSupported) + { + TempBuf.SetCapacity(0); + TempBuf.SetCapacity(item.Size); + } + TempBufMode = true; + m_BufStartFolderOffset = item.Offset; + } + } + RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &m_RealOutStream, askMode)); if (!m_RealOutStream && !m_TestMode) - askMode = NArchive::NExtract::NAskMode::kSkip; + askMode = NExtract::NAskMode::kSkip; return m_ExtractCallback->PrepareOperation(askMode); } -HRESULT CCabFolderOutStream::WriteEmptyFiles() +HRESULT CFolderOutStream::WriteEmptyFiles() { if (m_FileIsOpen) return S_OK; - for(;m_CurrentIndex < m_ExtractStatuses->Size(); m_CurrentIndex++) + for (; m_CurrentIndex < m_ExtractStatuses->Size(); m_CurrentIndex++) { const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex]; const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex]; @@ -419,22 +471,23 @@ HRESULT CCabFolderOutStream::WriteEmptyFiles() HRESULT result = OpenFile(); m_RealOutStream.Release(); RINOK(result); - RINOK(m_ExtractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); } return S_OK; } // This is Write function -HRESULT CCabFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK) +HRESULT CFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *processedSize, bool isOK) { + COM_TRY_BEGIN UInt32 realProcessed = 0; if (processedSize != NULL) *processedSize = 0; - while(size != 0) + while (size != 0) { if (m_FileIsOpen) { - UInt32 numBytesToWrite = (UInt32)MyMin(m_RemainFileSize, (UInt64)(size)); + UInt32 numBytesToWrite = MyMin(m_RemainFileSize, size); HRESULT res = S_OK; if (numBytesToWrite > 0) { @@ -446,6 +499,8 @@ HRESULT CCabFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *proce res = m_RealOutStream->Write((const Byte *)data, numBytesToWrite, &processedSizeLocal); numBytesToWrite = processedSizeLocal; } + if (TempBufMode && IsSupported) + memcpy(TempBuf + (m_PosInFolder - m_BufStartFolderOffset), data, numBytesToWrite); } realProcessed += numBytesToWrite; if (processedSize != NULL) @@ -459,11 +514,37 @@ HRESULT CCabFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *proce if (m_RemainFileSize == 0) { m_RealOutStream.Release(); - RINOK(m_ExtractCallback->SetOperationResult( - m_IsOk ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError)); - m_FileIsOpen = false; + RINOK(CloseFile()); + + if (TempBufMode) + { + while (m_CurrentIndex < m_ExtractStatuses->Size()) + { + const CMvItem &mvItem = m_Database->Items[m_StartIndex + m_CurrentIndex]; + const CItem &item = m_Database->Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex]; + if (item.Offset != m_BufStartFolderOffset) + break; + HRESULT result = OpenFile(); + m_FileIsOpen = true; + m_CurrentIndex++; + m_IsOk = true; + if (result == S_OK && m_RealOutStream && IsSupported) + result = WriteStream(m_RealOutStream, TempBuf, item.Size); + + if (IsSupported) + { + RINOK(CloseFile()); + RINOK(result); + } + else + { + m_RealOutStream.Release(); + RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod)); + m_FileIsOpen = false; + } + } + TempBufMode = false; + } } if (realProcessed > 0) break; // with this break this function works as Write-Part @@ -483,7 +564,7 @@ HRESULT CCabFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *proce return E_FAIL; if (fileOffset > m_PosInFolder) { - UInt32 numBytesToWrite = (UInt32)MyMin((UInt64)fileOffset - m_PosInFolder, UInt64(size)); + UInt32 numBytesToWrite = MyMin(fileOffset - (UInt32)m_PosInFolder, size); realProcessed += numBytesToWrite; if (processedSize != NULL) *processedSize = realProcessed; @@ -501,14 +582,15 @@ HRESULT CCabFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *proce } } return WriteEmptyFiles(); + COM_TRY_END } -STDMETHODIMP CCabFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) +STDMETHODIMP CFolderOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) { return Write2(data, size, processedSize, true); } -HRESULT CCabFolderOutStream::FlushCorrupted() +HRESULT CFolderOutStream::FlushCorrupted() { const UInt32 kBufferSize = (1 << 10); Byte buffer[kBufferSize]; @@ -525,7 +607,7 @@ HRESULT CCabFolderOutStream::FlushCorrupted() } } -HRESULT CCabFolderOutStream::Unsupported() +HRESULT CFolderOutStream::Unsupported() { while(m_CurrentIndex < m_ExtractStatuses->Size()) { @@ -533,23 +615,23 @@ HRESULT CCabFolderOutStream::Unsupported() if (result != S_FALSE && result != S_OK) return result; m_RealOutStream.Release(); - RINOK(m_ExtractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod)); + RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod)); m_CurrentIndex++; } return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testModeSpec, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool allFilesMode = (numItems == (UInt32)(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = m_Database.Items.Size(); if(numItems == 0) return S_OK; - bool testMode = (_aTestMode != 0); + bool testMode = (testModeSpec != 0); UInt64 totalUnPacked = 0; UInt32 i; @@ -610,14 +692,14 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, i++; if (item.IsDir()) { - Int32 askMode= testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + Int32 askMode = testMode ? + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; CMyComPtr<ISequentialOutStream> realOutStream; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); RINOK(extractCallback->PrepareOperation(askMode)); realOutStream.Release(); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } int folderIndex = m_Database.GetFolderIndex(&mvItem); @@ -625,13 +707,13 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, { // If we need previous archive Int32 askMode= testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; CMyComPtr<ISequentialOutStream> realOutStream; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); RINOK(extractCallback->PrepareOperation(askMode)); realOutStream.Release(); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kDataError)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kDataError)); continue; } int startIndex2 = m_Database.FolderStartFileIndex[folderIndex]; @@ -664,7 +746,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, lps->InSize = totalPacked; RINOK(lps->SetCur()); - CCabFolderOutStream *cabFolderOutStream = new CCabFolderOutStream; + CFolderOutStream *cabFolderOutStream = new CFolderOutStream; CMyComPtr<ISequentialOutStream> outStream(cabFolderOutStream); const CFolder &folder = db.Folders[item.GetFolderIndex(db.Folders.Size())]; diff --git a/CPP/7zip/Archive/Cab/CabHeader.cpp b/CPP/7zip/Archive/Cab/CabHeader.cpp index d1f71df3..0cba1b0b 100755 --- a/CPP/7zip/Archive/Cab/CabHeader.cpp +++ b/CPP/7zip/Archive/Cab/CabHeader.cpp @@ -1,15 +1,15 @@ -// Archive/Cab/Header.h +// CabHeader.cpp #include "StdAfx.h" #include "CabHeader.h" -namespace NArchive{ -namespace NCab{ -namespace NHeader{ +namespace NArchive { +namespace NCab { +namespace NHeader { -Byte kMarker[kMarkerSize] = {'M' + 1, 'S', 'C', 'F', 0, 0, 0, 0 }; +Byte kMarker[kMarkerSize] = {'M', 'S', 'C', 'F', 0, 0, 0, 0 }; -struct SignatureInitializer { SignatureInitializer() { kMarker[0]--; }; } g_SignatureInitializer; +// struct CSignatureInitializer { CSignatureInitializer() { kMarker[0]--; }; } g_SignatureInitializer; }}} diff --git a/CPP/7zip/Archive/Cab/CabIn.cpp b/CPP/7zip/Archive/Cab/CabIn.cpp index afc0faed..c0bffa2d 100755 --- a/CPP/7zip/Archive/Cab/CabIn.cpp +++ b/CPP/7zip/Archive/Cab/CabIn.cpp @@ -2,14 +2,14 @@ #include "StdAfx.h" -#include "CabIn.h" - #include "../Common/FindSignature.h" +#include "CabIn.h" + namespace NArchive { namespace NCab { -Byte CInArchive::ReadByte() +Byte CInArchive::Read8() { Byte b; if (!inBuffer.ReadByte(b)) @@ -17,23 +17,23 @@ Byte CInArchive::ReadByte() return b; } -UInt16 CInArchive::ReadUInt16() +UInt16 CInArchive::Read16() { UInt16 value = 0; for (int i = 0; i < 2; i++) { - Byte b = ReadByte(); + Byte b = Read8(); value |= (UInt16(b) << (8 * i)); } return value; } -UInt32 CInArchive::ReadUInt32() +UInt32 CInArchive::Read32() { UInt32 value = 0; for (int i = 0; i < 4; i++) { - Byte b = ReadByte(); + Byte b = Read8(); value |= (UInt32(b) << (8 * i)); } return value; @@ -44,7 +44,7 @@ AString CInArchive::SafeReadName() AString name; for (;;) { - Byte b = ReadByte(); + Byte b = Read8(); if (b == 0) return name; name += (char)b; @@ -57,61 +57,60 @@ void CInArchive::ReadOtherArchive(COtherArchive &oa) oa.DiskName = SafeReadName(); } -void CInArchive::Skip(size_t size) +void CInArchive::Skip(UInt32 size) { while (size-- != 0) - ReadByte(); + Read8(); } -HRESULT CInArchive::Open2(IInStream *stream, - const UInt64 *searchHeaderSizeLimit, - CDatabase &database) +HRESULT CInArchive::Open(const UInt64 *searchHeaderSizeLimit, CDatabaseEx &db) { - database.Clear(); - RINOK(stream->Seek(0, STREAM_SEEK_SET, &database.StartPosition)); + IInStream *stream = db.Stream; + db.Clear(); + RINOK(stream->Seek(0, STREAM_SEEK_SET, &db.StartPosition)); RINOK(FindSignatureInStream(stream, NHeader::kMarker, NHeader::kMarkerSize, - searchHeaderSizeLimit, database.StartPosition)); + searchHeaderSizeLimit, db.StartPosition)); - RINOK(stream->Seek(database.StartPosition + NHeader::kMarkerSize, STREAM_SEEK_SET, NULL)); + RINOK(stream->Seek(db.StartPosition + NHeader::kMarkerSize, STREAM_SEEK_SET, NULL)); if (!inBuffer.Create(1 << 17)) return E_OUTOFMEMORY; inBuffer.SetStream(stream); inBuffer.Init(); - CInArchiveInfo &ai = database.ArchiveInfo; + CInArchiveInfo &ai = db.ArchiveInfo; - ai.Size = ReadUInt32(); - if (ReadUInt32() != 0) + ai.Size = Read32(); + if (Read32() != 0) return S_FALSE; - ai.FileHeadersOffset = ReadUInt32(); - if (ReadUInt32() != 0) + ai.FileHeadersOffset = Read32(); + if (Read32() != 0) return S_FALSE; - ai.VersionMinor = ReadByte(); - ai.VersionMajor = ReadByte(); - ai.NumFolders = ReadUInt16(); - ai.NumFiles = ReadUInt16(); - ai.Flags = ReadUInt16(); + ai.VersionMinor = Read8(); + ai.VersionMajor = Read8(); + ai.NumFolders = Read16(); + ai.NumFiles = Read16(); + ai.Flags = Read16(); if (ai.Flags > 7) return S_FALSE; - ai.SetID = ReadUInt16(); - ai.CabinetNumber = ReadUInt16(); + ai.SetID = Read16(); + ai.CabinetNumber = Read16(); if (ai.ReserveBlockPresent()) { - ai.PerCabinetAreaSize = ReadUInt16(); - ai.PerFolderAreaSize = ReadByte(); - ai.PerDataBlockAreaSize = ReadByte(); + ai.PerCabinetAreaSize = Read16(); + ai.PerFolderAreaSize = Read8(); + ai.PerDataBlockAreaSize = Read8(); Skip(ai.PerCabinetAreaSize); } { if (ai.IsTherePrev()) - ReadOtherArchive(ai.PreviousArchive); + ReadOtherArchive(ai.PrevArc); if (ai.IsThereNext()) - ReadOtherArchive(ai.NextArchive); + ReadOtherArchive(ai.NextArc); } int i; @@ -119,54 +118,40 @@ HRESULT CInArchive::Open2(IInStream *stream, { CFolder folder; - folder.DataStart = ReadUInt32(); - folder.NumDataBlocks = ReadUInt16(); - folder.CompressionTypeMajor = ReadByte(); - folder.CompressionTypeMinor = ReadByte(); + folder.DataStart = Read32(); + folder.NumDataBlocks = Read16(); + folder.CompressionTypeMajor = Read8(); + folder.CompressionTypeMinor = Read8(); Skip(ai.PerFolderAreaSize); - database.Folders.Add(folder); + db.Folders.Add(folder); } - RINOK(stream->Seek(database.StartPosition + ai.FileHeadersOffset, STREAM_SEEK_SET, NULL)); + RINOK(stream->Seek(db.StartPosition + ai.FileHeadersOffset, STREAM_SEEK_SET, NULL)); inBuffer.SetStream(stream); inBuffer.Init(); for (i = 0; i < ai.NumFiles; i++) { CItem item; - item.Size = ReadUInt32(); - item.Offset = ReadUInt32(); - item.FolderIndex = ReadUInt16(); - UInt16 pureDate = ReadUInt16(); - UInt16 pureTime = ReadUInt16(); + item.Size = Read32(); + item.Offset = Read32(); + item.FolderIndex = Read16(); + UInt16 pureDate = Read16(); + UInt16 pureTime = Read16(); item.Time = ((UInt32(pureDate) << 16)) | pureTime; - item.Attributes = ReadUInt16(); + item.Attributes = Read16(); item.Name = SafeReadName(); - int folderIndex = item.GetFolderIndex(database.Folders.Size()); - if (folderIndex >= database.Folders.Size()) + int folderIndex = item.GetFolderIndex(db.Folders.Size()); + if (folderIndex >= db.Folders.Size()) return S_FALSE; - database.Items.Add(item); + db.Items.Add(item); } return S_OK; } #define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; } -HRESULT CInArchive::Open( - const UInt64 *searchHeaderSizeLimit, - CDatabaseEx &database) -{ - return Open2(database.Stream, searchHeaderSizeLimit, database); -} - - -static int CompareMvItems2(const CMvItem *p1, const CMvItem *p2) -{ - RINOZ(MyCompare(p1->VolumeIndex, p2->VolumeIndex)); - return MyCompare(p1->ItemIndex, p2->ItemIndex); -} - static int CompareMvItems(const CMvItem *p1, const CMvItem *p2, void *param) { const CMvDatabaseEx &mvDb = *(const CMvDatabaseEx *)param; @@ -185,7 +170,8 @@ static int CompareMvItems(const CMvItem *p1, const CMvItem *p2, void *param) RINOZ(MyCompare(f1, f2)); RINOZ(MyCompare(item1.Offset, item2.Offset)); RINOZ(MyCompare(item1.Size, item2.Size)); - return CompareMvItems2(p1, p2); + RINOZ(MyCompare(p1->VolumeIndex, p2->VolumeIndex)); + return MyCompare(p1->ItemIndex, p2->ItemIndex); } bool CMvDatabaseEx::AreItemsEqual(int i1, int i2) @@ -236,8 +222,7 @@ void CMvDatabaseEx::FillSortAndShrink() for (i = 0; i < Items.Size(); i++) { - const CMvItem &mvItem = Items[i]; - int folderIndex = GetFolderIndex(&mvItem); + int folderIndex = GetFolderIndex(&Items[i]); if (folderIndex >= FolderStartFileIndex.Size()) FolderStartFileIndex.Add(i); } @@ -260,7 +245,8 @@ bool CMvDatabaseEx::Check() return false; } } - UInt64 maxPos = 0; + UInt32 beginPos = 0; + UInt64 endPos = 0; int prevFolder = -2; for (int i = 0; i < Items.Size(); i++) { @@ -273,16 +259,12 @@ bool CMvDatabaseEx::Check() continue; int folderIndex = GetFolderIndex(&mvItem); if (folderIndex != prevFolder) - { prevFolder = folderIndex; - maxPos = 0; - continue; - } - if (item.Offset < maxPos) - return false; - maxPos = item.GetEndOffset(); - if (maxPos < item.Offset) + else if (item.Offset < endPos && + (item.Offset != beginPos || item.GetEndOffset() != endPos)) return false; + beginPos = item.Offset; + endPos = item.GetEndOffset(); } return true; } diff --git a/CPP/7zip/Archive/Cab/CabIn.h b/CPP/7zip/Archive/Cab/CabIn.h index c9cfcbdd..1e9b188b 100755 --- a/CPP/7zip/Archive/Cab/CabIn.h +++ b/CPP/7zip/Archive/Cab/CabIn.h @@ -50,8 +50,8 @@ struct CArchiveInfo Byte GetDataBlockReserveSize() const { return (Byte)(ReserveBlockPresent() ? PerDataBlockAreaSize : 0); } - COtherArchive PreviousArchive; - COtherArchive NextArchive; + COtherArchive PrevArc; + COtherArchive NextArc; CArchiveInfo() { @@ -63,7 +63,7 @@ struct CArchiveInfo PerCabinetAreaSize = 0; PerFolderAreaSize = 0; PerDataBlockAreaSize = 0; - } + } }; struct CInArchiveInfo: public CArchiveInfo @@ -73,13 +73,13 @@ struct CInArchiveInfo: public CArchiveInfo }; -class CDatabase +struct CDatabase { -public: UInt64 StartPosition; CInArchiveInfo ArchiveInfo; CObjectVector<CFolder> Folders; CObjectVector<CItem> Items; + void Clear() { ArchiveInfo.Clear(); @@ -104,9 +104,8 @@ public: UInt32 GetFileSize(int index) const { return Items[index].Size; } }; -class CDatabaseEx: public CDatabase +struct CDatabaseEx: public CDatabase { -public: CMyComPtr<IInStream> Stream; }; @@ -124,6 +123,7 @@ public: CRecordVector<CMvItem> Items; CRecordVector<int> StartFolderOfVol; CRecordVector<int> FolderStartFileIndex; + int GetFolderIndex(const CMvItem *mvi) const { const CDatabaseEx &db = Volumes[mvi->VolumeIndex]; @@ -145,20 +145,15 @@ class CInArchive { CInBuffer inBuffer; - Byte ReadByte(); - UInt16 ReadUInt16(); - UInt32 ReadUInt32(); + Byte Read8(); + UInt16 Read16(); + UInt32 Read32(); AString SafeReadName(); - void Skip(size_t size); + void Skip(UInt32 size); void ReadOtherArchive(COtherArchive &oa); - HRESULT Open2(IInStream *inStream, - const UInt64 *searchHeaderSizeLimit, - CDatabase &database); public: - HRESULT Open( - const UInt64 *searchHeaderSizeLimit, - CDatabaseEx &database); + HRESULT Open(const UInt64 *searchHeaderSizeLimit, CDatabaseEx &db); }; }} diff --git a/CPP/7zip/Archive/Cab/CabRegister.cpp b/CPP/7zip/Archive/Cab/CabRegister.cpp index 0ce8a87f..15fe4099 100755 --- a/CPP/7zip/Archive/Cab/CabRegister.cpp +++ b/CPP/7zip/Archive/Cab/CabRegister.cpp @@ -5,7 +5,7 @@ #include "../../Common/RegisterArc.h" #include "CabHandler.h" -static IInArchive *CreateArc() { return new NArchive::NCab::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NCab::CHandler; } static CArcInfo g_ArcInfo = { L"Cab", L"cab", 0, 8, { 0x4D, 0x53, 0x43, 0x46 }, 4, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/Chm/ChmHandler.cpp b/CPP/7zip/Archive/Chm/ChmHandler.cpp index 03bff821..a9e334b0 100755 --- a/CPP/7zip/Archive/Chm/ChmHandler.cpp +++ b/CPP/7zip/Archive/Chm/ChmHandler.cpp @@ -275,7 +275,7 @@ HRESULT CChmFolderOutStream::OpenFile() m_RealOutStream.Release(); RINOK(m_ExtractCallback->GetStream(m_StartIndex + m_CurrentIndex, &m_RealOutStream, askMode)); if (!m_RealOutStream && !m_TestMode) - askMode = NArchive::NExtract::NAskMode::kSkip; + askMode = NExtract::NAskMode::kSkip; return m_ExtractCallback->PrepareOperation(askMode); } @@ -291,7 +291,7 @@ HRESULT CChmFolderOutStream::WriteEmptyFiles() HRESULT result = OpenFile(); m_RealOutStream.Release(); RINOK(result); - RINOK(m_ExtractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(m_ExtractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); } return S_OK; } @@ -334,8 +334,8 @@ HRESULT CChmFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *proce m_RealOutStream.Release(); RINOK(m_ExtractCallback->SetOperationResult( m_IsOk ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError)); + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError)); m_FileIsOpen = false; } if (realProcessed > 0) @@ -398,11 +398,11 @@ HRESULT CChmFolderOutStream::FlushCorrupted(UInt64 maxSize) } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testModeSpec, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = m_Database.NewFormat ? 1: @@ -411,7 +411,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, m_Database.Indices.Size()); if (numItems == 0) return S_OK; - bool testMode = (_aTestMode != 0); + bool testMode = (testModeSpec != 0); UInt64 currentTotalSize = 0; @@ -447,8 +447,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode= testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; Int32 index = allFilesMode ? i : indices[i]; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); @@ -456,32 +456,32 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, { if (index != 0) return E_FAIL; - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; if (!testMode) { UInt32 size = m_Database.NewFormatString.Length(); RINOK(WriteStream(realOutStream, (const char *)m_Database.NewFormatString, size)); } - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } const CItem &item = m_Database.Items[index]; currentItemSize = item.Size; - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); if (item.Section != 0) { - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod)); continue; } if (testMode) { - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } @@ -491,8 +491,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress)); realOutStream.Release(); RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError)); + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError)); } return S_OK; } @@ -543,15 +543,15 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, const CItem &item = m_Database.Items[entryIndex]; UInt64 sectionIndex = item.Section; Int32 askMode= testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; if (item.IsDir()) { CMyComPtr<ISequentialOutStream> realOutStream; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); RINOK(extractCallback->PrepareOperation(askMode)); realOutStream.Release(); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } @@ -562,17 +562,17 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, { CMyComPtr<ISequentialOutStream> realOutStream; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); - Int32 opRes = NArchive::NExtract::NOperationResult::kOK; + Int32 opRes = NExtract::NOperationResult::kOK; if (!testMode && item.Size != 0) { RINOK(m_Stream->Seek(m_Database.ContentOffset + item.Offset, STREAM_SEEK_SET, NULL)); streamSpec->Init(item.Size); RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress)); if (copyCoderSpec->TotalSize != item.Size) - opRes = NArchive::NExtract::NOperationResult::kDataError; + opRes = NExtract::NOperationResult::kDataError; } realOutStream.Release(); RINOK(extractCallback->SetOperationResult(opRes)); @@ -586,10 +586,10 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, { CMyComPtr<ISequentialOutStream> realOutStream; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); - if(!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod)); continue; } @@ -603,7 +603,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, chmFolderOutStream->Init(&m_Database, extractCallback, testMode); - if(lzxDecoderSpec == NULL) + if (lzxDecoderSpec == NULL) { lzxDecoderSpec = new NCompress::NLzx::CDecoder; lzxDecoder = lzxDecoderSpec; diff --git a/CPP/7zip/Archive/Chm/ChmRegister.cpp b/CPP/7zip/Archive/Chm/ChmRegister.cpp index abebe6c6..e5f38afa 100755 --- a/CPP/7zip/Archive/Chm/ChmRegister.cpp +++ b/CPP/7zip/Archive/Chm/ChmRegister.cpp @@ -5,7 +5,7 @@ #include "../../Common/RegisterArc.h" #include "ChmHandler.h" -static IInArchive *CreateArc() { return new NArchive::NChm::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NChm::CHandler; } static CArcInfo g_ArcInfo = { L"Chm", L"chm chi chq chw hxs hxi hxr hxq hxw lit", 0, 0xE9, { 'I', 'T', 'S', 'F' }, 4, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/Com/ComHandler.cpp b/CPP/7zip/Archive/Com/ComHandler.cpp index 287f6156..39fce0ae 100755 --- a/CPP/7zip/Archive/Com/ComHandler.cpp +++ b/CPP/7zip/Archive/Com/ComHandler.cpp @@ -95,12 +95,11 @@ STDMETHODIMP CHandler::Close() return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _db.Refs.Size(); if (numItems == 0) @@ -135,30 +134,30 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, CMyComPtr<ISequentialOutStream> outStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; RINOK(extractCallback->GetStream(index, &outStream, askMode)); if (item.IsDir()) { RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } totalPackSize += _db.GetItemPackSize(item.Size); totalSize += item.Size; - if (!testMode && (!outStream)) + if (!testMode && !outStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); - Int32 res = NArchive::NExtract::NOperationResult::kDataError; + Int32 res = NExtract::NOperationResult::kDataError; CMyComPtr<ISequentialInStream> inStream; HRESULT hres = GetStream(index, &inStream); if (hres == S_FALSE) - res = NArchive::NExtract::NOperationResult::kDataError; + res = NExtract::NOperationResult::kDataError; else if (hres == E_NOTIMPL) - res = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + res = NExtract::NOperationResult::kUnSupportedMethod; else { RINOK(hres); @@ -166,7 +165,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, { RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress)); if (copyCoderSpec->TotalSize == item.Size) - res = NArchive::NExtract::NOperationResult::kOK; + res = NExtract::NOperationResult::kOK; } } outStream.Release(); diff --git a/CPP/7zip/Archive/Com/ComRegister.cpp b/CPP/7zip/Archive/Com/ComRegister.cpp index c744b04f..6712b890 100755 --- a/CPP/7zip/Archive/Com/ComRegister.cpp +++ b/CPP/7zip/Archive/Com/ComRegister.cpp @@ -5,9 +5,9 @@ #include "../../Common/RegisterArc.h" #include "ComHandler.h" -static IInArchive *CreateArc() { return new NArchive::NCom::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NCom::CHandler; } static CArcInfo g_ArcInfo = - { L"Compound", L"msi doc xls ppt", 0, 0xE5, { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 }, 8, false, CreateArc, 0 }; + { L"Compound", L"msi msp doc xls ppt", 0, 0xE5, { 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1 }, 8, false, CreateArc, 0 }; REGISTER_ARC(Com) diff --git a/CPP/7zip/Archive/Common/ItemNameUtils.cpp b/CPP/7zip/Archive/Common/ItemNameUtils.cpp index 6dfaf980..71996a63 100755 --- a/CPP/7zip/Archive/Common/ItemNameUtils.cpp +++ b/CPP/7zip/Archive/Common/ItemNameUtils.cpp @@ -39,7 +39,7 @@ bool HasTailSlash(const AString &name, UINT codePage) if (name.IsEmpty()) return false; LPCSTR prev = - #ifdef _WIN32 + #if defined(_WIN32) && !defined(UNDER_CE) CharPrevExA((WORD)codePage, name, &name[name.Length()], 0); #else (LPCSTR)(name) + (name.Length() - 1); diff --git a/CPP/7zip/Archive/CpioHandler.cpp b/CPP/7zip/Archive/CpioHandler.cpp index e5a32936..2e64d1cd 100755 --- a/CPP/7zip/Archive/CpioHandler.cpp +++ b/CPP/7zip/Archive/CpioHandler.cpp @@ -71,7 +71,7 @@ namespace NFileHeader char ChkSum[8]; // 0 for "new" portable format; for CRC format the sum of all the bytes in the file bool CheckMagic() const { return memcmp(Magic, NMagic::kMagic1, 6) == 0 || - memcmp(Magic, NMagic::kMagic2, 6) == 0; }; + memcmp(Magic, NMagic::kMagic2, 6) == 0; }; }; */ @@ -540,12 +540,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val COM_TRY_END } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _items.Size(); if (numItems == 0) @@ -575,8 +574,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); CMyComPtr<ISequentialOutStream> outStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; Int32 index = allFilesMode ? i : indices[i]; const CItemEx &item = _items[index]; RINOK(extractCallback->GetStream(index, &outStream, askMode)); @@ -584,7 +583,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (item.IsDir()) { RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } if (!testMode && !outStream) @@ -592,7 +591,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(extractCallback->PrepareOperation(askMode)); if (testMode) { - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } RINOK(_stream->Seek(item.GetDataPosition(), STREAM_SEEK_SET, NULL)); @@ -600,8 +599,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress)); outStream.Release(); RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError)); + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError)); } return S_OK; COM_TRY_END @@ -615,7 +614,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream) COM_TRY_END } -static IInArchive *CreateArc() { return new NArchive::NCpio::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NCpio::CHandler; } static CArcInfo g_ArcInfo = { L"Cpio", L"cpio", 0, 0xED, { 0 }, 0, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/DebHandler.cpp b/CPP/7zip/Archive/DebHandler.cpp index 0381e0fd..9f083269 100755 --- a/CPP/7zip/Archive/DebHandler.cpp +++ b/CPP/7zip/Archive/DebHandler.cpp @@ -236,7 +236,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream, COM_TRY_BEGIN { CInArchive archive; - if(archive.Open(stream) != S_OK) + if (archive.Open(stream) != S_OK) return S_FALSE; _items.Clear(); @@ -314,12 +314,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val COM_TRY_END } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _items.Size(); if (numItems == 0) @@ -349,19 +348,19 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; Int32 index = allFilesMode ? i : indices[i]; const CItem &item = _items[index]; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); currentTotalSize += item.Size; - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); if (testMode) { - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } RINOK(_stream->Seek(item.GetDataPos(), STREAM_SEEK_SET, NULL)); @@ -369,8 +368,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress)); realOutStream.Release(); RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError)); + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError)); } return S_OK; COM_TRY_END @@ -384,7 +383,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream) COM_TRY_END } -static IInArchive *CreateArc() { return new NArchive::NDeb::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NDeb::CHandler; } static CArcInfo g_ArcInfo = { L"Deb", L"deb", 0, 0xEC, { '!', '<', 'a', 'r', 'c', 'h', '>', '\n' }, 8, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/DeflateProps.cpp b/CPP/7zip/Archive/DeflateProps.cpp new file mode 100755 index 00000000..8498e056 --- /dev/null +++ b/CPP/7zip/Archive/DeflateProps.cpp @@ -0,0 +1,118 @@ +// DeflateProps.cpp + +#include "StdAfx.h" + +#include "Windows/PropVariant.h" + +#include "Common/ParseProperties.h" + +#include "DeflateProps.h" + +namespace NArchive { + +static const UInt32 kAlgo1 = 0; +static const UInt32 kAlgo5 = 1; + +static const UInt32 kPasses1 = 1; +static const UInt32 kPasses7 = 3; +static const UInt32 kPasses9 = 10; + +static const UInt32 kFb1 = 32; +static const UInt32 kFb7 = 64; +static const UInt32 kFb9 = 128; + +void CDeflateProps::Normalize() +{ + UInt32 level = Level; + if (level == 0xFFFFFFFF) + level = 5; + + if (Algo == 0xFFFFFFFF) + Algo = (level >= 5 ? + kAlgo5 : + kAlgo1); + + if (NumPasses == 0xFFFFFFFF) + NumPasses = + (level >= 9 ? kPasses9 : + (level >= 7 ? kPasses7 : + kPasses1)); + if (Fb == 0xFFFFFFFF) + Fb = + (level >= 9 ? kFb9 : + (level >= 7 ? kFb7 : + kFb1)); +} + +HRESULT CDeflateProps::SetCoderProperties(ICompressSetCoderProperties *setCoderProperties) +{ + Normalize(); + + NWindows::NCOM::CPropVariant props[] = + { + Algo, + NumPasses, + Fb, + Mc + }; + PROPID propIDs[] = + { + NCoderPropID::kAlgorithm, + NCoderPropID::kNumPasses, + NCoderPropID::kNumFastBytes, + NCoderPropID::kMatchFinderCycles + }; + int numProps = sizeof(propIDs) / sizeof(propIDs[0]); + if (!McDefined) + numProps--; + return setCoderProperties->SetCoderProperties(propIDs, props, numProps); +} + +HRESULT CDeflateProps::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProps) +{ + Init(); + for (int i = 0; i < numProps; i++) + { + UString name = names[i]; + name.MakeUpper(); + if (name.IsEmpty()) + return E_INVALIDARG; + const PROPVARIANT &prop = values[i]; + if (name[0] == L'X') + { + UInt32 a = 9; + RINOK(ParsePropValue(name.Mid(1), prop, a)); + Level = a; + } + else if (name.Left(1) == L"A") + { + UInt32 a = kAlgo5; + RINOK(ParsePropValue(name.Mid(1), prop, a)); + Algo = a; + } + else if (name.Left(4) == L"PASS") + { + UInt32 a = kPasses9; + RINOK(ParsePropValue(name.Mid(4), prop, a)); + NumPasses = a; + } + else if (name.Left(2) == L"FB") + { + UInt32 a = kFb9; + RINOK(ParsePropValue(name.Mid(2), prop, a)); + Fb = a; + } + else if (name.Left(2) == L"MC") + { + UInt32 a = 0xFFFFFFFF; + RINOK(ParsePropValue(name.Mid(2), prop, a)); + Mc = a; + McDefined = true; + } + else + return E_INVALIDARG; + } + return S_OK; +} + +} diff --git a/CPP/7zip/Archive/DeflateProps.h b/CPP/7zip/Archive/DeflateProps.h new file mode 100755 index 00000000..e05a9d4a --- /dev/null +++ b/CPP/7zip/Archive/DeflateProps.h @@ -0,0 +1,35 @@ +// DeflateProps.h + +#ifndef __DEFLATE_PROPS_H +#define __DEFLATE_PROPS_H + +#include "../ICoder.h" + +namespace NArchive { + +class CDeflateProps +{ + UInt32 Level; + UInt32 NumPasses; + UInt32 Fb; + UInt32 Algo; + UInt32 Mc; + bool McDefined; + + void Init() + { + Level = NumPasses = Fb = Algo = Mc = 0xFFFFFFFF; + McDefined = false; + } + void Normalize(); +public: + CDeflateProps() { Init(); } + bool IsMaximum() const { return Algo > 0; } + + HRESULT SetCoderProperties(ICompressSetCoderProperties *setCoderProperties); + HRESULT SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProps); +}; + +} + +#endif diff --git a/CPP/7zip/Archive/DllExports.cpp b/CPP/7zip/Archive/DllExports.cpp index ccad2126..6c72dea7 100755 --- a/CPP/7zip/Archive/DllExports.cpp +++ b/CPP/7zip/Archive/DllExports.cpp @@ -5,6 +5,8 @@ #include "../../Common/MyInitGuid.h" #include "../../Common/ComTry.h" #include "../../Common/Types.h" + +#include "../../Windows/NtCheck.h" #include "../../Windows/PropVariant.h" #include "IArchive.h" @@ -12,17 +14,8 @@ #include "../IPassword.h" HINSTANCE g_hInstance; -#ifndef _UNICODE -bool g_IsNT = false; -static bool IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} -#endif + +#define NT_CHECK_FAIL_ACTION return FALSE; extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) @@ -30,9 +23,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) if (dwReason == DLL_PROCESS_ATTACH) { g_hInstance = hInstance; - #ifndef _UNICODE - g_IsNT = IsItWindowsNT(); - #endif + NT_CHECK; } return TRUE; } diff --git a/CPP/7zip/Archive/DllExports2.cpp b/CPP/7zip/Archive/DllExports2.cpp index fd8bff28..ad14ff06 100755 --- a/CPP/7zip/Archive/DllExports2.cpp +++ b/CPP/7zip/Archive/DllExports2.cpp @@ -3,43 +3,38 @@ #include "StdAfx.h" #include "../../Common/MyInitGuid.h" -#include "../../Common/ComTry.h" -#include "../../Common/Types.h" -#include "../../Windows/PropVariant.h" + #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES) #include "../../../C/Alloc.h" #endif -#include "IArchive.h" +#include "../../Common/ComTry.h" + +#include "../../Windows/NtCheck.h" +#include "../../Windows/PropVariant.h" + #include "../ICoder.h" #include "../IPassword.h" +#include "IArchive.h" + HINSTANCE g_hInstance; -#ifndef _UNICODE -#ifdef _WIN32 -bool g_IsNT = false; -static bool IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} -#endif -#endif + +#define NT_CHECK_FAIL_ACTION return FALSE; extern "C" -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) +BOOL WINAPI DllMain( + #ifdef UNDER_CE + HANDLE + #else + HINSTANCE + #endif + hInstance, DWORD dwReason, LPVOID /*lpReserved*/) { if (dwReason == DLL_PROCESS_ATTACH) { - g_hInstance = hInstance; - #ifndef _UNICODE - #ifdef _WIN32 - g_IsNT = IsItWindowsNT(); - #endif - #endif + g_hInstance = (HINSTANCE)hInstance; + NT_CHECK; } return TRUE; } diff --git a/CPP/7zip/Archive/DmgHandler.cpp b/CPP/7zip/Archive/DmgHandler.cpp index dd1e95ec..e63542be 100755 --- a/CPP/7zip/Archive/DmgHandler.cpp +++ b/CPP/7zip/Archive/DmgHandler.cpp @@ -573,12 +573,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val COM_TRY_END } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _files.Size(); if (numItems == 0) @@ -635,14 +634,14 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; Int32 index = allFilesMode ? i : indices[i]; // const CItemEx &item = _files[index]; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); @@ -652,7 +651,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, realOutStream.Release(); - Int32 opRes = NArchive::NExtract::NOperationResult::kOK; + Int32 opRes = NExtract::NOperationResult::kOK; #ifdef DMG_SHOW_RAW if (index > _fileIndices.Size()) { @@ -688,7 +687,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, packPos += block.PackSize; if (block.UnpPos != unpPos) { - opRes = NArchive::NExtract::NOperationResult::kDataError; + opRes = NExtract::NOperationResult::kDataError; break; } @@ -705,13 +704,13 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, case METHOD_ZERO_2: realMethod = false; if (block.PackSize != 0) - opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + opRes = NExtract::NOperationResult::kUnSupportedMethod; break; case METHOD_COPY: if (block.UnpSize != block.PackSize) { - opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + opRes = NExtract::NOperationResult::kUnSupportedMethod; break; } res = copyCoder->Code(inStream, outStream, NULL, NULL, progress); @@ -730,26 +729,26 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, res = bzip2Coder->Code(inStream, outStream, NULL, NULL, progress); if (res == S_OK) if (streamSpec->GetSize() != block.PackSize) - opRes = NArchive::NExtract::NOperationResult::kDataError; + opRes = NExtract::NOperationResult::kDataError; break; } default: - opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + opRes = NExtract::NOperationResult::kUnSupportedMethod; break; } if (res != S_OK) { if (res != S_FALSE) return res; - if (opRes == NArchive::NExtract::NOperationResult::kOK) - opRes = NArchive::NExtract::NOperationResult::kDataError; + if (opRes == NExtract::NOperationResult::kOK) + opRes = NExtract::NOperationResult::kDataError; } unpPos += block.UnpSize; if (!outStreamSpec->IsFinishedOK()) { - if (realMethod && opRes == NArchive::NExtract::NOperationResult::kOK) - opRes = NArchive::NExtract::NOperationResult::kDataError; + if (realMethod && opRes == NExtract::NOperationResult::kOK) + opRes = NExtract::NOperationResult::kDataError; while (outStreamSpec->GetRem() != 0) { diff --git a/CPP/7zip/Archive/ElfHandler.cpp b/CPP/7zip/Archive/ElfHandler.cpp index 66b18e7a..6f5a6776 100755 --- a/CPP/7zip/Archive/ElfHandler.cpp +++ b/CPP/7zip/Archive/ElfHandler.cpp @@ -466,12 +466,11 @@ STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _sections.Size(); if (numItems == 0) @@ -501,8 +500,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, lps->InSize = lps->OutSize = currentTotalSize; RINOK(lps->SetCur()); Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; UInt32 index = allFilesMode ? i : indices[i]; const CSegment &item = _sections[index]; currentItemSize = item.PSize; @@ -518,8 +517,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress)); outStream.Release(); RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == currentItemSize ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError)); + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError)); } return S_OK; COM_TRY_END diff --git a/CPP/7zip/Archive/FatHandler.cpp b/CPP/7zip/Archive/FatHandler.cpp index f07d4ccb..6d7b249c 100755 --- a/CPP/7zip/Archive/FatHandler.cpp +++ b/CPP/7zip/Archive/FatHandler.cpp @@ -456,8 +456,11 @@ HRESULT CDatabase::ReadDir(Int32 parent, UInt32 cluster, int level) const Byte *p = ByteBuf + pos; if (p[0] == 0) { + /* + // FreeDOS formats FAT partition with cluster chain longer than required. if (clusterMode && !Header.IsEoc(cluster)) return S_FALSE; + */ break; } if (p[0] == 0xE5) @@ -883,12 +886,11 @@ STDMETHODIMP CHandler::Close() return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = Items.Size(); if (numItems == 0) @@ -923,8 +925,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; Int32 index = allFilesMode ? i : indices[i]; const CItem &item = Items[index]; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); @@ -932,14 +934,14 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (item.IsDir()) { RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } totalPackSize += Header.GetFilePackSize(item.Size); totalSize += item.Size; - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); @@ -947,7 +949,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, realOutStream.Release(); outStreamSpec->Init(); - int res = NArchive::NExtract::NOperationResult::kDataError; + int res = NExtract::NOperationResult::kDataError; CMyComPtr<ISequentialInStream> inStream; HRESULT hres = GetStream(index, &inStream); if (hres != S_FALSE) @@ -957,7 +959,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, { RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress)); if (copyCoderSpec->TotalSize == item.Size) - res = NArchive::NExtract::NOperationResult::kOK; + res = NExtract::NOperationResult::kOK; } } outStreamSpec->ReleaseStream(); @@ -973,7 +975,7 @@ STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) return S_OK; } -static IInArchive *CreateArc() { return new CHandler; } +static IInArchive *CreateArc() { return new CHandler; } static CArcInfo g_ArcInfo = { L"FAT", L"fat img", 0, 0xDA, { 0x55, 0xAA }, 2, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/FlvHandler.cpp b/CPP/7zip/Archive/FlvHandler.cpp new file mode 100755 index 00000000..a22c29e3 --- /dev/null +++ b/CPP/7zip/Archive/FlvHandler.cpp @@ -0,0 +1,544 @@ +// FlvHandler.cpp + +#include "StdAfx.h" + +#include "../../../C/CpuArch.h" + +#include "Common/Buffer.h" +#include "Common/ComTry.h" +// #include "Common/Defs.h" +#include "Common/MyString.h" + +#include "Windows/PropVariant.h" + +#include "../Common/ProgressUtils.h" +#include "../Common/RegisterArc.h" +#include "../Common/StreamObjects.h" +#include "../Common/StreamUtils.h" + +#define GetBe24(p) ( \ + ((UInt32)((const Byte *)(p))[0] << 16) | \ + ((UInt32)((const Byte *)(p))[1] << 8) | \ + ((const Byte *)(p))[2] ) + +#define Get16(p) GetBe16(p) +#define Get24(p) GetBe24(p) +#define Get32(p) GetBe32(p) + +namespace NArchive { +namespace NFlv { + +static const UInt32 kFileSizeMax = (UInt32)1 << 30; +static const int kNumChunksMax = (UInt32)1 << 23; + +const UInt32 kTagHeaderSize = 11; + +static const Byte kFlag_Video = 1; +static const Byte kFlag_Audio = 4; + +static const Byte kType_Audio = 8; +static const Byte kType_Video = 9; +static const Byte kType_Meta = 18; +static const int kNumTypes = 19; + +struct CItem +{ + UInt32 Offset; + UInt32 Size; + // UInt32 Time; + Byte Type; +}; + +struct CItem2 +{ + Byte Type; + Byte SubType; + Byte Props; + bool SameSubTypes; + int NumChunks; + size_t Size; + + CReferenceBuf *BufSpec; + CMyComPtr<IUnknown> RefBuf; + + bool IsAudio() const { return Type == kType_Audio; } +}; + +class CHandler: + public IInArchive, + public IInArchiveGetStream, + public CMyUnknownImp +{ + int _isRaw; + CMyComPtr<IInStream> _stream; + CObjectVector<CItem2> _items2; + // CByteBuffer _metadata; + HRESULT Open2(IInStream *stream, IArchiveOpenCallback *callback); + AString GetComment(); +public: + MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream) + INTERFACE_IInArchive(;) + STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream); +}; + +STATPROPSTG kProps[] = +{ + { NULL, kpidSize, VT_UI8}, + { NULL, kpidNumBlocks, VT_UI4}, + { NULL, kpidComment, VT_BSTR} +}; + +/* +STATPROPSTG kArcProps[] = +{ + { NULL, kpidComment, VT_BSTR} +}; +*/ + +IMP_IInArchive_Props +IMP_IInArchive_ArcProps_NO + +static const char *g_AudioTypes[16] = +{ + "pcm", + "adpcm", + "mp3", + "pcm_le", + "nellymoser16", + "nellymoser8", + "nellymoser", + "g711a", + "g711m", + "audio9", + "aac", + "speex", + "audio12", + "audio13", + "mp3", + "audio15" +}; + +static const char *g_VideoTypes[16] = +{ + "video0", + "jpeg", + "h263", + "screen", + "vp6", + "vp6alpha", + "screen2", + "avc", + "video8", + "video9", + "video10", + "video11", + "video12", + "video13", + "video14", + "video15" +}; + +static const char *g_Rates[4] = +{ + "5.5 kHz", + "11 kHz", + "22 kHz", + "44 kHz" +}; + +static void MyStrCat(char *d, const char *s) +{ + MyStringCopy(d + MyStringLen(d), s); +} + +STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) +{ + NWindows::NCOM::CPropVariant prop; + const CItem2 &item = _items2[index]; + switch(propID) + { + case kpidExtension: + prop = _isRaw ? + (item.IsAudio() ? g_AudioTypes[item.SubType] : g_VideoTypes[item.SubType]) : + (item.IsAudio() ? "audio.flv" : "video.flv"); + break; + case kpidSize: + case kpidPackSize: + prop = (UInt64)item.Size; + break; + case kpidNumBlocks: prop = (UInt32)item.NumChunks; break; + case kpidComment: + { + char sz[64]; + MyStringCopy(sz, (item.IsAudio() ? g_AudioTypes[item.SubType] : g_VideoTypes[item.SubType]) ); + if (item.IsAudio()) + { + MyStrCat(sz, " "); + MyStrCat(sz, g_Rates[(item.Props >> 2) & 3]); + MyStrCat(sz, (item.Props & 2) ? " 16-bit" : " 8-bit"); + MyStrCat(sz, (item.Props & 1) ? " stereo" : " mono"); + } + prop = sz; + break; + } + } + prop.Detach(value); + return S_OK; +} + +/* +AString CHandler::GetComment() +{ + const Byte *p = _metadata; + size_t size = _metadata.GetCapacity(); + AString res; + if (size > 0) + { + p++; + size--; + for (;;) + { + if (size < 2) + break; + int len = Get16(p); + p += 2; + size -= 2; + if (len == 0 || (size_t)len > size) + break; + { + AString temp; + char *sz = temp.GetBuffer(len); + memcpy(sz, p, len); + sz[len] = 0; + temp.ReleaseBuffer(); + if (!res.IsEmpty()) + res += '\n'; + res += temp; + } + p += len; + size -= len; + if (size < 1) + break; + Byte type = *p++; + size--; + bool ok = false; + switch(type) + { + case 0: + { + if (size < 8) + break; + ok = true; + Byte reverse[8]; + for (int i = 0; i < 8; i++) + { + bool little_endian = 1; + if (little_endian) + reverse[i] = p[7 - i]; + else + reverse[i] = p[i]; + } + double d = *(double *)reverse; + char temp[32]; + sprintf(temp, " = %.3f", d); + res += temp; + p += 8; + size -= 8; + break; + } + case 8: + { + if (size < 4) + break; + ok = true; + // UInt32 numItems = Get32(p); + p += 4; + size -= 4; + break; + } + } + if (!ok) + break; + } + } + return res; +} + +STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) +{ + COM_TRY_BEGIN + NWindows::NCOM::CPropVariant prop; + switch(propID) + { + case kpidComment: prop = GetComment(); break; + } + prop.Detach(value); + return S_OK; + COM_TRY_END +} +*/ + +HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback) +{ + CRecordVector<CItem> items; + + const UInt32 kHeaderSize = 13; + Byte header[kHeaderSize]; + RINOK(ReadStream_FALSE(stream, header, kHeaderSize)); + if (header[0] != 'F' || + header[1] != 'L' || + header[2] != 'V' || + header[3] != 1 || + (header[4] & 0xFA) != 0) + return S_FALSE; + UInt32 offset = Get32(header + 5); + if (offset != 9 || Get32(header + 9) != 0) + return S_FALSE; + offset += 4; + + CByteBuffer inBuf; + size_t fileSize; + { + UInt64 fileSize64; + RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize64)); + if (fileSize64 > kFileSizeMax) + return S_FALSE; + + if (callback) + RINOK(callback->SetTotal(NULL, &fileSize64)) + + RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL)); + fileSize = (size_t)fileSize64; + inBuf.SetCapacity(fileSize); + for (size_t pos = 0; pos < fileSize;) + { + UInt64 offset64 = pos; + if (callback) + RINOK(callback->SetCompleted(NULL, &offset64)) + size_t rem = MyMin(fileSize - pos, (size_t)(1 << 20)); + RINOK(ReadStream_FALSE(stream, inBuf + pos, rem)); + pos += rem; + } + } + + int lasts[kNumTypes]; + int i; + for (i = 0; i < kNumTypes; i++) + lasts[i] = -1; + + while (offset < fileSize) + { + CItem item; + item.Offset = offset; + const Byte *buf = inBuf + offset; + offset += kTagHeaderSize; + if (offset > fileSize) + return S_FALSE; + + item.Type = buf[0]; + UInt32 size = Get24(buf + 1); + if (size < 1) + return S_FALSE; + // item.Time = Get24(buf + 4); + // item.Time |= (UInt32)buf[7] << 24; + if (Get24(buf + 8) != 0) // streamID + return S_FALSE; + + UInt32 curSize = kTagHeaderSize + size + 4; + item.Size = curSize; + + offset += curSize - kTagHeaderSize; + if (offset > fileSize) + return S_FALSE; + + if (Get32(buf + kTagHeaderSize + size) != kTagHeaderSize + size) + return S_FALSE; + + // printf("\noffset = %6X type = %2d time = %6d size = %6d", (UInt32)offset, item.Type, item.Time, item.Size); + + if (item.Type == kType_Meta) + { + // _metadata = item.Buf; + } + else + { + if (item.Type != kType_Audio && item.Type != kType_Video) + return S_FALSE; + if (items.Size() >= kNumChunksMax) + return S_FALSE; + Byte firstByte = buf[kTagHeaderSize]; + Byte subType, props; + if (item.Type == kType_Audio) + { + subType = firstByte >> 4; + props = firstByte & 0xF; + } + else + { + subType = firstByte & 0xF; + props = firstByte >> 4; + } + int last = lasts[item.Type]; + if (last < 0) + { + CItem2 item2; + item2.RefBuf = item2.BufSpec = new CReferenceBuf; + item2.Size = curSize; + item2.Type = item.Type; + item2.SubType = subType; + item2.Props = props; + item2.NumChunks = 1; + item2.SameSubTypes = true; + lasts[item.Type] = _items2.Add(item2); + } + else + { + CItem2 &item2 = _items2[last]; + if (subType != item2.SubType) + item2.SameSubTypes = false; + item2.Size += curSize; + item2.NumChunks++; + } + items.Add(item); + } + } + + _isRaw = (_items2.Size() == 1); + for (i = 0; i < _items2.Size(); i++) + { + CItem2 &item2 = _items2[i]; + CByteBuffer &itemBuf = item2.BufSpec->Buf; + if (_isRaw) + { + if (!item2.SameSubTypes) + return S_FALSE; + itemBuf.SetCapacity((size_t)item2.Size - (kTagHeaderSize + 4 + 1) * item2.NumChunks); + item2.Size = 0; + } + else + { + itemBuf.SetCapacity(kHeaderSize + (size_t)item2.Size); + memcpy(itemBuf, header, kHeaderSize); + itemBuf[4] = item2.IsAudio() ? kFlag_Audio : kFlag_Video; + item2.Size = kHeaderSize; + } + } + + for (i = 0; i < items.Size(); i++) + { + const CItem &item = items[i]; + CItem2 &item2 = _items2[lasts[item.Type]]; + size_t size = item.Size; + const Byte *src = inBuf + item.Offset; + if (_isRaw) + { + src += kTagHeaderSize + 1; + size -= (kTagHeaderSize + 4 + 1); + } + memcpy(item2.BufSpec->Buf + item2.Size, src, size); + item2.Size += size; + } + return S_OK; +} + +STDMETHODIMP CHandler::Open(IInStream *inStream, const UInt64 *, IArchiveOpenCallback *callback) +{ + COM_TRY_BEGIN + Close(); + HRESULT res; + try + { + res = Open2(inStream, callback); + if (res == S_OK) + _stream = inStream; + } + catch(...) { res = S_FALSE; } + if (res != S_OK) + { + Close(); + return S_FALSE; + } + return S_OK; + COM_TRY_END +} + +STDMETHODIMP CHandler::Close() +{ + _stream.Release(); + _items2.Clear(); + // _metadata.SetCapacity(0); + return S_OK; +} + +STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) +{ + *numItems = _items2.Size(); + return S_OK; +} + +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) +{ + COM_TRY_BEGIN + bool allFilesMode = (numItems == (UInt32)-1); + if (allFilesMode) + numItems = _items2.Size(); + if (numItems == 0) + return S_OK; + UInt64 totalSize = 0; + UInt32 i; + for (i = 0; i < numItems; i++) + totalSize += _items2[allFilesMode ? i : indices[i]].Size; + extractCallback->SetTotal(totalSize); + + totalSize = 0; + + CLocalProgress *lps = new CLocalProgress; + CMyComPtr<ICompressProgressInfo> progress = lps; + lps->Init(extractCallback, false); + + for (i = 0; i < numItems; i++) + { + lps->InSize = lps->OutSize = totalSize; + RINOK(lps->SetCur()); + CMyComPtr<ISequentialOutStream> outStream; + Int32 askMode = testMode ? + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; + UInt32 index = allFilesMode ? i : indices[i]; + const CItem2 &item = _items2[index]; + RINOK(extractCallback->GetStream(index, &outStream, askMode)); + totalSize += item.Size; + if (!testMode && !outStream) + continue; + RINOK(extractCallback->PrepareOperation(askMode)); + if (outStream) + { + RINOK(WriteStream(outStream, item.BufSpec->Buf, item.BufSpec->Buf.GetCapacity())); + } + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); + } + return S_OK; + COM_TRY_END +} + +STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream) +{ + COM_TRY_BEGIN + *stream = 0; + CBufInStream *streamSpec = new CBufInStream; + CMyComPtr<ISequentialInStream> streamTemp = streamSpec; + streamSpec->Init(_items2[index].BufSpec); + *stream = streamTemp.Detach(); + return S_OK; + COM_TRY_END +} + +static IInArchive *CreateArc() { return new CHandler; } + +static CArcInfo g_ArcInfo = + { L"FLV", L"flv", 0, 0xD6, { 'F', 'L', 'V' }, 3, false, CreateArc, 0 }; + +REGISTER_ARC(Flv) + +}} diff --git a/CPP/7zip/Archive/GzHandler.cpp b/CPP/7zip/Archive/GzHandler.cpp index 8f91003f..7b73bddc 100755 --- a/CPP/7zip/Archive/GzHandler.cpp +++ b/CPP/7zip/Archive/GzHandler.cpp @@ -20,7 +20,8 @@ #include "Common/InStreamWithCRC.h" #include "Common/OutStreamWithCRC.h" -#include "Common/ParseProperties.h" + +#include "DeflateProps.h" #define Get32(p) GetUi32(p) @@ -288,54 +289,6 @@ HRESULT CItem::WriteFooter(ISequentialOutStream *stream) return WriteStream(stream, buf, 8); } -static const UInt32 kAlgoX1 = 0; -static const UInt32 kAlgoX5 = 1; - -static const UInt32 kNumPassesX1 = 1; -static const UInt32 kNumPassesX7 = 3; -static const UInt32 kNumPassesX9 = 10; - -static const UInt32 kNumFastBytesX1 = 32; -static const UInt32 kNumFastBytesX7 = 64; -static const UInt32 kNumFastBytesX9 = 128; - -struct CCompressMode -{ - UInt32 NumPasses; - UInt32 NumFastBytes; - UInt32 Algo; - UInt32 Mc; - bool McDefined; - - bool IsMaximum() const { return Algo > 0; } - - void Init() - { - NumPasses = NumFastBytes = Mc = Algo = 0xFFFFFFFF; - McDefined = false; - } - - void Normalize(UInt32 level) - { - if (level == 0xFFFFFFFF) - level = 5; - if (NumPasses == 0xFFFFFFFF) - NumPasses = - (level >= 9 ? kNumPassesX9 : - (level >= 7 ? kNumPassesX7 : - kNumPassesX1)); - if (NumFastBytes == 0xFFFFFFFF) - NumFastBytes = - (level >= 9 ? kNumFastBytesX9 : - (level >= 7 ? kNumFastBytesX7 : - kNumFastBytesX1)); - if (Algo == 0xFFFFFFFF) - Algo = (level >= 5 ? - kAlgoX5 : - kAlgoX1); - } -}; - class CHandler: public IInArchive, public IArchiveOpenSeq, @@ -352,14 +305,7 @@ class CHandler: CMyComPtr<ICompressCoder> _decoder; NCompress::NDeflate::NDecoder::CCOMCoder *_decoderSpec; - CCompressMode _method; - UInt32 _level; - - void InitMethodProperties() - { - _level = 0xFFFFFFFF; - _method.Init(); - } + CDeflateProps _method; public: MY_UNKNOWN_IMP4(IInArchive, IArchiveOpenSeq, IOutArchive, ISetProperties) @@ -370,7 +316,6 @@ public: CHandler() { - InitMethodProperties(); _decoderSpec = new NCompress::NDeflate::NDecoder::CCOMCoder; _decoder = _decoderSpec; } @@ -496,28 +441,23 @@ STDMETHODIMP CHandler::Close() return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool allFilesMode = (numItems == (UInt32)-1); - if (!allFilesMode) - { - if (numItems == 0) - return S_OK; - if (numItems != 1 || indices[0] != 0) - return E_INVALIDARG; - } + if (numItems == 0) + return S_OK; + if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0)) + return E_INVALIDARG; - bool testMode = (_aTestMode != 0); if (_stream) extractCallback->SetTotal(_packSize); UInt64 currentTotalPacked = 0; RINOK(extractCallback->SetCompleted(¤tTotalPacked)); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; RINOK(extractCallback->GetStream(0, &realOutStream, askMode)); if (!testMode && !realOutStream) return S_OK; @@ -557,8 +497,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (result != S_FALSE) return result; opRes = firstItem ? - NArchive::NExtract::NOperationResult::kDataError : - NArchive::NExtract::NOperationResult::kOK; + NExtract::NOperationResult::kDataError : + NExtract::NOperationResult::kOK; break; } } @@ -572,20 +512,20 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, { if (result != S_FALSE) return result; - opRes = NArchive::NExtract::NOperationResult::kDataError; + opRes = NExtract::NOperationResult::kDataError; break; } _decoderSpec->AlignToByte(); if (item.ReadFooter1(_decoderSpec) != S_OK) { - opRes = NArchive::NExtract::NOperationResult::kDataError; + opRes = NExtract::NOperationResult::kDataError; break; } if (item.Crc != outStreamSpec->GetCRC() || item.Size32 != (UInt32)(outStreamSpec->GetSize() - startOffset)) { - opRes = NArchive::NExtract::NOperationResult::kCRCError; + opRes = NExtract::NOperationResult::kCRCError; break; } } @@ -605,7 +545,7 @@ static HRESULT UpdateArchive( ISequentialOutStream *outStream, UInt64 unpackSize, const CItem &newItem, - const CCompressMode &compressionMode, + CDeflateProps &deflateProps, IArchiveUpdateCallback *updateCallback) { UInt64 complexity = 0; @@ -627,7 +567,7 @@ static HRESULT UpdateArchive( CItem item = newItem; item.Method = NHeader::NCompressionMethod::kDeflate; - item.ExtraFlags = compressionMode.IsMaximum() ? + item.ExtraFlags = deflateProps.IsMaximum() ? NHeader::NExtraFlags::kMaximum : NHeader::NExtraFlags::kFastest; @@ -637,26 +577,7 @@ static HRESULT UpdateArchive( NCompress::NDeflate::NEncoder::CCOMCoder *deflateEncoderSpec = new NCompress::NDeflate::NEncoder::CCOMCoder; CMyComPtr<ICompressCoder> deflateEncoder = deflateEncoderSpec; - { - NWindows::NCOM::CPropVariant props[] = - { - compressionMode.Algo, - compressionMode.NumPasses, - compressionMode.NumFastBytes, - compressionMode.Mc - }; - PROPID propIDs[] = - { - NCoderPropID::kAlgorithm, - NCoderPropID::kNumPasses, - NCoderPropID::kNumFastBytes, - NCoderPropID::kMatchFinderCycles - }; - int numProps = sizeof(propIDs) / sizeof(propIDs[0]); - if (!compressionMode.McDefined) - numProps--; - RINOK(deflateEncoderSpec->SetCoderProperties(propIDs, props, numProps)); - } + RINOK(deflateProps.SetCoderProperties(deflateEncoderSpec)); RINOK(deflateEncoder->Code(crcStream, outStream, NULL, NULL, progress)); item.Crc = inStreamSpec->GetCRC(); @@ -738,7 +659,6 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt size = prop.uhVal.QuadPart; } - _method.Normalize(_level); return UpdateArchive(outStream, size, newItem, _method, updateCallback); } @@ -760,49 +680,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProps) { - InitMethodProperties(); - for (int i = 0; i < numProps; i++) - { - UString name = names[i]; - name.MakeUpper(); - if (name.IsEmpty()) - return E_INVALIDARG; - const PROPVARIANT &prop = values[i]; - if (name[0] == L'X') - { - UInt32 level = 9; - RINOK(ParsePropValue(name.Mid(1), prop, level)); - _level = level; - } - else if (name.Left(4) == L"PASS") - { - UInt32 num = kNumPassesX9; - RINOK(ParsePropValue(name.Mid(4), prop, num)); - _method.NumPasses = num; - } - else if (name.Left(2) == L"FB") - { - UInt32 num = kNumFastBytesX9; - RINOK(ParsePropValue(name.Mid(2), prop, num)); - _method.NumFastBytes = num; - } - else if (name.Left(2) == L"MC") - { - UInt32 num = 0xFFFFFFFF; - RINOK(ParsePropValue(name.Mid(2), prop, num)); - _method.Mc = num; - _method.McDefined = true; - } - else if (name.Left(1) == L"A") - { - UInt32 num = kAlgoX5; - RINOK(ParsePropValue(name.Mid(1), prop, num)); - _method.Algo = num; - } - else - return E_INVALIDARG; - } - return S_OK; + return _method.SetProperties(names, values, numProps); } static IInArchive *CreateArc() { return new CHandler; } @@ -813,7 +691,7 @@ static IOutArchive *CreateArcOut() { return new CHandler; } #endif static CArcInfo g_ArcInfo = - { L"GZip", L"gz gzip tgz tpz", L"* * .tar .tar", 0xEF, { 0x1F, 0x8B, 8 }, 3, true, CreateArc, CreateArcOut }; + { L"gzip", L"gz gzip tgz tpz", L"* * .tar .tar", 0xEF, { 0x1F, 0x8B, 8 }, 3, true, CreateArc, CreateArcOut }; REGISTER_ARC(GZip) diff --git a/CPP/7zip/Archive/Hfs/HfsHandler.cpp b/CPP/7zip/Archive/Hfs/HfsHandler.cpp index ade53877..f226458d 100755 --- a/CPP/7zip/Archive/Hfs/HfsHandler.cpp +++ b/CPP/7zip/Archive/Hfs/HfsHandler.cpp @@ -137,12 +137,11 @@ STDMETHODIMP CHandler::Close() return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _db.Items.Size(); if (numItems == 0) @@ -174,27 +173,27 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); if (item.IsDir()) { RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); UInt64 pos = 0; - int res = NArchive::NExtract::NOperationResult::kOK; + int res = NExtract::NOperationResult::kOK; int i; for (i = 0; i < item.Extents.Size(); i++) { if (item.Size == pos) break; - if (res != NArchive::NExtract::NOperationResult::kOK) + if (res != NExtract::NOperationResult::kOK) break; const CExtent &e = item.Extents[i]; RINOK(_stream->Seek((UInt64)e.Pos << _db.Header.BlockSizeLog, STREAM_SEEK_SET, NULL)); @@ -207,7 +206,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (rem == 0) { if (extentSize >= (UInt64)((UInt32)1 << _db.Header.BlockSizeLog)) - res = NArchive::NExtract::NOperationResult::kDataError; + res = NExtract::NOperationResult::kDataError; break; } UInt32 curSize = kBufSize; @@ -227,7 +226,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, } } if (i != item.Extents.Size() || item.Size != pos) - res = NArchive::NExtract::NOperationResult::kDataError; + res = NExtract::NOperationResult::kDataError; realOutStream.Release(); RINOK(extractCallback->SetOperationResult(res)); } diff --git a/CPP/7zip/Archive/Hfs/HfsRegister.cpp b/CPP/7zip/Archive/Hfs/HfsRegister.cpp index 2d706900..51c3c2b1 100755 --- a/CPP/7zip/Archive/Hfs/HfsRegister.cpp +++ b/CPP/7zip/Archive/Hfs/HfsRegister.cpp @@ -5,7 +5,7 @@ #include "../../Common/RegisterArc.h" #include "HfsHandler.h" -static IInArchive *CreateArc() { return new NArchive::NHfs::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NHfs::CHandler; } static CArcInfo g_ArcInfo = { L"HFS", L"hfs", 0, 0xE3, { 'H', '+', 0, 4 }, 4, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/Icons/split.ico b/CPP/7zip/Archive/Icons/split.ico Binary files differindex 5cb93e84..79cb089b 100755 --- a/CPP/7zip/Archive/Icons/split.ico +++ b/CPP/7zip/Archive/Icons/split.ico diff --git a/CPP/7zip/Archive/Iso/IsoHandler.cpp b/CPP/7zip/Archive/Iso/IsoHandler.cpp index ed8da189..9c20fec3 100755 --- a/CPP/7zip/Archive/Iso/IsoHandler.cpp +++ b/CPP/7zip/Archive/Iso/IsoHandler.cpp @@ -152,12 +152,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val COM_TRY_END } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _archive.Refs.Size(); if (numItems == 0) @@ -203,8 +202,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); currentItemSize = 0; CMyComPtr<ISequentialOutStream> realOutStream; - Int32 askMode; - askMode = testMode ? NArchive::NExtract::NAskMode::kTest : NArchive::NExtract::NAskMode::kExtract; + Int32 askMode = testMode ? + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; UInt32 index = allFilesMode ? i : indices[i]; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); @@ -217,7 +217,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (item.IsDir()) { RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } currentItemSize = item.DataLength; @@ -231,7 +231,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, blockIndex = be.LoadRBA; } - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); outStreamSpec->SetStream(realOutStream); @@ -242,8 +242,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress)); outStreamSpec->ReleaseStream(); RINOK(extractCallback->SetOperationResult(outStreamSpec->IsFinishedOK() ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError)); + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError)); } return S_OK; COM_TRY_END diff --git a/CPP/7zip/Archive/Iso/IsoRegister.cpp b/CPP/7zip/Archive/Iso/IsoRegister.cpp index b43caba3..39f91198 100755 --- a/CPP/7zip/Archive/Iso/IsoRegister.cpp +++ b/CPP/7zip/Archive/Iso/IsoRegister.cpp @@ -5,7 +5,7 @@ #include "../../Common/RegisterArc.h" #include "IsoHandler.h" -static IInArchive *CreateArc() { return new NArchive::NIso::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NIso::CHandler; } static CArcInfo g_ArcInfo = { L"Iso", L"iso", 0, 0xE7, { 'C', 'D', '0', '0', '1', 0x1 }, 7, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/LzhHandler.cpp b/CPP/7zip/Archive/LzhHandler.cpp index 19a9516a..b9d953b9 100755 --- a/CPP/7zip/Archive/LzhHandler.cpp +++ b/CPP/7zip/Archive/LzhHandler.cpp @@ -168,13 +168,11 @@ struct CItem AString GetName() const { AString dirName = GetDirName(); - dirName.Replace((char)(unsigned char)0xFF, '\\'); - if (!dirName.IsEmpty()) - { - char c = dirName[dirName.Length() - 1]; - if (c != '\\') - dirName += '\\'; - } + const char kDirSeparator = '\\'; + // check kDirSeparator in Linux + dirName.Replace((char)(unsigned char)0xFF, kDirSeparator); + if (!dirName.IsEmpty() && dirName.Back() != kDirSeparator) + dirName += kDirSeparator; return dirName + GetFileName(); } }; @@ -469,7 +467,7 @@ STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *pro { UInt32 realProcessedSize; HRESULT result; - if(!_stream) + if (!_stream) { realProcessedSize = size; result = S_OK; @@ -477,7 +475,7 @@ STDMETHODIMP COutStreamWithCRC::Write(const void *data, UInt32 size, UInt32 *pro else result = _stream->Write(data, size, &realProcessedSize); _crc.Update(data, realProcessedSize); - if(processedSize != NULL) + if (processedSize != NULL) *processedSize = realProcessedSize; return result; } @@ -630,24 +628,19 @@ STDMETHODIMP CHandler::Close() return S_OK; } - - -////////////////////////////////////// -// CHandler::DecompressItems - -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, Int32 testModeSpec, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN bool testMode = (testModeSpec != 0); UInt64 totalUnPacked = 0, totalPacked = 0; - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _items.Size(); - if(numItems == 0) + if (numItems == 0) return S_OK; UInt32 i; - for(i = 0; i < numItems; i++) + for (i = 0; i < numItems; i++) { const CItemEx &item = _items[allFilesMode ? i : indices[i]]; totalUnPacked += item.Size; @@ -674,7 +667,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, CMyComPtr<ISequentialInStream> inStream(streamSpec); streamSpec->SetStream(_stream); - for(i = 0; i < numItems; i++, currentTotalUnPacked += currentItemUnPacked, + for (i = 0; i < numItems; i++, currentTotalUnPacked += currentItemUnPacked, currentTotalPacked += currentItemPacked) { currentItemUnPacked = 0; @@ -702,7 +695,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, continue; } - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); @@ -773,7 +766,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, COM_TRY_END } -static IInArchive *CreateArc() { return new CHandler; } +static IInArchive *CreateArc() { return new CHandler; } static CArcInfo g_ArcInfo = { L"Lzh", L"lzh lha", 0, 6, { '-', 'l' }, 2, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/LzmaHandler.cpp b/CPP/7zip/Archive/LzmaHandler.cpp index 5dd0aac7..d9851501 100755 --- a/CPP/7zip/Archive/LzmaHandler.cpp +++ b/CPP/7zip/Archive/LzmaHandler.cpp @@ -319,28 +319,23 @@ STDMETHODIMP CHandler::Close() } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool allFilesMode = (numItems == (UInt32)-1); - if (!allFilesMode) - { - if (numItems == 0) - return S_OK; - if (numItems != 1 || indices[0] != 0) - return E_INVALIDARG; - } + if (numItems == 0) + return S_OK; + if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0)) + return E_INVALIDARG; - bool testMode = (_aTestMode != 0); if (_stream) extractCallback->SetTotal(_packSize); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; RINOK(extractCallback->GetStream(0, &realOutStream, askMode)); if (!testMode && !realOutStream) return S_OK; @@ -368,7 +363,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, _lzma86, _seqStream); RINOK(result); - Int32 opRes = NArchive::NExtract::NOperationResult::kOK; + Int32 opRes = NExtract::NOperationResult::kOK; bool firstItem = true; for (;;) @@ -395,12 +390,12 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, result = decoder.Code(st, outStream, progress); if (result == E_NOTIMPL) { - opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + opRes = NExtract::NOperationResult::kUnSupportedMethod; break; } if (result == S_FALSE) { - opRes = NArchive::NExtract::NOperationResult::kDataError; + opRes = NExtract::NOperationResult::kDataError; break; } RINOK(result); diff --git a/CPP/7zip/Archive/MachoHandler.cpp b/CPP/7zip/Archive/MachoHandler.cpp index 342a8e76..8d313b54 100755 --- a/CPP/7zip/Archive/MachoHandler.cpp +++ b/CPP/7zip/Archive/MachoHandler.cpp @@ -399,12 +399,11 @@ STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _sections.Size(); if (numItems == 0) @@ -434,8 +433,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, lps->InSize = lps->OutSize = currentTotalSize; RINOK(lps->SetCur()); Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; UInt32 index = allFilesMode ? i : indices[i]; const CSection &item = _sections[index]; currentItemSize = item.GetPackSize(); @@ -451,8 +450,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress)); outStream.Release(); RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == currentItemSize ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError)); + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError)); } return S_OK; COM_TRY_END diff --git a/CPP/7zip/Archive/MbrHandler.cpp b/CPP/7zip/Archive/MbrHandler.cpp index 47b18f15..e2aa067f 100755 --- a/CPP/7zip/Archive/MbrHandler.cpp +++ b/CPP/7zip/Archive/MbrHandler.cpp @@ -431,12 +431,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val COM_TRY_END } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _items.Size(); if (numItems == 0) @@ -467,14 +466,14 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); CMyComPtr<ISequentialOutStream> outStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; Int32 index = allFilesMode ? i : indices[i]; const CItem &item = _items[index]; const CPartition &part = item.Part; RINOK(extractCallback->GetStream(index, &outStream, askMode)); totalSize += item.Size; - if (!testMode && (!outStream)) + if (!testMode && !outStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); @@ -483,8 +482,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress)); outStream.Release(); RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == item.Size ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError)); + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError)); } return S_OK; COM_TRY_END @@ -498,7 +497,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream) COM_TRY_END } -static IInArchive *CreateArc() { return new CHandler; } +static IInArchive *CreateArc() { return new CHandler; } static CArcInfo g_ArcInfo = { L"MBR", L"mbr", 0, 0xDB, { 1, 1, 0 }, 3, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/MslzHandler.cpp b/CPP/7zip/Archive/MslzHandler.cpp new file mode 100755 index 00000000..67495e76 --- /dev/null +++ b/CPP/7zip/Archive/MslzHandler.cpp @@ -0,0 +1,257 @@ +// MslzHandler.cpp + +#include "StdAfx.h" + +#include "../../../C/CpuArch.h" + +#include "Common/ComTry.h" +#include "Common/MyString.h" + +#include "Windows/PropVariant.h" + +#include "../Common/InBuffer.h" +#include "../Common/ProgressUtils.h" +#include "../Common/RegisterArc.h" +#include "../Common/StreamUtils.h" + +#include "Common/DummyOutStream.h" + +namespace NArchive { +namespace NMslz { + +class CHandler: + public IInArchive, + public CMyUnknownImp +{ + CMyComPtr<IInStream> _stream; + UInt32 _size; + UInt64 _packSize; + UString _name; +public: + MY_UNKNOWN_IMP1(IInArchive) + INTERFACE_IInArchive(;) +}; + +STATPROPSTG kProps[] = +{ + { NULL, kpidPath, VT_BSTR}, + { NULL, kpidSize, VT_UI8}, + { NULL, kpidPackSize, VT_UI8}, +}; + +IMP_IInArchive_Props +IMP_IInArchive_ArcProps_NO + +STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) +{ + *numItems = 1; + return S_OK; +} + +STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value) +{ + COM_TRY_BEGIN + NWindows::NCOM::CPropVariant prop; + switch(propID) + { + case kpidPath: if (!_name.IsEmpty()) prop = _name; break; + case kpidSize: prop = _size; break; + case kpidPackSize: prop = _packSize; break; + } + prop.Detach(value); + return S_OK; + COM_TRY_END +} + +static const unsigned kSignatureSize = 9; +static const unsigned kHeaderSize = kSignatureSize + 1 + 4; +#define MSLZ_SIGNATURE { 0x53, 0x5A, 0x44, 0x44, 0x88, 0xF0, 0x27, 0x33, 0x41 } +// old signature: 53 5A 20 88 F0 27 33 +static const Byte signature[kSignatureSize] = MSLZ_SIGNATURE; + +static const wchar_t *g_Exts[] = +{ + L"dll", + L"exe", + L"kmd", + L"sys" +}; + +STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 * /* maxCheckStartPosition */, + IArchiveOpenCallback *callback) +{ + COM_TRY_BEGIN + { + Close(); + Byte buffer[kHeaderSize]; + RINOK(ReadStream_FALSE(stream, buffer, kHeaderSize)); + if (memcmp(buffer, signature, kSignatureSize) != 0) + return S_FALSE; + _size = GetUi32(buffer + 10); + if (_size > 0xFFFFFFE0) + return S_FALSE; + RINOK(stream->Seek(0, STREAM_SEEK_END, &_packSize)); + + if (callback) + { + CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback; + callback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback); + if (openVolumeCallback) + { + NWindows::NCOM::CPropVariant prop; + if (openVolumeCallback->GetProperty(kpidName, &prop) == S_OK && prop.vt == VT_BSTR) + { + UString baseName = prop.bstrVal; + if (!baseName.IsEmpty() && baseName.Back() == L'_') + { + baseName.DeleteBack(); + Byte replaceByte = buffer[kSignatureSize]; + if (replaceByte == 0) + { + for (int i = 0; i < sizeof(g_Exts) / sizeof(g_Exts[0]); i++) + { + UString s = g_Exts[i]; + int len = s.Length(); + Byte b = (Byte)s.Back(); + s.DeleteBack(); + if (baseName.Length() >= len && + baseName[baseName.Length() - len] == '.' && + s.CompareNoCase(baseName.Right(len - 1)) == 0) + { + replaceByte = b; + break; + } + } + } + if (replaceByte >= 0x20 && replaceByte < 0x80) + _name = baseName + (wchar_t)replaceByte; + } + } + } + } + _stream = stream; + } + return S_OK; + COM_TRY_END +} + +STDMETHODIMP CHandler::Close() +{ + _stream.Release(); + _name.Empty(); + return S_OK; +} + +// MslzDec is modified LZSS algorithm of Haruhiko Okumura: +// maxLen = 18; Okumura +// maxLen = 16; MS + +#define PROGRESS_AND_WRITE \ + if ((dest & kMask) == 0) { RINOK(WriteStream(outStream, buf, kBufSize)); \ + if ((dest & ((1 << 20) - 1)) == 0) \ + { UInt64 inSize = inStream.GetProcessedSize(); UInt64 outSize = dest; \ + RINOK(progress->SetRatioInfo(&inSize, &outSize)); }} + +static HRESULT MslzDec(CInBuffer &inStream, ISequentialOutStream *outStream, UInt32 unpackSize, ICompressProgressInfo *progress) +{ + const unsigned kBufSize = (1 << 12); + const unsigned kMask = kBufSize - 1; + Byte buf[kBufSize]; + UInt32 dest = 0; + memset(buf, ' ', kBufSize); + while (dest < unpackSize) + { + Byte b; + if (!inStream.ReadByte(b)) + return S_FALSE; + for (unsigned mask = (unsigned)b | 0x100; mask > 1 && dest < unpackSize; mask >>= 1) + { + if (!inStream.ReadByte(b)) + return S_FALSE; + if (mask & 1) + { + buf[dest++ & kMask] = b; + PROGRESS_AND_WRITE + } + else + { + Byte b1; + if (!inStream.ReadByte(b1)) + return S_FALSE; + const unsigned kMaxLen = 16; // 18 in Okumura's code. + unsigned src = (((((unsigned)b1 & 0xF0) << 4) | b) + kMaxLen) & kMask; + unsigned len = (b1 & 0xF) + 3; + if (len > kMaxLen || dest + len > unpackSize) + return S_FALSE; + do + { + buf[dest++ & kMask] = buf[src++ & kMask]; + PROGRESS_AND_WRITE + } + while (--len != 0); + } + } + } + return WriteStream(outStream, buf, dest & kMask); +} + +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) +{ + COM_TRY_BEGIN + if (numItems == 0) + return S_OK; + if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0)) + return E_INVALIDARG; + + extractCallback->SetTotal(_size); + + CMyComPtr<ISequentialOutStream> realOutStream; + Int32 askMode = testMode ? + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; + RINOK(extractCallback->GetStream(0, &realOutStream, askMode)); + if (!testMode && !realOutStream) + return S_OK; + + extractCallback->PrepareOperation(askMode); + + CDummyOutStream *outStreamSpec = new CDummyOutStream; + CMyComPtr<ISequentialOutStream> outStream(outStreamSpec); + outStreamSpec->SetStream(realOutStream); + outStreamSpec->Init(); + realOutStream.Release(); + + CLocalProgress *lps = new CLocalProgress; + CMyComPtr<ICompressProgressInfo> progress = lps; + lps->Init(extractCallback, false); + + RINOK(_stream->Seek(0, STREAM_SEEK_SET, NULL)); + CInBuffer s; + if (!s.Create(1 << 20)) + return E_OUTOFMEMORY; + s.SetStream(_stream); + s.Init(); + Byte buffer[kHeaderSize]; + Int32 opRes = NExtract::NOperationResult::kDataError; + if (s.ReadBytes(buffer, kHeaderSize) == kHeaderSize) + { + HRESULT result = MslzDec(s, outStream, _size, progress); + if (result == S_OK) + opRes = NExtract::NOperationResult::kOK; + else if (result != S_FALSE) + return result; + } + outStream.Release(); + return extractCallback->SetOperationResult(opRes); + COM_TRY_END +} + +static IInArchive *CreateArc() { return new CHandler; } + +static CArcInfo g_ArcInfo = + { L"MsLZ", L"", 0, 0xD5, MSLZ_SIGNATURE, kSignatureSize, false, CreateArc, 0 }; + +REGISTER_ARC(Mslz) + +}} diff --git a/CPP/7zip/Archive/MubHandler.cpp b/CPP/7zip/Archive/MubHandler.cpp index f099aad2..da4df24c 100755 --- a/CPP/7zip/Archive/MubHandler.cpp +++ b/CPP/7zip/Archive/MubHandler.cpp @@ -187,12 +187,11 @@ STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _numItems; if (numItems == 0) @@ -222,19 +221,19 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; UInt32 index = allFilesMode ? i : indices[i]; const CItem &item = _items[index]; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); currentTotalSize += item.Size; - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); if (testMode) { - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } RINOK(_stream->Seek(_startPos + item.Offset, STREAM_SEEK_SET, NULL)); @@ -242,8 +241,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress)); realOutStream.Release(); RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError)); + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError)); } return S_OK; COM_TRY_END diff --git a/CPP/7zip/Archive/Nsis/NsisHandler.cpp b/CPP/7zip/Archive/Nsis/NsisHandler.cpp index f2e3aab6..9a5daadf 100755 --- a/CPP/7zip/Archive/Nsis/NsisHandler.cpp +++ b/CPP/7zip/Archive/Nsis/NsisHandler.cpp @@ -263,12 +263,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val COM_TRY_END } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) GetNumberOfItems(&numItems); if(numItems == 0) @@ -326,8 +325,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, currentItemSize = 0; RINOK(extractCallback->SetCompleted(¤tTotalSize)); CMyComPtr<ISequentialOutStream> realOutStream; - Int32 askMode; - askMode = testMode ? NArchive::NExtract::NAskMode::kTest : NArchive::NExtract::NAskMode::kExtract; + Int32 askMode = testMode ? + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; UInt32 index = allFilesMode ? i : indices[i]; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); @@ -336,7 +336,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (index >= (UInt32)_archive.Items.Size()) { currentItemSize = _archive.Script.Length(); - if(!testMode && (!realOutStream)) + if(!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); if (!testMode) @@ -352,7 +352,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, else GetCompressedSize(index, currentItemSize); - if(!testMode && (!realOutStream)) + if(!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); @@ -477,8 +477,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, } realOutStream.Release(); RINOK(extractCallback->SetOperationResult(dataError ? - NArchive::NExtract::NOperationResult::kDataError : - NArchive::NExtract::NOperationResult::kOK)); + NExtract::NOperationResult::kDataError : + NExtract::NOperationResult::kOK)); } return S_OK; COM_TRY_END diff --git a/CPP/7zip/Archive/Nsis/NsisIn.cpp b/CPP/7zip/Archive/Nsis/NsisIn.cpp index 9e7e89bb..06cc38eb 100755 --- a/CPP/7zip/Archive/Nsis/NsisIn.cpp +++ b/CPP/7zip/Archive/Nsis/NsisIn.cpp @@ -1,30 +1,21 @@ -// Archive/NsisIn.cpp +// NsisIn.cpp #include "StdAfx.h" -// #include <stdio.h> - -#include "NsisIn.h" -#include "NsisDecode.h" +#include "../../../../C/CpuArch.h" -#include "Windows/Defs.h" +#include "Common/IntToString.h" #include "../../Common/StreamUtils.h" -#include "Common/StringConvert.h" -#include "Common/IntToString.h" - -#include "../../../../C/CpuArch.h" +#include "NsisIn.h" #define Get32(p) GetUi32(p) namespace NArchive { namespace NNsis { -Byte kSignature[kSignatureSize] = { 0xEF + 1, 0xBE, 0xAD, 0xDE, -0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74}; - -struct CSignatureInit { CSignatureInit() { kSignature[0]--; } } g_SignatureInit; +Byte kSignature[kSignatureSize] = NSIS_SIGNATURE; #ifdef NSIS_SCRIPT static const char *kCrLf = "\x0D\x0A"; diff --git a/CPP/7zip/Archive/Nsis/NsisIn.h b/CPP/7zip/Archive/Nsis/NsisIn.h index 1fa6b4a6..3fc08440 100755 --- a/CPP/7zip/Archive/Nsis/NsisIn.h +++ b/CPP/7zip/Archive/Nsis/NsisIn.h @@ -1,17 +1,12 @@ -// Archive/NsisIn.h +// NsisIn.h #ifndef __ARCHIVE_NSIS_IN_H #define __ARCHIVE_NSIS_IN_H #include "Common/Buffer.h" -#include "Common/IntToString.h" #include "Common/MyCom.h" #include "Common/StringConvert.h" -#include "../../Common/CreateCoder.h" - -#include "../../IStream.h" - #include "NsisDecode.h" // #define NSIS_SCRIPT @@ -20,6 +15,8 @@ namespace NArchive { namespace NNsis { const int kSignatureSize = 16; +#define NSIS_SIGNATURE { 0xEF, 0xBE, 0xAD, 0xDE, 0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74} + extern Byte kSignature[kSignatureSize]; const UInt32 kFlagsMask = 0xF; diff --git a/CPP/7zip/Archive/Nsis/NsisRegister.cpp b/CPP/7zip/Archive/Nsis/NsisRegister.cpp index 7e6f7acb..41dedb0d 100755 --- a/CPP/7zip/Archive/Nsis/NsisRegister.cpp +++ b/CPP/7zip/Archive/Nsis/NsisRegister.cpp @@ -5,10 +5,9 @@ #include "../../Common/RegisterArc.h" #include "NsisHandler.h" -static IInArchive *CreateArc() { return new NArchive::NNsis::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NNsis::CHandler; } static CArcInfo g_ArcInfo = - { L"Nsis", 0, 0, 0x9, { 0xEF, 0xBE, 0xAD, 0xDE, -0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74}, 16, false, CreateArc, 0 }; + { L"Nsis", L"", 0, 0x9, NSIS_SIGNATURE, NArchive::NNsis::kSignatureSize, false, CreateArc, 0 }; REGISTER_ARC(Nsis) diff --git a/CPP/7zip/Archive/NtfsHandler.cpp b/CPP/7zip/Archive/NtfsHandler.cpp index 37847a24..f88dd012 100755 --- a/CPP/7zip/Archive/NtfsHandler.cpp +++ b/CPP/7zip/Archive/NtfsHandler.cpp @@ -124,7 +124,11 @@ bool CHeader::Parse(const Byte *p) // DriveNumber = p[0x24]; if (p[0x25] != 0) // CurrentHead return false; - if (p[0x26] != 0x80) // ExtendedBootSig + /* + NTFS-HDD: p[0x26] = 0x80 + NTFS-FLASH: p[0x26] = 0 + */ + if (p[0x26] != 0x80 && p[0x26] != 0) // ExtendedBootSig return false; if (p[0x27] != 0) // reserved return false; @@ -916,6 +920,9 @@ struct CDataRef int Num; }; +static const UInt32 kMagic_FILE = 0x454c4946; +static const UInt32 kMagic_BAAD = 0x44414142; + struct CMftRec { UInt32 Magic; @@ -934,7 +941,6 @@ struct CMftRec CSiAttr SiAttr; - void MoveAttrsFrom(CMftRec &src) { DataAttrs += src.DataAttrs; @@ -954,6 +960,8 @@ struct CMftRec bool Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNumber, CObjectVector<CAttr> *attrs); bool IsEmpty() const { return (Magic <= 2); } + bool IsFILE() const { return (Magic == kMagic_FILE); } + bool IsBAAD() const { return (Magic == kMagic_BAAD); } bool InUse() const { return (Flags & 1) != 0; } bool IsDir() const { return (Flags & 2) != 0; } @@ -1032,10 +1040,8 @@ bool CMftRec::Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNum CObjectVector<CAttr> *attrs) { G32(p, Magic); - if (IsEmpty()) - return true; - if (Magic != 0x454c4946) - return false; + if (!IsFILE()) + return IsEmpty() || IsBAAD(); UInt32 usaOffset; UInt32 numUsaItems; @@ -1246,7 +1252,7 @@ HRESULT CDatabase::Open() numSectorsInRec = 1 << (recSizeLog - Header.SectorSizeLog); if (!mftRec.Parse(ByteBuf, Header.SectorSizeLog, numSectorsInRec, NULL, 0)) return S_FALSE; - if (mftRec.IsEmpty()) + if (!mftRec.IsFILE()) return S_FALSE; mftRec.ParseDataNames(); if (mftRec.DataRefs.IsEmpty()) @@ -1331,7 +1337,7 @@ HRESULT CDatabase::Open() for (i = 0; i < Recs.Size(); i++) { CMftRec &rec = Recs[i]; - if (rec.IsEmpty() || !rec.BaseMftRef.IsBaseItself()) + if (!rec.IsFILE() || !rec.BaseMftRef.IsBaseItself()) continue; int numNames = 0; // printf("\n%4d: ", i); @@ -1610,12 +1616,11 @@ STDMETHODIMP CHandler::Close() return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = Items.Size(); if (numItems == 0) @@ -1655,8 +1660,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; Int32 index = allFilesMode ? i : indices[i]; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); @@ -1664,11 +1669,11 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (item.IsDir()) { RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); @@ -1679,12 +1684,12 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, const CMftRec &rec = Recs[item.RecIndex]; const CAttr &data = rec.DataAttrs[rec.DataRefs[item.DataIndex].Start]; - int res = NArchive::NExtract::NOperationResult::kDataError; + int res = NExtract::NOperationResult::kDataError; { CMyComPtr<IInStream> inStream; HRESULT hres = rec.GetStream(InStream, item.DataIndex, Header.ClusterSizeLog, Header.NumClusters, &inStream); if (hres == S_FALSE) - res = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + res = NExtract::NOperationResult::kUnSupportedMethod; else { RINOK(hres); @@ -1696,7 +1701,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(hres); } if (/* copyCoderSpec->TotalSize == item.GetSize() && */ hres == S_OK) - res = NArchive::NExtract::NOperationResult::kOK; + res = NExtract::NOperationResult::kOK; } } } @@ -1715,7 +1720,7 @@ STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) return S_OK; } -static IInArchive *CreateArc() { return new CHandler; } +static IInArchive *CreateArc() { return new CHandler; } static CArcInfo g_ArcInfo = { L"NTFS", L"ntfs img", 0, 0xD9, { 'N', 'T', 'F', 'S', ' ', ' ', ' ', ' ', 0 }, 9, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/PeHandler.cpp b/CPP/7zip/Archive/PeHandler.cpp index a1304ae4..fd900a58 100755 --- a/CPP/7zip/Archive/PeHandler.cpp +++ b/CPP/7zip/Archive/PeHandler.cpp @@ -4,9 +4,10 @@ #include "../../../C/CpuArch.h" -#include "Common/Buffer.h" +#include "Common/DynamicBuffer.h" #include "Common/ComTry.h" #include "Common/IntToString.h" +#include "Common/StringConvert.h" #include "Windows/PropVariantUtils.h" #include "Windows/Time.h" @@ -14,6 +15,7 @@ #include "../Common/LimitedStreams.h" #include "../Common/ProgressUtils.h" #include "../Common/RegisterArc.h" +#include "../Common/StreamObjects.h" #include "../Common/StreamUtils.h" #include "../Compress/CopyCoder.h" @@ -168,6 +170,14 @@ struct COptHeader bool Is64Bit() const { return Magic == PE_OptHeader_Magic_64; } bool Parse(const Byte *p, UInt32 size); + + int GetNumFileAlignBits() const + { + for (int i = 9; i <= 16; i++) + if (((UInt32)1 << i) == FileAlign) + return i; + return -1; + } }; bool COptHeader::Parse(const Byte *p, UInt32 size) @@ -262,8 +272,8 @@ struct CSection void Parse(const Byte *p); }; -static bool operator <(const CSection &a1, const CSection &a2) { return (a1.Pa < a2.Pa); } -static bool operator ==(const CSection &a1, const CSection &a2) { return (a1.Pa == a2.Pa); } +static bool operator <(const CSection &a1, const CSection &a2) { return (a1.Pa < a2.Pa) || ((a1.Pa == a2.Pa) && (a1.PSize < a2.PSize)) ; } +static bool operator ==(const CSection &a1, const CSection &a2) { return (a1.Pa == a2.Pa) && (a1.PSize == a2.PSize); } static AString GetName(const Byte *name) { @@ -378,23 +388,182 @@ static const CUInt32PCharPair g_SubSystems[] = { 14, "XBOX" } }; +static const wchar_t *g_ResTypes[] = +{ + NULL, + L"CURSOR", + L"BITMAP", + L"ICON", + L"MENU", + L"DIALOG", + L"STRING", + L"FONTDIR", + L"FONT", + L"ACCELERATOR", + L"RCDATA", + L"MESSAGETABLE", + L"GROUP_CURSOR", + NULL, + L"GROUP_ICON", + NULL, + L"VERSION", + L"DLGINCLUDE", + NULL, + L"PLUGPLAY", + L"VXD", + L"ANICURSOR", + L"ANIICON", + L"HTML", + L"MANIFEST" +}; + +const UInt32 kFlag = (UInt32)1 << 31; +const UInt32 kMask = ~kFlag; + +struct CTableItem +{ + UInt32 Offset; + UInt32 ID; +}; + + +const UInt32 kBmpHeaderSize = 14; +const UInt32 kIconHeaderSize = 22; + +struct CResItem +{ + UInt32 Type; + UInt32 ID; + UInt32 Lang; + + UInt32 Size; + UInt32 Offset; + + UInt32 HeaderSize; + Byte Header[kIconHeaderSize]; // it must be enough for max size header. + bool Enabled; + + bool IsNameEqual(const CResItem &item) const { return Lang == item.Lang; } + UInt32 GetSize() const { return Size + HeaderSize; } + bool IsBmp() const { return Type == 2; } + bool IsIcon() const { return Type == 3; } + bool IsString() const { return Type == 6; } +}; + +struct CStringItem +{ + UInt32 Lang; + UInt32 Size; + CByteDynamicBuffer Buf; + + void AddChar(Byte c); + void AddWChar(UInt16 c); +}; + +void CStringItem::AddChar(Byte c) +{ + Buf.EnsureCapacity(Size + 2); + Buf[Size++] = c; + Buf[Size++] = 0; +} + +void CStringItem::AddWChar(UInt16 c) +{ + if (c == '\n') + { + AddChar('\\'); + c = 'n'; + } + Buf.EnsureCapacity(Size + 2); + SetUi16(Buf + Size, c); + Size += 2; +} + +struct CMixItem +{ + int SectionIndex; + int ResourceIndex; + int StringIndex; + + bool IsSectionItem() const { return ResourceIndex < 0 && StringIndex < 0; }; +}; + +struct CUsedBitmap +{ + CByteBuffer Buf; +public: + void Alloc(size_t size) + { + size = (size + 7) / 8; + Buf.SetCapacity(size); + memset(Buf, 0, size); + } + void Free() + { + Buf.SetCapacity(0); + } + bool SetRange(size_t from, int size) + { + for (int i = 0; i < size; i++) + { + size_t pos = (from + i) >> 3; + Byte mask = (Byte)(1 << ((from + i) & 7)); + Byte b = Buf[pos]; + if ((b & mask) != 0) + return false; + Buf[pos] = b | mask; + } + return true; + } +}; + + class CHandler: public IInArchive, + public IInArchiveGetStream, public CMyUnknownImp { - CMyComPtr<IInStream> _inStream; + CMyComPtr<IInStream> _stream; CObjectVector<CSection> _sections; UInt32 _peOffset; CHeader _header; COptHeader _optHeader; UInt32 _totalSize; UInt32 _totalSizeLimited; + + CRecordVector<CResItem> _items; + CObjectVector<CStringItem> _strings; + + CByteBuffer _buf; + bool _oneLang; + UString _resourceFileName; + CUsedBitmap _usedRes; + bool _parseResources; + + CRecordVector<CMixItem> _mixItems; + HRESULT LoadDebugSections(IInStream *stream, bool &thereIsSection); - HRESULT Open2(IInStream *stream); + HRESULT Open2(IInStream *stream, IArchiveOpenCallback *callback); bool Parse(const Byte *buf, UInt32 size); + + void AddResNameToString(UString &s, UInt32 id) const; + UString GetLangPrefix(UInt32 lang); + HRESULT ReadString(UInt32 offset, UString &dest) const; + HRESULT ReadTable(UInt32 offset, CRecordVector<CTableItem> &items); + bool ParseStringRes(UInt32 id, UInt32 lang, const Byte *src, UInt32 size); + HRESULT OpenResources(int sectIndex, IInStream *stream, IArchiveOpenCallback *callback); + void CloseResources(); + + + bool CheckItem(const CSection §, const CResItem &item, size_t offset) const + { + return item.Offset >= sect.Va && offset <= _buf.GetCapacity() && _buf.GetCapacity() - offset >= item.Size; + } + public: - MY_UNKNOWN_IMP1(IInArchive) + MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream) INTERFACE_IInArchive(;) + STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream); }; bool CHandler::Parse(const Byte *buf, UInt32 size) @@ -524,25 +693,25 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) break; } - case kpidOsVer: VerToProp(_optHeader.OsVer, prop); break; - case kpidImageVer: VerToProp(_optHeader.ImageVer, prop); break; - case kpidSubsysVer: VerToProp(_optHeader.SubsysVer, prop); break; - case kpidCodeSize: prop = _optHeader.CodeSize; break; - case kpidInitDataSize: prop = _optHeader.InitDataSize; break; - case kpidUnInitDataSize: prop = _optHeader.UninitDataSize; break; - case kpidImageSize: prop = _optHeader.ImageSize; break; - case kpidPhySize: prop = _totalSize; break; - case kpidHeadersSize: prop = _optHeader.HeadersSize; break; - case kpidChecksum: prop = _optHeader.CheckSum; break; + case kpidOsVer: VerToProp(_optHeader.OsVer, prop); break; + case kpidImageVer: VerToProp(_optHeader.ImageVer, prop); break; + case kpidSubsysVer: VerToProp(_optHeader.SubsysVer, prop); break; + case kpidCodeSize: prop = _optHeader.CodeSize; break; + case kpidInitDataSize: prop = _optHeader.InitDataSize; break; + case kpidUnInitDataSize: prop = _optHeader.UninitDataSize; break; + case kpidImageSize: prop = _optHeader.ImageSize; break; + case kpidPhySize: prop = _totalSize; break; + case kpidHeadersSize: prop = _optHeader.HeadersSize; break; + case kpidChecksum: prop = _optHeader.CheckSum; break; - case kpidCpu: PAIR_TO_PROP(g_MachinePairs, _header.Machine, prop); break; - case kpidBit64: if (_optHeader.Is64Bit()) prop = true; break; - case kpidSubSystem: PAIR_TO_PROP(g_SubSystems, _optHeader.SubSystem, prop); break; + case kpidCpu: PAIR_TO_PROP(g_MachinePairs, _header.Machine, prop); break; + case kpidBit64: if (_optHeader.Is64Bit()) prop = true; break; + case kpidSubSystem: PAIR_TO_PROP(g_SubSystems, _optHeader.SubSystem, prop); break; case kpidMTime: - case kpidCTime: TimeToProp(_header.Time, prop); break; - case kpidCharacts: FLAGS_TO_PROP(g_HeaderCharacts, _header.Flags, prop); break; - case kpidDllCharacts: FLAGS_TO_PROP(g_DllCharacts, _optHeader.DllCharacts, prop); break; + case kpidCTime: TimeToProp(_header.Time, prop); break; + case kpidCharacts: FLAGS_TO_PROP(g_HeaderCharacts, _header.Flags, prop); break; + case kpidDllCharacts: FLAGS_TO_PROP(g_DllCharacts, _optHeader.DllCharacts, prop); break; case kpidStackReserve: prop = _optHeader.StackReserve; break; case kpidStackCommit: prop = _optHeader.StackCommit; break; case kpidHeapReserve: prop = _optHeader.HeapReserve; break; @@ -553,22 +722,105 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) COM_TRY_END } +void CHandler::AddResNameToString(UString &s, UInt32 id) const +{ + if ((id & kFlag) != 0) + { + UString name; + if (ReadString(id & kMask, name) == S_OK) + { + if (name.IsEmpty()) + s += L"[]"; + else + { + if (name.Length() > 1 && name[0] == '"' && name.Back() == '"') + name = name.Mid(1, name.Length() - 2); + s += name; + } + return; + } + } + wchar_t sz[32]; + ConvertUInt32ToString(id, sz); + s += sz; +} + +UString CHandler::GetLangPrefix(UInt32 lang) +{ + UString s = _resourceFileName; + s += WCHAR_PATH_SEPARATOR; + if (!_oneLang) + { + AddResNameToString(s, lang); + s += WCHAR_PATH_SEPARATOR; + } + return s; +} + STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) { COM_TRY_BEGIN NCOM::CPropVariant prop; - const CSection &item = _sections[index]; - switch(propID) + const CMixItem &mixItem = _mixItems[index]; + if (mixItem.StringIndex >= 0) { - case kpidPath: StringToProp(item.Name, prop); break; - case kpidSize: prop = (UInt64)item.VSize; break; - case kpidPackSize: prop = (UInt64)item.GetPackSize(); break; - case kpidOffset: prop = item.Pa; break; - case kpidVa: if (item.IsRealSect) prop = item.Va; break; - case kpidMTime: - case kpidCTime: - TimeToProp(item.IsDebug ? item.Time : _header.Time, prop); break; - case kpidCharacts: if (item.IsRealSect) FLAGS_TO_PROP(g_SectFlags, item.Flags, prop); break; + const CStringItem &item = _strings[mixItem.StringIndex]; + switch(propID) + { + case kpidPath: prop = GetLangPrefix(item.Lang) + L"string.txt"; break; + case kpidSize: + case kpidPackSize: + prop = (UInt64)item.Size; break; + } + } + else if (mixItem.ResourceIndex < 0) + { + const CSection &item = _sections[mixItem.SectionIndex]; + switch(propID) + { + case kpidPath: StringToProp(item.Name, prop); break; + case kpidSize: prop = (UInt64)item.VSize; break; + case kpidPackSize: prop = (UInt64)item.GetPackSize(); break; + case kpidOffset: prop = item.Pa; break; + case kpidVa: if (item.IsRealSect) prop = item.Va; break; + case kpidMTime: + case kpidCTime: + TimeToProp(item.IsDebug ? item.Time : _header.Time, prop); break; + case kpidCharacts: if (item.IsRealSect) FLAGS_TO_PROP(g_SectFlags, item.Flags, prop); break; + } + } + else + { + const CResItem &item = _items[mixItem.ResourceIndex]; + switch(propID) + { + case kpidPath: + { + UString s = GetLangPrefix(item.Lang); + { + const wchar_t *p = NULL; + if (item.Type < sizeof(g_ResTypes) / sizeof(g_ResTypes[0])) + p = g_ResTypes[item.Type]; + if (p != 0) + s += p; + else + AddResNameToString(s, item.Type); + } + s += WCHAR_PATH_SEPARATOR; + AddResNameToString(s, item.ID); + if (item.HeaderSize != 0) + { + if (item.IsBmp()) + s += L".bmp"; + else if (item.IsIcon()) + s += L".ico"; + } + prop = s; + break; + } + case kpidSize: prop = (UInt64)item.GetSize(); break; + case kpidPackSize: prop = (UInt64)item.Size; break; + } } prop.Detach(value); return S_OK; @@ -640,7 +892,372 @@ HRESULT CHandler::LoadDebugSections(IInStream *stream, bool &thereIsSection) return S_OK; } -HRESULT CHandler::Open2(IInStream *stream) +HRESULT CHandler::ReadString(UInt32 offset, UString &dest) const +{ + if ((offset & 1) != 0 || offset >= _buf.GetCapacity()) + return S_FALSE; + size_t rem = _buf.GetCapacity() - offset; + if (rem < 2) + return S_FALSE; + unsigned length = Get16(_buf + offset); + if ((rem - 2) / 2 < length) + return S_FALSE; + dest.Empty(); + offset += 2; + for (unsigned i = 0; i < length; i++) + dest += (wchar_t)Get16(_buf + offset + i * 2); + return S_OK; +} + +HRESULT CHandler::ReadTable(UInt32 offset, CRecordVector<CTableItem> &items) +{ + if ((offset & 3) != 0 || offset >= _buf.GetCapacity()) + return S_FALSE; + size_t rem = _buf.GetCapacity() - offset; + if (rem < 16) + return S_FALSE; + items.Clear(); + unsigned numNameItems = Get16(_buf + offset + 12); + unsigned numIdItems = Get16(_buf + offset + 14); + unsigned numItems = numNameItems + numIdItems; + if ((rem - 16) / 8 < numItems) + return S_FALSE; + if (!_usedRes.SetRange(offset, 16 + numItems * 8)) + return S_FALSE; + offset += 16; + _oneLang = true; + unsigned i; + for (i = 0; i < numItems; i++) + { + CTableItem item; + const Byte *buf = _buf + offset; + offset += 8; + item.ID = Get32(buf + 0); + if (((item.ID & kFlag) != 0) != (i < numNameItems)) + return S_FALSE; + item.Offset = Get32(buf + 4); + items.Add(item); + } + return S_OK; +} + +static const UInt32 kFileSizeMax = (UInt32)1 << 30; +static const int kNumResItemsMax = (UInt32)1 << 23; +static const int kNumStringLangsMax = 128; + +// BITMAPINFOHEADER +struct CBitmapInfoHeader +{ + // UInt32 HeaderSize; + UInt32 XSize; + Int32 YSize; + UInt16 Planes; + UInt16 BitCount; + UInt32 Compression; + UInt32 SizeImage; + + bool Parse(const Byte *p, size_t size); +}; + +static const UInt32 kBitmapInfoHeader_Size = 0x28; + +bool CBitmapInfoHeader::Parse(const Byte *p, size_t size) +{ + if (size < kBitmapInfoHeader_Size || Get32(p) != kBitmapInfoHeader_Size) + return false; + XSize = Get32(p + 4); + YSize = (Int32)Get32(p + 8); + Planes = Get16(p + 12); + BitCount = Get16(p + 14); + Compression = Get32(p + 16); + SizeImage = Get32(p + 20); + return true; +}; + +static UInt32 GetImageSize(UInt32 xSize, UInt32 ySize, UInt32 bitCount) +{ + return ((xSize * bitCount + 7) / 8 + 3) / 4 * 4 * ySize; +} + +static UInt32 SetBitmapHeader(Byte *dest, const Byte *src, UInt32 size) +{ + CBitmapInfoHeader h; + if (!h.Parse(src, size)) + return 0; + if (h.YSize < 0) + h.YSize = -h.YSize; + if (h.XSize > (1 << 26) || h.YSize > (1 << 26) || h.Planes != 1 || h.BitCount > 32 || + h.Compression != 0) // BI_RGB + return 0; + if (h.SizeImage == 0) + h.SizeImage = GetImageSize(h.XSize, h.YSize, h.BitCount); + UInt32 totalSize = kBmpHeaderSize + size; + UInt32 offBits = totalSize - h.SizeImage; + // BITMAPFILEHEADER + SetUi16(dest, 0x4D42); + SetUi32(dest + 2, totalSize); + SetUi32(dest + 6, 0); + SetUi32(dest + 10, offBits); + return kBmpHeaderSize; +} + +static UInt32 SetIconHeader(Byte *dest, const Byte *src, UInt32 size) +{ + CBitmapInfoHeader h; + if (!h.Parse(src, size)) + return 0; + if (h.YSize < 0) + h.YSize = -h.YSize; + if (h.XSize > (1 << 26) || h.YSize > (1 << 26) || h.Planes != 1 || + h.Compression != 0) // BI_RGB + return 0; + + UInt32 numBitCount = h.BitCount; + if (numBitCount != 1 && + numBitCount != 4 && + numBitCount != 8 && + numBitCount != 24 && + numBitCount != 32) + return 0; + + if ((h.YSize & 1) != 0) + return 0; + h.YSize /= 2; + if (h.XSize > 0x100 || h.YSize > 0x100) + return 0; + + UInt32 imageSize; + // imageSize is not correct if AND mask array contains zeros + // in this case it is equal image1Size + + // UInt32 imageSize = h.SizeImage; + // if (imageSize == 0) + // { + UInt32 image1Size = GetImageSize(h.XSize, h.YSize, h.BitCount); + UInt32 image2Size = GetImageSize(h.XSize, h.YSize, 1); + imageSize = image1Size + image2Size; + // } + UInt32 numColors = 0; + if (numBitCount < 16) + numColors = 1 << numBitCount; + + SetUi16(dest, 0); // Reserved + SetUi16(dest + 2, 1); // RES_ICON + SetUi16(dest + 4, 1); // ResCount + + dest[6] = (Byte)h.XSize; // Width + dest[7] = (Byte)h.YSize; // Height + dest[8] = (Byte)numColors; // ColorCount + dest[9] = 0; // Reserved + + SetUi32(dest + 10, 0); // Reserved1 / Reserved2 + + UInt32 numQuadsBytes = numColors * 4; + UInt32 BytesInRes = kBitmapInfoHeader_Size + numQuadsBytes + imageSize; + SetUi32(dest + 14, BytesInRes); + SetUi32(dest + 18, kIconHeaderSize); + + /* + Description = DWORDToString(xSize) + + kDelimiterChar + DWORDToString(ySize) + + kDelimiterChar + DWORDToString(numBitCount); + */ + return kIconHeaderSize; +} + +bool CHandler::ParseStringRes(UInt32 id, UInt32 lang, const Byte *src, UInt32 size) +{ + if ((size & 1) != 0) + return false; + + int i; + for (i = 0; i < _strings.Size(); i++) + if (_strings[i].Lang == lang) + break; + if (i == _strings.Size()) + { + if (_strings.Size() >= kNumStringLangsMax) + return false; + CStringItem item; + item.Size = 0; + item.Lang = lang; + i = _strings.Add(item); + } + + CStringItem &item = _strings[i]; + id = (id - 1) << 4; + UInt32 pos = 0; + for (i = 0; i < 16; i++) + { + if (size - pos < 2) + return false; + UInt32 len = Get16(src + pos); + pos += 2; + if (len != 0) + { + if (size - pos < len * 2) + return false; + char temp[32]; + ConvertUInt32ToString(id + i, temp); + size_t tempLen = strlen(temp); + size_t j; + for (j = 0; j < tempLen; j++) + item.AddChar(temp[j]); + item.AddChar('\t'); + for (j = 0; j < len; j++, pos += 2) + item.AddWChar(Get16(src + pos)); + item.AddChar(0x0D); + item.AddChar(0x0A); + } + } + return (size == pos); +} + +HRESULT CHandler::OpenResources(int sectionIndex, IInStream *stream, IArchiveOpenCallback *callback) +{ + const CSection § = _sections[sectionIndex]; + size_t fileSize = sect.PSize; // Maybe we need sect.VSize here !!! + if (fileSize > kFileSizeMax) + return S_FALSE; + { + UInt64 fileSize64 = fileSize; + if (callback) + RINOK(callback->SetTotal(NULL, &fileSize64)); + RINOK(stream->Seek(sect.Pa, STREAM_SEEK_SET, NULL)); + _buf.SetCapacity(fileSize); + for (size_t pos = 0; pos < fileSize;) + { + UInt64 offset64 = pos; + if (callback) + RINOK(callback->SetCompleted(NULL, &offset64)) + size_t rem = MyMin(fileSize - pos, (size_t)(1 << 20)); + RINOK(ReadStream_FALSE(stream, _buf + pos, rem)); + pos += rem; + } + } + + _usedRes.Alloc(fileSize); + CRecordVector<CTableItem> specItems; + RINOK(ReadTable(0, specItems)); + + _oneLang = true; + bool stringsOk = true; + size_t maxOffset = 0; + for (int i = 0; i < specItems.Size(); i++) + { + const CTableItem &item1 = specItems[i]; + if ((item1.Offset & kFlag) == 0) + return S_FALSE; + + CRecordVector<CTableItem> specItems2; + RINOK(ReadTable(item1.Offset & kMask, specItems2)); + + for (int j = 0; j < specItems2.Size(); j++) + { + const CTableItem &item2 = specItems2[j]; + if ((item2.Offset & kFlag) == 0) + return S_FALSE; + + CRecordVector<CTableItem> specItems3; + RINOK(ReadTable(item2.Offset & kMask, specItems3)); + + CResItem item; + item.Type = item1.ID; + item.ID = item2.ID; + + for (int k = 0; k < specItems3.Size(); k++) + { + if (_items.Size() >= kNumResItemsMax) + return S_FALSE; + const CTableItem &item3 = specItems3[k]; + if ((item3.Offset & kFlag) != 0) + return S_FALSE; + if (item3.Offset >= _buf.GetCapacity() || _buf.GetCapacity() - item3.Offset < 16) + return S_FALSE; + const Byte *buf = _buf + item3.Offset; + item.Lang = item3.ID; + item.Offset = Get32(buf + 0); + item.Size = Get32(buf + 4); + // UInt32 codePage = Get32(buf + 8); + if (Get32(buf + 12) != 0) + return S_FALSE; + if (!_items.IsEmpty() && _oneLang && !item.IsNameEqual(_items.Back())) + _oneLang = false; + + item.HeaderSize = 0; + + size_t offset = item.Offset - sect.Va; + if (offset > maxOffset) + maxOffset = offset; + if (offset + item.Size > maxOffset) + maxOffset = offset + item.Size; + + if (CheckItem(sect, item, offset)) + { + const Byte *data = _buf + offset; + if (item.IsBmp()) + item.HeaderSize = SetBitmapHeader(item.Header, data, item.Size); + else if (item.IsIcon()) + item.HeaderSize = SetIconHeader(item.Header, data, item.Size); + else if (item.IsString()) + { + if (stringsOk) + stringsOk = ParseStringRes(item.ID, item.Lang, data, item.Size); + } + } + + item.Enabled = true; + _items.Add(item); + } + } + } + + if (stringsOk && !_strings.IsEmpty()) + { + int i; + for (i = 0; i < _items.Size(); i++) + { + CResItem &item = _items[i]; + if (item.IsString()) + item.Enabled = false; + } + for (i = 0; i < _strings.Size(); i++) + { + if (_strings[i].Size == 0) + continue; + CMixItem mixItem; + mixItem.ResourceIndex = -1; + mixItem.StringIndex = i; + mixItem.SectionIndex = sectionIndex; + _mixItems.Add(mixItem); + } + } + + _usedRes.Free(); + + int numBits = _optHeader.GetNumFileAlignBits(); + if (numBits >= 0) + { + UInt32 mask = (1 << numBits) - 1; + size_t end = ((maxOffset + mask) & ~mask); + if (end < sect.VSize) + { + CSection sect2; + sect2.Flags = 0; + sect2.Pa = sect.Pa + (UInt32)maxOffset; + sect2.Va = sect.Va + (UInt32)maxOffset; + sect2.PSize = sect.VSize - (UInt32)maxOffset; + sect2.VSize = sect2.PSize; + sect2.Name = ".rsrc_1"; + sect2.Time = 0; + _sections.Add(sect2); + } + } + + return S_OK; +} + +HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback) { const UInt32 kBufSize = 1 << 18; const UInt32 kSigSize = 2; @@ -732,7 +1349,8 @@ HRESULT CHandler::Open2(IInStream *stream) sections.Sort(); UInt32 limit = (1 << 12); int num = 0; - for (int i = 0; i < sections.Size(); i++) + int numSections = sections.Size(); + for (int i = 0; i < numSections; i++) { const CSection &s = sections[i]; if (s.Pa > limit) @@ -740,20 +1358,72 @@ HRESULT CHandler::Open2(IInStream *stream) CSection s2; s2.Pa = s2.Va = limit; s2.PSize = s2.VSize = s.Pa - limit; - char sz[32]; - ConvertUInt64ToString(++num, sz); - s2.Name = "[data-"; - s2.Name += sz; - s2.Name += "]"; + s2.Name = '['; + s2.Name += GetDecString(num++); + s2.Name += ']'; _sections.Add(s2); + limit = s.Pa; } UInt32 next = s.Pa + s.PSize; - if (next < limit) + if (next < s.Pa) break; - limit = next; + if (next >= limit) + limit = next; } } + _parseResources = true; + + for (int i = 0; i < _sections.Size(); i++) + { + const CSection § = _sections[i]; + CMixItem mixItem; + mixItem.SectionIndex = i; + if (_parseResources && sect.Name == ".rsrc" && _items.IsEmpty()) + { + HRESULT res = OpenResources(i, stream, callback); + if (res == S_OK) + { + _resourceFileName = GetUnicodeString(sect.Name); + for (int j = 0; j < _items.Size(); j++) + if (_items[j].Enabled) + { + mixItem.ResourceIndex = j; + mixItem.StringIndex = -1; + _mixItems.Add(mixItem); + } + if (sect.PSize > sect.VSize) + { + int numBits = _optHeader.GetNumFileAlignBits(); + if (numBits >= 0) + { + UInt32 mask = (1 << numBits) - 1; + UInt32 end = ((sect.VSize + mask) & ~mask); + + if (sect.PSize > end) + { + CSection sect2; + sect2.Flags = 0; + sect2.Pa = sect.Pa + end; + sect2.Va = sect.Va + end; + sect2.PSize = sect.PSize - end; + sect2.VSize = sect2.PSize; + sect2.Name = ".rsrc_2"; + sect2.Time = 0; + _sections.Add(sect2); + } + } + } + continue; + } + if (res != S_FALSE) + return res; + CloseResources(); + } + mixItem.StringIndex = -1; + mixItem.ResourceIndex = -1; + _mixItems.Add(mixItem); + } return S_OK; } @@ -766,8 +1436,8 @@ HRESULT CalcCheckSum(ISequentialInStream *stream, UInt32 size, UInt32 excludePos Byte *buf = buffer; UInt32 sum = 0; - UInt32 pos; - for(pos = 0;;) + UInt32 pos = 0; + for (;;) { UInt32 rem = size - pos; if (rem > kBufSize) @@ -806,46 +1476,60 @@ HRESULT CalcCheckSum(ISequentialInStream *stream, UInt32 size, UInt32 excludePos return S_OK; } -STDMETHODIMP CHandler::Open(IInStream *inStream, - const UInt64 * /* maxCheckStartPosition */, - IArchiveOpenCallback * /* openArchiveCallback */) +STDMETHODIMP CHandler::Open(IInStream *inStream, const UInt64 *, IArchiveOpenCallback *callback) { COM_TRY_BEGIN Close(); - RINOK(Open2(inStream)); - _inStream = inStream; + RINOK(Open2(inStream, callback)); + _stream = inStream; return S_OK; COM_TRY_END } +void CHandler::CloseResources() +{ + _usedRes.Free(); + _items.Clear(); + _strings.Clear(); + _buf.SetCapacity(0); +} + STDMETHODIMP CHandler::Close() { - _inStream.Release(); + _stream.Release(); _sections.Clear(); - + _mixItems.Clear(); + CloseResources(); return S_OK; } STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) { - *numItems = _sections.Size(); + *numItems = _mixItems.Size(); return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) - numItems = _sections.Size(); + numItems = _mixItems.Size(); if (numItems == 0) return S_OK; UInt64 totalSize = 0; UInt32 i; for (i = 0; i < numItems; i++) - totalSize += _sections[allFilesMode ? i : indices[i]].GetPackSize(); + { + const CMixItem &mixItem = _mixItems[allFilesMode ? i : indices[i]]; + if (mixItem.StringIndex >= 0) + totalSize += _strings[mixItem.StringIndex].Size; + else if (mixItem.ResourceIndex < 0) + totalSize += _sections[mixItem.SectionIndex].GetPackSize(); + else + totalSize += _items[mixItem.ResourceIndex].GetSize(); + } extractCallback->SetTotal(totalSize); UInt64 currentTotalSize = 0; @@ -859,53 +1543,127 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, lps->Init(extractCallback, false); bool checkSumOK = true; - if (_optHeader.CheckSum != 0 && (int)numItems == _sections.Size()) + if (_optHeader.CheckSum != 0 && (int)numItems == _mixItems.Size()) { UInt32 checkSum = 0; - RINOK(_inStream->Seek(0, STREAM_SEEK_SET, NULL)); - CalcCheckSum(_inStream, _totalSizeLimited, _peOffset + kHeaderSize + 64, checkSum); + RINOK(_stream->Seek(0, STREAM_SEEK_SET, NULL)); + CalcCheckSum(_stream, _totalSizeLimited, _peOffset + kHeaderSize + 64, checkSum); checkSumOK = (checkSum == _optHeader.CheckSum); } CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream; CMyComPtr<ISequentialInStream> inStream(streamSpec); - streamSpec->SetStream(_inStream); + streamSpec->SetStream(_stream); for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize) { lps->InSize = lps->OutSize = currentTotalSize; RINOK(lps->SetCur()); Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; UInt32 index = allFilesMode ? i : indices[i]; - const CSection &item = _sections[index]; - currentItemSize = item.GetPackSize(); CMyComPtr<ISequentialOutStream> outStream; RINOK(extractCallback->GetStream(index, &outStream, askMode)); - if (!testMode && !outStream) - continue; + const CMixItem &mixItem = _mixItems[index]; + + const CSection § = _sections[mixItem.SectionIndex]; + bool isOk = true; + if (mixItem.StringIndex >= 0) + { + const CStringItem &item = _strings[mixItem.StringIndex]; + currentItemSize = item.Size; + if (!testMode && !outStream) + continue; + + RINOK(extractCallback->PrepareOperation(askMode)); + if (outStream) + RINOK(WriteStream(outStream, item.Buf, item.Size)); + } + else if (mixItem.ResourceIndex < 0) + { + currentItemSize = sect.GetPackSize(); + if (!testMode && !outStream) + continue; - RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(_inStream->Seek(item.Pa, STREAM_SEEK_SET, NULL)); - streamSpec->Init(currentItemSize); - RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress)); + RINOK(extractCallback->PrepareOperation(askMode)); + RINOK(_stream->Seek(sect.Pa, STREAM_SEEK_SET, NULL)); + streamSpec->Init(currentItemSize); + RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress)); + isOk = (copyCoderSpec->TotalSize == currentItemSize); + } + else + { + const CResItem &item = _items[mixItem.ResourceIndex]; + currentItemSize = item.GetSize(); + if (!testMode && !outStream) + continue; + + RINOK(extractCallback->PrepareOperation(askMode)); + size_t offset = item.Offset - sect.Va; + if (!CheckItem(sect, item, offset)) + isOk = false; + else if (outStream) + { + if (item.HeaderSize != 0) + RINOK(WriteStream(outStream, item.Header, item.HeaderSize)); + RINOK(WriteStream(outStream, _buf + offset, item.Size)); + } + } + outStream.Release(); - RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == currentItemSize) ? + RINOK(extractCallback->SetOperationResult(isOk ? checkSumOK ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kCRCError: - NArchive::NExtract::NOperationResult::kDataError)); + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kCRCError: + NExtract::NOperationResult::kDataError)); } return S_OK; COM_TRY_END } +STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream) +{ + COM_TRY_BEGIN + *stream = 0; + + const CMixItem &mixItem = _mixItems[index]; + const CSection § = _sections[mixItem.SectionIndex]; + if (mixItem.IsSectionItem()) + return CreateLimitedInStream(_stream, sect.Pa, sect.PSize, stream); + + CBufInStream *inStreamSpec = new CBufInStream; + CMyComPtr<ISequentialInStream> streamTemp = inStreamSpec; + CReferenceBuf *referenceBuf = new CReferenceBuf; + CMyComPtr<IUnknown> ref = referenceBuf; + if (mixItem.StringIndex >= 0) + { + const CStringItem &item = _strings[mixItem.StringIndex]; + referenceBuf->Buf.SetCapacity(item.Size); + memcpy(referenceBuf->Buf, item.Buf, item.Size); + } + else + { + const CResItem &item = _items[mixItem.ResourceIndex]; + size_t offset = item.Offset - sect.Va; + if (!CheckItem(sect, item, offset)) + return S_FALSE; + referenceBuf->Buf.SetCapacity(item.HeaderSize + item.Size); + memcpy(referenceBuf->Buf, item.Header, item.HeaderSize); + memcpy(referenceBuf->Buf + item.HeaderSize, _buf + offset, item.Size); + } + inStreamSpec->Init(referenceBuf); + + *stream = streamTemp.Detach(); + return S_OK; + COM_TRY_END +} + static IInArchive *CreateArc() { return new CHandler; } static CArcInfo g_ArcInfo = - { L"PE", L"", 0, 0xDD, { 0 }, 0, false, CreateArc, 0 }; + { L"PE", L"exe dll sys", 0, 0xDD, { 'P', 'E', 0, 0 }, 4, false, CreateArc, 0 }; REGISTER_ARC(Pe) diff --git a/CPP/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp index 93c19265..b5decec8 100755 --- a/CPP/7zip/Archive/Rar/RarHandler.cpp +++ b/CPP/7zip/Archive/Rar/RarHandler.cpp @@ -350,7 +350,7 @@ HRESULT CHandler::Open2(IInStream *stream, if (!openVolumeCallback) break; - if(_archives.Size() == 1) + if (_archives.Size() == 1) { if (!_archiveInfo.IsVolume()) break; @@ -395,9 +395,14 @@ HRESULT CHandler::Open2(IInStream *stream, CItemEx item; for (;;) { - HRESULT result = archive.GetNextItem(item, getTextPassword); + bool decryptionError; + HRESULT result = archive.GetNextItem(item, getTextPassword, decryptionError); if (result == S_FALSE) + { + if (decryptionError && _items.IsEmpty()) + return S_FALSE; break; + } RINOK(result); if (item.IgnoreItem()) continue; @@ -470,27 +475,25 @@ struct CMethodItem }; -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *_anExtractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN CMyComPtr<ICryptoGetTextPassword> getTextPassword; - bool testMode = (_aTestMode != 0); - CMyComPtr<IArchiveExtractCallback> extractCallback = _anExtractCallback; UInt64 censoredTotalUnPacked = 0, // censoredTotalPacked = 0, importantTotalUnPacked = 0; // importantTotalPacked = 0; - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _refItems.Size(); - if(numItems == 0) + if (numItems == 0) return S_OK; int lastIndex = 0; CRecordVector<int> importantIndexes; CRecordVector<bool> extractStatuses; - for(UInt32 t = 0; t < numItems; t++) + for (UInt32 t = 0; t < numItems; t++) { int index = allFilesMode ? t : indices[t]; const CRefItem &refItem = _refItems[index]; @@ -498,11 +501,11 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, censoredTotalUnPacked += item.Size; // censoredTotalPacked += item.PackSize; int j; - for(j = lastIndex; j <= index; j++) - // if(!_items[_refItems[j].ItemIndex].IsSolid()) - if(!IsSolid(j)) + for (j = lastIndex; j <= index; j++) + // if (!_items[_refItems[j].ItemIndex].IsSolid()) + if (!IsSolid(j)) lastIndex = j; - for(j = lastIndex; j <= index; j++) + for (j = lastIndex; j <= index; j++) { const CRefItem &refItem = _refItems[j]; const CItemEx &item = _items[refItem.ItemIndex]; @@ -543,7 +546,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, lps->Init(extractCallback, false); bool solidStart = true; - for(int i = 0; i < importantIndexes.Size(); i++, + for (int i = 0; i < importantIndexes.Size(); i++, currentImportantTotalUnPacked += currentUnPackSize, currentImportantTotalPacked += currentPackSize) { @@ -553,12 +556,12 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode; - if(extractStatuses[i]) + if (extractStatuses[i]) askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; else - askMode = NArchive::NExtract::NAskMode::kSkip; + askMode = NExtract::NAskMode::kSkip; UInt32 index = importantIndexes[i]; @@ -569,22 +572,22 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, currentPackSize = GetPackSize(index); - if(item.IgnoreItem()) + if (item.IgnoreItem()) continue; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); if (!IsSolid(index)) solidStart = true; - if(item.IsDir()) + if (item.IsDir()) { RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } bool mustBeProcessedAnywhere = false; - if(i < importantIndexes.Size() - 1) + if (i < importantIndexes.Size() - 1) { // const CRefItem &nextRefItem = _refItems[importantIndexes[i + 1]]; // const CItemEx &nextItemInfo = _items[nextRefItem.ItemIndex]; @@ -596,7 +599,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, continue; if (!realOutStream && !testMode) - askMode = NArchive::NExtract::NAskMode::kSkip; + askMode = NExtract::NAskMode::kSkip; RINOK(extractCallback->PrepareOperation(askMode)); @@ -664,15 +667,14 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, else { outStream.Release(); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod)); continue; } RINOK(filterStreamSpec->Filter.QueryInterface(IID_ICryptoSetPassword, &cryptoSetPassword)); if (!getTextPassword) - extractCallback.QueryInterface(IID_ICryptoGetTextPassword, - &getTextPassword); + extractCallback->QueryInterface(IID_ICryptoGetTextPassword, (void **)&getTextPassword); if (getTextPassword) { CMyComBSTR password; @@ -729,7 +731,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (item.UnPackVersion >= 29) { outStream.Release(); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod)); continue; } */ @@ -758,7 +760,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (mi.Coder == 0) { outStream.Release(); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod)); continue; } @@ -785,7 +787,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, } default: outStream.Release(); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod)); continue; } HRESULT result = commonCoder->Code(inStream, outStream, &packSize, &item.Size, progress); @@ -794,7 +796,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (result == S_FALSE) { outStream.Release(); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kDataError)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kDataError)); continue; } if (result != S_OK) @@ -808,8 +810,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, const CItemEx &lastItem = _items[refItem.ItemIndex + refItem.NumItems - 1]; bool crcOK = outStreamSpec->GetCRC() == lastItem.FileCRC; outStream.Release(); - RINOK(extractCallback->SetOperationResult(crcOK ? NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kCRCError)); + RINOK(extractCallback->SetOperationResult(crcOK ? + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kCRCError)); } /* else @@ -824,8 +827,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, break; } } - RINOK(extractCallback->SetOperationResult(crcOK ? NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kCRCError)); + RINOK(extractCallback->SetOperationResult(crcOK ? + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kCRCError)); } */ } diff --git a/CPP/7zip/Archive/Rar/RarIn.cpp b/CPP/7zip/Archive/Rar/RarIn.cpp index 4810649b..5ea12c2d 100755 --- a/CPP/7zip/Archive/Rar/RarIn.cpp +++ b/CPP/7zip/Archive/Rar/RarIn.cpp @@ -372,8 +372,9 @@ void CInArchive::AddToSeekValue(UInt64 addValue) m_Position += addValue; } -HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword) +HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword, bool &decryptionError) { + decryptionError = false; if (m_SeekOnArchiveComment) SkipArchiveComment(); for (;;) @@ -469,8 +470,11 @@ HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPa AddToSeekValue(item.PackSize); // m_Position points to next header; return S_OK; } - if (m_CryptoMode && m_BlockHeader.HeadSize > (1 << 12)) - return E_FAIL; // it's for bad passwords + if (m_CryptoMode && m_BlockHeader.HeadSize > (1 << 10)) + { + decryptionError = true; + return S_FALSE; + } if ((m_BlockHeader.Flags & NHeader::NBlock::kLongBlock) != 0) { m_FileHeaderData.EnsureCapacity(7 + 4); @@ -480,7 +484,10 @@ HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPa UInt32 dataSize = ReadUInt32(); AddToSeekValue(dataSize); if (m_CryptoMode && dataSize > (1 << 27)) - return E_FAIL; // it's for bad passwords + { + decryptionError = true; + return S_FALSE; + } m_CryptoPos = m_BlockHeader.HeadSize; } else diff --git a/CPP/7zip/Archive/Rar/RarIn.h b/CPP/7zip/Archive/Rar/RarIn.h index ff97a109..3d446977 100755 --- a/CPP/7zip/Archive/Rar/RarIn.h +++ b/CPP/7zip/Archive/Rar/RarIn.h @@ -111,7 +111,7 @@ protected: public: HRESULT Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit); void Close(); - HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword); + HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword, bool &decryptionError); void SkipArchiveComment(); diff --git a/CPP/7zip/Archive/Rar/RarRegister.cpp b/CPP/7zip/Archive/Rar/RarRegister.cpp index a79fd026..2bcf569e 100755 --- a/CPP/7zip/Archive/Rar/RarRegister.cpp +++ b/CPP/7zip/Archive/Rar/RarRegister.cpp @@ -5,7 +5,7 @@ #include "../../Common/RegisterArc.h" #include "RarHandler.h" -static IInArchive *CreateArc() { return new NArchive::NRar::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NRar::CHandler; } static CArcInfo g_ArcInfo = { L"Rar", L"rar r00", 0, 3, {0x52 , 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00}, 7, false, CreateArc, 0, }; diff --git a/CPP/7zip/Archive/RpmHandler.cpp b/CPP/7zip/Archive/RpmHandler.cpp index 13b67390..f533e78f 100755 --- a/CPP/7zip/Archive/RpmHandler.cpp +++ b/CPP/7zip/Archive/RpmHandler.cpp @@ -71,7 +71,7 @@ struct CSigHeaderSig bool MagicCheck() { return Magic[0] == 0x8e && Magic[1] == 0xad && Magic[2] == 0xe8 && Magic[3] == 0x01; }; UInt32 GetLostHeaderLen() - { return IndexLen * kEntryInfoSize + DataLen; }; + { return IndexLen * kEntryInfoSize + DataLen; }; }; static HRESULT RedSigHeaderSig(IInStream *inStream, CSigHeaderSig &h) @@ -243,30 +243,25 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIAN return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - if (numItems == UInt32(-1)) - numItems = 1; if (numItems == 0) return S_OK; - if (numItems != 1 || indices[0] != 0) + if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0)) return E_INVALIDARG; - bool testMode = (_aTestMode != 0); - RINOK(extractCallback->SetTotal(_size)); CMyComPtr<ISequentialOutStream> outStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; RINOK(extractCallback->GetStream(0, &outStream, askMode)); if (!testMode && !outStream) return S_OK; RINOK(extractCallback->PrepareOperation(askMode)); - CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder; CLocalProgress *lps = new CLocalProgress; @@ -276,7 +271,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(_stream->Seek(_pos, STREAM_SEEK_SET, NULL)); RINOK(copyCoder->Code(_stream, outStream, NULL, NULL, progress)); outStream.Release(); - return extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK); + return extractCallback->SetOperationResult(NExtract::NOperationResult::kOK); COM_TRY_END } @@ -287,7 +282,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 /* index */, ISequentialInStream **strea COM_TRY_END } -static IInArchive *CreateArc() { return new NArchive::NRpm::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NRpm::CHandler; } static CArcInfo g_ArcInfo = { L"Rpm", L"rpm", 0, 0xEB, { 0xED, 0xAB, 0xEE, 0xDB}, 4, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/SplitHandler.cpp b/CPP/7zip/Archive/SplitHandler.cpp index 892e12af..e3129c6a 100755 --- a/CPP/7zip/Archive/SplitHandler.cpp +++ b/CPP/7zip/Archive/SplitHandler.cpp @@ -294,24 +294,21 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIAN return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - if (numItems == UInt32(-1)) - numItems = 1; if (numItems == 0) return S_OK; - if (numItems != 1 || indices[0] != 0) + if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0)) return E_INVALIDARG; - bool testMode = (_aTestMode != 0); UInt64 currentTotalSize = 0; RINOK(extractCallback->SetTotal(_totalSize)); CMyComPtr<ISequentialOutStream> outStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; RINOK(extractCallback->GetStream(0, &outStream, askMode)); if (!testMode && !outStream) return S_OK; @@ -334,7 +331,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, currentTotalSize += copyCoderSpec->TotalSize; } outStream.Release(); - return extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK); + return extractCallback->SetOperationResult(NExtract::NOperationResult::kOK); COM_TRY_END } @@ -360,7 +357,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream) COM_TRY_END } -static IInArchive *CreateArc() { return new CHandler; } +static IInArchive *CreateArc() { return new CHandler; } static CArcInfo g_ArcInfo = { L"Split", L"001", 0, 0xEA, { 0 }, 0, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/SwfHandler.cpp b/CPP/7zip/Archive/SwfHandler.cpp new file mode 100755 index 00000000..dfc0326d --- /dev/null +++ b/CPP/7zip/Archive/SwfHandler.cpp @@ -0,0 +1,706 @@ +// SwfHandler.cpp + +#include "StdAfx.h" + +#include "../../../C/CpuArch.h" + +#include "Common/Buffer.h" +#include "Common/ComTry.h" +#include "Common/IntToString.h" +#include "Common/MyString.h" + +#include "Windows/PropVariant.h" + +#include "../Common/InBuffer.h" +#include "../Common/ProgressUtils.h" +#include "../Common/RegisterArc.h" +#include "../Common/StreamUtils.h" + +#include "../Compress/CopyCoder.h" +#include "../Compress/ZlibDecoder.h" +#include "../Compress/ZlibEncoder.h" + +#include "Common/DummyOutStream.h" + +#include "DeflateProps.h" + +using namespace NWindows; + +namespace NArchive { +namespace NSwfc { + +static const UInt32 kHeaderSize = 8; + +static const Byte SWF_UNCOMPRESSED = 'F'; +static const Byte SWF_COMPRESSED = 'C'; +static const Byte SWF_MIN_COMPRESSED_VER = 6; + +struct CItem +{ + Byte Buf[kHeaderSize]; + + UInt32 GetSize() const { return GetUi32(Buf + 4); } + bool IsSwf(Byte c) const { return (Buf[0] == c && Buf[1] == 'W' && Buf[2] == 'S' && Buf[3] < 32); } + bool IsUncompressed() const { return IsSwf(SWF_UNCOMPRESSED); } + bool IsCompressed() const { return IsSwf(SWF_COMPRESSED); } + + void MakeUncompressed() { Buf[0] = SWF_UNCOMPRESSED; } + void MakeCompressed() + { + Buf[0] = SWF_COMPRESSED; + if (Buf[3] < SWF_MIN_COMPRESSED_VER) + Buf[3] = SWF_MIN_COMPRESSED_VER; + } + + HRESULT ReadHeader(ISequentialInStream *stream) { return ReadStream_FALSE(stream, Buf, kHeaderSize); } + HRESULT WriteHeader(ISequentialOutStream *stream) { return WriteStream(stream, Buf, kHeaderSize); } +}; + +class CHandler: + public IInArchive, + public IArchiveOpenSeq, + public IOutArchive, + public ISetProperties, + public CMyUnknownImp +{ + CItem _item; + UInt64 _packSize; + bool _packSizeDefined; + CMyComPtr<ISequentialInStream> _seqStream; + CMyComPtr<IInStream> _stream; + + CDeflateProps _method; + +public: + MY_UNKNOWN_IMP4(IInArchive, IArchiveOpenSeq, IOutArchive, ISetProperties) + INTERFACE_IInArchive(;) + INTERFACE_IOutArchive(;) + STDMETHOD(OpenSeq)(ISequentialInStream *stream); + STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProps); +}; + +STATPROPSTG kProps[] = +{ + { NULL, kpidSize, VT_UI8}, + { NULL, kpidPackSize, VT_UI8} +}; + +IMP_IInArchive_Props +IMP_IInArchive_ArcProps_NO_Table + +STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) +{ + NCOM::CPropVariant prop; + switch(propID) + { + case kpidPhySize: if (_packSizeDefined) prop = _packSize; break; + } + prop.Detach(value); + return S_OK; +} + +STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) +{ + *numItems = 1; + return S_OK; +} + +STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value) +{ + NWindows::NCOM::CPropVariant prop; + switch(propID) + { + case kpidSize: prop = (UInt64)_item.GetSize(); break; + case kpidPackSize: if (_packSizeDefined) prop = _packSize; break; + } + prop.Detach(value); + return S_OK; +} + +STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *) +{ + RINOK(OpenSeq(stream)); + _stream = stream; + return S_OK; +} + +STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream) +{ + Close(); + HRESULT res = _item.ReadHeader(stream); + if (res == S_OK) + if (_item.IsCompressed()) + _seqStream = stream; + else + res = S_FALSE; + return res; +} + +STDMETHODIMP CHandler::Close() +{ + _packSizeDefined = false; + _seqStream.Release(); + _stream.Release(); + return S_OK; +} + +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) +{ + COM_TRY_BEGIN + if (numItems == 0) + return S_OK; + if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0)) + return E_INVALIDARG; + + extractCallback->SetTotal(_item.GetSize()); + CMyComPtr<ISequentialOutStream> realOutStream; + Int32 askMode = testMode ? + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; + RINOK(extractCallback->GetStream(0, &realOutStream, askMode)); + if (!testMode && !realOutStream) + return S_OK; + + extractCallback->PrepareOperation(askMode); + + NCompress::NZlib::CDecoder *_decoderSpec = new NCompress::NZlib::CDecoder; + CMyComPtr<ICompressCoder> _decoder = _decoderSpec; + + CDummyOutStream *outStreamSpec = new CDummyOutStream; + CMyComPtr<ISequentialOutStream> outStream(outStreamSpec); + outStreamSpec->SetStream(realOutStream); + outStreamSpec->Init(); + realOutStream.Release(); + + CLocalProgress *lps = new CLocalProgress; + CMyComPtr<ICompressProgressInfo> progress = lps; + lps->Init(extractCallback, false); + + lps->InSize = kHeaderSize; + lps->OutSize = outStreamSpec->GetSize(); + RINOK(lps->SetCur()); + + CItem item = _item; + item.MakeUncompressed(); + RINOK(item.WriteHeader(outStream)); + if (_stream) + RINOK(_stream->Seek(kHeaderSize, STREAM_SEEK_SET, NULL)); + HRESULT result = _decoderSpec->Code(_seqStream, outStream, NULL, NULL, progress); + Int32 opRes = NExtract::NOperationResult::kDataError; + if (result == S_OK) + { + if (_item.GetSize() == outStreamSpec->GetSize()) + { + _packSizeDefined = true; + _packSize = _decoderSpec->GetInputProcessedSize() + kHeaderSize; + opRes = NExtract::NOperationResult::kOK; + } + } + else if (result != S_FALSE) + return result; + + outStream.Release(); + return extractCallback->SetOperationResult(opRes); + COM_TRY_END +} + +static HRESULT UpdateArchive(ISequentialOutStream *outStream, + UInt64 size, CDeflateProps &deflateProps, + IArchiveUpdateCallback *updateCallback) +{ + UInt64 complexity = 0; + RINOK(updateCallback->SetTotal(size)); + RINOK(updateCallback->SetCompleted(&complexity)); + + CMyComPtr<ISequentialInStream> fileInStream; + RINOK(updateCallback->GetStream(0, &fileInStream)); + + CItem item; + HRESULT res = item.ReadHeader(fileInStream); + if (res == S_FALSE) + return E_INVALIDARG; + RINOK(res); + if (!item.IsUncompressed() || size != item.GetSize()) + return E_INVALIDARG; + + item.MakeCompressed(); + item.WriteHeader(outStream); + + CLocalProgress *lps = new CLocalProgress; + CMyComPtr<ICompressProgressInfo> progress = lps; + lps->Init(updateCallback, true); + + NCompress::NZlib::CEncoder *encoderSpec = new NCompress::NZlib::CEncoder; + CMyComPtr<ICompressCoder> encoder = encoderSpec; + encoderSpec->Create(); + RINOK(deflateProps.SetCoderProperties(encoderSpec->DeflateEncoderSpec)); + RINOK(encoder->Code(fileInStream, outStream, NULL, NULL, progress)); + if (encoderSpec->GetInputProcessedSize() + kHeaderSize != size) + return E_INVALIDARG; + return updateCallback->SetOperationResult(NUpdate::NOperationResult::kOK); +} + +STDMETHODIMP CHandler::GetFileTimeType(UInt32 *timeType) +{ + *timeType = NFileTimeType::kUnix; + return S_OK; +} + +STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems, + IArchiveUpdateCallback *updateCallback) +{ + if (numItems != 1) + return E_INVALIDARG; + + Int32 newData, newProps; + UInt32 indexInArchive; + if (!updateCallback) + return E_FAIL; + RINOK(updateCallback->GetUpdateItemInfo(0, &newData, &newProps, &indexInArchive)); + + if (IntToBool(newProps)) + { + { + NCOM::CPropVariant prop; + RINOK(updateCallback->GetProperty(0, kpidIsDir, &prop)); + if (prop.vt == VT_BOOL) + { + if (prop.boolVal != VARIANT_FALSE) + return E_INVALIDARG; + } + else if (prop.vt != VT_EMPTY) + return E_INVALIDARG; + } + } + + if (IntToBool(newData)) + { + UInt64 size; + { + NCOM::CPropVariant prop; + RINOK(updateCallback->GetProperty(0, kpidSize, &prop)); + if (prop.vt != VT_UI8) + return E_INVALIDARG; + size = prop.uhVal.QuadPart; + } + return UpdateArchive(outStream, size, _method, updateCallback); + } + + if (indexInArchive != 0) + return E_INVALIDARG; + + if (!_seqStream) + return E_NOTIMPL; + + if (_stream) + { + RINOK(_stream->Seek(0, STREAM_SEEK_SET, NULL)); + } + else + _item.WriteHeader(outStream); + return NCompress::CopyStream(_seqStream, outStream, NULL); +} + +STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, Int32 numProps) +{ + return _method.SetProperties(names, values, numProps); +} + +static IInArchive *CreateArc() { return new CHandler; } +#ifndef EXTRACT_ONLY +static IOutArchive *CreateArcOut() { return new CHandler; } +#else +#define CreateArcOut 0 +#endif + +static CArcInfo g_ArcInfo = + { L"SWFc", L"swf", L"~.swf", 0xD8, { 'C', 'W', 'S' }, 3, true, CreateArc, CreateArcOut }; + +REGISTER_ARC(Swfc) + +} + +namespace NSwf { + +static const UInt32 kFileSizeMax = (UInt32)1 << 30; +static const int kNumTagsMax = (UInt32)1 << 23; + +struct CTag +{ + UInt32 Type; + CByteBuffer Buf; +}; + +class CHandler: + public IInArchive, + public IArchiveOpenSeq, + public CMyUnknownImp +{ + CObjectVector<CTag> _tags; + NSwfc::CItem _item; + UInt64 _packSize; + + HRESULT OpenSeq3(ISequentialInStream *stream, IArchiveOpenCallback *callback); + HRESULT OpenSeq2(ISequentialInStream *stream, IArchiveOpenCallback *callback); +public: + MY_UNKNOWN_IMP2(IInArchive, IArchiveOpenSeq) + INTERFACE_IInArchive(;) + + STDMETHOD(OpenSeq)(ISequentialInStream *stream); +}; + +STATPROPSTG kProps[] = +{ + { NULL, kpidPath, VT_BSTR}, + { NULL, kpidSize, VT_UI8}, + { NULL, kpidComment, VT_BSTR} +}; + +IMP_IInArchive_Props +IMP_IInArchive_ArcProps_NO_Table + +STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) +{ + NCOM::CPropVariant prop; + switch(propID) + { + case kpidPhySize: prop = _packSize; break; + } + prop.Detach(value); + return S_OK; +} + + +STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) +{ + *numItems = _tags.Size(); + return S_OK; +} + +static const char *g_TagDesc[92] = +{ + "End", + "ShowFrame", + "DefineShape", + NULL, + "PlaceObject", + "RemoveObject", + "DefineBits", + "DefineButton", + "JPEGTables", + "SetBackgroundColor", + "DefineFont", + "DefineText", + "DoAction", + "DefineFontInfo", + "DefineSound", + "StartSound", + NULL, + "DefineButtonSound", + "SoundStreamHead", + "SoundStreamBlock", + "DefineBitsLossless", + "DefineBitsJPEG2", + "DefineShape2", + "DefineButtonCxform", + "Protect", + NULL, + "PlaceObject2", + NULL, + "RemoveObject2", + NULL, + NULL, + NULL, + "DefineShape3", + "DefineText2", + "DefineButton2", + "DefineBitsJPEG3", + "DefineBitsLossless2", + "DefineEditText", + NULL, + "DefineSprite", + NULL, + "41", + NULL, + "FrameLabel", + NULL, + "SoundStreamHead2", + "DefineMorphShape", + NULL, + "DefineFont2", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + "ExportAssets", + "ImportAssets", + "EnableDebugger", + "DoInitAction", + "DefineVideoStream", + "VideoFrame", + "DefineFontInfo2", + NULL, + "EnableDebugger2", + "ScriptLimits", + "SetTabIndex", + NULL, + NULL, + "FileAttributes", + "PlaceObject3", + "ImportAssets2", + NULL, + "DefineFontAlignZones", + "CSMTextSettings", + "DefineFont3", + "SymbolClass", + "Metadata", + "DefineScalingGrid", + NULL, + NULL, + NULL, + "DoABC", + "DefineShape4", + "DefineMorphShape2", + NULL, + "DefineSceneAndFrameLabelData", + "DefineBinaryData", + "DefineFontName", + "StartSound2", + "DefineBitsJPEG4", + "DefineFont4" +}; + +STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) +{ + NWindows::NCOM::CPropVariant prop; + const CTag &tag = _tags[index]; + switch(propID) + { + case kpidPath: + { + char s[32]; + ConvertUInt32ToString(index, s); + size_t i = strlen(s); + s[i++] = '.'; + ConvertUInt32ToString(tag.Type, s + i); + prop = s; + break; + } + case kpidSize: + case kpidPackSize: + prop = (UInt64)tag.Buf.GetCapacity(); break; + case kpidComment: + if (tag.Type < sizeof(g_TagDesc) / sizeof(g_TagDesc[0])) + { + const char *s = g_TagDesc[tag.Type]; + if (s != NULL) + prop = s; + } + break; + } + prop.Detach(value); + return S_OK; +} + +STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *callback) +{ + return OpenSeq2(stream, callback); +} + +static UInt16 Read16(CInBuffer &stream) +{ + UInt16 res = 0; + for (int i = 0; i < 2; i++) + { + Byte b; + if (!stream.ReadByte(b)) + throw 1; + res |= (UInt16)b << (i * 8); + } + return res; +} + +static UInt32 Read32(CInBuffer &stream) +{ + UInt32 res = 0; + for (int i = 0; i < 4; i++) + { + Byte b; + if (!stream.ReadByte(b)) + throw 1; + res |= (UInt32)b << (i * 8); + } + return res; +} + +struct CBitReader +{ + CInBuffer *stream; + unsigned NumBits; + Byte Val; + + CBitReader(): NumBits(0), Val(0) {} + + UInt32 ReadBits(unsigned numBits); +}; + +UInt32 CBitReader::ReadBits(unsigned numBits) +{ + UInt32 res = 0; + while (numBits > 0) + { + if (NumBits == 0) + { + Val = stream->ReadByte(); + NumBits = 8; + } + if (numBits <= NumBits) + { + res <<= numBits; + NumBits -= numBits; + res |= (Val >> NumBits); + Val &= (1 << NumBits) - 1; + break; + } + else + { + res <<= NumBits; + res |= Val; + numBits -= NumBits; + NumBits = 0; + } + } + return res; +} + +HRESULT CHandler::OpenSeq3(ISequentialInStream *stream, IArchiveOpenCallback *callback) +{ + RINOK(_item.ReadHeader(stream)) + if (!_item.IsUncompressed()) + return S_FALSE; + + CInBuffer s; + if (!s.Create(1 << 20)) + return E_OUTOFMEMORY; + s.SetStream(stream); + s.Init(); + { + CBitReader br; + br.stream = &s; + unsigned numBits = br.ReadBits(5); + /* UInt32 xMin = */ br.ReadBits(numBits); + /* UInt32 xMax = */ br.ReadBits(numBits); + /* UInt32 yMin = */ br.ReadBits(numBits); + /* UInt32 yMax = */ br.ReadBits(numBits); + } + /* UInt32 frameDelay = */ Read16(s); + /* UInt32 numFrames = */ Read16(s); + + _tags.Clear(); + UInt64 offsetPrev = 0; + for (;;) + { + UInt32 pair = Read16(s); + UInt32 type = pair >> 6; + UInt32 length = pair & 0x3F; + if (length == 0x3F) + length = Read32(s); + if (type == 0) + break; + UInt64 offset = s.GetProcessedSize() + NSwfc::kHeaderSize + length; + if (offset > kFileSizeMax || _tags.Size() >= kNumTagsMax) + return S_FALSE; + _tags.Add(CTag()); + CTag &tag = _tags.Back(); + tag.Type = type; + tag.Buf.SetCapacity(length); + if (s.ReadBytes(tag.Buf, length) != length) + return S_FALSE; + if (callback && offset >= offsetPrev + (1 << 20)) + { + UInt64 numItems = _tags.Size(); + RINOK(callback->SetCompleted(&numItems, &offset)); + offsetPrev = offset; + } + } + _packSize = s.GetProcessedSize() + NSwfc::kHeaderSize; + return S_OK; +} + +HRESULT CHandler::OpenSeq2(ISequentialInStream *stream, IArchiveOpenCallback *callback) +{ + HRESULT res; + try { res = OpenSeq3(stream, callback); } + catch(...) { res = S_FALSE; } + return res; +} + +STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream) +{ + return OpenSeq2(stream, NULL); +} + +STDMETHODIMP CHandler::Close() +{ + return S_OK; +} + +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) +{ + COM_TRY_BEGIN + bool allFilesMode = (numItems == (UInt32)-1); + if (allFilesMode) + numItems = _tags.Size(); + if (numItems == 0) + return S_OK; + UInt64 totalSize = 0; + UInt32 i; + for (i = 0; i < numItems; i++) + totalSize += _tags[allFilesMode ? i : indices[i]].Buf.GetCapacity(); + extractCallback->SetTotal(totalSize); + + CLocalProgress *lps = new CLocalProgress; + CMyComPtr<ICompressProgressInfo> progress = lps; + lps->Init(extractCallback, false); + + totalSize = 0; + + for (i = 0; i < numItems; i++) + { + lps->InSize = lps->OutSize = totalSize; + RINOK(lps->SetCur()); + Int32 askMode = testMode ? + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; + UInt32 index = allFilesMode ? i : indices[i]; + const CByteBuffer &buf = _tags[index].Buf; + totalSize += buf.GetCapacity(); + + CMyComPtr<ISequentialOutStream> outStream; + RINOK(extractCallback->GetStream(index, &outStream, askMode)); + if (!testMode && !outStream) + continue; + + RINOK(extractCallback->PrepareOperation(askMode)); + if (outStream) + RINOK(WriteStream(outStream, buf, buf.GetCapacity())); + outStream.Release(); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); + } + return S_OK; + COM_TRY_END +} + +static IInArchive *CreateArc() { return new CHandler; } + +static CArcInfo g_ArcInfo = + { L"SWF", L"swf", 0, 0xD7, { 'F', 'W', 'S' }, 3, true, CreateArc, 0 }; + +REGISTER_ARC(Swf) + +}} diff --git a/CPP/7zip/Archive/Tar/TarHandler.cpp b/CPP/7zip/Archive/Tar/TarHandler.cpp index aa4b2aec..31e30573 100755 --- a/CPP/7zip/Archive/Tar/TarHandler.cpp +++ b/CPP/7zip/Archive/Tar/TarHandler.cpp @@ -227,8 +227,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val COM_TRY_END } -HRESULT CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +HRESULT CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN ISequentialInStream *stream = _seqStream; @@ -236,7 +236,6 @@ HRESULT CHandler::Extract(const UInt32* indices, UInt32 numItems, if (!seqMode) stream = _stream; - bool testMode = (_aTestMode != 0); bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _items.Size(); @@ -269,8 +268,8 @@ HRESULT CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; Int32 index = allFilesMode ? i : indices[i]; const CItemEx *item; if (seqMode) @@ -290,7 +289,7 @@ HRESULT CHandler::Extract(const UInt32* indices, UInt32 numItems, if (item->IsDir()) { RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } bool skipMode = false; @@ -299,7 +298,7 @@ HRESULT CHandler::Extract(const UInt32* indices, UInt32 numItems, if (!seqMode) continue; skipMode = true; - askMode = NArchive::NExtract::NAskMode::kSkip; + askMode = NExtract::NAskMode::kSkip; } RINOK(extractCallback->PrepareOperation(askMode)); @@ -320,8 +319,8 @@ HRESULT CHandler::Extract(const UInt32* indices, UInt32 numItems, } outStreamSpec->ReleaseStream(); RINOK(extractCallback->SetOperationResult(outStreamSpec->GetRem() == 0 ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError)); + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError)); } return S_OK; COM_TRY_END diff --git a/CPP/7zip/Archive/Tar/TarRegister.cpp b/CPP/7zip/Archive/Tar/TarRegister.cpp index 3cc0d605..e21c0aac 100755 --- a/CPP/7zip/Archive/Tar/TarRegister.cpp +++ b/CPP/7zip/Archive/Tar/TarRegister.cpp @@ -5,14 +5,14 @@ #include "../../Common/RegisterArc.h" #include "TarHandler.h" -static IInArchive *CreateArc() { return new NArchive::NTar::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NTar::CHandler; } #ifndef EXTRACT_ONLY -static IOutArchive *CreateArcOut() { return new NArchive::NTar::CHandler; } +static IOutArchive *CreateArcOut() { return new NArchive::NTar::CHandler; } #else #define CreateArcOut 0 #endif static CArcInfo g_ArcInfo = -{ L"Tar", L"tar", 0, 0xEE, { 'u', 's', 't', 'a', 'r' }, 5, false, CreateArc, CreateArcOut }; +{ L"tar", L"tar", 0, 0xEE, { 'u', 's', 't', 'a', 'r' }, 5, false, CreateArc, CreateArcOut }; REGISTER_ARC(Tar) diff --git a/CPP/7zip/Archive/Udf/UdfHandler.cpp b/CPP/7zip/Archive/Udf/UdfHandler.cpp index 07b61c51..42419a9d 100755 --- a/CPP/7zip/Archive/Udf/UdfHandler.cpp +++ b/CPP/7zip/Archive/Udf/UdfHandler.cpp @@ -10,6 +10,7 @@ #include "../../Common/LimitedStreams.h" #include "../../Common/ProgressUtils.h" +#include "../../Common/StreamObjects.h" #include "../../Compress/CopyCoder.h" @@ -200,57 +201,6 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val COM_TRY_END } -class CBufInStream: - public IInStream, - public CMyUnknownImp -{ - CByteBuffer _data; - UInt64 _pos; - -public: - void Init(const CByteBuffer &data) - { - _data = data; - _pos = 0; - } - - MY_UNKNOWN_IMP - - STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); - STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); -}; - - -STDMETHODIMP CBufInStream::Read(void *data, UInt32 size, UInt32 *processedSize) -{ - if (processedSize != NULL) - *processedSize = 0; - if (_pos > _data.GetCapacity()) - return E_FAIL; - size_t rem = _data.GetCapacity() - (size_t)_pos; - if (size < rem) - rem = (size_t)size; - memcpy(data, (const Byte *)_data + _pos, rem); - _pos += rem; - if (processedSize != NULL) - *processedSize = (UInt32)rem; - return S_OK; -} - -STDMETHODIMP CBufInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) -{ - switch(seekOrigin) - { - case STREAM_SEEK_SET: _pos = offset; break; - case STREAM_SEEK_CUR: _pos += offset; break; - case STREAM_SEEK_END: _pos = _data.GetCapacity() + offset; break; - default: return STG_E_INVALIDFUNCTION; - } - if (newPosition) - *newPosition = _pos; - return S_OK; -} - struct CSeekExtent { UInt64 Phy; @@ -362,8 +312,11 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream) { CBufInStream *inStreamSpec = new CBufInStream; CMyComPtr<ISequentialInStream> inStream = inStreamSpec; - inStreamSpec->Init(item.InlineData); - *stream = inStream .Detach(); + CReferenceBuf *referenceBuf = new CReferenceBuf; + CMyComPtr<IUnknown> ref = referenceBuf; + referenceBuf->Buf = item.InlineData; + inStreamSpec->Init(referenceBuf); + *stream = inStream.Detach(); return S_OK; } @@ -407,12 +360,11 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream) return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _refs2.Size(); if (numItems == 0) @@ -450,8 +402,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; UInt32 index = allFilesMode ? i : indices[i]; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); @@ -464,7 +416,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (item.IsDir()) { RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } currentTotalSize += item.Size; @@ -480,15 +432,15 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, CMyComPtr<ISequentialInStream> udfInStream; HRESULT res = GetStream(index, &udfInStream); if (res == E_NOTIMPL) - opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + opRes = NExtract::NOperationResult::kUnSupportedMethod; else if (res != S_OK) - opRes = NArchive::NExtract::NOperationResult::kDataError; + opRes = NExtract::NOperationResult::kDataError; else { RINOK(copyCoder->Code(udfInStream, outStream, NULL, NULL, progress)); opRes = outStreamSpec->IsFinishedOK() ? - NArchive::NExtract::NOperationResult::kOK: - NArchive::NExtract::NOperationResult::kDataError; + NExtract::NOperationResult::kOK: + NExtract::NOperationResult::kDataError; } outStreamSpec->ReleaseStream(); RINOK(extractCallback->SetOperationResult(opRes)); diff --git a/CPP/7zip/Archive/Udf/UdfRegister.cpp b/CPP/7zip/Archive/Udf/UdfRegister.cpp index b3a6c152..5dc7db6a 100755 --- a/CPP/7zip/Archive/Udf/UdfRegister.cpp +++ b/CPP/7zip/Archive/Udf/UdfRegister.cpp @@ -5,7 +5,7 @@ #include "../../Common/RegisterArc.h" #include "UdfHandler.h" -static IInArchive *CreateArc() { return new NArchive::NUdf::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NUdf::CHandler; } static CArcInfo g_ArcInfo = { L"Udf", L"iso", 0, 0xE0, { 0, 'N', 'S', 'R', '0' }, 5, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/VhdHandler.cpp b/CPP/7zip/Archive/VhdHandler.cpp index 5fc2c918..439b8691 100755 --- a/CPP/7zip/Archive/VhdHandler.cpp +++ b/CPP/7zip/Archive/VhdHandler.cpp @@ -641,24 +641,20 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIAN COM_TRY_END } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - if (numItems == UInt32(-1)) - numItems = 1; if (numItems == 0) return S_OK; - if (numItems != 1 || indices[0] != 0) + if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0)) return E_INVALIDARG; - bool testMode = (_aTestMode != 0); - RINOK(extractCallback->SetTotal(GetSize())); CMyComPtr<ISequentialOutStream> outStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; RINOK(extractCallback->GetStream(0, &outStream, askMode)); if (!testMode && !outStream) return S_OK; @@ -671,11 +667,11 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, CMyComPtr<ICompressProgressInfo> progress = lps; lps->Init(extractCallback, false); - int res = NArchive::NExtract::NOperationResult::kDataError; + int res = NExtract::NOperationResult::kDataError; CMyComPtr<ISequentialInStream> inStream; HRESULT hres = GetStream(0, &inStream); if (hres == S_FALSE) - res = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + res = NExtract::NOperationResult::kUnSupportedMethod; else { RINOK(hres); @@ -683,7 +679,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (hres == S_OK) { if (copyCoderSpec->TotalSize == GetSize()) - res = NArchive::NExtract::NOperationResult::kOK; + res = NExtract::NOperationResult::kOK; } else { @@ -721,7 +717,7 @@ STDMETHODIMP CHandler::GetStream(UInt32 /* index */, ISequentialInStream **strea COM_TRY_END } -static IInArchive *CreateArc() { return new CHandler; } +static IInArchive *CreateArc() { return new CHandler; } static CArcInfo g_ArcInfo = { L"VHD", L"vhd", L".mbr", 0xDC, { 'c', 'o', 'n', 'e', 'c', 't', 'i', 'x', 0, 0 }, 10, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/Wim/WimHandler.cpp b/CPP/7zip/Archive/Wim/WimHandler.cpp index 1b8661c9..8093af77 100755 --- a/CPP/7zip/Archive/Wim/WimHandler.cpp +++ b/CPP/7zip/Archive/Wim/WimHandler.cpp @@ -485,17 +485,16 @@ STDMETHODIMP CHandler::Close() return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = m_Database.Items.Size() + m_Xmls.Size(); if (numItems == 0) return S_OK; - bool testMode = (_aTestMode != 0); UInt32 i; UInt64 totalSize = 0; @@ -549,7 +548,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); if (index >= (UInt32)m_Database.Items.Size()) { - if(!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); const CByteBuffer &data = m_Xmls[index - (UInt32)m_Database.Items.Size()].Data; @@ -567,7 +566,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, int streamIndex = item.StreamIndex; if (streamIndex < 0) { - if(!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); realOutStream.Release(); @@ -581,7 +580,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, currentItemUnPacked = si.Resource.UnpackSize; currentItemPacked = si.Resource.PackSize; - if(!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); Int32 opRes = NExtract::NOperationResult::kOK; diff --git a/CPP/7zip/Archive/Wim/WimRegister.cpp b/CPP/7zip/Archive/Wim/WimRegister.cpp index 22344b3a..3c8e216f 100755 --- a/CPP/7zip/Archive/Wim/WimRegister.cpp +++ b/CPP/7zip/Archive/Wim/WimRegister.cpp @@ -5,7 +5,7 @@ #include "../../Common/RegisterArc.h" #include "WimHandler.h" -static IInArchive *CreateArc() { return new NArchive::NWim::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NWim::CHandler; } static CArcInfo g_ArcInfo = { L"Wim", L"wim swm", 0, 0xE6, { 'M', 'S', 'W', 'I', 'M', 0, 0, 0 }, 8, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/XarHandler.cpp b/CPP/7zip/Archive/XarHandler.cpp index 2dddad9f..5a2489d2 100755 --- a/CPP/7zip/Archive/XarHandler.cpp +++ b/CPP/7zip/Archive/XarHandler.cpp @@ -401,12 +401,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val COM_TRY_END } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool testMode = (_aTestMode != 0); - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = _files.Size(); if (numItems == 0) @@ -474,8 +473,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, RINOK(lps->SetCur()); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; Int32 index = allFilesMode ? i : indices[i]; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); @@ -485,19 +484,19 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (item.IsDir) { RINOK(extractCallback->PrepareOperation(askMode)); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); continue; } } - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); outStreamSha1Spec->SetStream(realOutStream); realOutStream.Release(); - Int32 opRes = NArchive::NExtract::NOperationResult::kOK; + Int32 opRes = NExtract::NOperationResult::kOK; #ifdef XAR_SHOW_RAW if (index == _files.Size()) { @@ -526,13 +525,13 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (item.PackSize == item.Size) coder = copyCoder; else - opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + opRes = NExtract::NOperationResult::kUnSupportedMethod; else if (item.Method == METHOD_NAME_ZLIB) coder = zlibCoder; else if (item.Method == "bzip2") coder = bzip2Coder; else - opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + opRes = NExtract::NOperationResult::kUnSupportedMethod; if (coder) res = coder->Code(inStream, outStream, NULL, NULL, progress); @@ -540,32 +539,32 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, if (res != S_OK) { if (!outStreamLimSpec->IsFinishedOK()) - opRes = NArchive::NExtract::NOperationResult::kDataError; + opRes = NExtract::NOperationResult::kDataError; else if (res != S_FALSE) return res; - if (opRes == NArchive::NExtract::NOperationResult::kOK) - opRes = NArchive::NExtract::NOperationResult::kDataError; + if (opRes == NExtract::NOperationResult::kOK) + opRes = NExtract::NOperationResult::kDataError; } - if (opRes == NArchive::NExtract::NOperationResult::kOK) + if (opRes == NExtract::NOperationResult::kOK) { if (outStreamLimSpec->IsFinishedOK() && outStreamSha1Spec->GetSize() == item.Size) { if (!outStreamLimSpec->IsFinishedOK()) { - opRes = NArchive::NExtract::NOperationResult::kDataError; + opRes = NExtract::NOperationResult::kDataError; } else if (item.Sha1IsDefined) { Byte digest[NCrypto::NSha1::kDigestSize]; outStreamSha1Spec->Final(digest); if (memcmp(digest, item.Sha1, NCrypto::NSha1::kDigestSize) != 0) - opRes = NArchive::NExtract::NOperationResult::kCRCError; + opRes = NExtract::NOperationResult::kCRCError; } } else - opRes = NArchive::NExtract::NOperationResult::kDataError; + opRes = NExtract::NOperationResult::kDataError; } } } @@ -576,7 +575,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, COM_TRY_END } -static IInArchive *CreateArc() { return new NArchive::NXar::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NXar::CHandler; } static CArcInfo g_ArcInfo = { L"Xar", L"xar", 0, 0xE1, { 'x', 'a', 'r', '!', 0, 0x1C }, 6, false, CreateArc, 0 }; diff --git a/CPP/7zip/Archive/XzHandler.cpp b/CPP/7zip/Archive/XzHandler.cpp index 116e96b6..f37a5841 100755 --- a/CPP/7zip/Archive/XzHandler.cpp +++ b/CPP/7zip/Archive/XzHandler.cpp @@ -449,28 +449,22 @@ struct CXzUnpackerCPP } }; -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool allFilesMode = (numItems == UInt32(-1)); - if (!allFilesMode) - { - if (numItems == 0) - return S_OK; - if (numItems != 1 || indices[0] != 0) - return E_INVALIDARG; - } - - bool testMode = (_aTestMode != 0); + if (numItems == 0) + return S_OK; + if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0)) + return E_INVALIDARG; extractCallback->SetTotal(_packSize); UInt64 currentTotalPacked = 0; RINOK(extractCallback->SetCompleted(¤tTotalPacked)); CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; RINOK(extractCallback->GetStream(0, &realOutStream, askMode)); @@ -567,15 +561,15 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, switch(res) { case SZ_OK: - opRes = NArchive::NExtract::NOperationResult::kOK; break; + opRes = NExtract::NOperationResult::kOK; break; case SZ_ERROR_UNSUPPORTED: - opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod; break; + opRes = NExtract::NOperationResult::kUnSupportedMethod; break; case SZ_ERROR_CRC: - opRes = NArchive::NExtract::NOperationResult::kCRCError; break; + opRes = NExtract::NOperationResult::kCRCError; break; case SZ_ERROR_DATA: case SZ_ERROR_ARCHIVE: case SZ_ERROR_NO_ARCHIVE: - opRes = NArchive::NExtract::NOperationResult::kDataError; break; + opRes = NExtract::NOperationResult::kDataError; break; default: return SResToHRESULT(res); } @@ -699,9 +693,9 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v #endif -static IInArchive *CreateArc() { return new NArchive::NXz::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NXz::CHandler; } #ifndef EXTRACT_ONLY -static IOutArchive *CreateArcOut() { return new NArchive::NXz::CHandler; } +static IOutArchive *CreateArcOut() { return new NArchive::NXz::CHandler; } #else #define CreateArcOut 0 #endif diff --git a/CPP/7zip/Archive/ZHandler.cpp b/CPP/7zip/Archive/ZHandler.cpp index 21432b22..49b76a11 100755 --- a/CPP/7zip/Archive/ZHandler.cpp +++ b/CPP/7zip/Archive/ZHandler.cpp @@ -21,24 +21,15 @@ class CHandler: public IInArchive, public CMyUnknownImp { -public: - MY_UNKNOWN_IMP1(IInArchive) - INTERFACE_IInArchive(;) - -private: CMyComPtr<IInStream> _stream; UInt64 _streamStartPosition; UInt64 _packSize; Byte _properties; +public: + MY_UNKNOWN_IMP1(IInArchive) + INTERFACE_IInArchive(;) }; -static IInArchive *CreateArc() { return new CHandler; } - -static CArcInfo g_ArcInfo = - { L"Z", L"z taz", L"* .tar", 5, { 0x1F, 0x9D }, 2, false, CreateArc, 0 }; - -REGISTER_ARC(Z) - STATPROPSTG kProps[] = { { NULL, kpidPackSize, VT_UI8} @@ -96,22 +87,14 @@ STDMETHODIMP CHandler::Close() } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 testModeSpec, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN - bool allFilesMode = (numItems == (UInt32)(-1)); - if (!allFilesMode) - { - if (numItems == 0) - return S_OK; - if (numItems != 1) - return E_INVALIDARG; - if (indices[0] != 0) - return E_INVALIDARG; - } - - bool testMode = (testModeSpec != 0); + if (numItems == 0) + return S_OK; + if (numItems != (UInt32)-1 && (numItems != 1 || indices[0] != 0)) + return E_INVALIDARG; extractCallback->SetTotal(_packSize); @@ -168,4 +151,11 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, COM_TRY_END } +static IInArchive *CreateArc() { return new CHandler; } + +static CArcInfo g_ArcInfo = + { L"Z", L"z taz", L"* .tar", 5, { 0x1F, 0x9D }, 2, false, CreateArc, 0 }; + +REGISTER_ARC(Z) + }} diff --git a/CPP/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp index 547ecf92..2e551931 100755 --- a/CPP/7zip/Archive/Zip/ZipHandler.cpp +++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp @@ -448,7 +448,7 @@ HRESULT CZipDecoder::Decode( ICompressProgressInfo *compressProgress, UInt32 numThreads, Int32 &res) { - res = NArchive::NExtract::NOperationResult::kDataError; + res = NExtract::NOperationResult::kDataError; CInStreamReleaser inStreamReleaser; bool needCRC = true; @@ -466,7 +466,7 @@ HRESULT CZipDecoder::Decode( } if (!pkAesMode) { - res = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + res = NExtract::NOperationResult::kUnSupportedMethod; return S_OK; } } @@ -560,7 +560,7 @@ HRESULT CZipDecoder::Decode( break; if (c >= 0x80) { - res = NArchive::NExtract::NOperationResult::kDataError; + res = NExtract::NOperationResult::kDataError; return S_OK; } charPassword += (char)c; @@ -609,7 +609,7 @@ HRESULT CZipDecoder::Decode( { if (methodId > 0xFF) { - res = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + res = NExtract::NOperationResult::kUnSupportedMethod; return S_OK; } szMethodID = kMethodId_ZipBase + (Byte)methodId; @@ -619,7 +619,7 @@ HRESULT CZipDecoder::Decode( if (mi.Coder == 0) { - res = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + res = NExtract::NOperationResult::kUnSupportedMethod; return S_OK; } } @@ -699,7 +699,7 @@ HRESULT CZipDecoder::Decode( return S_OK; if (result == E_NOTIMPL) { - res = NArchive::NExtract::NOperationResult::kUnSupportedMethod; + res = NExtract::NOperationResult::kUnSupportedMethod; return S_OK; } @@ -717,26 +717,25 @@ HRESULT CZipDecoder::Decode( } res = ((crcOK && authOk) ? - NArchive::NExtract::NOperationResult::kOK : - NArchive::NExtract::NOperationResult::kCRCError); + NExtract::NOperationResult::kOK : + NExtract::NOperationResult::kCRCError); return S_OK; } -STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, - Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback) { COM_TRY_BEGIN CZipDecoder myDecoder; - bool testMode = (_aTestMode != 0); UInt64 totalUnPacked = 0, totalPacked = 0; - bool allFilesMode = (numItems == UInt32(-1)); + bool allFilesMode = (numItems == (UInt32)-1); if (allFilesMode) numItems = m_Items.Size(); if(numItems == 0) return S_OK; UInt32 i; - for(i = 0; i < numItems; i++) + for (i = 0; i < numItems; i++) { const CItemEx &item = m_Items[allFilesMode ? i : indices[i]]; totalUnPacked += item.UnPackSize; @@ -763,8 +762,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, CMyComPtr<ISequentialOutStream> realOutStream; Int32 askMode = testMode ? - NArchive::NExtract::NAskMode::kTest : - NArchive::NExtract::NAskMode::kExtract; + NExtract::NAskMode::kTest : + NExtract::NAskMode::kExtract; Int32 index = allFilesMode ? i : indices[i]; RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); @@ -779,7 +778,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, { RINOK(extractCallback->PrepareOperation(askMode)); realOutStream.Release(); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kUnSupportedMethod)); } continue; } @@ -792,7 +791,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, { RINOK(extractCallback->PrepareOperation(askMode)); realOutStream.Release(); - RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK)); } continue; } @@ -800,7 +799,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, currentItemUnPacked = item.UnPackSize; currentItemPacked = item.PackSize; - if (!testMode && (!realOutStream)) + if (!testMode && !realOutStream) continue; RINOK(extractCallback->PrepareOperation(askMode)); diff --git a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp index 2f28d5ec..22d8eeea 100755 --- a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp +++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp @@ -112,7 +112,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt ui.NewData = IntToBool(newData); ui.IndexInArchive = indexInArchive; ui.IndexInClient = i; - bool existInArchive = (indexInArchive != UInt32(-1)); + bool existInArchive = (indexInArchive != (UInt32)-1); if (existInArchive && newData) if (m_Items[indexInArchive].IsAesEncrypted()) thereAreAesUpdates = true; diff --git a/CPP/7zip/Archive/Zip/ZipIn.cpp b/CPP/7zip/Archive/Zip/ZipIn.cpp index e396fe5b..6943c9ed 100755 --- a/CPP/7zip/Archive/Zip/ZipIn.cpp +++ b/CPP/7zip/Archive/Zip/ZipIn.cpp @@ -318,14 +318,17 @@ HRESULT CInArchive::ReadLocalItemAfterCdItem(CItemEx &item) RINOK(ReadLocalItem(localItem)); if (item.Flags != localItem.Flags) { - if ( - (item.CompressionMethod != NFileHeader::NCompressionMethod::kDeflated || - (item.Flags & 0x7FF9) != (localItem.Flags & 0x7FF9)) && - (item.CompressionMethod != NFileHeader::NCompressionMethod::kStored || - (item.Flags & 0x7FFF) != (localItem.Flags & 0x7FFF)) && - (item.CompressionMethod != NFileHeader::NCompressionMethod::kImploded || - (item.Flags & 0x7FFF) != (localItem.Flags & 0x7FFF)) - ) + UInt32 mask = 0xFFFF; + switch(item.CompressionMethod) + { + case NFileHeader::NCompressionMethod::kDeflated: + mask = 0x7FF9; + break; + default: + if (item.CompressionMethod <= NFileHeader::NCompressionMethod::kImploded) + mask = 0x7FFF; + } + if ((item.Flags & mask) != (localItem.Flags & mask)) return S_FALSE; } @@ -501,7 +504,9 @@ HRESULT CInArchive::FindCd(CCdInfo &cdInfo) UInt64 endPosition; RINOK(m_Stream->Seek(0, STREAM_SEEK_END, &endPosition)); const UInt32 kBufSizeMax = (1 << 16) + kEcdSize + kZip64EcdLocatorSize; - Byte buf[kBufSizeMax]; + CByteBuffer byteBuffer; + byteBuffer.SetCapacity(kBufSizeMax); + Byte *buf = byteBuffer; UInt32 bufSize = (endPosition < kBufSizeMax) ? (UInt32)endPosition : kBufSizeMax; if (bufSize < kEcdSize) return S_FALSE; @@ -622,10 +627,7 @@ HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt RINOK(ReadCdItem(cdItem)); if (i == 0) - { - if (cdItem.LocalHeaderPosition == 0) - m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition; - } + m_ArchiveInfo.Base = items[i].LocalHeaderPosition - cdItem.LocalHeaderPosition; int index; int left = 0, right = items.Size(); @@ -733,7 +735,15 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr items.Clear(); UInt64 cdSize, cdStartOffset; - HRESULT res = ReadCd(items, cdStartOffset, cdSize, progress); + HRESULT res; + try + { + res = ReadCd(items, cdStartOffset, cdSize, progress); + } + catch(CInArchiveException &) + { + res = S_FALSE; + } if (res != S_FALSE && res != S_OK) return res; @@ -793,7 +803,7 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr return S_FALSE; } if (m_Signature != NSignature::kEndOfCentralDir) - return S_FALSE; + return S_FALSE; const int kBufSize = kEcdSize - 4; Byte buf[kBufSize]; @@ -817,7 +827,7 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr (UInt32)ecd64.cdSize != (UInt32)cdSize || ((UInt32)(ecd64.cdStartOffset) != (UInt32)cdStartOffset && (!items.IsEmpty()))) - return S_FALSE; + return S_FALSE; _inBufMode = false; _inBuffer.Free(); diff --git a/CPP/7zip/Archive/Zip/ZipRegister.cpp b/CPP/7zip/Archive/Zip/ZipRegister.cpp index 2fd36950..3e7aade8 100755 --- a/CPP/7zip/Archive/Zip/ZipRegister.cpp +++ b/CPP/7zip/Archive/Zip/ZipRegister.cpp @@ -5,14 +5,14 @@ #include "../../Common/RegisterArc.h" #include "ZipHandler.h" -static IInArchive *CreateArc() { return new NArchive::NZip::CHandler; } +static IInArchive *CreateArc() { return new NArchive::NZip::CHandler; } #ifndef EXTRACT_ONLY -static IOutArchive *CreateArcOut() { return new NArchive::NZip::CHandler; } +static IOutArchive *CreateArcOut() { return new NArchive::NZip::CHandler; } #else #define CreateArcOut 0 #endif static CArcInfo g_ArcInfo = - { L"Zip", L"zip jar xpi odt ods docx xlsx", 0, 1, { 0x50, 0x4B, 0x03, 0x04 }, 4, false, CreateArc, CreateArcOut }; + { L"zip", L"zip jar xpi odt ods docx xlsx", 0, 1, { 0x50, 0x4B, 0x03, 0x04 }, 4, false, CreateArc, CreateArcOut }; REGISTER_ARC(Zip) diff --git a/CPP/7zip/Bundles/Alone/makefile b/CPP/7zip/Bundles/Alone/makefile index 5a8a359b..bd18aa73 100755 --- a/CPP/7zip/Bundles/Alone/makefile +++ b/CPP/7zip/Bundles/Alone/makefile @@ -1,14 +1,15 @@ PROG = 7za.exe -LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib +MY_CONSOLE = 1 CFLAGS = $(CFLAGS) -I ../../../ \ - -DWIN_LONG_PATH \ -DCOMPRESS_MT \ -DCOMPRESS_BZIP2_MT \ -DCOMPRESS_MF_MT \ - -D_7ZIP_LARGE_PAGES \ -DBREAK_HANDLER \ -DBENCH_MT \ - -DSUPPORT_DEVICE_FILE \ + +!IFNDEF UNDER_CE +CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -D_7ZIP_LARGE_PAGES -DSUPPORT_DEVICE_FILE +!ENDIF CONSOLE_OBJS = \ $O\ConsoleClose.obj \ @@ -96,6 +97,7 @@ UI_COMMON_OBJS = \ AR_OBJS = \ $O\Bz2Handler.obj \ + $O\DeflateProps.obj \ $O\GzHandler.obj \ $O\LzmaHandler.obj \ $O\SplitHandler.obj \ diff --git a/CPP/7zip/Bundles/Alone7z/makefile b/CPP/7zip/Bundles/Alone7z/makefile index c2bf482c..94d28509 100755 --- a/CPP/7zip/Bundles/Alone7z/makefile +++ b/CPP/7zip/Bundles/Alone7z/makefile @@ -1,15 +1,15 @@ PROG = 7zr.exe -LIBS = $(LIBS) user32.lib oleaut32.lib Advapi32.lib - +MY_CONSOLE = 1 CFLAGS = $(CFLAGS) -I ../../../ \ - -D_NO_CRYPTO \ - -DWIN_LONG_PATH \ -DCOMPRESS_MT \ -DCOMPRESS_MF_MT \ -D_NO_CRYPTO \ -DBREAK_HANDLER \ -DBENCH_MT \ +!IFNDEF UNDER_CE +CFLAGS = $(CFLAGS) -DWIN_LONG_PATH +!ENDIF CONSOLE_OBJS = \ $O\ConsoleClose.obj \ diff --git a/CPP/7zip/Bundles/Fm/FM.dsp b/CPP/7zip/Bundles/Fm/FM.dsp new file mode 100755 index 00000000..fa36bd66 --- /dev/null +++ b/CPP/7zip/Bundles/Fm/FM.dsp @@ -0,0 +1,1664 @@ +# Microsoft Developer Studio Project File - Name="FM" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=FM - Win32 DebugU +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "FM.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "FM.mak" CFG="FM - Win32 DebugU" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "FM - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "FM - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE "FM - Win32 ReleaseU" (based on "Win32 (x86) Application") +!MESSAGE "FM - Win32 DebugU" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "FM - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "EXTERNAL_LZMA" /Yu"StdAfx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x419 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /opt:NOWIN98 +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "FM - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "EXTERNAL_LZMA" /Yu"StdAfx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x419 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /pdbtype:sept + +!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseU" +# PROP BASE Intermediate_Dir "ReleaseU" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseU" +# PROP Intermediate_Dir "ReleaseU" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /c +# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "EXTERNAL_LZMA" /Yu"StdAfx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x419 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /opt:NOWIN98 +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "FM - Win32 DebugU" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugU" +# PROP BASE Intermediate_Dir "DebugU" +# PROP BASE Ignore_Export_Lib 0 +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugU" +# PROP Intermediate_Dir "DebugU" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c +# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /D "EXTERNAL_LZMA" /Yu"StdAfx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x419 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib Mpr.lib htmlhelp.lib Urlmon.lib /nologo /subsystem:windows /debug /machine:I386 /out:"C:\Program Files\7-ZIP\7zFM.exe" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "FM - Win32 Release" +# Name "FM - Win32 Debug" +# Name "FM - Win32 ReleaseU" +# Name "FM - Win32 DebugU" +# Begin Group "Spec" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\UI\FileManager\7zipLogo.ico +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\add.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ClassDefs.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Copy.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Delete.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Extract.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FM.ico +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Move.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Parent.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Properties.bmp +# End Source File +# Begin Source File + +SOURCE=.\resource.rc +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\StdAfx.cpp +# ADD CPP /Yc"StdAfx.h" +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Test.bmp +# End Source File +# End Group +# Begin Group "Archive" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\Archive\IArchive.h +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\Common\OutStreamWithCRC.h +# End Source File +# End Group +# Begin Group "Folders" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\UI\FileManager\FSDrives.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FSDrives.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FSFolder.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FSFolder.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FSFolderCopy.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\IFolder.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\NetFolder.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\NetFolder.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\RootFolder.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\RootFolder.h +# End Source File +# End Group +# Begin Group "Registry" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\UI\FileManager\RegistryAssociations.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\RegistryAssociations.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\RegistryPlugins.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\RegistryPlugins.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\RegistryUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\RegistryUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ViewSettings.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ViewSettings.h +# End Source File +# End Group +# Begin Group "Panel" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\UI\FileManager\App.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\App.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\AppState.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\EnumFormatEtc.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\EnumFormatEtc.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FileFolderPluginOpen.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FileFolderPluginOpen.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Panel.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Panel.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelCopy.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelCrc.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelDrag.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelFolderChange.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelItemOpen.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelItems.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelKey.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelListNotify.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelMenu.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelOperations.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelSelect.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelSort.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PanelSplitFile.cpp +# End Source File +# End Group +# Begin Group "Dialog" + +# PROP Default_Filter "" +# Begin Group "Options" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\UI\FileManager\EditPage.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\EditPage.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FoldersPage.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FoldersPage.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\LangPage.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\LangPage.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\MenuPage.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\MenuPage.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\OptionsDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PluginsPage.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PluginsPage.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\SettingsPage.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\SettingsPage.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\SystemPage.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\SystemPage.h +# End Source File +# End Group +# Begin Source File + +SOURCE=..\..\UI\FileManager\AboutDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\AboutDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\BrowseDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\BrowseDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ComboDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ComboDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\CopyDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\CopyDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\DialogSize.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ListViewDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ListViewDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\MessagesDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\MessagesDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\OverwriteDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\OverwriteDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PasswordDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PasswordDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ProgressDialog2.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ProgressDialog2.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\SplitDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\SplitDialog.h +# End Source File +# End Group +# Begin Group "FM Common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\UI\FileManager\ExtractCallback.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ExtractCallback.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FormatUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FormatUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\HelpUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\HelpUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\LangUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\LangUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ProgramLocation.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\ProgramLocation.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\UpdateCallback100.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\UpdateCallback100.h +# End Source File +# End Group +# Begin Group "7-Zip Common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\Common\FilePathAutoRename.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Common\FilePathAutoRename.h +# End Source File +# Begin Source File + +SOURCE=..\..\Common\FileStreams.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Common\FileStreams.h +# End Source File +# Begin Source File + +SOURCE=..\..\Common\ProgressUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Common\ProgressUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\Common\StreamObjects.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Common\StreamObjects.h +# End Source File +# Begin Source File + +SOURCE=..\..\Common\StreamUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Common\StreamUtils.h +# End Source File +# End Group +# Begin Group "C" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\..\..\C\7zCrc.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\7zCrc.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Alloc.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Alloc.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Sha256.c + +!IF "$(CFG)" == "FM - Win32 Release" + +# ADD CPP /O2 +# SUBTRACT CPP /YX /Yc /Yu + +!ELSEIF "$(CFG)" == "FM - Win32 Debug" + +# SUBTRACT CPP /YX /Yc /Yu + +!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU" + +# SUBTRACT CPP /YX /Yc /Yu + +!ELSEIF "$(CFG)" == "FM - Win32 DebugU" + +# SUBTRACT CPP /YX /Yc /Yu + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Sha256.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Sort.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Sort.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Threads.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Threads.h +# End Source File +# End Group +# Begin Group "Windows" + +# PROP Default_Filter "" +# Begin Group "Control" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\..\Windows\Control\ComboBox.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\ComboBox.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\CommandBar.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\Dialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\Dialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\Edit.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\ImageList.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\ListView.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\ListView.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\ProgressBar.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\PropertyPage.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\PropertyPage.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\ReBar.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\Static.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\StatusBar.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\ToolBar.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\Trackbar.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\Window2.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\Window2.h +# End Source File +# End Group +# Begin Source File + +SOURCE=..\..\..\Windows\Clipboard.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Clipboard.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\COM.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\CommonDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\CommonDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Defs.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Device.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\DLL.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\DLL.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Error.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Error.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\FileDir.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\FileDir.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\FileFind.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\FileFind.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\FileIO.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\FileIO.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\FileMapping.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\FileName.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\FileName.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\FileSystem.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\FileSystem.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Handle.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Memory.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Memory.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\MemoryLock.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\MemoryLock.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Menu.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Menu.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Net.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Net.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Process.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Process.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\PropVariant.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\PropVariant.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\PropVariantConversions.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\PropVariantConversions.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Registry.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Registry.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\ResourceString.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\ResourceString.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Security.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Security.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Shell.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Shell.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Synchronization.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Synchronization.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\System.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\System.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Thread.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Time.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Time.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Timer.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Window.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Window.h +# End Source File +# End Group +# Begin Group "Common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\..\Common\Buffer.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\CommandLineParser.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\CommandLineParser.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\ComTry.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\CRC.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Defs.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\DynamicBuffer.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Exception.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\IntToString.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\IntToString.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Lang.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Lang.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\ListFileUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\ListFileUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\MyCom.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\MyString.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\MyString.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\MyVector.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\MyVector.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\NewHandler.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\NewHandler.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Random.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Random.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\StringConvert.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\StringConvert.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\StringToInt.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\StringToInt.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\TextConfig.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\TextConfig.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Types.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\UTFConvert.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\UTFConvert.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Wildcard.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Wildcard.h +# End Source File +# End Group +# Begin Group "UI" + +# PROP Default_Filter "" +# Begin Group "UI Common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\UI\Common\ArchiveCommandLine.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ArchiveCommandLine.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ArchiveExtractCallback.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ArchiveExtractCallback.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ArchiveName.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ArchiveName.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ArchiveOpenCallback.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ArchiveOpenCallback.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\CompressCall.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\CompressCall2.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\DefaultName.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\DefaultName.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\DirItem.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\EnumDirItems.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\EnumDirItems.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ExitCode.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\Extract.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\Extract.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ExtractingFilePath.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ExtractingFilePath.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ExtractMode.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\IFileExtractCallback.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\LoadCodecs.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\LoadCodecs.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\OpenArchive.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\OpenArchive.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\Property.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\PropIDUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\PropIDUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\SetProperties.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\SetProperties.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\SortUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\SortUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\TempFiles.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\TempFiles.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\Update.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\Update.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\UpdateAction.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\UpdateAction.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\UpdateCallback.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\UpdateCallback.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\UpdatePair.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\UpdatePair.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\UpdateProduce.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\UpdateProduce.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\WorkDir.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\WorkDir.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ZipRegistry.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Common\ZipRegistry.h +# End Source File +# End Group +# Begin Group "Agent" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\UI\Agent\Agent.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Agent\Agent.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Agent\AgentOut.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Agent\AgentProxy.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Agent\AgentProxy.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Agent\ArchiveFolder.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Agent\ArchiveFolderOpen.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Agent\ArchiveFolderOut.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Agent\IFolderArchive.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Agent\UpdateCallbackAgent.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Agent\UpdateCallbackAgent.h +# End Source File +# End Group +# Begin Group "Explorer" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\UI\Explorer\ContextMenu.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Explorer\ContextMenu.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Explorer\MyMessages.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Explorer\MyMessages.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Explorer\RegistryContextMenu.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\Explorer\RegistryContextMenu.h +# End Source File +# End Group +# Begin Group "GUI" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\UI\GUI\BenchmarkDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\BenchmarkDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\BenchmarkDialogRes.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\CompressDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\CompressDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\ExtractDialog.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\ExtractDialog.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\ExtractGUI.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\ExtractGUI.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\UpdateCallbackGUI.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\UpdateCallbackGUI.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\UpdateGUI.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\GUI\UpdateGUI.h +# End Source File +# End Group +# End Group +# Begin Group "Compress" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\Compress\CopyCoder.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Compress\CopyCoder.h +# End Source File +# Begin Source File + +SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Compress\LZMA_Alone\LzmaBench.h +# End Source File +# End Group +# Begin Group "Interface" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\ICoder.h +# End Source File +# Begin Source File + +SOURCE=..\..\IDecl.h +# End Source File +# Begin Source File + +SOURCE=..\..\IPassword.h +# End Source File +# Begin Source File + +SOURCE=..\..\IProgress.h +# End Source File +# End Group +# Begin Source File + +SOURCE=..\..\UI\FileManager\7zFM.exe.manifest +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\7zipLogo.ico +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Add2.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Copy2.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Delete2.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Extract2.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FilePlugins.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FilePlugins.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\FM.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Info.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Info2.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Move2.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\MyCom2.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\MyLoadMenu.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\MyLoadMenu.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\OpenCallback.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\OpenCallback.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PluginInterface.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PluginLoader.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PropertyName.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\PropertyName.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\resource.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\SplitUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\SplitUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\StringUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\StringUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\SysIconUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\SysIconUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\Test2.bmp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\TextPairs.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\UI\FileManager\TextPairs.h +# End Source File +# End Target +# End Project diff --git a/CPP/7zip/Bundles/Fm/FM.dsw b/CPP/7zip/Bundles/Fm/FM.dsw new file mode 100755 index 00000000..1c955d95 --- /dev/null +++ b/CPP/7zip/Bundles/Fm/FM.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "FM"=.\FM.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/CPP/7zip/Bundles/Fm/StdAfx.cpp b/CPP/7zip/Bundles/Fm/StdAfx.cpp new file mode 100755 index 00000000..d0feea85 --- /dev/null +++ b/CPP/7zip/Bundles/Fm/StdAfx.cpp @@ -0,0 +1,3 @@ +// StdAfx.cpp + +#include "StdAfx.h" diff --git a/CPP/7zip/Bundles/Fm/StdAfx.h b/CPP/7zip/Bundles/Fm/StdAfx.h new file mode 100755 index 00000000..b09de592 --- /dev/null +++ b/CPP/7zip/Bundles/Fm/StdAfx.h @@ -0,0 +1,23 @@ +// stdafx.h + +#ifndef __STDAFX_H +#define __STDAFX_H + +#define _WIN32_WINNT 0x0400 + +// it's for Windows NT supporting (MENUITEMINFOW) +#define WINVER 0x0400 + +#include <windows.h> +#include <stdio.h> +#include <commctrl.h> +#include <ShlObj.h> +#include <limits.h> +#include <tchar.h> +#include <shlwapi.h> + +// #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include "Common/NewHandler.h" + +#endif diff --git a/CPP/7zip/Bundles/Fm/makefile b/CPP/7zip/Bundles/Fm/makefile new file mode 100755 index 00000000..47bc8eb3 --- /dev/null +++ b/CPP/7zip/Bundles/Fm/makefile @@ -0,0 +1,533 @@ +PROG = 7zFM.exe +CFLAGS = $(CFLAGS) -I ../../../ \ + -DLANG \ + -DNEW_FOLDER_INTERFACE \ + -DEXTERNAL_CODECS \ + -DCOMPRESS_MT \ + -DCOMPRESS_BZIP2_MT \ + -DCOMPRESS_MF_MT \ + +!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 + +FM_OBJS = \ + $O\App.obj \ + $O\BrowseDialog.obj \ + $O\ClassDefs.obj \ + $O\EnumFormatEtc.obj \ + $O\ExtractCallback.obj \ + $O\FileFolderPluginOpen.obj \ + $O\FilePlugins.obj \ + $O\FM.obj \ + $O\FoldersPage.obj \ + $O\FormatUtils.obj \ + $O\FSFolder.obj \ + $O\FSFolderCopy.obj \ + $O\HelpUtils.obj \ + $O\LangUtils.obj \ + $O\MenuPage.obj \ + $O\MyLoadMenu.obj \ + $O\OpenCallback.obj \ + $O\OptionsDialog.obj \ + $O\Panel.obj \ + $O\PanelCopy.obj \ + $O\PanelCrc.obj \ + $O\PanelDrag.obj \ + $O\PanelFolderChange.obj \ + $O\PanelItemOpen.obj \ + $O\PanelItems.obj \ + $O\PanelKey.obj \ + $O\PanelListNotify.obj \ + $O\PanelMenu.obj \ + $O\PanelOperations.obj \ + $O\PanelSelect.obj \ + $O\PanelSort.obj \ + $O\PanelSplitFile.obj \ + $O\ProgramLocation.obj \ + $O\PropertyName.obj \ + $O\RegistryAssociations.obj \ + $O\RegistryPlugins.obj \ + $O\RegistryUtils.obj \ + $O\RootFolder.obj \ + $O\SplitUtils.obj \ + $O\StringUtils.obj \ + $O\SysIconUtils.obj \ + $O\TextPairs.obj \ + $O\UpdateCallback100.obj \ + $O\ViewSettings.obj \ + $O\AboutDialog.obj \ + $O\ComboDialog.obj \ + $O\CopyDialog.obj \ + $O\EditPage.obj \ + $O\LangPage.obj \ + $O\ListViewDialog.obj \ + $O\MessagesDialog.obj \ + $O\OverwriteDialog.obj \ + $O\PasswordDialog.obj \ + $O\PluginsPage.obj \ + $O\ProgressDialog2.obj \ + $O\SettingsPage.obj \ + $O\SplitDialog.obj \ + $O\SystemPage.obj \ + +COMMON_OBJS = \ + $O\CommandLineParser.obj \ + $O\CRC.obj \ + $O\IntToString.obj \ + $O\Lang.obj \ + $O\ListFileUtils.obj \ + $O\MyMap.obj \ + $O\MyString.obj \ + $O\MyVector.obj \ + $O\MyXml.obj \ + $O\NewHandler.obj \ + $O\Random.obj \ + $O\StringConvert.obj \ + $O\StringToInt.obj \ + $O\TextConfig.obj \ + $O\UTFConvert.obj \ + $O\Wildcard.obj \ + +WIN_OBJS = \ + $O\Clipboard.obj \ + $O\DLL.obj \ + $O\Error.obj \ + $O\FileDir.obj \ + $O\FileFind.obj \ + $O\FileIO.obj \ + $O\FileName.obj \ + $O\Memory.obj \ + $O\MemoryLock.obj \ + $O\Menu.obj \ + $O\Process.obj \ + $O\PropVariant.obj \ + $O\PropVariantConversions.obj \ + $O\PropVariantUtils.obj \ + $O\Registry.obj \ + $O\ResourceString.obj \ + $O\Shell.obj \ + $O\Synchronization.obj \ + $O\System.obj \ + $O\Time.obj \ + $O\Window.obj \ + +!IFNDEF UNDER_CE + +FM_OBJS = $(FM_OBJS) \ + $O\FSDrives.obj \ + $O\NetFolder.obj \ + +WIN_OBJS = $(WIN_OBJS) \ + $O\CommonDialog.obj \ + $O\FileSystem.obj \ + $O\Net.obj \ + $O\Security.obj \ + +!ENDIF + + +WIN_CTRL_OBJS = \ + $O\ComboBox.obj \ + $O\Dialog.obj \ + $O\ListView.obj \ + $O\PropertyPage.obj \ + $O\Window2.obj \ + +7ZIP_COMMON_OBJS = \ + $O\CreateCoder.obj \ + $O\CWrappers.obj \ + $O\FilePathAutoRename.obj \ + $O\FileStreams.obj \ + $O\FilterCoder.obj \ + $O\InBuffer.obj \ + $O\InOutTempBuffer.obj \ + $O\LimitedStreams.obj \ + $O\LockedStream.obj \ + $O\MemBlocks.obj \ + $O\MethodId.obj \ + $O\MethodProps.obj \ + $O\OffsetStream.obj \ + $O\OutBuffer.obj \ + $O\OutMemStream.obj \ + $O\ProgressMt.obj \ + $O\ProgressUtils.obj \ + $O\StreamBinder.obj \ + $O\StreamObjects.obj \ + $O\StreamUtils.obj \ + $O\VirtThread.obj \ + +AR_OBJS = \ + $O\ArjHandler.obj \ + $O\Bz2Handler.obj \ + $O\CpioHandler.obj \ + $O\DebHandler.obj \ + $O\DeflateProps.obj \ + $O\DmgHandler.obj \ + $O\ElfHandler.obj \ + $O\FatHandler.obj \ + $O\FlvHandler.obj \ + $O\GzHandler.obj \ + $O\LzhHandler.obj \ + $O\LzmaHandler.obj \ + $O\MachoHandler.obj \ + $O\MbrHandler.obj \ + $O\MslzHandler.obj \ + $O\MubHandler.obj \ + $O\NtfsHandler.obj \ + $O\PeHandler.obj \ + $O\RpmHandler.obj \ + $O\SplitHandler.obj \ + $O\SwfHandler.obj \ + $O\VhdHandler.obj \ + $O\XarHandler.obj \ + $O\XzHandler.obj \ + $O\ZHandler.obj \ + +AR_COMMON_OBJS = \ + $O\CoderMixer2.obj \ + $O\CoderMixer2MT.obj \ + $O\CrossThreadProgress.obj \ + $O\DummyOutStream.obj \ + $O\FindSignature.obj \ + $O\InStreamWithCRC.obj \ + $O\ItemNameUtils.obj \ + $O\MultiStream.obj \ + $O\OutStreamWithCRC.obj \ + $O\OutStreamWithSha1.obj \ + $O\HandlerOut.obj \ + $O\ParseProperties.obj \ + +UI_COMMON_OBJS = \ + $O\ArchiveCommandLine.obj \ + $O\ArchiveExtractCallback.obj \ + $O\ArchiveName.obj \ + $O\ArchiveOpenCallback.obj \ + $O\CompressCall2.obj \ + $O\DefaultName.obj \ + $O\EnumDirItems.obj \ + $O\Extract.obj \ + $O\ExtractingFilePath.obj \ + $O\LoadCodecs.obj \ + $O\OpenArchive.obj \ + $O\PropIDUtils.obj \ + $O\SetProperties.obj \ + $O\SortUtils.obj \ + $O\TempFiles.obj \ + $O\Update.obj \ + $O\UpdateAction.obj \ + $O\UpdateCallback.obj \ + $O\UpdatePair.obj \ + $O\UpdateProduce.obj \ + $O\WorkDir.obj \ + $O\ZipRegistry.obj \ + +AGENT_OBJS = \ + $O\Agent.obj \ + $O\AgentOut.obj \ + $O\AgentProxy.obj \ + $O\ArchiveFolder.obj \ + $O\ArchiveFolderOpen.obj \ + $O\ArchiveFolderOut.obj \ + $O\UpdateCallbackAgent.obj \ + +EXPLORER_OBJS = \ + $O\ContextMenu.obj \ + $O\MyMessages.obj \ + $O\RegistryContextMenu.obj \ + +GUI_OBJS = \ + $O\BenchmarkDialog.obj \ + $O\CompressDialog.obj \ + $O\ExtractDialog.obj \ + $O\ExtractGUI.obj \ + $O\UpdateCallbackGUI.obj \ + $O\UpdateGUI.obj \ + + +7Z_OBJS = \ + $O\7zCompressionMode.obj \ + $O\7zDecode.obj \ + $O\7zEncode.obj \ + $O\7zExtract.obj \ + $O\7zFolderInStream.obj \ + $O\7zFolderOutStream.obj \ + $O\7zHandler.obj \ + $O\7zHandlerOut.obj \ + $O\7zHeader.obj \ + $O\7zIn.obj \ + $O\7zOut.obj \ + $O\7zProperties.obj \ + $O\7zSpecStream.obj \ + $O\7zUpdate.obj \ + $O\7zRegister.obj \ + +CAB_OBJS = \ + $O\CabBlockInStream.obj \ + $O\CabHandler.obj \ + $O\CabHeader.obj \ + $O\CabIn.obj \ + $O\CabRegister.obj \ + +CHM_OBJS = \ + $O\ChmHandler.obj \ + $O\ChmHeader.obj \ + $O\ChmIn.obj \ + $O\ChmRegister.obj \ + +COM_OBJS = \ + $O\ComHandler.obj \ + $O\ComIn.obj \ + $O\ComRegister.obj \ + +HFS_OBJS = \ + $O\HfsHandler.obj \ + $O\HfsIn.obj \ + $O\HfsRegister.obj \ + +ISO_OBJS = \ + $O\IsoHandler.obj \ + $O\IsoHeader.obj \ + $O\IsoIn.obj \ + $O\IsoRegister.obj \ + +NSIS_OBJS = \ + $O\NsisDecode.obj \ + $O\NsisHandler.obj \ + $O\NsisIn.obj \ + $O\NsisRegister.obj \ + +RAR_OBJS = \ + $O\RarHandler.obj \ + $O\RarHeader.obj \ + $O\RarIn.obj \ + $O\RarItem.obj \ + $O\RarVolumeInStream.obj \ + $O\RarRegister.obj \ + +TAR_OBJS = \ + $O\TarHandler.obj \ + $O\TarHandlerOut.obj \ + $O\TarHeader.obj \ + $O\TarIn.obj \ + $O\TarOut.obj \ + $O\TarUpdate.obj \ + $O\TarRegister.obj \ + +UDF_OBJS = \ + $O\UdfHandler.obj \ + $O\UdfIn.obj \ + $O\UdfRegister.obj \ + +WIM_OBJS = \ + $O\WimHandler.obj \ + $O\WimIn.obj \ + $O\WimRegister.obj \ + +ZIP_OBJS = \ + $O\ZipAddCommon.obj \ + $O\ZipHandler.obj \ + $O\ZipHandlerOut.obj \ + $O\ZipHeader.obj \ + $O\ZipIn.obj \ + $O\ZipItem.obj \ + $O\ZipOut.obj \ + $O\ZipUpdate.obj \ + $O\ZipRegister.obj \ + +COMPRESS_OBJS = \ + $O\ArjDecoder1.obj \ + $O\ArjDecoder2.obj \ + $O\Bcj2Coder.obj \ + $O\Bcj2Register.obj \ + $O\BcjCoder.obj \ + $O\BcjRegister.obj \ + $O\BitlDecoder.obj \ + $O\BranchCoder.obj \ + $O\BranchMisc.obj \ + $O\BranchRegister.obj \ + $O\ByteSwap.obj \ + $O\BZip2Crc.obj \ + $O\BZip2Decoder.obj \ + $O\BZip2Encoder.obj \ + $O\BZip2Register.obj \ + $O\CopyCoder.obj \ + $O\CopyRegister.obj \ + $O\Deflate64Register.obj \ + $O\DeflateDecoder.obj \ + $O\DeflateEncoder.obj \ + $O\DeflateNsisRegister.obj \ + $O\DeflateRegister.obj \ + $O\DeltaFilter.obj \ + $O\ImplodeDecoder.obj \ + $O\ImplodeHuffmanDecoder.obj \ + $O\LzhDecoder.obj \ + $O\Lzma2Decoder.obj \ + $O\Lzma2Encoder.obj \ + $O\Lzma2Register.obj \ + $O\LzmaDecoder.obj \ + $O\LzmaEncoder.obj \ + $O\LzmaRegister.obj \ + $O\LzOutWindow.obj \ + $O\Lzx86Converter.obj \ + $O\LzxDecoder.obj \ + $O\PpmdDecoder.obj \ + $O\PpmdEncoder.obj \ + $O\PpmdRegister.obj \ + $O\QuantumDecoder.obj \ + $O\Rar1Decoder.obj \ + $O\Rar2Decoder.obj \ + $O\Rar3Decoder.obj \ + $O\Rar3Vm.obj \ + $O\RarCodecsRegister.obj \ + $O\ShrinkDecoder.obj \ + $O\ZlibDecoder.obj \ + $O\ZlibEncoder.obj \ + $O\ZDecoder.obj \ + +LZMA_BENCH_OBJS = \ + $O\LzmaBench.obj \ + +CRYPTO_OBJS = \ + $O\7zAes.obj \ + $O\7zAesRegister.obj \ + $O\HmacSha1.obj \ + $O\MyAes.obj \ + $O\Pbkdf2HmacSha1.obj \ + $O\RandGen.obj \ + $O\Rar20Crypto.obj \ + $O\RarAes.obj \ + $O\Sha1.obj \ + $O\WzAes.obj \ + $O\ZipCrypto.obj \ + $O\ZipStrong.obj \ + + +C_OBJS = \ + $O\7zBuf2.obj \ + $O\7zStream.obj \ + $O\Aes.obj \ + $O\Alloc.obj \ + $O\Bra.obj \ + $O\Bra86.obj \ + $O\BraIA64.obj \ + $O\BwtSort.obj \ + $O\Delta.obj \ + $O\HuffEnc.obj \ + $O\LzFind.obj \ + $O\LzFindMt.obj \ + $O\Lzma2Dec.obj \ + $O\Lzma2Enc.obj \ + $O\LzmaDec.obj \ + $O\LzmaEnc.obj \ + $O\MtCoder.obj \ + $O\Sha256.obj \ + $O\Sort.obj \ + $O\Threads.obj \ + $O\Xz.obj \ + $O\XzCrc64.obj \ + $O\XzDec.obj \ + $O\XzEnc.obj \ + $O\XzIn.obj \ + +!include "../../Crc2.mak" + +OBJS = \ + $O\StdAfx.obj \ + $(FM_OBJS)\ + $(COMMON_OBJS) \ + $(WIN_OBJS) \ + $(WIN_CTRL_OBJS) \ + $(7ZIP_COMMON_OBJS) \ + $(AR_OBJS) \ + $(AR_COMMON_OBJS) \ + $(UI_COMMON_OBJS) \ + $(AGENT_OBJS) \ + $(EXPLORER_OBJS) \ + $(GUI_OBJS) \ + $(7Z_OBJS) \ + $(CAB_OBJS) \ + $(CHM_OBJS) \ + $(COM_OBJS) \ + $(HFS_OBJS) \ + $(ISO_OBJS) \ + $(NSIS_OBJS) \ + $(RAR_OBJS) \ + $(TAR_OBJS) \ + $(UDF_OBJS) \ + $(WIM_OBJS) \ + $(ZIP_OBJS) \ + $(COMPRESS_OBJS) \ + $(LZMA_BENCH_OBJS) \ + $(CRYPTO_OBJS) \ + $(CRC_OBJS) \ + $(C_OBJS) \ + $O\resource.res \ + +!include "../../../Build.mak" + +$(FM_OBJS): ../../UI/FileManager/$(*B).cpp + $(COMPL) +$(COMMON_OBJS): ../../../Common/$(*B).cpp + $(COMPL) +$(WIN_OBJS): ../../../Windows/$(*B).cpp + $(COMPL) +$(WIN_CTRL_OBJS): ../../../Windows/Control/$(*B).cpp + $(COMPL) +$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp + $(COMPL) + +$(AR_OBJS): ../../Archive/$(*B).cpp + $(COMPL) +$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp + $(COMPL) + +$(7Z_OBJS): ../../Archive/7z/$(*B).cpp + $(COMPL) +$(CAB_OBJS): ../../Archive/Cab/$(*B).cpp + $(COMPL) +$(CHM_OBJS): ../../Archive/Chm/$(*B).cpp + $(COMPL) +$(COM_OBJS): ../../Archive/Com/$(*B).cpp + $(COMPL) +$(HFS_OBJS): ../../Archive/Hfs/$(*B).cpp + $(COMPL) +$(ISO_OBJS): ../../Archive/Iso/$(*B).cpp + $(COMPL) +$(NSIS_OBJS): ../../Archive/Nsis/$(*B).cpp + $(COMPL) +$(RAR_OBJS): ../../Archive/Rar/$(*B).cpp + $(COMPL) +$(TAR_OBJS): ../../Archive/Tar/$(*B).cpp + $(COMPL) +$(UDF_OBJS): ../../Archive/Udf/$(*B).cpp + $(COMPL) +$(WIM_OBJS): ../../Archive/Wim/$(*B).cpp + $(COMPL) +$(ZIP_OBJS): ../../Archive/Zip/$(*B).cpp + $(COMPL) + +$(COMPRESS_OBJS): ../../Compress/$(*B).cpp + $(COMPL_O2) +$(LZMA_BENCH_OBJS): ../../Compress/LZMA_Alone/$(*B).cpp + $(COMPL) + +$(CRYPTO_OBJS): ../../Crypto/$(*B).cpp + $(COMPL_O2) + +$(UI_COMMON_OBJS): ../../UI/Common/$(*B).cpp + $(COMPL) +$(AGENT_OBJS): ../../UI/Agent/$(*B).cpp + $(COMPL) +$(EXPLORER_OBJS): ../../UI/Explorer/$(*B).cpp + $(COMPL) +$(GUI_OBJS): ../../UI/GUI/$(*B).cpp + $(COMPL) + +$(C_OBJS): ../../../../C/$(*B).c + $(COMPL_O2) + +!include "../../Crc.mak" diff --git a/CPP/7zip/Bundles/Fm/resource.rc b/CPP/7zip/Bundles/Fm/resource.rc new file mode 100755 index 00000000..c2aab047 --- /dev/null +++ b/CPP/7zip/Bundles/Fm/resource.rc @@ -0,0 +1,7 @@ +#include "../../UI/FileManager/resource.rc" +#include "../../UI/GUI/resource2.rc" + +STRINGTABLE +BEGIN + 100 "7z zip bz2 bzip2 tbz2 tbz rar arj z taz lzh lha cab iso 001 rpm deb cpio tar gz gzip tgz tpz4 wim swm lzma dmg hfs xar vhd fat ntfs xz" +END diff --git a/CPP/7zip/Bundles/Format7z/makefile b/CPP/7zip/Bundles/Format7z/makefile index e26aeadd..a475bf9b 100755 --- a/CPP/7zip/Bundles/Format7z/makefile +++ b/CPP/7zip/Bundles/Format7z/makefile @@ -1,6 +1,5 @@ PROG = 7za.dll DEF_FILE = ../../Archive/Archive2.def -LIBS = $(LIBS) user32.lib oleaut32.lib CFLAGS = $(CFLAGS) -I ../../../ \ -DCOMPRESS_MT \ -DCOMPRESS_MF_MT \ diff --git a/CPP/7zip/Bundles/Format7zExtract/makefile b/CPP/7zip/Bundles/Format7zExtract/makefile index c2dd4f7f..d082a007 100755 --- a/CPP/7zip/Bundles/Format7zExtract/makefile +++ b/CPP/7zip/Bundles/Format7zExtract/makefile @@ -1,6 +1,5 @@ PROG = 7zxa.dll DEF_FILE = ../../Archive/Archive2.def -LIBS = $(LIBS) user32.lib oleaut32.lib CFLAGS = $(CFLAGS) -I ../../../ \ -DEXTRACT_ONLY \ -DCOMPRESS_MT \ @@ -17,9 +16,6 @@ COMMON_OBJS = \ $O\Wildcard.obj \ WIN_OBJS = \ - $O\FileDir.obj \ - $O\FileFind.obj \ - $O\FileIO.obj \ $O\PropVariant.obj \ $O\Synchronization.obj \ $O\System.obj \ @@ -28,7 +24,6 @@ WIN_OBJS = \ $O\CreateCoder.obj \ $O\CWrappers.obj \ $O\InBuffer.obj \ - $O\InOutTempBuffer.obj \ $O\FilterCoder.obj \ $O\LimitedStreams.obj \ $O\LockedStream.obj \ diff --git a/CPP/7zip/Bundles/Format7zExtractR/makefile b/CPP/7zip/Bundles/Format7zExtractR/makefile index 9f06ca5a..5c5a9187 100755 --- a/CPP/7zip/Bundles/Format7zExtractR/makefile +++ b/CPP/7zip/Bundles/Format7zExtractR/makefile @@ -1,6 +1,5 @@ PROG = 7zxr.dll DEF_FILE = ../../Archive/Archive2.def -LIBS = $(LIBS) user32.lib oleaut32.lib CFLAGS = $(CFLAGS) -I ../../../ \ -DEXTRACT_ONLY \ -DCOMPRESS_MT \ @@ -17,9 +16,6 @@ COMMON_OBJS = \ $O\Wildcard.obj \ WIN_OBJS = \ - $O\FileDir.obj \ - $O\FileFind.obj \ - $O\FileIO.obj \ $O\PropVariant.obj \ $O\Synchronization.obj \ $O\System.obj \ @@ -28,7 +24,6 @@ WIN_OBJS = \ $O\CreateCoder.obj \ $O\CWrappers.obj \ $O\InBuffer.obj \ - $O\InOutTempBuffer.obj \ $O\FilterCoder.obj \ $O\LimitedStreams.obj \ $O\LockedStream.obj \ diff --git a/CPP/7zip/Bundles/Format7zF/Format7z.dsp b/CPP/7zip/Bundles/Format7zF/Format7z.dsp index 33caaf95..8785faaf 100755 --- a/CPP/7zip/Bundles/Format7zF/Format7z.dsp +++ b/CPP/7zip/Bundles/Format7zF/Format7z.dsp @@ -234,6 +234,10 @@ SOURCE=..\..\..\Common\CRC.cpp # End Source File # Begin Source File +SOURCE=..\..\..\Common\DynamicBuffer.h +# End Source File +# Begin Source File + SOURCE=..\..\..\Common\IntToString.cpp # End Source File # Begin Source File @@ -555,6 +559,14 @@ SOURCE=..\..\Compress\ZlibDecoder.cpp SOURCE=..\..\Compress\ZlibDecoder.h # End Source File +# Begin Source File + +SOURCE=..\..\Compress\ZlibEncoder.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Compress\ZlibEncoder.h +# End Source File # End Group # Begin Group "7z Compress" @@ -2179,6 +2191,14 @@ SOURCE=..\..\Archive\DebHandler.cpp # End Source File # Begin Source File +SOURCE=..\..\Archive\DeflateProps.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Archive\DeflateProps.h +# End Source File +# Begin Source File + SOURCE=..\..\Archive\DmgHandler.cpp # End Source File # Begin Source File @@ -2191,6 +2211,10 @@ SOURCE=..\..\Archive\FatHandler.cpp # End Source File # Begin Source File +SOURCE=..\..\Archive\FlvHandler.cpp +# End Source File +# Begin Source File + SOURCE=..\..\Archive\GzHandler.cpp # End Source File # Begin Source File @@ -2215,6 +2239,10 @@ SOURCE=..\..\Archive\MbrHandler.cpp # End Source File # Begin Source File +SOURCE=..\..\Archive\MslzHandler.cpp +# End Source File +# Begin Source File + SOURCE=..\..\Archive\MubHandler.cpp # End Source File # Begin Source File @@ -2235,6 +2263,10 @@ SOURCE=..\..\Archive\SplitHandler.cpp # End Source File # Begin Source File +SOURCE=..\..\Archive\SwfHandler.cpp +# End Source File +# Begin Source File + SOURCE=..\..\Archive\VhdHandler.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/Bundles/Format7zF/makefile b/CPP/7zip/Bundles/Format7zF/makefile index a1f09365..7c35791e 100755 --- a/CPP/7zip/Bundles/Format7zF/makefile +++ b/CPP/7zip/Bundles/Format7zF/makefile @@ -1,23 +1,25 @@ PROG = 7z.dll DEF_FILE = ../../Archive/Archive2.def -LIBS = $(LIBS) user32.lib oleaut32.lib CFLAGS = $(CFLAGS) -I ../../../ \ -DEXTERNAL_CODECS \ -DCOMPRESS_MT \ -DCOMPRESS_BZIP2_MT \ -DCOMPRESS_MF_MT \ - -D_7ZIP_LARGE_PAGES \ + +!IFNDEF UNDER_CE +CFLAGS = $(CFLAGS) -D_7ZIP_LARGE_PAGES +!ENDIF COMMON_OBJS = \ $O\CRC.obj \ $O\IntToString.obj \ - $O\NewHandler.obj \ $O\MyMap.obj \ $O\MyString.obj \ + $O\MyVector.obj \ $O\MyXml.obj \ + $O\NewHandler.obj \ $O\StringConvert.obj \ $O\StringToInt.obj \ - $O\MyVector.obj \ $O\UTFConvert.obj \ $O\Wildcard.obj \ @@ -32,16 +34,16 @@ WIN_OBJS = \ $O\Time.obj \ 7ZIP_COMMON_OBJS = \ - $O\InBuffer.obj \ - $O\InOutTempBuffer.obj \ $O\CreateCoder.obj \ $O\CWrappers.obj \ + $O\InBuffer.obj \ + $O\InOutTempBuffer.obj \ $O\FilterCoder.obj \ $O\LimitedStreams.obj \ $O\LockedStream.obj \ + $O\MemBlocks.obj \ $O\MethodId.obj \ $O\MethodProps.obj \ - $O\MemBlocks.obj \ $O\OffsetStream.obj \ $O\OutBuffer.obj \ $O\OutMemStream.obj \ @@ -59,19 +61,23 @@ AR_OBJS = \ $O\Bz2Handler.obj \ $O\CpioHandler.obj \ $O\DebHandler.obj \ + $O\DeflateProps.obj \ $O\DmgHandler.obj \ $O\ElfHandler.obj \ $O\FatHandler.obj \ + $O\FlvHandler.obj \ $O\GzHandler.obj \ $O\LzhHandler.obj \ $O\LzmaHandler.obj \ $O\MachoHandler.obj \ $O\MbrHandler.obj \ + $O\MslzHandler.obj \ $O\MubHandler.obj \ $O\NtfsHandler.obj \ $O\PeHandler.obj \ $O\RpmHandler.obj \ $O\SplitHandler.obj \ + $O\SwfHandler.obj \ $O\VhdHandler.obj \ $O\XarHandler.obj \ $O\XzHandler.obj \ @@ -230,6 +236,7 @@ COMPRESS_OBJS = \ $O\RarCodecsRegister.obj \ $O\ShrinkDecoder.obj \ $O\ZlibDecoder.obj \ + $O\ZlibEncoder.obj \ $O\ZDecoder.obj \ CRYPTO_OBJS = \ diff --git a/CPP/7zip/Bundles/Format7zF/resource.rc b/CPP/7zip/Bundles/Format7zF/resource.rc index babd1149..60c1f732 100755 --- a/CPP/7zip/Bundles/Format7zF/resource.rc +++ b/CPP/7zip/Bundles/Format7zF/resource.rc @@ -32,5 +32,5 @@ MY_VERSION_INFO_DLL("7z Standalone Plugin", "7za") STRINGTABLE BEGIN - 100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 split:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15 lzma:16 dmg:17 hfs:18 xar:19 vhd:20 fat:21 ntfs:22 xz:23" + 100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 001:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15 lzma:16 dmg:17 hfs:18 xar:19 vhd:20 fat:21 ntfs:22 xz:23" END diff --git a/CPP/7zip/Bundles/Format7zR/makefile b/CPP/7zip/Bundles/Format7zR/makefile index 77544ce2..a286303d 100755 --- a/CPP/7zip/Bundles/Format7zR/makefile +++ b/CPP/7zip/Bundles/Format7zR/makefile @@ -1,6 +1,5 @@ PROG = 7zra.dll DEF_FILE = ../../Archive/Archive2.def -LIBS = $(LIBS) user32.lib oleaut32.lib CFLAGS = $(CFLAGS) -I ../../../ \ -DCOMPRESS_MT \ -DCOMPRESS_MF_MT \ diff --git a/CPP/7zip/Bundles/SFXCon/Main.cpp b/CPP/7zip/Bundles/SFXCon/Main.cpp index 140f8364..b136ae7c 100755 --- a/CPP/7zip/Bundles/SFXCon/Main.cpp +++ b/CPP/7zip/Bundles/SFXCon/Main.cpp @@ -191,7 +191,7 @@ static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor, const UString &name, bool include, NRecursedType::EEnum type) { /* - if(!IsWildCardFilePathLegal(name)) + if (!IsWildCardFilePathLegal(name)) return false; */ bool isWildCard = DoesNameContainWildCard(name); @@ -229,12 +229,12 @@ void AddToCensorFromNonSwitchesStrings(NWildcard::CCensor &wildcardCensor, #ifndef _WIN32 -static void GetArguments(int numArguments, const char *arguments[], UStringVector &parts) +static void GetArguments(int numArgs, const char *args[], UStringVector &parts) { parts.Clear(); - for(int i = 0; i < numArguments; i++) + for (int i = 0; i < numArgs; i++) { - UString s = MultiByteToUnicodeString(arguments[i]); + UString s = MultiByteToUnicodeString(args[i]); parts.Add(s); } } @@ -242,11 +242,11 @@ static void GetArguments(int numArguments, const char *arguments[], UStringVecto int Main2( #ifndef _WIN32 - int numArguments, const char *arguments[] + int numArgs, const char *args[] #endif ) { - #ifdef _WIN32 + #if defined(_WIN32) && !defined(UNDER_CE) SetFileApisToOEM(); #endif @@ -256,7 +256,7 @@ int Main2( #ifdef _WIN32 NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings); #else - GetArguments(numArguments, arguments, commandStrings); + GetArguments(numArgs, args, commandStrings); #endif #ifdef _WIN32 diff --git a/CPP/7zip/Bundles/SFXCon/makefile b/CPP/7zip/Bundles/SFXCon/makefile index cac6d6ef..eadd5684 100755 --- a/CPP/7zip/Bundles/SFXCon/makefile +++ b/CPP/7zip/Bundles/SFXCon/makefile @@ -1,5 +1,5 @@ PROG = 7zCon.sfx -LIBS = $(LIBS) user32.lib oleaut32.lib +MY_CONSOLE = 1 CFLAGS = $(CFLAGS) -I ../../../ \ -DEXTRACT_ONLY \ -DNO_READ_FROM_CODER \ diff --git a/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp index 8ebe2504..a28e82d3 100755 --- a/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp +++ b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp @@ -36,7 +36,7 @@ void CExtractCallbackImp::Init(IInArchive *archiveHandler, HRESULT CExtractCallbackImp::Open_CheckBreak() { #ifndef _NO_PROGRESS - return ProgressDialog.ProgressSynch.ProcessStopAndPause(); + return ProgressDialog.Sync.ProcessStopAndPause(); #else return S_OK; #endif @@ -50,7 +50,7 @@ HRESULT CExtractCallbackImp::Open_SetTotal(const UInt64 * /* numFiles */, const HRESULT CExtractCallbackImp::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) { #ifndef _NO_PROGRESS - return ProgressDialog.ProgressSynch.ProcessStopAndPause(); + return ProgressDialog.Sync.ProcessStopAndPause(); #else return S_OK; #endif @@ -59,7 +59,7 @@ HRESULT CExtractCallbackImp::Open_SetCompleted(const UInt64 * /* numFiles */, co STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 size) { #ifndef _NO_PROGRESS - ProgressDialog.ProgressSynch.SetProgress(size, 0); + ProgressDialog.Sync.SetProgress(size, 0); #endif return S_OK; } @@ -67,9 +67,9 @@ STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 size) STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *completeValue) { #ifndef _NO_PROGRESS - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + RINOK(ProgressDialog.Sync.ProcessStopAndPause()); if (completeValue != NULL) - ProgressDialog.ProgressSynch.SetPos(*completeValue); + ProgressDialog.Sync.SetPos(*completeValue); #endif return S_OK; } @@ -89,7 +89,7 @@ STDMETHODIMP CExtractCallbackImp::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode) { #ifndef _NO_PROGRESS - if (ProgressDialog.ProgressSynch.GetStopped()) + if (ProgressDialog.Sync.GetStopped()) return E_ABORT; #endif _outFileStream.Release(); diff --git a/CPP/7zip/Bundles/SFXSetup/ExtractCallback.h b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.h index 4f4258bc..c78ff22b 100755 --- a/CPP/7zip/Bundles/SFXSetup/ExtractCallback.h +++ b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.h @@ -1,7 +1,7 @@ // ExtractCallback.h -#ifndef __EXTRACTCALLBACK_H -#define __EXTRACTCALLBACK_H +#ifndef __EXTRACT_CALLBACK_H +#define __EXTRACT_CALLBACK_H #include "resource.h" @@ -66,9 +66,9 @@ public: UInt32 defaultAttributes); #ifndef _NO_PROGRESS - HRESULT StartProgressDialog(const UString &title) + HRESULT StartProgressDialog(const UString &title, NWindows::CThread &thread) { - ProgressDialog.Create(title, 0); + ProgressDialog.Create(title, thread, 0); { #ifdef LANG ProgressDialog.SetText(LangLoadString(IDS_PROGRESS_EXTRACTING, 0x02000890)); diff --git a/CPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp b/CPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp index e5353c21..cc561090 100755 --- a/CPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp +++ b/CPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp @@ -19,9 +19,6 @@ static LPCWSTR kCantOpenArchive = L"Can not open the file as archive"; struct CThreadExtracting { - #ifndef _NO_PROGRESS - bool ShowProgress; - #endif CCodecs *Codecs; UString FileName; UString DestFolder; @@ -33,7 +30,7 @@ struct CThreadExtracting HRESULT Result; UString ErrorMessage; - void Process() + void Process2() { NFile::NFind::CFileInfoW fi; if (!fi.Find(FileName)) @@ -67,15 +64,19 @@ struct CThreadExtracting ExtractCallbackSpec->Init(ArchiveLink.GetArchive(), dirPath, L"Default", fi.MTime, 0); - #ifndef _NO_PROGRESS - if (ShowProgress) - ExtractCallbackSpec->ProgressDialog.WaitCreating(); - #endif Result = ArchiveLink.GetArchive()->Extract(0, (UInt32)-1 , BoolToInt(false), ExtractCallback); - #ifndef _NO_PROGRESS - if (ShowProgress) - ExtractCallbackSpec->ProgressDialog.MyClose(); - #endif + } + + void Process() + { + try + { + #ifndef _NO_PROGRESS + CProgressCloser closer(ExtractCallbackSpec->ProgressDialog); + #endif + Process2(); + } + catch(...) { Result = E_FAIL; } } static THREAD_FUNC_DECL MyThreadFunction(void *param) @@ -100,9 +101,9 @@ HRESULT ExtractArchive(CCodecs *codecs,const UString &fileName, const UString &d #ifndef _NO_PROGRESS - t.ShowProgress = showProgress; if (showProgress) { + t.ExtractCallbackSpec->ProgressDialog.IconID = IDI_ICON; NWindows::CThread thread; RINOK(thread.Create(CThreadExtracting::MyThreadFunction, &t)); @@ -112,13 +113,13 @@ HRESULT ExtractArchive(CCodecs *codecs,const UString &fileName, const UString &d #else title = NWindows::MyLoadStringW(IDS_PROGRESS_EXTRACTING); #endif - t.ExtractCallbackSpec->StartProgressDialog(title); + t.ExtractCallbackSpec->StartProgressDialog(title, thread); } else #endif { - t.Process(); + t.Process2(); } errorMessage = t.ErrorMessage; diff --git a/CPP/7zip/Bundles/SFXSetup/Main.cpp b/CPP/7zip/Bundles/SFXSetup/Main.cpp index ece6e3de..80e23c4e 100755 --- a/CPP/7zip/Bundles/SFXSetup/Main.cpp +++ b/CPP/7zip/Bundles/SFXSetup/Main.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#include <initguid.h> +#include "Common/MyInitGuid.h" #include "Common/CommandLineParser.h" #include "Common/StringConvert.h" @@ -12,6 +12,7 @@ #include "Windows/FileDir.h" #include "Windows/FileFind.h" #include "Windows/FileIO.h" +#include "Windows/NtCheck.h" #include "Windows/ResourceString.h" #include "../../UI/Explorer/MyMessages.h" @@ -38,8 +39,8 @@ static bool ReadDataString(LPCWSTR fileName, LPCSTR startID, const int kBufferSize = (1 << 12); Byte buffer[kBufferSize]; - int signatureStartSize = lstrlenA(startID); - int signatureEndSize = lstrlenA(endID); + int signatureStartSize = MyStringLen(startID); + int signatureEndSize = MyStringLen(endID); UInt32 numBytesPrev = 0; bool writeMode = false; @@ -103,37 +104,32 @@ public: } g_CInstallIDInit; +#ifndef UNDER_CE class CCurrentDirRestorer { CSysString m_CurrentDirectory; public: - CCurrentDirRestorer() - { NFile::NDirectory::MyGetCurrentDirectory(m_CurrentDirectory); } - ~CCurrentDirRestorer() - { RestoreDirectory();} - bool RestoreDirectory() - { return BOOLToBool(::SetCurrentDirectory(m_CurrentDirectory)); } + CCurrentDirRestorer() { NFile::NDirectory::MyGetCurrentDirectory(m_CurrentDirectory); } + ~CCurrentDirRestorer() { RestoreDirectory();} + bool RestoreDirectory() { return BOOLToBool(::SetCurrentDirectory(m_CurrentDirectory)); } }; - -#ifndef _UNICODE -bool g_IsNT = false; -static inline bool IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} #endif -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */,int /* nCmdShow */) +#define NT_CHECK_FAIL_ACTION ShowErrorMessage(L"Unsupported Windows version"); return 1; + +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, + #ifdef UNDER_CE + LPWSTR + #else + LPSTR + #endif + /* lpCmdLine */,int /* nCmdShow */) { g_hInstance = (HINSTANCE)hInstance; - #ifndef _UNICODE - g_IsNT = IsItWindowsNT(); - #endif - InitCommonControls(); + + NT_CHECK + + // InitCommonControls(); UString archiveName, switches; #ifdef _SHELL_EXECUTE @@ -235,10 +231,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR / } } + #ifndef UNDER_CE CCurrentDirRestorer currentDirRestorer; - if (!SetCurrentDirectory(tempDir.GetPath())) return 1; + #endif HANDLE hProcess = 0; #ifdef _SHELL_EXECUTE @@ -247,7 +244,11 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR / CSysString filePath = GetSystemString(executeFile); SHELLEXECUTEINFO execInfo; execInfo.cbSize = sizeof(execInfo); - execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT; + execInfo.fMask = SEE_MASK_NOCLOSEPROCESS + #ifndef UNDER_CE + | SEE_MASK_FLAG_DDEWAIT + #endif + ; execInfo.hwnd = NULL; execInfo.lpVerb = NULL; execInfo.lpFile = filePath; diff --git a/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp index 1f5d99cb..61ec0470 100755 --- a/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp +++ b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp @@ -619,25 +619,21 @@ SOURCE=..\..\UI\Common\OpenArchive.h # Begin Group "File Manager" # PROP Default_Filter "" -# Begin Group "Dialog" - -# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\UI\FileManager\ProgressDialog.cpp +SOURCE=..\..\UI\FileManager\FormatUtils.cpp # End Source File # Begin Source File -SOURCE=..\..\UI\FileManager\ProgressDialog.h +SOURCE=..\..\UI\FileManager\FormatUtils.h # End Source File -# End Group # Begin Source File -SOURCE=..\..\UI\FileManager\FormatUtils.cpp +SOURCE=..\..\UI\FileManager\ProgressDialog.cpp # End Source File # Begin Source File -SOURCE=..\..\UI\FileManager\FormatUtils.h +SOURCE=..\..\UI\FileManager\ProgressDialog.h # End Source File # End Group # Begin Group "C" diff --git a/CPP/7zip/Bundles/SFXSetup/makefile b/CPP/7zip/Bundles/SFXSetup/makefile index 44ffc9c6..a3c2b12c 100755 --- a/CPP/7zip/Bundles/SFXSetup/makefile +++ b/CPP/7zip/Bundles/SFXSetup/makefile @@ -1,5 +1,4 @@ PROG = 7zS.sfx -LIBS = $(LIBS) user32.lib oleaut32.lib shell32.lib ole32.lib comctl32.lib CFLAGS = $(CFLAGS) -I ../../../ \ -DNO_REGISTRY \ -DEXTRACT_ONLY \ diff --git a/CPP/7zip/Bundles/SFXSetup/resource.h b/CPP/7zip/Bundles/SFXSetup/resource.h index 2c7e5a22..58cd13cb 100755 --- a/CPP/7zip/Bundles/SFXSetup/resource.h +++ b/CPP/7zip/Bundles/SFXSetup/resource.h @@ -1,4 +1,4 @@ -#define IDI_ICON3 159 +#define IDI_ICON 1 #define IDS_EXTRACTION_ERROR_TITLE 7 #define IDS_EXTRACTION_ERROR_MESSAGE 8 diff --git a/CPP/7zip/Bundles/SFXSetup/resource.rc b/CPP/7zip/Bundles/SFXSetup/resource.rc index 85c24f0b..8ccdcf2c 100755 --- a/CPP/7zip/Bundles/SFXSetup/resource.rc +++ b/CPP/7zip/Bundles/SFXSetup/resource.rc @@ -3,7 +3,7 @@ MY_VERSION_INFO_APP("7z Setup SFX", "7zS.sfx") -IDI_ICON3 ICON "setup.ico" +IDI_ICON ICON "setup.ico" STRINGTABLE BEGIN diff --git a/CPP/7zip/Bundles/SFXWin/Main.cpp b/CPP/7zip/Bundles/SFXWin/Main.cpp index a538960b..ec5098dd 100755 --- a/CPP/7zip/Bundles/SFXWin/Main.cpp +++ b/CPP/7zip/Bundles/SFXWin/Main.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#include <initguid.h> +#include "Common/MyInitGuid.h" #include "Common/CommandLineParser.h" #include "Common/StringConvert.h" @@ -11,6 +11,7 @@ #include "Windows/Error.h" #include "Windows/FileDir.h" #include "Windows/FileName.h" +#include "Windows/NtCheck.h" #include "Windows/ResourceString.h" #include "../../ICoder.h" @@ -23,28 +24,16 @@ #include "../../UI/GUI/ExtractRes.h" HINSTANCE g_hInstance; -#ifndef _UNICODE -bool g_IsNT = false; -static inline bool IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} + +#ifdef UNDER_CE +bool g_LVN_ITEMACTIVATE_Support = true; #endif static const wchar_t *kUnknownExceptionMessage = L"ERROR: Unknown Error!"; void ErrorMessageForHRESULT(HRESULT res) { - UString s; - if (res == E_OUTOFMEMORY) - s = NWindows::MyLoadStringW(IDS_MEM_ERROR); - else - s = NWindows::NError::MyFormatMessageW(res); - ShowErrorMessage(s); + ShowErrorMessage(HResultToMessage(res)); } int APIENTRY WinMain2() @@ -53,11 +42,17 @@ int APIENTRY WinMain2() bool assumeYes = false; bool outputFolderDefined = false; UString outputFolder; - UStringVector subStrings; - NCommandLineParser::SplitCommandLine(GetCommandLineW(), subStrings); - for (int i = 1; i < subStrings.Size(); i++) + UStringVector commandStrings; + NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings); + + #ifndef UNDER_CE + if (commandStrings.Size() > 0) + commandStrings.Delete(0); + #endif + + for (int i = 0; i < commandStrings.Size(); i++) { - const UString &s = subStrings[i]; + const UString &s = commandStrings[i]; if (s.CompareNoCase(L"-y") == 0) assumeYes = true; else if (s.Left(2).CompareNoCase(L"-o") == 0) @@ -122,32 +117,44 @@ int APIENTRY WinMain2() NWildcard::CCensorNode wildcardCensor; wildcardCensor.AddItem(true, L"*", true, true, true); + bool messageWasDisplayed = false; result = ExtractGUI(codecs, CIntVector(), v1, v2, - wildcardCensor, eo, (assumeYes ? false: true), ecs); + wildcardCensor, eo, (assumeYes ? false: true), messageWasDisplayed, ecs); if (result == S_OK) { - if (ecs->Messages.Size() > 0 || ecs->NumArchiveErrors != 0) + if (!ecs->IsOK()) return NExitCode::kFatalError; return 0; } if (result == E_ABORT) return NExitCode::kUserBreak; - if (result == S_FALSE) - ShowErrorMessage(L"Error in archive"); - else - ErrorMessageForHRESULT(result); + if (!messageWasDisplayed) + { + if (result == S_FALSE) + ShowErrorMessage(L"Error in archive"); + else + ErrorMessageForHRESULT(result); + } if (result == E_OUTOFMEMORY) return NExitCode::kMemoryError; return NExitCode::kFatalError; } -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */) +#define NT_CHECK_FAIL_ACTION ShowErrorMessage(L"Unsupported Windows version"); return NExitCode::kFatalError; + +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, + #ifdef UNDER_CE + LPWSTR + #else + LPSTR + #endif + /* lpCmdLine */, int /* nCmdShow */) { g_hInstance = (HINSTANCE)hInstance; - #ifndef _UNICODE - g_IsNT = IsItWindowsNT(); - #endif + + NT_CHECK + try { return WinMain2(); diff --git a/CPP/7zip/Bundles/SFXWin/SFXWin.dsp b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp index ddd7c5fa..f41bc029 100755 --- a/CPP/7zip/Bundles/SFXWin/SFXWin.dsp +++ b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp @@ -337,11 +337,11 @@ SOURCE=..\..\UI\FileManager\PasswordDialog.h # End Source File # Begin Source File -SOURCE=..\..\UI\FileManager\ProgressDialog.cpp +SOURCE=..\..\UI\FileManager\ProgressDialog2.cpp # End Source File # Begin Source File -SOURCE=..\..\UI\FileManager\ProgressDialog.h +SOURCE=..\..\UI\FileManager\ProgressDialog2.h # End Source File # End Group # Begin Group "7zip Common" diff --git a/CPP/7zip/Bundles/SFXWin/makefile b/CPP/7zip/Bundles/SFXWin/makefile index ec0b8590..5668fc13 100755 --- a/CPP/7zip/Bundles/SFXWin/makefile +++ b/CPP/7zip/Bundles/SFXWin/makefile @@ -1,11 +1,16 @@ PROG = 7z.sfx -LIBS = $(LIBS) user32.lib oleaut32.lib shell32.lib ole32.lib CFLAGS = $(CFLAGS) -I ../../../ \ -DNO_REGISTRY \ -DEXTRACT_ONLY \ -DNO_READ_FROM_CODER \ -D_SFX \ +!IFDEF UNDER_CE +LIBS = $(LIBS) ceshell.lib Commctrl.lib +!ELSE +LIBS = $(LIBS) comctl32.lib comdlg32.lib +!ENDIF + SFX_WIN_OBJS = \ $O\Main.obj \ @@ -68,10 +73,15 @@ UI_COMMON_OBJS = \ FM_OBJS = \ $O\ExtractCallback.obj \ $O\FormatUtils.obj \ - $O\MessagesDialog.obj \ $O\OverwriteDialog.obj \ $O\PasswordDialog.obj \ - $O\ProgressDialog.obj \ + $O\ProgressDialog2.obj \ + +!IFDEF UNDER_CE +FM_OBJS = $(FM_OBJS) \ + $O\BrowseDialog.obj \ + $O\SysIconUtils.obj \ +!ENDIF AR_COMMON_OBJS = \ $O\CoderMixer2.obj \ diff --git a/CPP/7zip/Bundles/SFXWin/resource.h b/CPP/7zip/Bundles/SFXWin/resource.h index 0a460213..99878ee6 100755 --- a/CPP/7zip/Bundles/SFXWin/resource.h +++ b/CPP/7zip/Bundles/SFXWin/resource.h @@ -1,7 +1 @@ -#define IDD_DIALOG_EXTRACT 137 - -#define IDI_ICON3 159 - -#define IDC_STATIC_EXTRACT_EXTRACT_TO 1020 -#define IDC_EXTRACT_COMBO_PATH 1021 -#define IDC_EXTRACT_BUTTON_SET_PATH 1022 +#define IDI_ICON 1 diff --git a/CPP/7zip/Bundles/SFXWin/resource.rc b/CPP/7zip/Bundles/SFXWin/resource.rc index 8dd95bf0..35234cae 100755 --- a/CPP/7zip/Bundles/SFXWin/resource.rc +++ b/CPP/7zip/Bundles/SFXWin/resource.rc @@ -1,34 +1,43 @@ #include "../../MyVersionInfo.rc" #include "../../GuiCommon.rc" +#include "../../UI/GUI/ExtractDialogRes.h" #include "resource.h" MY_VERSION_INFO_APP("7z SFX", "7z.sfx") -#define xSize2 214 -#define ySize2 64 +#define xc 240 +#define yc 64 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +IDI_ICON ICON "7z.ico" -#define bYPos (ySize - marg - bYSize) -#define bXPos1 (xSize - marg - bXSize) -#define bXPos2 (bXPos1 - 10 - bXSize) +IDD_DIALOG_EXTRACT MY_DIALOG +CAPTION "7-Zip self-extracting archive" +BEGIN + LTEXT "E&xtract to:", IDC_STATIC_EXTRACT_EXTRACT_TO, m, m, xc, 8 + EDITTEXT IDC_EXTRACT_COMBO_PATH, m, 21, xc - bxsDots - 12, 14, ES_AUTOHSCROLL + PUSHBUTTON "...", IDC_EXTRACT_BUTTON_SET_PATH, xs - m - bxsDots, 20, bxsDots, bys, WS_GROUP + DEFPUSHBUTTON "Extract", IDOK, bx2, by, bxs, bys, WS_GROUP + PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys +END -IDI_ICON3 ICON "7z.ico" +#ifdef UNDER_CE -IDD_DIALOG_EXTRACT DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +#undef xc +#define xc 144 + +IDD_DIALOG_EXTRACT_2 MY_DIALOG CAPTION "7-Zip self-extracting archive" -MY_FONT BEGIN - LTEXT "E&xtract to:", IDC_STATIC_EXTRACT_EXTRACT_TO, marg, marg, xSize2, 8 - EDITTEXT IDC_EXTRACT_COMBO_PATH, marg, 21, xSize2 - bDotsSize - 13, 14, ES_AUTOHSCROLL - PUSHBUTTON "...", IDC_EXTRACT_BUTTON_SET_PATH, xSize - marg - bDotsSize, 20, bDotsSize, bYSize, WS_GROUP - DEFPUSHBUTTON "Extract", IDOK, , bXPos2, bYPos, bXSize, bYSize, WS_GROUP - PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize + LTEXT "E&xtract to:", IDC_STATIC_EXTRACT_EXTRACT_TO, m, m, xc - bxsDots - 12, 8 + EDITTEXT IDC_EXTRACT_COMBO_PATH, m, m + bys + 4, xc, 14, ES_AUTOHSCROLL + PUSHBUTTON "...", IDC_EXTRACT_BUTTON_SET_PATH, xs - m - bxsDots, m, bxsDots, bys, WS_GROUP + DEFPUSHBUTTON "Extract", IDOK, bx2, by, bxs, bys, WS_GROUP + PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys END -#include "../../UI/FileManager/MessagesDialog.rc" +#endif + #include "../../UI/FileManager/OverwriteDialog.rc" #include "../../UI/FileManager/PasswordDialog.rc" -#include "../../UI/FileManager/ProgressDialog.rc" +#include "../../UI/FileManager/ProgressDialog2.rc" #include "../../UI/GUI/Extract.rc" diff --git a/CPP/7zip/Bundles/makefile b/CPP/7zip/Bundles/makefile index fd95af31..6a4f16cd 100755 --- a/CPP/7zip/Bundles/makefile +++ b/CPP/7zip/Bundles/makefile @@ -1,6 +1,7 @@ DIRS = \ Alone\~ \ Alone7z\~ \ + Fm\~ \ Format7z\~ \ Format7zF\~ \ Format7zR\~ \ diff --git a/CPP/7zip/Common/FileStreams.cpp b/CPP/7zip/Common/FileStreams.cpp index f7c01d2c..292fc7c2 100755 --- a/CPP/7zip/Common/FileStreams.cpp +++ b/CPP/7zip/Common/FileStreams.cpp @@ -195,7 +195,15 @@ STDMETHODIMP CInFileStream::Read(void *data, UInt32 size, UInt32 *processedSize) #endif } -#ifndef _WIN32_WCE +#ifdef UNDER_CE +STDMETHODIMP CStdInFileStream::Read(void *data, UInt32 size, UInt32 *processedSize) +{ + size_t s2 = fread(data, 1, size, stdout); + if (processedSize != 0) + *processedSize = s2; + return (s2 = size) ? S_OK : E_FAIL; +} +#else STDMETHODIMP CStdInFileStream::Read(void *data, UInt32 size, UInt32 *processedSize) { #ifdef _WIN32 @@ -360,7 +368,15 @@ STDMETHODIMP COutFileStream::SetSize(Int64 newSize) #endif } -#ifndef _WIN32_WCE +#ifdef UNDER_CE +STDMETHODIMP CStdOutFileStream::Write(const void *data, UInt32 size, UInt32 *processedSize) +{ + size_t s2 = fwrite(data, 1, size, stdout); + if (processedSize != 0) + *processedSize = s2; + return (s2 = size) ? S_OK : E_FAIL; +} +#else STDMETHODIMP CStdOutFileStream::Write(const void *data, UInt32 size, UInt32 *processedSize) { if (processedSize != NULL) @@ -402,5 +418,4 @@ STDMETHODIMP CStdOutFileStream::Write(const void *data, UInt32 size, UInt32 *pro return S_OK; #endif } - #endif diff --git a/CPP/7zip/Common/FileStreams.h b/CPP/7zip/Common/FileStreams.h index 32869192..0b91380d 100755 --- a/CPP/7zip/Common/FileStreams.h +++ b/CPP/7zip/Common/FileStreams.h @@ -63,7 +63,6 @@ public: STDMETHOD(GetSize)(UInt64 *size); }; -#ifndef _WIN32_WCE class CStdInFileStream: public ISequentialInStream, public CMyUnknownImp @@ -74,7 +73,6 @@ public: virtual ~CStdInFileStream() {} STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); }; -#endif class COutFileStream: public IOutStream, @@ -132,7 +130,6 @@ public: STDMETHOD(SetSize)(Int64 newSize); }; -#ifndef _WIN32_WCE class CStdOutFileStream: public ISequentialOutStream, public CMyUnknownImp @@ -143,6 +140,5 @@ public: virtual ~CStdOutFileStream() {} STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); }; -#endif #endif diff --git a/CPP/7zip/Common/InBuffer.cpp b/CPP/7zip/Common/InBuffer.cpp index 03924d2a..ad4f8825 100755 --- a/CPP/7zip/Common/InBuffer.cpp +++ b/CPP/7zip/Common/InBuffer.cpp @@ -74,7 +74,10 @@ bool CInBuffer::ReadBlock() Byte CInBuffer::ReadBlock2() { - if(!ReadBlock()) + if (!ReadBlock()) + { + _processedSize++; return 0xFF; + } return *_buffer++; } diff --git a/CPP/7zip/Common/InOutTempBuffer.cpp b/CPP/7zip/Common/InOutTempBuffer.cpp index 4cc0b2f2..dfe8b3d3 100755 --- a/CPP/7zip/Common/InOutTempBuffer.cpp +++ b/CPP/7zip/Common/InOutTempBuffer.cpp @@ -2,121 +2,121 @@ #include "StdAfx.h" -#include "InOutTempBuffer.h" -#include "../../Common/Defs.h" -// #include "Windows/Defs.h" +#include "../../../C/7zCrc.h" +#include "InOutTempBuffer.h" #include "StreamUtils.h" using namespace NWindows; using namespace NFile; using namespace NDirectory; -static UInt32 kTmpBufferMemorySize = (1 << 20); +static const UInt32 kTempBufSize = (1 << 20); -static LPCTSTR kTempFilePrefixString = TEXT("iot"); +static LPCTSTR kTempFilePrefixString = TEXT("7zt"); -CInOutTempBuffer::CInOutTempBuffer(): - _buffer(NULL) -{ -} +CInOutTempBuffer::CInOutTempBuffer(): _buf(NULL) { } void CInOutTempBuffer::Create() { - _buffer = new Byte[kTmpBufferMemorySize]; + if (!_buf) + _buf = new Byte[kTempBufSize]; } CInOutTempBuffer::~CInOutTempBuffer() { - delete []_buffer; + delete []_buf; } + void CInOutTempBuffer::InitWriting() { - _bufferPosition = 0; - _tmpFileCreated = false; - _fileSize = 0; + _bufPos = 0; + _tempFileCreated = false; + _size = 0; + _crc = CRC_INIT_VAL; } bool CInOutTempBuffer::WriteToFile(const void *data, UInt32 size) { if (size == 0) return true; - if(!_tmpFileCreated) + if (!_tempFileCreated) { CSysString tempDirPath; - if(!MyGetTempPath(tempDirPath)) + if (!MyGetTempPath(tempDirPath)) return false; - if (_tempFile.Create(tempDirPath, kTempFilePrefixString, _tmpFileName) == 0) + if (_tempFile.Create(tempDirPath, kTempFilePrefixString, _tempFileName) == 0) return false; - // _outFile.SetOpenCreationDispositionCreateAlways(); - if(!_outFile.Create(_tmpFileName, true)) + if (!_outFile.Create(_tempFileName, true)) return false; - _tmpFileCreated = true; + _tempFileCreated = true; } - UInt32 processedSize; - if(!_outFile.Write(data, size, processedSize)) + UInt32 processed; + if (!_outFile.Write(data, size, processed)) return false; - _fileSize += processedSize; - return (processedSize == size); -} - -bool CInOutTempBuffer::FlushWrite() -{ - return _outFile.Close(); + _crc = CrcUpdate(_crc, data, processed); + _size += processed; + return (processed == size); } bool CInOutTempBuffer::Write(const void *data, UInt32 size) { - if(_bufferPosition < kTmpBufferMemorySize) + if (_bufPos < kTempBufSize) { - UInt32 curSize = MyMin(kTmpBufferMemorySize - _bufferPosition, size); - memmove(_buffer + _bufferPosition, (const Byte *)data, curSize); - _bufferPosition += curSize; - size -= curSize; - data = ((const Byte *)data) + curSize; - _fileSize += curSize; + UInt32 cur = MyMin(kTempBufSize - _bufPos, size); + memcpy(_buf + _bufPos, data, cur); + _crc = CrcUpdate(_crc, data, cur); + _bufPos += cur; + size -= cur; + data = ((const Byte *)data) + cur; + _size += cur; } return WriteToFile(data, size); } -bool CInOutTempBuffer::InitReading() -{ - _currentPositionInBuffer = 0; - if(_tmpFileCreated) - return _inFile.Open(_tmpFileName); - return true; -} - HRESULT CInOutTempBuffer::WriteToStream(ISequentialOutStream *stream) { - if (_currentPositionInBuffer < _bufferPosition) + if (!_outFile.Close()) + return E_FAIL; + + UInt64 size = 0; + UInt32 crc = CRC_INIT_VAL; + + if (_bufPos > 0) { - UInt32 sizeToWrite = _bufferPosition - _currentPositionInBuffer; - RINOK(WriteStream(stream, _buffer + _currentPositionInBuffer, sizeToWrite)); - _currentPositionInBuffer += sizeToWrite; + RINOK(WriteStream(stream, _buf, _bufPos)); + crc = CrcUpdate(crc, _buf, _bufPos); + size += _bufPos; } - if (!_tmpFileCreated) - return true; - for (;;) + if (_tempFileCreated) { - UInt32 localProcessedSize; - if (!_inFile.ReadPart(_buffer, kTmpBufferMemorySize, localProcessedSize)) + NIO::CInFile inFile; + if (!inFile.Open(_tempFileName)) return E_FAIL; - if (localProcessedSize == 0) - return S_OK; - RINOK(WriteStream(stream, _buffer, localProcessedSize)); + while (size < _size) + { + UInt32 processed; + if (!inFile.ReadPart(_buf, kTempBufSize, processed)) + return E_FAIL; + if (processed == 0) + break; + RINOK(WriteStream(stream, _buf, processed)); + crc = CrcUpdate(crc, _buf, processed); + size += processed; + } } + return (_crc == crc && size == _size) ? S_OK : E_FAIL; } -STDMETHODIMP CSequentialOutTempBufferImp::Write(const void *data, UInt32 size, UInt32 *processedSize) +STDMETHODIMP CSequentialOutTempBufferImp::Write(const void *data, UInt32 size, UInt32 *processed) { - if (!_buffer->Write(data, size)) + if (!_buf->Write(data, size)) { - if (processedSize != NULL) - *processedSize = 0; + if (processed != NULL) + *processed = 0; return E_FAIL; } - if (processedSize != NULL) - *processedSize = size; + if (processed != NULL) + *processed = size; return S_OK; } diff --git a/CPP/7zip/Common/InOutTempBuffer.h b/CPP/7zip/Common/InOutTempBuffer.h index e1e0e971..073f95ac 100755 --- a/CPP/7zip/Common/InOutTempBuffer.h +++ b/CPP/7zip/Common/InOutTempBuffer.h @@ -1,11 +1,11 @@ -// Util/InOutTempBuffer.h +// InOutTempBuffer.h #ifndef __IN_OUT_TEMP_BUFFER_H #define __IN_OUT_TEMP_BUFFER_H -#include "../../Windows/FileIO.h" -#include "../../Windows/FileDir.h" #include "../../Common/MyCom.h" +#include "../../Windows/FileDir.h" +#include "../../Windows/FileIO.h" #include "../IStream.h" @@ -13,14 +13,12 @@ class CInOutTempBuffer { NWindows::NFile::NDirectory::CTempFile _tempFile; NWindows::NFile::NIO::COutFile _outFile; - NWindows::NFile::NIO::CInFile _inFile; - Byte *_buffer; - UInt32 _bufferPosition; - UInt32 _currentPositionInBuffer; - CSysString _tmpFileName; - bool _tmpFileCreated; - - UInt64 _fileSize; + Byte *_buf; + UInt32 _bufPos; + CSysString _tempFileName; + bool _tempFileCreated; + UInt64 _size; + UInt32 _crc; bool WriteToFile(const void *data, UInt32 size); public: @@ -30,23 +28,18 @@ public: void InitWriting(); bool Write(const void *data, UInt32 size); - UInt64 GetDataSize() const { return _fileSize; } - bool FlushWrite(); - bool InitReading(); + HRESULT WriteToStream(ISequentialOutStream *stream); + UInt64 GetDataSize() const { return _size; } }; class CSequentialOutTempBufferImp: public ISequentialOutStream, public CMyUnknownImp { - CInOutTempBuffer *_buffer; + CInOutTempBuffer *_buf; public: - // CSequentialOutStreamImp(): _size(0) {} - // UInt32 _size; - void Init(CInOutTempBuffer *buffer) { _buffer = buffer; } - // UInt32 GetSize() const { return _size; } - + void Init(CInOutTempBuffer *buffer) { _buf = buffer; } MY_UNKNOWN_IMP STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); diff --git a/CPP/7zip/Common/StreamObjects.cpp b/CPP/7zip/Common/StreamObjects.cpp index e043e565..2237b930 100755 --- a/CPP/7zip/Common/StreamObjects.cpp +++ b/CPP/7zip/Common/StreamObjects.cpp @@ -3,21 +3,37 @@ #include "StdAfx.h" #include "StreamObjects.h" -#include "../../Common/Defs.h" - -STDMETHODIMP CSequentialInStreamImp::Read(void *data, UInt32 size, UInt32 *processedSize) +STDMETHODIMP CBufInStream::Read(void *data, UInt32 size, UInt32 *processedSize) { - size_t rem = _size - _pos; + if (processedSize != NULL) + *processedSize = 0; + if (_pos > _size) + return E_FAIL; + size_t rem = _size - (size_t)_pos; if (size < rem) rem = (size_t)size; - memcpy(data, _dataPointer + _pos, rem); + memcpy(data, _data + (size_t)_pos, rem); _pos += rem; if (processedSize != NULL) *processedSize = (UInt32)rem; return S_OK; } +STDMETHODIMP CBufInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) +{ + switch(seekOrigin) + { + case STREAM_SEEK_SET: _pos = offset; break; + case STREAM_SEEK_CUR: _pos += offset; break; + case STREAM_SEEK_END: _pos = _size + offset; break; + default: return STG_E_INVALIDFUNCTION; + } + if (newPosition) + *newPosition = _pos; + return S_OK; +} + void CWriteBuffer::Write(const void *data, size_t size) { diff --git a/CPP/7zip/Common/StreamObjects.h b/CPP/7zip/Common/StreamObjects.h index a21089cb..e94513ee 100755 --- a/CPP/7zip/Common/StreamObjects.h +++ b/CPP/7zip/Common/StreamObjects.h @@ -1,34 +1,44 @@ // StreamObjects.h -#ifndef __STREAMOBJECTS_H -#define __STREAMOBJECTS_H +#ifndef __STREAM_OBJECTS_H +#define __STREAM_OBJECTS_H #include "../../Common/DynamicBuffer.h" #include "../../Common/MyCom.h" #include "../IStream.h" -class CSequentialInStreamImp: - public ISequentialInStream, +struct CReferenceBuf: + public IUnknown, public CMyUnknownImp { - const Byte *_dataPointer; - size_t _size; - size_t _pos; + CByteBuffer Buf; + MY_UNKNOWN_IMP +}; +class CBufInStream: + public IInStream, + public CMyUnknownImp +{ + const Byte *_data; + UInt64 _pos; + size_t _size; + CMyComPtr<IUnknown> _ref; public: - void Init(const Byte *dataPointer, size_t size) + void Init(const Byte *data, size_t size, IUnknown *ref = 0) { - _dataPointer = dataPointer; + _data = data; _size = size; _pos = 0; + _ref = ref; } + void Init(CReferenceBuf *ref) { Init(ref->Buf, ref->Buf.GetCapacity(), ref); } - MY_UNKNOWN_IMP + MY_UNKNOWN_IMP1(IInStream) STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); + STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); }; - class CWriteBuffer { CByteDynamicBuffer _buffer; diff --git a/CPP/7zip/Compress/BZip2Decoder.cpp b/CPP/7zip/Compress/BZip2Decoder.cpp index ef896f6a..76a7187b 100755 --- a/CPP/7zip/Compress/BZip2Decoder.cpp +++ b/CPP/7zip/Compress/BZip2Decoder.cpp @@ -584,12 +584,7 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress) CState &state = m_States[0]; for (;;) { - if (progress) - { - UInt64 packSize = m_InStream.GetProcessedSize(); - UInt64 unpackSize = m_OutStream.GetProcessedSize(); - RINOK(progress->SetRatioInfo(&packSize, &unpackSize)); - } + RINOK(SetRatioProgress(m_InStream.GetProcessedSize())); bool wasFinished; UInt32 crc; RINOK(ReadSignatures(wasFinished, crc)); @@ -608,7 +603,7 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress) return S_FALSE; } } - return S_OK; + return SetRatioProgress(m_InStream.GetProcessedSize()); } HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, @@ -766,16 +761,9 @@ void CState::ThreadFunc() if (!needFinish) { if ((randMode ? - DecodeBlock2Rand(Counters + 256, blockSize, origPtr, Decoder->m_OutStream) : - DecodeBlock2(Counters + 256, blockSize, origPtr, Decoder->m_OutStream)) == crc) - { - if (Decoder->Progress) - { - UInt64 inSize = packSize - Decoder->_inStart; - UInt64 unpackSize = Decoder->m_OutStream.GetProcessedSize(); - res = Decoder->Progress->SetRatioInfo(&inSize, &unpackSize); - } - } + DecodeBlock2Rand(Counters + 256, blockSize, origPtr, Decoder->m_OutStream) : + DecodeBlock2(Counters + 256, blockSize, origPtr, Decoder->m_OutStream)) == crc) + res = Decoder->SetRatioProgress(packSize); else res = S_FALSE; } @@ -808,4 +796,13 @@ STDMETHODIMP CDecoder::SetNumberOfThreads(UInt32 numThreads) } #endif +HRESULT CDecoder::SetRatioProgress(UInt64 packSize) +{ + if (!Progress) + return S_OK; + packSize -= _inStart; + UInt64 unpackSize = m_OutStream.GetProcessedSize(); + return Progress->SetRatioInfo(&packSize, &unpackSize); +} + }} diff --git a/CPP/7zip/Compress/BZip2Decoder.h b/CPP/7zip/Compress/BZip2Decoder.h index ea06449e..39520ee3 100755 --- a/CPP/7zip/Compress/BZip2Decoder.h +++ b/CPP/7zip/Compress/BZip2Decoder.h @@ -134,9 +134,9 @@ public: CDecoder(); + HRESULT SetRatioProgress(UInt64 packSize); HRESULT ReadSignatures(bool &wasFinished, UInt32 &crc); - HRESULT Flush() { return m_OutStream.Flush(); } void ReleaseStreams(bool releaseInStream) { diff --git a/CPP/7zip/Compress/Bcj2Coder.cpp b/CPP/7zip/Compress/Bcj2Coder.cpp index 13ce5160..7d93155a 100755 --- a/CPP/7zip/Compress/Bcj2Coder.cpp +++ b/CPP/7zip/Compress/Bcj2Coder.cpp @@ -24,11 +24,11 @@ static bool inline Test86MSByte(Byte b) bool CEncoder::Create() { - if (!_mainStream.Create(1 << 16)) + if (!_mainStream.Create(1 << 18)) return false; - if (!_callStream.Create(1 << 20)) + if (!_callStream.Create(1 << 18)) return false; - if (!_jumpStream.Create(1 << 20)) + if (!_jumpStream.Create(1 << 18)) return false; if (!_rangeEncoder.Create(1 << 20)) return false; diff --git a/CPP/7zip/Compress/DeflateDecoder.cpp b/CPP/7zip/Compress/DeflateDecoder.cpp index cf4a5105..2848cd81 100755 --- a/CPP/7zip/Compress/DeflateDecoder.cpp +++ b/CPP/7zip/Compress/DeflateDecoder.cpp @@ -250,7 +250,7 @@ HRESULT CCoder::CodeReal(ISequentialOutStream *outStream, m_OutWindowStream.SetStream(outStream); CCoderReleaser flusher(this); - const UInt64 inStart = m_InBitStream.GetProcessedSize(); + const UInt64 inStart = _needInitInStream ? 0 : m_InBitStream.GetProcessedSize(); const UInt64 start = m_OutWindowStream.GetProcessedSize(); for (;;) { diff --git a/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp b/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp index 9b005efb..6c31e3ea 100755 --- a/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp +++ b/CPP/7zip/Compress/LZMA_Alone/AloneLZMA.dsp @@ -44,7 +44,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /FAcs /Yu"StdAfx.h" /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /FAcs /Yu"StdAfx.h" /FD /c # ADD BASE RSC /l 0x419 /d "NDEBUG" # ADD RSC /l 0x419 /d "NDEBUG" BSC32=bscmake.exe @@ -69,7 +69,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /GZ /c # ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD RSC /l 0x419 /d "_DEBUG" BSC32=bscmake.exe @@ -94,7 +94,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /c # ADD BASE RSC /l 0x419 /d "NDEBUG" # ADD RSC /l 0x419 /d "NDEBUG" BSC32=bscmake.exe @@ -121,7 +121,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /D "COMPRESS_MF_MT" /D "BENCH_MT" /Yu"StdAfx.h" /FD /GZ /c # ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD RSC /l 0x419 /d "_DEBUG" BSC32=bscmake.exe @@ -342,24 +342,6 @@ SOURCE=..\..\Common\StreamUtils.h # Begin Group "LzmaUtil" # PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Dec.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Dec.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Enc.c -# SUBTRACT CPP /YX /Yc /Yu -# End Source File -# Begin Source File - -SOURCE=..\..\..\..\C\LzmaUtil\Lzma86Enc.h -# End Source File # End Group # Begin Source File @@ -412,6 +394,20 @@ SOURCE=..\..\..\..\C\LzHash.h # End Source File # Begin Source File +SOURCE=..\..\..\..\C\Lzma86.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Lzma86Dec.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + +SOURCE=..\..\..\..\C\Lzma86Enc.c +# SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File + SOURCE=..\..\..\..\C\LzmaDec.c # SUBTRACT CPP /YX /Yc /Yu # End Source File diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp index 3d8e475f..90476378 100755 --- a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp +++ b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp @@ -7,7 +7,7 @@ #include <stdio.h> -#if defined(_WIN32) || defined(OS2) || defined(MSDOS) +#if (defined(_WIN32) || defined(OS2) || defined(MSDOS)) && !defined(UNDER_CE) #include <fcntl.h> #include <io.h> #define MY_SET_BINARY_MODE(file) _setmode(_fileno(file), O_BINARY) @@ -19,6 +19,8 @@ #include "../../../Common/StringConvert.h" #include "../../../Common/StringToInt.h" +#include "../../../Windows/NtCheck.h" + #include "../../Common/FileStreams.h" #include "../../Common/StreamUtils.h" @@ -33,23 +35,10 @@ #include "../../../../C/7zVersion.h" #include "../../../../C/Alloc.h" -#include "../../../../C/LzmaUtil/Lzma86Dec.h" -#include "../../../../C/LzmaUtil/Lzma86Enc.h" +#include "../../../../C/Lzma86.h" using namespace NCommandLineParser; -#ifdef _WIN32 -bool g_IsNT = false; -static inline bool IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} -#endif - static const char *kCantAllocate = "Can not allocate memory"; static const char *kReadError = "Read error"; static const char *kWriteError = "Write error"; @@ -96,9 +85,14 @@ static const CSwitchForm kSwitchForms[] = static const int kNumSwitches = sizeof(kSwitchForms) / sizeof(kSwitchForms[0]); +static void PrintMessage(const char *s) +{ + fprintf(stderr, s); +} + static void PrintHelp() { - fprintf(stderr, "\nUsage: LZMA <e|d> inputFile outputFile [<switches>...]\n" + PrintMessage("\nUsage: LZMA <e|d> inputFile outputFile [<switches>...]\n" " e: encode file\n" " d: decode file\n" " b: Benchmark\n" @@ -130,11 +124,10 @@ static void IncorrectCommand() PrintHelpAndExit("Incorrect command"); } -static void WriteArgumentsToStringList(int numArguments, const char *arguments[], - UStringVector &strings) +static void WriteArgumentsToStringList(int numArgs, const char *args[], UStringVector &strings) { - for(int i = 1; i < numArguments; i++) - strings.Add(MultiByteToUnicodeString(arguments[i])); + for (int i = 1; i < numArgs; i++) + strings.Add(MultiByteToUnicodeString(args[i])); } static bool GetNumber(const wchar_t *s, UInt32 &value) @@ -159,15 +152,15 @@ static void ParseUInt32(const CParser &parser, int index, UInt32 &res) IncorrectCommand(); } -int main2(int n, const char *args[]) +#define NT_CHECK_FAIL_ACTION PrintMessage("Unsupported Windows version"); return 1; + +int main2(int numArgs, const char *args[]) { - #ifdef _WIN32 - g_IsNT = IsItWindowsNT(); - #endif + NT_CHECK - fprintf(stderr, "\nLZMA " MY_VERSION_COPYRIGHT_DATE "\n"); + PrintMessage("\nLZMA " MY_VERSION_COPYRIGHT_DATE "\n"); - if (n == 1) + if (numArgs == 1) { PrintHelp(); return 0; @@ -176,12 +169,12 @@ int main2(int n, const char *args[]) bool unsupportedTypes = (sizeof(Byte) != 1 || sizeof(UInt32) < 4 || sizeof(UInt64) < 4); if (unsupportedTypes) { - fprintf(stderr, "Unsupported base types. Edit Common/Types.h and recompile"); + PrintMessage("Unsupported base types. Edit Common/Types.h and recompile"); return 1; } UStringVector commandStrings; - WriteArgumentsToStringList(n, args, commandStrings); + WriteArgumentsToStringList(numArgs, args, commandStrings); CParser parser(kNumSwitches); try { @@ -461,14 +454,14 @@ int main2(int n, const char *args[]) Byte b = Byte(fileSize >> (8 * i)); if (outStream->Write(&b, 1, 0) != S_OK) { - fprintf(stderr, kWriteError); + PrintMessage(kWriteError); return 1; } } HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0); if (result == E_OUTOFMEMORY) { - fprintf(stderr, "\nError: Can not allocate memory\n"); + PrintMessage("\nError: Can not allocate memory\n"); return 1; } else if (result != S_OK) @@ -486,12 +479,12 @@ int main2(int n, const char *args[]) Byte header[kPropertiesSize + 8]; if (ReadStream_FALSE(inStream, header, kPropertiesSize + 8) != S_OK) { - fprintf(stderr, kReadError); + PrintMessage(kReadError); return 1; } if (decoderSpec->SetDecoderProperties2(header, kPropertiesSize) != S_OK) { - fprintf(stderr, "SetDecoderProperties error"); + PrintMessage("SetDecoderProperties error"); return 1; } fileSize = 0; @@ -500,7 +493,7 @@ int main2(int n, const char *args[]) if (decoder->Code(inStream, outStream, 0, (fileSize == (UInt64)(Int64)-1) ? 0 : &fileSize, 0) != S_OK) { - fprintf(stderr, "Decoder error"); + PrintMessage("Decoder error"); return 1; } } @@ -508,16 +501,16 @@ int main2(int n, const char *args[]) { if (outStreamSpec->Close() != S_OK) { - fprintf(stderr, "File closing error"); + PrintMessage("File closing error"); return 1; } } return 0; } -int MY_CDECL main(int n, const char *args[]) +int MY_CDECL main(int numArgs, const char *args[]) { - try { return main2(n, args); } + try { return main2(numArgs, args); } catch(const char *s) { fprintf(stderr, "\nError: %s\n", s); @@ -525,7 +518,7 @@ int MY_CDECL main(int n, const char *args[]) } catch(...) { - fprintf(stderr, "\nError\n"); + PrintMessage("\nError\n"); return 1; } } diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp index 6a325fe0..d115ed23 100755 --- a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp +++ b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp @@ -46,7 +46,20 @@ #include "../LzmaEncoder.h" #endif -static const UInt32 kUncompressMinBlockSize = 1 << 26; +static const UInt32 kUncompressMinBlockSize = +#ifdef UNDER_CE +1 << 24; +#else +1 << 26; +#endif + +static const UInt32 kCrcBlockSize = +#ifdef UNDER_CE +1 << 25; +#else +1 << 30; +#endif + static const UInt32 kAdditionalSize = (1 << 16); static const UInt32 kCompressedAdditionalSize = (1 << 10); static const UInt32 kMaxLzmaPropSize = 5; @@ -273,13 +286,20 @@ static UInt64 GetFreq() #ifndef USE_POSIX_TIME static inline UInt64 GetTime64(const FILETIME &t) { return ((UInt64)t.dwHighDateTime << 32) | t.dwLowDateTime; } #endif + static UInt64 GetUserTime() { #ifdef USE_POSIX_TIME return clock(); #else FILETIME creationTime, exitTime, kernelTime, userTime; - if (::GetProcessTimes(::GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime) != 0) + if ( + #ifdef UNDER_CE + ::GetThreadTimes(::GetCurrentThread() + #else + ::GetProcessTimes(::GetCurrentProcess() + #endif + , &creationTime, &exitTime, &kernelTime, &userTime) != 0) return GetTime64(userTime) + GetTime64(kernelTime); return (UInt64)GetTickCount() * 10000; #endif @@ -332,7 +352,7 @@ public: STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); }; -void SetStartTime(CBenchInfo &bi) +static void SetStartTime(CBenchInfo &bi) { bi.GlobalFreq = GetFreq(); bi.UserFreq = GetUserFreq(); @@ -340,7 +360,7 @@ void SetStartTime(CBenchInfo &bi) bi.UserTime = ::GetUserTime(); } -void SetFinishTime(const CBenchInfo &biStart, CBenchInfo &dest) +static void SetFinishTime(const CBenchInfo &biStart, CBenchInfo &dest) { dest.GlobalFreq = GetFreq(); dest.UserFreq = GetUserFreq(); @@ -820,6 +840,18 @@ HRESULT LzmaBench( #endif RINOK(status.Res); SetFinishTime(encoders[0].progressInfoSpec[0]->BenchInfo, info); + #ifdef BENCH_MT + #ifdef UNDER_CE + if (numDecoderThreads > 1) + for (i = 0; i < numEncoderThreads; i++) + for (UInt32 j = 0; j < numSubDecoderThreads; j++) + { + FILETIME creationTime, exitTime, kernelTime, userTime; + if (::GetThreadTimes(encoders[i].thread[j], &creationTime, &exitTime, &kernelTime, &userTime) != 0) + info.UserTime += GetTime64(userTime) + GetTime64(kernelTime); + } + #endif + #endif info.UnpackSize = 0; info.PackSize = 0; info.NumIterations = numSubDecoderThreads * encoders[0].NumIterations; @@ -969,7 +1001,7 @@ HRESULT CrcBench(UInt32 numThreads, UInt32 bufferSize, UInt64 &speed) Byte *buf = buffer.Buffer; CBaseRandomGenerator RG; - UInt32 numCycles = ((UInt32)1 << 30) / ((bufferSize >> 2) + 1) + 1; + UInt32 numCycles = (kCrcBlockSize) / ((bufferSize >> 2) + 1) + 1; UInt64 timeVal; #ifdef BENCH_MT diff --git a/CPP/7zip/Compress/LZMA_Alone/makefile b/CPP/7zip/Compress/LZMA_Alone/makefile index f6d94081..197b0ee6 100755 --- a/CPP/7zip/Compress/LZMA_Alone/makefile +++ b/CPP/7zip/Compress/LZMA_Alone/makefile @@ -1,5 +1,5 @@ PROG = lzma.exe -LIBS = $(LIBS) user32.lib +MY_CONSOLE = 1 CFLAGS = $(CFLAGS) \ -DCOMPRESS_MF_MT \ -DBENCH_MT \ @@ -37,14 +37,12 @@ C_OBJS = \ $O\Bra86.obj \ $O\LzFind.obj \ $O\LzFindMt.obj \ + $O\Lzma86Dec.obj \ + $O\Lzma86Enc.obj \ $O\LzmaDec.obj \ $O\LzmaEnc.obj \ $O\Threads.obj \ -C_LZMAUTIL_OBJS = \ - $O\Lzma86Dec.obj \ - $O\Lzma86Enc.obj \ - OBJS = \ $O\StdAfx.obj \ $(LZMA_OBJS) \ @@ -53,7 +51,6 @@ OBJS = \ $(WIN_OBJS) \ $(7ZIP_COMMON_OBJS) \ $(C_OBJS) \ - $(C_LZMAUTIL_OBJS) \ $O\FileStreams.obj \ $O\FileIO.obj \ @@ -76,5 +73,3 @@ $O\FileIO.obj: ../../../Windows/FileIO.cpp $(COMPL) $(C_OBJS): ../../../../C/$(*B).c $(COMPL_O2) -$(C_LZMAUTIL_OBJS): ../../../../C/LzmaUtil/$(*B).c - $(COMPL_O2) diff --git a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc index 8d534372..288ed33a 100755 --- a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc +++ b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc @@ -24,6 +24,7 @@ OBJS = \ LzmaBenchCon.o \ LzmaDecoder.o \ LzmaEncoder.o \ + CWrappers.o \ InBuffer.o \ OutBuffer.o \ FileStreams.o \ @@ -66,6 +67,9 @@ LzmaDecoder.o: ../LzmaDecoder.cpp LzmaEncoder.o: ../LzmaEncoder.cpp $(CXX) $(CFLAGS) ../LzmaEncoder.cpp +CWrappers.o: ../../Common/CWrappers.cpp + $(CXX) $(CFLAGS) ../../Common/CWrappers.cpp + InBuffer.o: ../../Common/InBuffer.cpp $(CXX) $(CFLAGS) ../../Common/InBuffer.cpp @@ -124,11 +128,11 @@ LzmaDec.o: ../../../../C/LzmaDec.c LzmaEnc.o: ../../../../C/LzmaEnc.c $(CXX_C) $(CFLAGS) ../../../../C/LzmaEnc.c -Lzma86Dec.o: ../../../../C/LzmaUtil/Lzma86Dec.c - $(CXX_C) $(CFLAGS) ../../../../C/LzmaUtil/Lzma86Dec.c +Lzma86Dec.o: ../../../../C/Lzma86Dec.c + $(CXX_C) $(CFLAGS) ../../../../C/Lzma86Dec.c -Lzma86Enc.o: ../../../../C/LzmaUtil/Lzma86Enc.c - $(CXX_C) $(CFLAGS) ../../../../C/LzmaUtil/Lzma86Enc.c +Lzma86Enc.o: ../../../../C/Lzma86Enc.c + $(CXX_C) $(CFLAGS) ../../../../C/Lzma86Enc.c clean: -$(RM) $(PROG) $(OBJS) diff --git a/CPP/7zip/Compress/Mtf8.h b/CPP/7zip/Compress/Mtf8.h index 7a6b7fe6..d15dd4a5 100755 --- a/CPP/7zip/Compress/Mtf8.h +++ b/CPP/7zip/Compress/Mtf8.h @@ -3,6 +3,8 @@ #ifndef __COMPRESS_MTF8_H #define __COMPRESS_MTF8_H +#include "../../../C/CpuArch.h" + #include "../../Common/Types.h" namespace NCompress { @@ -63,11 +65,7 @@ struct CMtf8Decoder }; */ -#ifdef _WIN64 -#define MODE_64BIT -#endif - -#ifdef MODE_64BIT +#ifdef MY_CPU_64BIT typedef UInt64 CMtfVar; #define MTF_MOVS 3 #else @@ -102,12 +100,11 @@ struct CMtf8Decoder } for (; i < lim; i += 2) { - CMtfVar next = Buf[i]; - Buf[i] = (next << 8) | prev; - prev = (next >> (MTF_MASK << 3)); - next = Buf[i + 1]; - Buf[i + 1] = (next << 8) | prev; - prev = (next >> (MTF_MASK << 3)); + CMtfVar n0 = Buf[i]; + CMtfVar n1 = Buf[i + 1]; + Buf[i ] = (n0 << 8) | prev; + Buf[i + 1] = (n1 << 8) | (n0 >> (MTF_MASK << 3)); + prev = (n1 >> (MTF_MASK << 3)); } CMtfVar next = Buf[i]; CMtfVar mask = (((CMtfVar)0x100 << pos) - 1); diff --git a/CPP/7zip/Compress/ZlibDecoder.cpp b/CPP/7zip/Compress/ZlibDecoder.cpp index a1bac27b..90d6715d 100755 --- a/CPP/7zip/Compress/ZlibDecoder.cpp +++ b/CPP/7zip/Compress/ZlibDecoder.cpp @@ -4,20 +4,18 @@ #include "../Common/StreamUtils.h" -#include "DeflateDecoder.h" #include "ZlibDecoder.h" namespace NCompress { namespace NZlib { #define DEFLATE_TRY_BEGIN try { -#define DEFLATE_TRY_END } \ - catch(...) { return S_FALSE; } +#define DEFLATE_TRY_END } catch(...) { return S_FALSE; } #define ADLER_MOD 65521 #define ADLER_LOOP_MAX 5550 -static UInt32 Adler32_Update(UInt32 adler, const Byte *buf, size_t size) +UInt32 Adler32_Update(UInt32 adler, const Byte *buf, size_t size) { UInt32 a = adler & 0xFFFF; UInt32 b = (adler >> 16) & 0xFFFF; @@ -52,13 +50,10 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream { DEFLATE_TRY_BEGIN if (!AdlerStream) - { - AdlerSpec = new COutStreamWithAdler; - AdlerStream = AdlerSpec; - } + AdlerStream = AdlerSpec = new COutStreamWithAdler; if (!DeflateDecoder) { - DeflateDecoderSpec = new NCompress::NDeflate::NDecoder::CCOMCoder; + DeflateDecoderSpec = new NDeflate::NDecoder::CCOMCoder; DeflateDecoderSpec->ZlibMode = true; DeflateDecoder = DeflateDecoderSpec; } diff --git a/CPP/7zip/Compress/ZlibDecoder.h b/CPP/7zip/Compress/ZlibDecoder.h index 906e241b..95c11002 100755 --- a/CPP/7zip/Compress/ZlibDecoder.h +++ b/CPP/7zip/Compress/ZlibDecoder.h @@ -38,6 +38,8 @@ public: STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); + UInt64 GetInputProcessedSize() const { return DeflateDecoderSpec->GetInputProcessedSize() + 2; } + MY_UNKNOWN_IMP }; diff --git a/CPP/7zip/Compress/ZlibEncoder.cpp b/CPP/7zip/Compress/ZlibEncoder.cpp new file mode 100755 index 00000000..09235c33 --- /dev/null +++ b/CPP/7zip/Compress/ZlibEncoder.cpp @@ -0,0 +1,61 @@ +// ZlibEncoder.cpp + +#include "StdAfx.h" + +#include "../Common/StreamUtils.h" + +#include "ZlibEncoder.h" + +namespace NCompress { +namespace NZlib { + +#define DEFLATE_TRY_BEGIN try { +#define DEFLATE_TRY_END } catch(...) { return S_FALSE; } + +UInt32 Adler32_Update(UInt32 adler, const Byte *buf, size_t size); + +STDMETHODIMP CInStreamWithAdler::Read(void *data, UInt32 size, UInt32 *processedSize) +{ + HRESULT result = _stream->Read(data, size, &size); + _adler = Adler32_Update(_adler, (const Byte *)data, size); + _size += size; + if (processedSize != NULL) + *processedSize = size; + return result; +} + +void CEncoder::Create() +{ + if (!DeflateEncoder) + DeflateEncoder = DeflateEncoderSpec = new NDeflate::NEncoder::CCOMCoder; +} + +STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream, + const UInt64 *inSize, const UInt64 * /* outSize */, ICompressProgressInfo *progress) +{ + DEFLATE_TRY_BEGIN + if (!AdlerStream) + AdlerStream = AdlerSpec = new CInStreamWithAdler; + Create(); + + { + Byte buf[2] = { 0x78, 0xDA }; + RINOK(WriteStream(outStream, buf, 2)); + } + + AdlerSpec->SetStream(inStream); + AdlerSpec->Init(); + HRESULT res = DeflateEncoder->Code(AdlerStream, outStream, inSize, NULL, progress); + AdlerSpec->ReleaseStream(); + + RINOK(res); + + { + UInt32 a = AdlerSpec->GetAdler(); + Byte buf[4] = { (Byte)(a >> 24), (Byte)(a >> 16), (Byte)(a >> 8), (Byte)(a) }; + return WriteStream(outStream, buf, 4); + } + DEFLATE_TRY_END +} + +}} diff --git a/CPP/7zip/Compress/ZlibEncoder.h b/CPP/7zip/Compress/ZlibEncoder.h new file mode 100755 index 00000000..621cc1d0 --- /dev/null +++ b/CPP/7zip/Compress/ZlibEncoder.h @@ -0,0 +1,48 @@ +// ZlibEncoder.h + +#ifndef __ZLIB_ENCODER_H +#define __ZLIB_ENCODER_H + +#include "DeflateEncoder.h" + +namespace NCompress { +namespace NZlib { + +class CInStreamWithAdler: + public ISequentialInStream, + public CMyUnknownImp +{ + CMyComPtr<ISequentialInStream> _stream; + UInt32 _adler; + UInt64 _size; +public: + MY_UNKNOWN_IMP + STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); + void SetStream(ISequentialInStream *stream) { _stream = stream; } + void ReleaseStream() { _stream.Release(); } + void Init() { _adler = 1; _size = 0; } // ADLER_INIT_VAL + UInt32 GetAdler() const { return _adler; } + UInt64 GetSize() const { return _size; } +}; + +class CEncoder: + public ICompressCoder, + public CMyUnknownImp +{ + CInStreamWithAdler *AdlerSpec; + CMyComPtr<ISequentialInStream> AdlerStream; + CMyComPtr<ICompressCoder> DeflateEncoder; +public: + NCompress::NDeflate::NEncoder::CCOMCoder *DeflateEncoderSpec; + + void Create(); + STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, + const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); + UInt64 GetInputProcessedSize() const { return AdlerSpec->GetSize(); } + + MY_UNKNOWN_IMP +}; + +}} + +#endif diff --git a/CPP/7zip/Compress/makefile b/CPP/7zip/Compress/makefile index 7c1387c8..e981319d 100755 --- a/CPP/7zip/Compress/makefile +++ b/CPP/7zip/Compress/makefile @@ -1,12 +1,5 @@ DIRS = \ - Branch\~ \ - ByteSwap\~ \ - BZip2\~ \ - Copy\~ \ - Deflate\~ \ - LZMA\~ \ - PPMD\~ \ - Rar\~ \ + LZMA_Alone\~ \ all: $(DIRS) diff --git a/CPP/7zip/Crc.mak b/CPP/7zip/Crc.mak index 99c370b8..872fb378 100755 --- a/CPP/7zip/Crc.mak +++ b/CPP/7zip/Crc.mak @@ -1,11 +1,11 @@ -!IF "$(CPU)" != "IA64" -!IF "$(CPU)" != "AMD64" +!IFNDEF CPU $O\7zCrcT8U.obj: ../../../../Asm/x86/$(*B).asm $(COMPL_ASM) -!ELSE +$O\7zCrcT8.obj: ../../../../C/$(*B).c + $(COMPL_O2) +!ELSE IF "$(CPU)" == "AMD64" $O\7zCrcT8U.obj: ../../../../Asm/x64/$(*B).asm $(COMPL_ASM) -!ENDIF $O\7zCrcT8.obj: ../../../../C/$(*B).c $(COMPL_O2) !ELSE diff --git a/CPP/7zip/Crc2.mak b/CPP/7zip/Crc2.mak index 44d264f7..c257a077 100755 --- a/CPP/7zip/Crc2.mak +++ b/CPP/7zip/Crc2.mak @@ -1,5 +1,5 @@ CRC_OBJS = \ -!IF "$(CPU)" != "IA64" +!IF "$(CPU)" != "IA64" && "$(CPU)" != "ARM" $O\7zCrcT8U.obj \ $O\7zCrcT8.obj \ !ELSE diff --git a/CPP/7zip/Crypto/ZipStrong.cpp b/CPP/7zip/Crypto/ZipStrong.cpp index b29a3ad4..be5b4275 100755 --- a/CPP/7zip/Crypto/ZipStrong.cpp +++ b/CPP/7zip/Crypto/ZipStrong.cpp @@ -7,7 +7,7 @@ #include "../Common/StreamUtils.h" -#include "MyAES.h" +#include "MyAes.h" #include "Sha1.h" #include "ZipStrong.h" diff --git a/CPP/7zip/GuiCommon.rc b/CPP/7zip/GuiCommon.rc index 66dc5ca6..736f94da 100755 --- a/CPP/7zip/GuiCommon.rc +++ b/CPP/7zip/GuiCommon.rc @@ -2,36 +2,69 @@ #include <WinUser.h> #include <CommCtrl.h> -#define marg 7 -#undef bXSize -#undef bYSize -#define bXSize 64 -#define bYSize 14 -#define bDotsSize 20 - LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#undef xSize2 -#undef ySize2 -#undef xSize -#undef ySize -#undef bXPos -#undef bYPos -#undef b1XPos -#undef b1YPos -#undef b2XPos -#undef b2YPos -#undef b3XPos -#undef b3YPos -#undef gPos -#undef gPos2 +#undef m +#undef bxs +#undef bys +#undef bxsDots +#undef y +#undef xc +#undef yc +#undef xs +#undef ys +#undef bx +#undef bx1 +#undef bx2 +#undef bx3 +#undef by +#undef by1 +#undef by2 +#undef by3 #undef gSpace #undef gSize #undef marg2 #undef marg3 +#define m 8 +#define bxs 64 +#define bys 16 +#define bxsDots 20 + +#define xs (xc + m + m) +#define ys (yc + m + m) + +#define bx1 (xs - m - bxs) +#define bx2 (bx1 - m - bxs) +#define bx3 (bx2 - m - bxs) +#define bx bx1 + +#define by1 (ys - m - bys) +#define by2 (by1 - m - bys) +#define by by1 + + +#define MY_MODAL_DIALOG_STYLE STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU + +#define MY_MODAL_RESIZE_DIALOG_STYLE MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SIZEBOX | WS_THICKFRAME + +#define MY_PAGE_STYLE STYLE WS_CHILD | WS_DISABLED | WS_CAPTION + +#define MY_FONT FONT 8, "MS Shell Dlg" + +#define SMALL_PAGE_SIZE_X 120 + +#define MY_DIALOG DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT +#define MY_RESIZE_DIALOG DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT +#define MY_PAGE DIALOG 0, 0, xs, ys MY_PAGE_STYLE MY_FONT + +#define OK_CANCEL \ + DEFPUSHBUTTON "OK", IDOK, bx2, by, bxs, bys \ + PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys + -#define MY_MODAL_DIALOG_STYLE STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -#define MY_PAGE_STYLE STYLE DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION +#define MY_COMBO CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP +#define MY_COMBO_SORTED MY_COMBO | CBS_SORT +#define MY_COMBO_WITH_EDIT CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP -#define MY_FONT FONT 8, "MS Shell Dlg" +#define MY_CHECKBOX "Button", BS_AUTOCHECKBOX | WS_TABSTOP diff --git a/CPP/7zip/Guid.txt b/CPP/7zip/Guid.txt index 25939aaa..cb4d73d9 100755 --- a/CPP/7zip/Guid.txt +++ b/CPP/7zip/Guid.txt @@ -125,6 +125,10 @@ Handler GUIDs: 0B lzma86 0C xz + D5 Mslz + D6 Flv + D7 Swf + D8 Swfc D9 Ntfs DA Fat DB Mbr diff --git a/CPP/7zip/MyVersion.h b/CPP/7zip/MyVersion.h index ad2f0242..ea5222ac 100755 --- a/CPP/7zip/MyVersion.h +++ b/CPP/7zip/MyVersion.h @@ -1,8 +1,8 @@ #define MY_VER_MAJOR 9 -#define MY_VER_MINOR 04 +#define MY_VER_MINOR 06 #define MY_VER_BUILD 0 -#define MY_VERSION "9.04 beta" -#define MY_7ZIP_VERSION "7-Zip 9.04 beta" -#define MY_DATE "2009-05-30" +#define MY_VERSION "9.06 beta" +#define MY_7ZIP_VERSION "7-Zip 9.06 beta" +#define MY_DATE "2009-08-17" #define MY_COPYRIGHT "Copyright (c) 1999-2009 Igor Pavlov" #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE diff --git a/CPP/7zip/MyVersionInfo.rc b/CPP/7zip/MyVersionInfo.rc index c3712b16..814d7a4a 100755 --- a/CPP/7zip/MyVersionInfo.rc +++ b/CPP/7zip/MyVersionInfo.rc @@ -1,4 +1,11 @@ -#include <WinVer.h> +#define MY_VS_FFI_FILEFLAGSMASK 0x0000003FL +#define MY_VOS_NT_WINDOWS32 0x00040004L +#define MY_VOS_CE_WINDOWS32 0x00050004L + +#define MY_VFT_APP 0x00000001L +#define MY_VFT_DLL 0x00000002L + +// #include <WinVer.h> #include "MyVersion.h" #define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0 @@ -14,9 +21,9 @@ LANGUAGE 9, 1 \ 1 VERSIONINFO \ FILEVERSION MY_VER \ PRODUCTVERSION MY_VER \ - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK \ + FILEFLAGSMASK MY_VS_FFI_FILEFLAGSMASK \ FILEFLAGS DBG_FL \ - FILEOS VOS_NT_WINDOWS32 \ + FILEOS MY_VOS_NT_WINDOWS32 \ FILETYPE fileType \ FILESUBTYPE 0x0L \ BEGIN \ @@ -40,6 +47,6 @@ BEGIN \ END \ END -#define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(VFT_APP, descr, intName, intName ".exe") +#define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(MY_VFT_APP, descr, intName, intName ".exe") -#define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(VFT_DLL, descr, intName, intName ".dll") +#define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(MY_VFT_DLL, descr, intName, intName ".dll") diff --git a/CPP/7zip/UI/Agent/Agent.h b/CPP/7zip/UI/Agent/Agent.h index b95725e4..50b101f4 100755 --- a/CPP/7zip/UI/Agent/Agent.h +++ b/CPP/7zip/UI/Agent/Agent.h @@ -206,8 +206,8 @@ public: #endif const CArc &GetArc() { return _archiveLink.Arcs.Back(); } - IInArchive *GetArchive() { return GetArc().Archive; } - bool CanUpdate() const { return _archiveLink.Arcs.Size() == 1; } + IInArchive *GetArchive() { if ( _archiveLink.Arcs.IsEmpty()) return 0; return GetArc().Archive; } + bool CanUpdate() const { return _archiveLink.Arcs.Size() <= 1; } }; #ifdef NEW_FOLDER_INTERFACE diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp index 51a5affa..5d9ae62d 100755 --- a/CPP/7zip/UI/Agent/AgentOut.cpp +++ b/CPP/7zip/UI/Agent/AgentOut.cpp @@ -5,7 +5,6 @@ #include "Common/IntToString.h" #include "Common/StringConvert.h" -#include "Windows/Defs.h" #include "Windows/FileDir.h" #include "Windows/PropVariant.h" #include "Windows/PropVariantConversions.h" @@ -16,7 +15,6 @@ #include "../../Common/FileStreams.h" #include "../Common/EnumDirItems.h" -#include "../Common/HandlerLoader.h" #include "../Common/OpenArchive.h" #include "../Common/UpdateCallback.h" #include "../Common/UpdatePair.h" @@ -208,7 +206,7 @@ STDMETHODIMP CAgent::DoOperation( if (GetArchive()) { RINOK(ReadItems()); - EnumerateArchiveItems(this, _proxyArchive->RootFolder, L"", arcItems); + EnumerateArchiveItems(this, _proxyArchive->RootFolder, L"", arcItems); } CRecordVector<CUpdatePair2> updatePairs2; diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp index 98c75f4d..af9f6df0 100755 --- a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp +++ b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp @@ -6,8 +6,16 @@ #include "Common/StringConvert.h" +extern HINSTANCE g_hInstance; + static inline UINT GetCurrentFileCodePage() - { return AreFileApisANSI() ? CP_ACP : CP_OEMCP; } +{ + #ifdef UNDER_CE + return CP_ACP; + #else + return AreFileApisANSI() ? CP_ACP : CP_OEMCP; + #endif +} void CArchiveFolderManager::LoadFormats() { @@ -61,21 +69,25 @@ STDMETHODIMP CArchiveFolderManager::GetExtensions(const wchar_t *type, BSTR *ext return StringToBstr(_codecs.Formats[formatIndex].GetAllExtensions(), extensions); } */ + +static void AddIconExt(const CCodecIcons &lib, UString &dest) +{ + for (int j = 0; j < lib.IconPairs.Size(); j++) + { + if (!dest.IsEmpty()) + dest += L' '; + dest += lib.IconPairs[j].Ext; + } +} + STDMETHODIMP CArchiveFolderManager::GetExtensions(BSTR *extensions) { LoadFormats(); *extensions = 0; UString res; for (int i = 0; i < _codecs->Libs.Size(); i++) - { - const CCodecLib &lib = _codecs->Libs[i]; - for (int j = 0; j < lib.IconPairs.Size(); j++) - { - if (!res.IsEmpty()) - res += L' '; - res += lib.IconPairs[j].Ext; - } - } + AddIconExt(_codecs->Libs[i], res); + AddIconExt(_codecs->InternalIcons, res); return StringToBstr(res, extensions); } @@ -87,13 +99,21 @@ STDMETHODIMP CArchiveFolderManager::GetIconPath(const wchar_t *ext, BSTR *iconPa for (int i = 0; i < _codecs->Libs.Size(); i++) { const CCodecLib &lib = _codecs->Libs[i]; - int ii = lib.FindIconIndex(ext); - if (ii >= 0) + int ii; + if (lib.FindIconIndex(ext, ii)) { *iconIndex = ii; return StringToBstr(GetUnicodeString(lib.Path, GetCurrentFileCodePage()), iconPath); } } + int ii; + if (_codecs->InternalIcons.FindIconIndex(ext, ii)) + { + *iconIndex = ii; + UString path; + NWindows::NDLL::MyGetModuleFileName(g_hInstance, path); + return StringToBstr(path, iconPath); + } return S_OK; } diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp index 8f03f44d..cf3e2d5a 100755 --- a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp +++ b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp @@ -31,7 +31,7 @@ HRESULT CAgentFolder::CommonUpdateOperation( IFolderArchiveUpdateCallback *updateCallback100) { NWorkDir::CInfo workDirInfo; - ReadWorkDirInfo(workDirInfo); + workDirInfo.Load(); UString archiveFilePath = _agentSpec->_archiveFilePath; UString workDir = GetWorkDir(workDirInfo, archiveFilePath); CreateComplexDirectory(workDir); diff --git a/CPP/7zip/UI/Agent/IFolderArchive.h b/CPP/7zip/UI/Agent/IFolderArchive.h index 91da1150..7b5b0ba4 100755 --- a/CPP/7zip/UI/Agent/IFolderArchive.h +++ b/CPP/7zip/UI/Agent/IFolderArchive.h @@ -11,7 +11,7 @@ #include "../Common/ExtractMode.h" #include "../Common/IFileExtractCallback.h" -#define FOLDER_ARCHIVE_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 0x01, x) +#define FOLDER_ARCHIVE_INTERFACE_SUB(i, base, x) DECL_INTERFACE_SUB(i, base, 0x01, x) #define FOLDER_ARCHIVE_INTERFACE(i, x) FOLDER_ARCHIVE_INTERFACE_SUB(i, IUnknown, x) #define INTERFACE_IArchiveFolder(x) \ diff --git a/CPP/7zip/UI/Client7z/Client7z.cpp b/CPP/7zip/UI/Client7z/Client7z.cpp index 7c052171..410b800d 100755 --- a/CPP/7zip/UI/Client7z/Client7z.cpp +++ b/CPP/7zip/UI/Client7z/Client7z.cpp @@ -10,6 +10,7 @@ #include "Windows/FileDir.h" #include "Windows/FileFind.h" #include "Windows/FileName.h" +#include "Windows/NtCheck.h" #include "Windows/PropVariant.h" #include "Windows/PropVariantConversions.h" @@ -46,19 +47,6 @@ typedef UINT32 (WINAPI * CreateObjectFunc)( const GUID *interfaceID, void **outObject); -#ifdef _WIN32 -#ifndef _UNICODE -bool g_IsNT = false; -static inline bool IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} -#endif -#endif void PrintString(const UString &s) { @@ -660,51 +648,57 @@ STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDef ////////////////////////////////////////////////////////////////////////// // Main function -int MY_CDECL main(int argc, char* argv[]) +#define NT_CHECK_FAIL_ACTION PrintError("Unsupported Windows version"); return 1; + +int MY_CDECL main(int numArgs, const char *args[]) { - #ifdef _WIN32 - #ifndef _UNICODE - g_IsNT = IsItWindowsNT(); - #endif - #endif + NT_CHECK PrintStringLn(kCopyrightString); - if (argc < 3) + if (numArgs < 3) { PrintStringLn(kHelpString); return 1; } - NWindows::NDLL::CLibrary library; - if (!library.Load(TEXT(kDllName))) + NWindows::NDLL::CLibrary lib; + if (!lib.Load(TEXT(kDllName))) { - PrintError("Can not load library"); + PrintError("Can not load 7-zip library"); return 1; } - CreateObjectFunc createObjectFunc = (CreateObjectFunc)library.GetProcAddress("CreateObject"); + CreateObjectFunc createObjectFunc = (CreateObjectFunc)lib.GetProc("CreateObject"); if (createObjectFunc == 0) { PrintError("Can not get CreateObject"); return 1; } - AString command = argv[1]; - command.MakeLower(); - UString archiveName = GetUnicodeString(argv[2], CP_OEMCP); - if (command.Compare("a") == 0) + char c; + { + AString command = args[1]; + if (command.Length() != 1) + { + PrintError("incorrect command"); + return 1; + } + c = MyCharLower(command[0]); + } + UString archiveName = GetUnicodeString(args[2]); + if (c == 'a') { // create archive command - if (argc < 4) + if (numArgs < 4) { PrintStringLn(kHelpString); return 1; } CObjectVector<CDirItem> dirItems; int i; - for (i = 3; i < argc; i++) + for (i = 3; i < numArgs; i++) { CDirItem di; - UString name = GetUnicodeString(argv[i], CP_OEMCP); + UString name = GetUnicodeString(args[i]); NFile::NFind::CFileInfoW fi; if (!fi.Find(name)) @@ -743,6 +737,30 @@ int MY_CDECL main(int argc, char* argv[]) // updateCallbackSpec->PasswordIsDefined = true; // updateCallbackSpec->Password = L"1"; + /* + { + const wchar_t *names[] = + { + L"s", + L"x" + }; + const int kNumProps = sizeof(names) / sizeof(names[0]); + NWindows::NCOM::CPropVariant values[kNumProps] = + { + false, // solid mode OFF + (UInt32)9 // compression level = 9 - ultra + }; + CMyComPtr<ISetProperties> setProperties; + outArchive->QueryInterface(IID_ISetProperties, (void **)&setProperties); + if (!setProperties) + { + PrintError("ISetProperties unsupported"); + return 1; + } + RINOK(setProperties->SetProperties(names, values, kNumProps)); + } + */ + HRESULT result = outArchive->UpdateItems(outFileStream, dirItems.Size(), updateCallback); updateCallbackSpec->Finilize(); if (result != S_OK) @@ -760,16 +778,16 @@ int MY_CDECL main(int argc, char* argv[]) } else { - if (argc != 3) + if (numArgs != 3) { PrintStringLn(kHelpString); return 1; } bool listCommand; - if (command.Compare("l") == 0) + if (c == 'l') listCommand = true; - else if (command.Compare("x") == 0) + else if (c == 'x') listCommand = false; else { diff --git a/CPP/7zip/UI/Client7z/makefile b/CPP/7zip/UI/Client7z/makefile index 226c36a2..0ff8e72f 100755 --- a/CPP/7zip/UI/Client7z/makefile +++ b/CPP/7zip/UI/Client7z/makefile @@ -1,5 +1,5 @@ PROG = 7z.exe -LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib +MY_CONSOLE = 1 CFLAGS = $(CFLAGS) -I ../../../ CONSOLE_OBJS = \ diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp index 96d47c08..cfb0f796 100755 --- a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp +++ b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp @@ -3,8 +3,10 @@ #include "StdAfx.h" #ifdef _WIN32 +#ifndef UNDER_CE #include <io.h> #endif +#endif #include <stdio.h> #include "Common/ListFileUtils.h" @@ -26,6 +28,12 @@ extern bool g_CaseSensitive; +#ifdef UNDER_CE + +#define MY_IS_TERMINAL(x) false; + +#else + #if _MSC_VER >= 1400 #define MY_isatty_fileno(x) _isatty(_fileno(x)) #else @@ -34,6 +42,8 @@ extern bool g_CaseSensitive; #define MY_IS_TERMINAL(x) (MY_isatty_fileno(x) != 0); +#endif + using namespace NCommandLineParser; using namespace NWindows; using namespace NFile; @@ -250,26 +260,21 @@ static bool ParseArchiveCommand(const UString &commandString, CArchiveCommand &c // ------------------------------------------------------------------ // filenames functions -static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor, +static void AddNameToCensor(NWildcard::CCensor &wildcardCensor, const UString &name, bool include, NRecursedType::EEnum type) { - bool isWildCard = DoesNameContainWildCard(name); bool recursed = false; switch (type) { case NRecursedType::kWildCardOnlyRecursed: - recursed = isWildCard; + recursed = DoesNameContainWildCard(name); break; case NRecursedType::kRecursed: recursed = true; break; - case NRecursedType::kNonRecursed: - recursed = false; - break; } wildcardCensor.AddItem(include, name, recursed); - return true; } static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor, @@ -279,15 +284,7 @@ static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor, if (!ReadNamesFromListFile(fileName, names, codePage)) throw kIncorrectListFile; for (int i = 0; i < names.Size(); i++) - if (!AddNameToCensor(wildcardCensor, names[i], include, type)) - throw kIncorrectWildCardInListFile; -} - -static void AddCommandLineWildCardToCensr(NWildcard::CCensor &wildcardCensor, - const UString &name, bool include, NRecursedType::EEnum recursedType) -{ - if (!AddNameToCensor(wildcardCensor, name, include, recursedType)) - throw kIncorrectWildCardInCommandLine; + AddNameToCensor(wildcardCensor, names[i], include, type); } static void AddToCensorFromNonSwitchesStrings( @@ -297,14 +294,14 @@ static void AddToCensorFromNonSwitchesStrings( bool thereAreSwitchIncludes, UINT codePage) { if (nonSwitchStrings.Size() == startIndex && (!thereAreSwitchIncludes)) - AddCommandLineWildCardToCensr(wildcardCensor, kUniversalWildcard, true, type); + AddNameToCensor(wildcardCensor, kUniversalWildcard, true, type); for (int i = startIndex; i < nonSwitchStrings.Size(); i++) { const UString &s = nonSwitchStrings[i]; if (s[0] == kFileListID) AddToCensorFromListFile(wildcardCensor, s.Mid(1), true, type, codePage); else - AddCommandLineWildCardToCensr(wildcardCensor, s, true, type); + AddNameToCensor(wildcardCensor, s, true, type); } } @@ -330,9 +327,9 @@ static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor, UInt32 dataSize = (UInt32)dataSize64; { CFileMapping fileMapping; - if (!fileMapping.Open(FILE_MAP_READ, false, GetSystemString(mappingName))) + if (fileMapping.Open(FILE_MAP_READ, GetSystemString(mappingName)) != 0) ThrowException("Can not open mapping"); - LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_READ, 0, dataSize); + LPVOID data = fileMapping.Map(FILE_MAP_READ, 0, dataSize); if (data == NULL) ThrowException("MapViewOfFile error"); try @@ -347,8 +344,7 @@ static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor, wchar_t c = curData[i]; if (c == L'\0') { - AddCommandLineWildCardToCensr(wildcardCensor, - name, include, commonRecursedType); + AddNameToCensor(wildcardCensor, name, include, commonRecursedType); name.Empty(); } else @@ -398,7 +394,7 @@ static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor, ThrowUserErrorException(); UString tail = name.Mid(pos + 1); if (name[pos] == kImmediateNameID) - AddCommandLineWildCardToCensr(wildcardCensor, tail, include, recursedType); + AddNameToCensor(wildcardCensor, tail, include, recursedType); else if (name[pos] == kFileListID) AddToCensorFromListFile(wildcardCensor, tail, include, recursedType, codePage); #ifdef _WIN32 @@ -764,6 +760,52 @@ static bool ConvertStringToUInt32(const wchar_t *s, UInt32 &v) return true; } +void EnumerateDirItemsAndSort(NWildcard::CCensor &wildcardCensor, + UStringVector &sortedPaths, + UStringVector &sortedFullPaths) +{ + UStringVector paths; + { + CDirItems dirItems; + { + UStringVector errorPaths; + CRecordVector<DWORD> errorCodes; + HRESULT res = EnumerateItems(wildcardCensor, dirItems, NULL, errorPaths, errorCodes); + if (res != S_OK || errorPaths.Size() > 0) + throw "cannot find archive"; + } + for (int i = 0; i < dirItems.Items.Size(); i++) + { + const CDirItem &dirItem = dirItems.Items[i]; + if (!dirItem.IsDir()) + paths.Add(dirItems.GetPhyPath(i)); + } + } + + if (paths.Size() == 0) + throw "there is no such archive"; + + UStringVector fullPaths; + + int i; + for (i = 0; i < paths.Size(); i++) + { + UString fullPath; + NFile::NDirectory::MyGetFullPathName(paths[i], fullPath); + fullPaths.Add(fullPath); + } + CIntVector indices; + SortFileNames(fullPaths, indices); + sortedPaths.Reserve(indices.Size()); + sortedFullPaths.Reserve(indices.Size()); + for (i = 0; i < indices.Size(); i++) + { + int index = indices[i]; + sortedPaths.Add(paths[index]); + sortedFullPaths.Add(fullPaths[index]); + } +} + void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options) { const UStringVector &nonSwitchStrings = parser.NonSwitchStrings; @@ -844,16 +886,14 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options) NWildcard::CCensor archiveWildcardCensor; if (parser[NKey::kArInclude].ThereIs) - { AddSwitchWildCardsToCensor(archiveWildcardCensor, - parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed, codePage); - } + parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed, codePage); if (parser[NKey::kArExclude].ThereIs) AddSwitchWildCardsToCensor(archiveWildcardCensor, - parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed, codePage); + parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed, codePage); if (thereIsArchiveName) - AddCommandLineWildCardToCensr(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed); + AddNameToCensor(archiveWildcardCensor, options.ArchiveName, true, NRecursedType::kNonRecursed); #ifdef _WIN32 ConvertToLongNames(archiveWildcardCensor); @@ -869,50 +909,11 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options) } else { - - UStringVector archivePaths; - - { - CDirItems dirItems; - { - UStringVector errorPaths; - CRecordVector<DWORD> errorCodes; - HRESULT res = EnumerateItems(archiveWildcardCensor, dirItems, NULL, errorPaths, errorCodes); - if (res != S_OK || errorPaths.Size() > 0) - throw "cannot find archive"; - } - for (int i = 0; i < dirItems.Items.Size(); i++) - { - const CDirItem &dirItem = dirItems.Items[i]; - if (!dirItem.IsDir()) - archivePaths.Add(dirItems.GetPhyPath(i)); - } - } - - if (archivePaths.Size() == 0) - throw "there is no such archive"; - - UStringVector archivePathsFull; - - int i; - for (i = 0; i < archivePaths.Size(); i++) - { - UString fullPath; - NFile::NDirectory::MyGetFullPathName(archivePaths[i], fullPath); - archivePathsFull.Add(fullPath); - } - CIntVector indices; - SortFileNames(archivePathsFull, indices); - options.ArchivePathsSorted.Reserve(indices.Size()); - options.ArchivePathsFullSorted.Reserve(indices.Size()); - for (i = 0; i < indices.Size(); i++) - { - options.ArchivePathsSorted.Add(archivePaths[indices[i]]); - options.ArchivePathsFullSorted.Add(archivePathsFull[indices[i]]); + EnumerateDirItemsAndSort(archiveWildcardCensor, + options.ArchivePathsSorted, + options.ArchivePathsFullSorted); } - } - if (isExtractGroupCommand) { SetMethodOptions(parser, options.ExtractProperties); @@ -926,8 +927,7 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options) options.OverwriteMode = NExtract::NOverwriteMode::kAskBefore; if (parser[NKey::kOverwrite].ThereIs) - options.OverwriteMode = - k_OverwriteModes[parser[NKey::kOverwrite].PostCharIndex]; + options.OverwriteMode = k_OverwriteModes[parser[NKey::kOverwrite].PostCharIndex]; else if (options.YesToAll) options.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt; } diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.h b/CPP/7zip/UI/Common/ArchiveCommandLine.h index 6f79b7ee..e8f601df 100755 --- a/CPP/7zip/UI/Common/ArchiveCommandLine.h +++ b/CPP/7zip/UI/Common/ArchiveCommandLine.h @@ -1,10 +1,10 @@ // ArchiveCommandLine.h -#ifndef __ARCHIVECOMMANDLINE_H -#define __ARCHIVECOMMANDLINE_H +#ifndef __ARCHIVE_COMMAND_LINE_H +#define __ARCHIVE_COMMAND_LINE_H -#include "Common/Wildcard.h" #include "Common/CommandLineParser.h" +#include "Common/Wildcard.h" #include "Extract.h" #include "Update.h" @@ -104,4 +104,8 @@ public: void Parse2(CArchiveCommandLineOptions &options); }; +void EnumerateDirItemsAndSort(NWildcard::CCensor &wildcardCensor, + UStringVector &sortedPaths, + UStringVector &sortedFullPaths); + #endif diff --git a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp index 7188bcb6..e7e61713 100755 --- a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp +++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp @@ -75,9 +75,12 @@ struct CInFileStreamVol: public CInFileStream CMyComPtr<IArchiveOpenCallback> OpenCallbackRef; ~CInFileStreamVol() { - int index = OpenCallbackImp->FindName(Name); - if (index >= 0) - OpenCallbackImp->FileNames.Delete(index); + if (OpenCallbackRef) + { + int index = OpenCallbackImp->FindName(Name); + if (index >= 0) + OpenCallbackImp->FileNames.Delete(index); + } } }; diff --git a/CPP/7zip/UI/Common/CompressCall.cpp b/CPP/7zip/UI/Common/CompressCall.cpp index 47f89ed6..c2685f79 100755 --- a/CPP/7zip/UI/Common/CompressCall.cpp +++ b/CPP/7zip/UI/Common/CompressCall.cpp @@ -9,6 +9,7 @@ #include "Windows/FileDir.h" #include "Windows/FileMapping.h" +#include "Windows/Process.h" #include "Windows/Synchronization.h" #include "../FileManager/ProgramLocation.h" @@ -16,253 +17,170 @@ #include "CompressCall.h" -#ifndef _UNICODE -extern bool g_IsNT; -#endif _UNICODE - using namespace NWindows; +#define MY_TRY_BEGIN try { +#define MY_TRY_FINISH } \ + catch(...) { ErrorMessageHRESULT(E_FAIL); return E_FAIL; } + static LPCWSTR kShowDialogSwitch = L" -ad"; static LPCWSTR kEmailSwitch = L" -seml."; -static LPCWSTR kMapSwitch = L" -i#"; -static LPCWSTR kArchiveNoNameSwitch = L" -an"; +static LPCWSTR kIncludeSwitch = L" -i"; static LPCWSTR kArchiveTypeSwitch = L" -t"; -static LPCWSTR kArchiveMapSwitch = L" -ai#"; +static LPCWSTR kArcIncludeSwitches = L" -an -ai"; static LPCWSTR kStopSwitchParsing = L" --"; static LPCWSTR kLargePagesDisable = L" -slp-"; -static void AddLagePagesSwitch(UString ¶ms) +UString GetQuotedString(const UString &s) { - if (!ReadLockMemoryEnable()) - params += kLargePagesDisable; + return UString(L'\"') + s + UString(L'\"'); +} +static void ErrorMessage(LPCWSTR message) +{ + MessageBoxW(g_HWND, message, L"7-Zip", MB_ICONERROR | MB_OK); } -HRESULT MyCreateProcess(const UString ¶ms, - LPCWSTR curDir, bool waitFinish, - NWindows::NSynchronization::CBaseEvent *event) +static void ErrorMessageHRESULT(HRESULT res, LPCWSTR s = NULL) { - const UString params2 = params; - PROCESS_INFORMATION processInformation; - BOOL result; - #ifndef _UNICODE - if (!g_IsNT) + UString s2 = HResultToMessage(res); + if (s) { - STARTUPINFOA startupInfo; - startupInfo.cb = sizeof(startupInfo); - startupInfo.lpReserved = 0; - startupInfo.lpDesktop = 0; - startupInfo.lpTitle = 0; - startupInfo.dwFlags = 0; - startupInfo.cbReserved2 = 0; - startupInfo.lpReserved2 = 0; - - CSysString curDirA; - if (curDir != 0) - curDirA = GetSystemString(curDir); - result = ::CreateProcessA(NULL, (LPSTR)(LPCSTR)GetSystemString(params), - NULL, NULL, FALSE, 0, NULL, - ((curDir != 0) ? (LPCSTR)curDirA: 0), - &startupInfo, &processInformation); + s2 += L'\n'; + s2 += s; } - else - #endif + ErrorMessage(s2); +} + +static HRESULT MyCreateProcess(LPCWSTR imageName, const UString ¶ms, + LPCWSTR curDir, bool waitFinish, + NSynchronization::CBaseEvent *event) +{ + CProcess process; + WRes res = process.Create(imageName, params, curDir); + if (res != 0) { - STARTUPINFOW startupInfo; - startupInfo.cb = sizeof(startupInfo); - startupInfo.lpReserved = 0; - startupInfo.lpDesktop = 0; - startupInfo.lpTitle = 0; - startupInfo.dwFlags = 0; - startupInfo.cbReserved2 = 0; - startupInfo.lpReserved2 = 0; - - result = ::CreateProcessW(NULL, (LPWSTR)(LPCWSTR)params, - NULL, NULL, FALSE, 0, NULL, - curDir, - &startupInfo, &processInformation); + ErrorMessageHRESULT(res, imageName); + return res; } - if (result == 0) - return ::GetLastError(); - else + if (waitFinish) + process.Wait(); + else if (event != NULL) { - ::CloseHandle(processInformation.hThread); - if (waitFinish) - WaitForSingleObject(processInformation.hProcess, INFINITE); - else if (event != NULL) - { - HANDLE handles[] = {processInformation.hProcess, *event }; - ::WaitForMultipleObjects(sizeof(handles) / sizeof(handles[0]), - handles, FALSE, INFINITE); - } - ::CloseHandle(processInformation.hProcess); + HANDLE handles[] = { process, *event }; + ::WaitForMultipleObjects(sizeof(handles) / sizeof(handles[0]), handles, FALSE, INFINITE); } return S_OK; } -static UString GetQuotedString(const UString &s) +static void AddLagePagesSwitch(UString ¶ms) { - return UString(L"\"") + s + UString(L"\""); + if (!ReadLockMemoryEnable()) + params += kLargePagesDisable; } static UString Get7zGuiPath() { UString path; - UString folder; - if (GetProgramFolderPath(folder)) - path += folder; - path += L"7zG.exe"; - return GetQuotedString(path); + GetProgramFolderPath(path); + return path + L"7zG.exe"; } -static HRESULT CreateTempEvent(const wchar_t *name, - NSynchronization::CManualResetEvent &event, UString &eventName) +class CRandNameGenerator { - CRandom random; - random.Init(GetTickCount()); - for (;;) + CRandom _random; +public: + CRandNameGenerator() { _random.Init(); } + UString GenerateName() { - int number = random.Generate(); wchar_t temp[16]; - ConvertUInt32ToString((UInt32)number, temp); - eventName = name; - eventName += temp; - RINOK(event.CreateWithName(false, GetSystemString(eventName))); - if (::GetLastError() != ERROR_ALREADY_EXISTS) - return S_OK; - event.Close(); + ConvertUInt32ToString((UInt32)_random.Generate(), temp); + return temp; } -} +}; static HRESULT CreateMap(const UStringVector &names, - const UString &id, CFileMapping &fileMapping, NSynchronization::CManualResetEvent &event, UString ¶ms) { - UInt32 extraSize = 2; - UInt32 dataSize = 0; + UInt32 totalSize = 1; for (int i = 0; i < names.Size(); i++) - dataSize += (names[i].Length() + 1) * sizeof(wchar_t); - UInt32 totalSize = extraSize + dataSize; + totalSize += (names[i].Length() + 1); + totalSize *= sizeof(wchar_t); + CRandNameGenerator random; + UString mappingName; - - CRandom random; - random.Init(GetTickCount()); for (;;) { - int number = random.Generate(); - wchar_t temp[16]; - ConvertUInt32ToString(UInt32(number), temp); - mappingName = id; - mappingName += L"Mapping"; - mappingName += temp; - if (!fileMapping.Create(INVALID_HANDLE_VALUE, NULL, - PAGE_READWRITE, totalSize, GetSystemString(mappingName))) - return E_FAIL; - if (::GetLastError() != ERROR_ALREADY_EXISTS) + mappingName = L"7zMap" + random.GenerateName(); + + WRes res = fileMapping.Create(PAGE_READWRITE, totalSize, GetSystemString(mappingName)); + if (fileMapping.IsCreated() && res == 0) break; + if (res != ERROR_ALREADY_EXISTS) + return res; fileMapping.Close(); } UString eventName; - RINOK(CreateTempEvent(id + L"MappingEndEvent", event, eventName)); + for (;;) + { + eventName = L"7zEvent" + random.GenerateName(); + WRes res = event.CreateWithName(false, GetSystemString(eventName)); + if (event.IsCreated() && res == 0) + break; + if (res != ERROR_ALREADY_EXISTS) + return res; + event.Close(); + } + params += L'#'; params += mappingName; - params += L":"; - wchar_t string[16]; - ConvertUInt32ToString(totalSize, string); - params += string; + params += L':'; + wchar_t temp[16]; + ConvertUInt32ToString(totalSize, temp); + params += temp; - params += L":"; + params += L':'; params += eventName; - LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_WRITE, 0, totalSize); + LPVOID data = fileMapping.Map(FILE_MAP_WRITE, 0, totalSize); if (data == NULL) return E_FAIL; + CFileUnmapper unmapper(data); { - wchar_t *curData = (wchar_t *)data; - *curData = 0; - curData++; + wchar_t *cur = (wchar_t *)data; + *cur++ = 0; for (int i = 0; i < names.Size(); i++) { const UString &s = names[i]; - memcpy(curData, (const wchar_t *)s, s.Length() * sizeof(wchar_t)); - curData += s.Length(); - *curData++ = L'\0'; + int len = s.Length() + 1; + memcpy(cur, (const wchar_t *)s, len * sizeof(wchar_t)); + cur += len; } } return S_OK; } HRESULT CompressFiles( - const UString &curDir, - const UString &archiveName, - const UString &archiveType, + const UString &arcPathPrefix, + const UString &arcName, + const UString &arcType, const UStringVector &names, - // const UString &outFolder, - bool email, - bool showDialog, - bool waitFinish) + bool email, bool showDialog, bool waitFinish) { - /* - UString curDir; - if (names.Size() > 0) - { - NFile::NDirectory::GetOnlyDirPrefix(names[0], curDir); - } - */ - UString params; - params = Get7zGuiPath(); - params += L" a"; - params += kMapSwitch; - // params += _fileNames[0]; - - UInt32 extraSize = 2; - UInt32 dataSize = 0; - for (int i = 0; i < names.Size(); i++) - dataSize += (names[i].Length() + 1) * sizeof(wchar_t); - UInt32 totalSize = extraSize + dataSize; - - UString mappingName; + MY_TRY_BEGIN + UString params = L'a'; CFileMapping fileMapping; - CRandom random; - random.Init(GetTickCount()); - for (;;) - { - int number = random.Generate(); - wchar_t temp[16]; - ConvertUInt32ToString(UInt32(number), temp); - mappingName = L"7zCompressMapping"; - mappingName += temp; - if (!fileMapping.Create(INVALID_HANDLE_VALUE, NULL, - PAGE_READWRITE, totalSize, GetSystemString(mappingName))) - { - // MyMessageBox(IDS_ERROR, 0x02000605); - return E_FAIL; - } - if (::GetLastError() != ERROR_ALREADY_EXISTS) - break; - fileMapping.Close(); - } - NSynchronization::CManualResetEvent event; - UString eventName; - RINOK(CreateTempEvent(L"7zCompressMappingEndEvent", event, eventName)); - - params += mappingName; - params += L":"; - wchar_t string[16]; - ConvertUInt32ToString(totalSize, string); - params += string; - - params += L":"; - params += eventName; + params += kIncludeSwitch; + RINOK(CreateMap(names, fileMapping, event, params)); - if (!archiveType.IsEmpty()) + if (!arcType.IsEmpty()) { params += kArchiveTypeSwitch; - params += archiveType; + params += arcType; } if (email) @@ -274,71 +192,33 @@ HRESULT CompressFiles( AddLagePagesSwitch(params); params += kStopSwitchParsing; - params += L" "; - - params += GetQuotedString(archiveName); + params += L' '; - LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_WRITE, 0, totalSize); - if (data == NULL) - { - // MyMessageBox(IDS_ERROR, 0x02000605); - return E_FAIL; - } - try - { - wchar_t *curData = (wchar_t *)data; - *curData = 0; - curData++; - for (int i = 0; i < names.Size(); i++) - { - const UString &unicodeString = names[i]; - memcpy(curData, (const wchar_t *)unicodeString , - unicodeString .Length() * sizeof(wchar_t)); - curData += unicodeString.Length(); - *curData++ = L'\0'; - } - // MessageBox(0, params, 0, 0); - RINOK(MyCreateProcess(params, - (curDir.IsEmpty()? 0: (LPCWSTR)curDir), - waitFinish, &event)); - } - catch(...) - { - UnmapViewOfFile(data); - throw; - } - UnmapViewOfFile(data); + params += GetQuotedString( + #ifdef UNDER_CE + arcPathPrefix + + #endif + arcName); - - /* - CThreadCompressMain *compressor = new CThreadCompressMain();; - compressor->FileNames = _fileNames; - CThread thread; - if (!thread.Create(CThreadCompressMain::MyThreadFunction, compressor)) - throw 271824; - */ - return S_OK; + return MyCreateProcess(Get7zGuiPath(), params, + (arcPathPrefix.IsEmpty()? 0: (LPCWSTR)arcPathPrefix), waitFinish, &event); + MY_TRY_FINISH } -static HRESULT ExtractGroupCommand(const UStringVector &archivePaths, - const UString ¶ms) +static HRESULT ExtractGroupCommand(const UStringVector &arcPaths, UString ¶ms) { - UString params2 = params; - AddLagePagesSwitch(params2); - params2 += kArchiveNoNameSwitch; - params2 += kArchiveMapSwitch; + AddLagePagesSwitch(params); + params += kArcIncludeSwitches; CFileMapping fileMapping; NSynchronization::CManualResetEvent event; - RINOK(CreateMap(archivePaths, L"7zExtract", fileMapping, event, params2)); - return MyCreateProcess(params2, 0, false, &event); + RINOK(CreateMap(arcPaths, fileMapping, event, params)); + return MyCreateProcess(Get7zGuiPath(), params, 0, false, &event); } -HRESULT ExtractArchives(const UStringVector &archivePaths, - const UString &outFolder, bool showDialog) +HRESULT ExtractArchives(const UStringVector &arcPaths, const UString &outFolder, bool showDialog) { - UString params; - params = Get7zGuiPath(); - params += L" x"; + MY_TRY_BEGIN + UString params = L'x'; if (!outFolder.IsEmpty()) { params += L" -o"; @@ -346,21 +226,21 @@ HRESULT ExtractArchives(const UStringVector &archivePaths, } if (showDialog) params += kShowDialogSwitch; - return ExtractGroupCommand(archivePaths, params); + return ExtractGroupCommand(arcPaths, params); + MY_TRY_FINISH } -HRESULT TestArchives(const UStringVector &archivePaths) +HRESULT TestArchives(const UStringVector &arcPaths) { - UString params; - params = Get7zGuiPath(); - params += L" t"; - return ExtractGroupCommand(archivePaths, params); + MY_TRY_BEGIN + UString params = L't'; + return ExtractGroupCommand(arcPaths, params); + MY_TRY_FINISH } HRESULT Benchmark() { - UString params; - params = Get7zGuiPath(); - params += L" b"; - return MyCreateProcess(params, 0, false, NULL); + MY_TRY_BEGIN + return MyCreateProcess(Get7zGuiPath(), L'b', 0, false, NULL); + MY_TRY_FINISH } diff --git a/CPP/7zip/UI/Common/CompressCall.h b/CPP/7zip/UI/Common/CompressCall.h index feb45790..fc18df57 100755 --- a/CPP/7zip/UI/Common/CompressCall.h +++ b/CPP/7zip/UI/Common/CompressCall.h @@ -1,30 +1,24 @@ // CompressCall.h -#ifndef __COMPRESSCALL_H -#define __COMPRESSCALL_H +#ifndef __COMPRESS_CALL_H +#define __COMPRESS_CALL_H #include "Common/MyString.h" -#include "Windows/Synchronization.h" -HRESULT MyCreateProcess(const UString ¶ms, - LPCWSTR lpCurrentDirectory, bool waitFinish, - NWindows::NSynchronization::CBaseEvent *event); +UString GetQuotedString(const UString &s); + +extern HWND g_HWND; +UString HResultToMessage(HRESULT errorCode); HRESULT CompressFiles( - const UString &curDir, - const UString &archiveName, - const UString &archiveType, + const UString &arcPathPrefix, + const UString &arcName, + const UString &arcType, const UStringVector &names, - // const UString &outFolder, bool email, bool showDialog, bool waitFinish); -HRESULT ExtractArchives( - const UStringVector &archivePaths, - const UString &outFolder, bool showDialog); - -HRESULT TestArchives(const UStringVector &archivePaths); - +HRESULT ExtractArchives(const UStringVector &arcPaths, const UString &outFolder, bool showDialog); +HRESULT TestArchives(const UStringVector &arcPaths); HRESULT Benchmark(); #endif - diff --git a/CPP/7zip/UI/Common/CompressCall2.cpp b/CPP/7zip/UI/Common/CompressCall2.cpp new file mode 100755 index 00000000..0ed227ca --- /dev/null +++ b/CPP/7zip/UI/Common/CompressCall2.cpp @@ -0,0 +1,173 @@ +// CompressCall.cpp + +#include "StdAfx.h" + +#include "Common/MyException.h" + +#include "../../UI/common/ArchiveCommandLine.h" + +#include "../../UI/GUI/BenchmarkDialog.h" +#include "../../UI/GUI/ExtractGUI.h" +#include "../../UI/GUI/UpdateGUI.h" + +#include "../../UI/GUI/ExtractRes.h" + +#include "CompressCall.h" + +#define MY_TRY_BEGIN try { +#define MY_TRY_FINISH } \ + catch(CSystemException &e) { result = e.ErrorCode; } \ + catch(...) { result = E_FAIL; } \ + if (result != S_OK && result != E_ABORT) \ + ErrorMessageHRESULT(result); + +#define CREATE_CODECS \ + CCodecs *codecs = new CCodecs; \ + CMyComPtr<IUnknown> compressCodecsInfo = codecs; \ + result = codecs->Load(); \ + if (result != S_OK) \ + throw CSystemException(result); + +UString GetQuotedString(const UString &s) +{ + return UString(L'\"') + s + UString(L'\"'); +} + +static void ErrorMessage(LPCWSTR message) +{ + MessageBoxW(g_HWND, message, L"7-Zip", MB_ICONERROR); +} + +static void ErrorMessageHRESULT(HRESULT res) +{ + ErrorMessage(HResultToMessage(res)); +} + +static void ErrorLangMessage(UINT resourceID, UInt32 langID) +{ + ErrorMessage(LangString(resourceID, langID)); +} + +HRESULT CompressFiles( + const UString &arcPathPrefix, + const UString &arcName, + const UString &arcType, + const UStringVector &names, + bool email, bool showDialog, bool /* waitFinish */) +{ + HRESULT result; + MY_TRY_BEGIN + CREATE_CODECS + + CUpdateCallbackGUI callback; + + callback.Init(); + + CUpdateOptions uo; + uo.EMailMode = email; + uo.SetAddActionCommand(); + + CIntVector formatIndices; + if (!codecs->FindFormatForArchiveType(arcType, formatIndices)) + { + ErrorLangMessage(IDS_UNSUPPORTED_ARCHIVE_TYPE, 0x0200060D); + return E_FAIL; + } + if (!uo.Init(codecs, formatIndices, arcPathPrefix + arcName)) + { + ErrorLangMessage(IDS_UPDATE_NOT_SUPPORTED, 0x02000601); + return E_FAIL; + } + + NWildcard::CCensor censor; + for (int i = 0; i < names.Size(); i++) + censor.AddItem(true, names[i], false); + + bool messageWasDisplayed = false; + result = UpdateGUI(codecs, censor, uo, showDialog, messageWasDisplayed, &callback, g_HWND); + + if (result != S_OK) + { + if (result != E_ABORT && messageWasDisplayed) + return E_FAIL; + throw CSystemException(result); + } + if (callback.FailedFiles.Size() > 0) + { + if (!messageWasDisplayed) + throw CSystemException(E_FAIL); + return E_FAIL; + } + MY_TRY_FINISH + return S_OK; +} + +static HRESULT ExtractGroupCommand(const UStringVector &arcPaths, + bool showDialog, const UString &outFolder, bool testMode) +{ + HRESULT result; + MY_TRY_BEGIN + CREATE_CODECS + + CExtractOptions eo; + eo.OutputDir = outFolder; + eo.TestMode = testMode; + + CExtractCallbackImp *ecs = new CExtractCallbackImp; + CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs; + + ecs->Init(); + + // eo.CalcCrc = options.CalcCrc; + + UStringVector arcPathsSorted; + UStringVector arcFullPathsSorted; + { + NWildcard::CCensor acrCensor; + for (int i = 0; i < arcPaths.Size(); i++) + acrCensor.AddItem(true, arcPaths[i], false); + EnumerateDirItemsAndSort(acrCensor, arcPathsSorted, arcFullPathsSorted); + } + + CIntVector formatIndices; + + NWildcard::CCensor censor; + censor.AddItem(true, L"*", false); + + bool messageWasDisplayed = false; + result = ExtractGUI(codecs, formatIndices, arcPathsSorted, arcFullPathsSorted, + censor.Pairs.Front().Head, eo, showDialog, messageWasDisplayed, ecs, g_HWND); + if (result != S_OK) + { + if (result != E_ABORT && messageWasDisplayed) + return E_FAIL; + throw CSystemException(result); + } + return ecs->IsOK() ? S_OK : E_FAIL; + MY_TRY_FINISH + return result; +} + +HRESULT ExtractArchives(const UStringVector &arcPaths, const UString &outFolder, bool showDialog) +{ + return ExtractGroupCommand(arcPaths, showDialog, outFolder, false); +} + +HRESULT TestArchives(const UStringVector &arcPaths) +{ + return ExtractGroupCommand(arcPaths, true, UString(), true); +} + +HRESULT Benchmark() +{ + HRESULT result; + MY_TRY_BEGIN + CREATE_CODECS + result = Benchmark( + #ifdef EXTERNAL_LZMA + codecs, + #endif + (UInt32)-1, (UInt32)-1, g_HWND); + MY_TRY_FINISH + return result; +} diff --git a/CPP/7zip/UI/Common/HandlerLoader.h b/CPP/7zip/UI/Common/HandlerLoader.h deleted file mode 100755 index 4c7e1a8f..00000000 --- a/CPP/7zip/UI/Common/HandlerLoader.h +++ /dev/null @@ -1,38 +0,0 @@ -// HandlerLoader.h - -#ifndef __HANDLERLOADER_H -#define __HANDLERLOADER_H - -#include "../../ICoder.h" -#include "Windows/DLL.h" - -typedef UInt32 (WINAPI * CreateObjectFunc)( - const GUID *clsID, - const GUID *interfaceID, - void **outObject); - -class CHandlerLoader: public NWindows::NDLL::CLibrary -{ -public: - HRESULT CreateHandler(LPCWSTR filepath, REFGUID clsID, - void **archive, bool outHandler) - { - if (!Load(filepath)) - return GetLastError(); - CreateObjectFunc createObject = (CreateObjectFunc) - GetProcAddress("CreateObject"); - if (createObject == NULL) - { - HRESULT res = ::GetLastError(); - Free(); - return res; - } - HRESULT res = createObject(&clsID, - outHandler ? &IID_IOutArchive : &IID_IInArchive, (void **)archive); - if (res != 0) - Free(); - return res; - } -}; - -#endif diff --git a/CPP/7zip/UI/Common/LoadCodecs.cpp b/CPP/7zip/UI/Common/LoadCodecs.cpp index dac8c4d2..856e47fb 100755 --- a/CPP/7zip/UI/Common/LoadCodecs.cpp +++ b/CPP/7zip/UI/Common/LoadCodecs.cpp @@ -111,12 +111,12 @@ static HRESULT GetCoderClass(GetMethodPropertyFunc getMethodProperty, UInt32 ind HRESULT CCodecs::LoadCodecs() { CCodecLib &lib = Libs.Back(); - lib.GetMethodProperty = (GetMethodPropertyFunc)lib.Lib.GetProcAddress("GetMethodProperty"); + lib.GetMethodProperty = (GetMethodPropertyFunc)lib.Lib.GetProc("GetMethodProperty"); if (lib.GetMethodProperty == NULL) return S_OK; UInt32 numMethods = 1; - GetNumberOfMethodsFunc getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)lib.Lib.GetProcAddress("GetNumberOfMethods"); + GetNumberOfMethodsFunc getNumberOfMethodsFunc = (GetNumberOfMethodsFunc)lib.Lib.GetProc("GetNumberOfMethods"); if (getNumberOfMethodsFunc != NULL) { RINOK(getNumberOfMethodsFunc(&numMethods)); @@ -210,10 +210,11 @@ static void SplitString(const UString &srcString, UStringVector &destStrings) destStrings.Add(s); } -void CArcInfoEx::AddExts(const wchar_t* ext, const wchar_t* addExt) +void CArcInfoEx::AddExts(const wchar_t *ext, const wchar_t *addExt) { UStringVector exts, addExts; - SplitString(ext, exts); + if (ext != 0) + SplitString(ext, exts); if (addExt != 0) SplitString(addExt, addExts); for (int i = 0; i < exts.Size(); i++) @@ -236,19 +237,16 @@ HRESULT CCodecs::LoadFormats() { const NDLL::CLibrary &lib = Libs.Back().Lib; GetHandlerPropertyFunc getProp = 0; - GetHandlerPropertyFunc2 getProp2 = (GetHandlerPropertyFunc2) - lib.GetProcAddress("GetHandlerProperty2"); + GetHandlerPropertyFunc2 getProp2 = (GetHandlerPropertyFunc2)lib.GetProc("GetHandlerProperty2"); if (getProp2 == NULL) { - getProp = (GetHandlerPropertyFunc) - lib.GetProcAddress("GetHandlerProperty"); + getProp = (GetHandlerPropertyFunc)lib.GetProc("GetHandlerProperty"); if (getProp == NULL) return S_OK; } UInt32 numFormats = 1; - GetNumberOfFormatsFunc getNumberOfFormats = (GetNumberOfFormatsFunc) - lib.GetProcAddress("GetNumberOfFormats"); + GetNumberOfFormatsFunc getNumberOfFormats = (GetNumberOfFormatsFunc)lib.GetProc("GetNumberOfFormats"); if (getNumberOfFormats != NULL) { RINOK(getNumberOfFormats(&numFormats)); @@ -294,37 +292,48 @@ HRESULT CCodecs::LoadFormats() } #ifdef NEW_FOLDER_INTERFACE -void CCodecLib::LoadIcons() +void CCodecIcons::LoadIcons(HMODULE m) { - UString iconTypes = MyLoadStringW((HMODULE)Lib, kIconTypesResId); + UString iconTypes = MyLoadStringW(m, kIconTypesResId); UStringVector pairs; SplitString(iconTypes, pairs); for (int i = 0; i < pairs.Size(); i++) { const UString &s = pairs[i]; int pos = s.Find(L':'); - if (pos < 0) - continue; CIconPair iconPair; - const wchar_t *end; - UString num = s.Mid(pos + 1); - iconPair.IconIndex = (UInt32)ConvertStringToUInt64(num, &end); - if (*end != L'\0') - continue; + iconPair.IconIndex = -1; + if (pos < 0) + pos = s.Length(); + else + { + UString num = s.Mid(pos + 1); + if (!num.IsEmpty()) + { + const wchar_t *end; + iconPair.IconIndex = (UInt32)ConvertStringToUInt64(num, &end); + if (*end != L'\0') + continue; + } + } iconPair.Ext = s.Left(pos); IconPairs.Add(iconPair); } } -int CCodecLib::FindIconIndex(const UString &ext) const +bool CCodecIcons::FindIconIndex(const UString &ext, int &iconIndex) const { + iconIndex = -1; for (int i = 0; i < IconPairs.Size(); i++) { const CIconPair &pair = IconPairs[i]; if (ext.CompareNoCase(pair.Ext) == 0) - return pair.IconIndex; + { + iconIndex = pair.IconIndex; + return true; + } } - return -1; + return false; } #endif @@ -335,8 +344,9 @@ extern "C" } #endif -HRESULT CCodecs::LoadDll(const CSysString &dllPath) +HRESULT CCodecs::LoadDll(const CSysString &dllPath, bool needCheckDll) { + if (needCheckDll) { NDLL::CLibrary library; if (!library.LoadEx(dllPath, LOAD_LIBRARY_AS_DATAFILE)) @@ -358,13 +368,13 @@ HRESULT CCodecs::LoadDll(const CSysString &dllPath) #ifdef _7ZIP_LARGE_PAGES if (g_LargePageSize != 0) { - SetLargePageModeFunc setLargePageMode = (SetLargePageModeFunc)lib.Lib.GetProcAddress("SetLargePageMode"); + SetLargePageModeFunc setLargePageMode = (SetLargePageModeFunc)lib.Lib.GetProc("SetLargePageMode"); if (setLargePageMode != 0) setLargePageMode(); } #endif - lib.CreateObject = (CreateObjectFunc)lib.Lib.GetProcAddress("CreateObject"); + lib.CreateObject = (CreateObjectFunc)lib.Lib.GetProc("CreateObject"); if (lib.CreateObject != 0) { int startSize = Codecs.Size(); @@ -391,7 +401,7 @@ HRESULT CCodecs::LoadDllsFromFolder(const CSysString &folderPrefix) { if (fi.IsDir()) continue; - RINOK(LoadDll(folderPrefix + fi.Name)); + RINOK(LoadDll(folderPrefix + fi.Name, true)); } return S_OK; } @@ -408,6 +418,10 @@ static inline void SetBuffer(CByteBuffer &bb, const Byte *data, int size) HRESULT CCodecs::Load() { + #ifdef NEW_FOLDER_INTERFACE + InternalIcons.LoadIcons(g_hInstance); + #endif + Formats.Clear(); #ifdef EXTERNAL_CODECS Codecs.Clear(); @@ -430,7 +444,7 @@ HRESULT CCodecs::Load() } #ifdef EXTERNAL_CODECS const CSysString baseFolder = GetBaseFolderPrefixFromRegistry(); - RINOK(LoadDll(baseFolder + kMainDll)); + RINOK(LoadDll(baseFolder + kMainDll, false)); RINOK(LoadDllsFromFolder(baseFolder + kCodecsFolderName TEXT(STRING_PATH_SEPARATOR))); RINOK(LoadDllsFromFolder(baseFolder + kFormatsFolderName TEXT(STRING_PATH_SEPARATOR))); #endif diff --git a/CPP/7zip/UI/Common/LoadCodecs.h b/CPP/7zip/UI/Common/LoadCodecs.h index 71de2ff1..a633dd2e 100755 --- a/CPP/7zip/UI/Common/LoadCodecs.h +++ b/CPP/7zip/UI/Common/LoadCodecs.h @@ -102,21 +102,31 @@ typedef UInt32 (WINAPI *GetMethodPropertyFunc)(UInt32 index, PROPID propID, PROP typedef UInt32 (WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *interfaceID, void **outObject); +#ifdef NEW_FOLDER_INTERFACE +struct CCodecIcons +{ + struct CIconPair + { + UString Ext; + int IconIndex; + }; + CObjectVector<CIconPair> IconPairs; + void LoadIcons(HMODULE m); + bool FindIconIndex(const UString &ext, int &iconIndex) const; +}; +#endif + struct CCodecLib +#ifdef NEW_FOLDER_INTERFACE +: public CCodecIcons +#endif { NWindows::NDLL::CLibrary Lib; GetMethodPropertyFunc GetMethodProperty; CreateObjectFunc CreateObject; #ifdef NEW_FOLDER_INTERFACE - struct CIconPair - { - UString Ext; - UInt32 IconIndex; - }; CSysString Path; - CObjectVector<CIconPair> IconPairs; - void LoadIcons(); - int FindIconIndex(const UString &ext) const; + void LoadIcons() { CCodecIcons::LoadIcons((HMODULE)Lib); } #endif CCodecLib(): GetMethodProperty(0) {} }; @@ -134,9 +144,14 @@ public: #ifdef EXTERNAL_CODECS CObjectVector<CCodecLib> Libs; CObjectVector<CDllCodecInfo> Codecs; + + #ifdef NEW_FOLDER_INTERFACE + CCodecIcons InternalIcons; + #endif + HRESULT LoadCodecs(); HRESULT LoadFormats(); - HRESULT LoadDll(const CSysString &path); + HRESULT LoadDll(const CSysString &path, bool needCheckDll); HRESULT LoadDllsFromFolder(const CSysString &folderPrefix); HRESULT CreateArchiveHandler(const CArcInfoEx &ai, void **archive, bool outHandler) const diff --git a/CPP/7zip/UI/Common/OpenArchive.cpp b/CPP/7zip/UI/Common/OpenArchive.cpp index ec9f9a45..90c39de9 100755 --- a/CPP/7zip/UI/Common/OpenArchive.cpp +++ b/CPP/7zip/UI/Common/OpenArchive.cpp @@ -94,6 +94,15 @@ static inline bool TestSignature(const Byte *p1, const Byte *p2, size_t size) } #endif +#ifdef UNDER_CE +static const int kNumHashBytes = 1; +#define HASH_VAL(buf, pos) ((buf)[pos]) +#else +static const int kNumHashBytes = 2; +#define HASH_VAL(buf, pos) ((buf)[pos] | ((UInt32)(buf)[pos + 1] << 8)) +#endif + + HRESULT CArc::OpenStream( CCodecs *codecs, int formatIndex, @@ -144,30 +153,33 @@ HRESULT CArc::OpenStream( return S_FALSE; const Byte *buf = byteBuffer; - Byte hash[1 << 16]; - memset(hash, 0xFF, 1 << 16); + CByteBuffer hashBuffer; + const UInt32 kNumVals = 1 << (kNumHashBytes * 8); + hashBuffer.SetCapacity(kNumVals); + Byte *hash = hashBuffer; + memset(hash, 0xFF, kNumVals); Byte prevs[256]; - if (orderIndices.Size() > 255) + if (orderIndices.Size() >= 256) return S_FALSE; int i; for (i = 0; i < orderIndices.Size(); i++) { const CArcInfoEx &ai = codecs->Formats[orderIndices[i]]; const CByteBuffer &sig = ai.StartSignature; - if (sig.GetCapacity() < 2) + if (sig.GetCapacity() < kNumHashBytes) continue; - UInt32 v = sig[0] | ((UInt32)sig[1] << 8); + UInt32 v = HASH_VAL(sig, 0); prevs[i] = hash[v]; hash[v] = (Byte)i; } - processedSize--; + processedSize -= (kNumHashBytes - 1); for (UInt32 pos = 0; pos < processedSize; pos++) { - for (; pos < processedSize && hash[buf[pos] | ((UInt32)buf[pos + 1] << 8)] == 0xFF; pos++); + for (; pos < processedSize && hash[HASH_VAL(buf, pos)] == 0xFF; pos++); if (pos == processedSize) break; - UInt32 v = buf[pos] | ((UInt32)buf[pos + 1] << 8); + UInt32 v = HASH_VAL(buf, pos); Byte *ptr = &hash[v]; int i = *ptr; do @@ -175,14 +187,15 @@ HRESULT CArc::OpenStream( int index = orderIndices[i]; const CArcInfoEx &ai = codecs->Formats[index]; const CByteBuffer &sig = ai.StartSignature; - if (sig.GetCapacity() != 0 && pos + sig.GetCapacity() <= processedSize + 1) - if (TestSignature(buf + pos, sig, sig.GetCapacity())) - { - orderIndices2.Add(index); - orderIndices[i] = 0xFF; - *ptr = prevs[i]; - } - ptr = &prevs[i]; + if (sig.GetCapacity() != 0 && pos + sig.GetCapacity() <= processedSize + (kNumHashBytes - 1) && + TestSignature(buf + pos, sig, sig.GetCapacity())) + { + orderIndices2.Add(index); + orderIndices[i] = 0xFF; + *ptr = prevs[i]; + } + else + ptr = &prevs[i]; i = *ptr; } while (i != 0xFF); @@ -323,6 +336,15 @@ HRESULT CArc::OpenStreamOrFile( stream = fileStream; } + /* + if (callback) + { + UInt64 fileSize; + RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize)); + RINOK(callback->SetTotal(NULL, &fileSize)) + } + */ + return OpenStream(codecs, formatIndex, stream, seqStream, callback); } diff --git a/CPP/7zip/UI/Common/Update.cpp b/CPP/7zip/UI/Common/Update.cpp index 8c8db8de..4ed6049d 100755 --- a/CPP/7zip/UI/Common/Update.cpp +++ b/CPP/7zip/UI/Common/Update.cpp @@ -439,7 +439,7 @@ static HRESULT Compress( { errorInfo.SystemError = ::GetLastError(); errorInfo.FileName = realPath; - errorInfo.Message = L"Can not open file"; + errorInfo.Message = L"7-Zip cannot open file"; return E_FAIL; } } @@ -472,7 +472,7 @@ static HRESULT Compress( if (!sfxStreamSpec->Open(sfxModule)) { errorInfo.SystemError = ::GetLastError(); - errorInfo.Message = L"Can't open sfx module"; + errorInfo.Message = L"7-Zip cannot open SFX module"; errorInfo.FileName = sfxModule; return E_FAIL; } @@ -490,7 +490,7 @@ static HRESULT Compress( { errorInfo.SystemError = ::GetLastError(); errorInfo.FileName = realPath; - errorInfo.Message = L"Can not open file"; + errorInfo.Message = L"7-Zip cannot open file"; return E_FAIL; } } @@ -606,17 +606,14 @@ static HRESULT UpdateWithItemLists( return S_OK; } -#ifdef _WIN32 +#if defined(_WIN32) && !defined(UNDER_CE) class CCurrentDirRestorer { - UString m_CurrentDirectory; + UString _path; public: - CCurrentDirRestorer() - { NFile::NDirectory::MyGetCurrentDirectory(m_CurrentDirectory); } - ~CCurrentDirRestorer() - { RestoreDirectory();} - bool RestoreDirectory() - { return BOOLToBool(NFile::NDirectory::MySetCurrentDirectory(m_CurrentDirectory)); } + CCurrentDirRestorer() { NFile::NDirectory::MyGetCurrentDirectory(_path); } + ~CCurrentDirRestorer() { RestoreDirectory();} + bool RestoreDirectory() { return BOOLToBool(NFile::NDirectory::MySetCurrentDirectory(_path)); } }; #endif @@ -662,13 +659,19 @@ HRESULT UpdateArchive( options.MethodMode.Properties.Add(property); if (options.SfxModule.IsEmpty()) { - errorInfo.Message = L"sfx file is not specified"; + errorInfo.Message = L"SFX file is not specified"; return E_FAIL; } UString name = options.SfxModule; + #ifdef UNDER_CE + if (!NFind::DoesFileExist(name)) + #else if (!NDirectory::MySearchPath(NULL, name, NULL, options.SfxModule)) + #endif { - errorInfo.Message = L"can't find specified sfx module"; + errorInfo.SystemError = ::GetLastError(); + errorInfo.Message = L"7-Zip cannot find specified SFX module"; + errorInfo.FileName = name; return E_FAIL; } } @@ -744,7 +747,6 @@ HRESULT UpdateArchive( { if (res != E_ABORT) errorInfo.Message = L"Scanning error"; - // errorInfo.FileName = errorPath; return res; } RINOK(callback->FinishScanning()); @@ -804,7 +806,7 @@ HRESULT UpdateArchive( if (NFind::DoesFileOrDirExist(path)) { errorInfo.SystemError = 0; - errorInfo.Message = L"File already exists"; + errorInfo.Message = L"The file already exists"; errorInfo.FileName = path; return E_FAIL; } @@ -839,14 +841,14 @@ HRESULT UpdateArchive( if (!NDirectory::DeleteFileAlways(archiveName)) { errorInfo.SystemError = ::GetLastError(); - errorInfo.Message = L"delete file error"; + errorInfo.Message = L"7-Zip cannot delete the file"; errorInfo.FileName = archiveName; return E_FAIL; } if (!NDirectory::MyMoveFile(tempPath, archiveName)) { errorInfo.SystemError = ::GetLastError(); - errorInfo.Message = L"move file error"; + errorInfo.Message = L"7-Zip cannot move the file"; errorInfo.FileName = tempPath; errorInfo.FileName2 = archiveName; return E_FAIL; @@ -858,22 +860,21 @@ HRESULT UpdateArchive( } } - #ifdef _WIN32 + #if defined(_WIN32) && !defined(UNDER_CE) if (options.EMailMode) { NDLL::CLibrary mapiLib; if (!mapiLib.Load(TEXT("Mapi32.dll"))) { errorInfo.SystemError = ::GetLastError(); - errorInfo.Message = L"can not load Mapi32.dll"; + errorInfo.Message = L"7-Zip cannot load Mapi32.dll"; return E_FAIL; } - MY_LPMAPISENDDOCUMENTS fnSend = (MY_LPMAPISENDDOCUMENTS) - mapiLib.GetProcAddress("MAPISendDocuments"); + MY_LPMAPISENDDOCUMENTS fnSend = (MY_LPMAPISENDDOCUMENTS)mapiLib.GetProc("MAPISendDocuments"); if (fnSend == 0) { errorInfo.SystemError = ::GetLastError(); - errorInfo.Message = L"can not find MAPISendDocuments function"; + errorInfo.Message = L"7-Zip cannot find MAPISendDocuments function"; return E_FAIL; } UStringVector fullPaths; @@ -885,6 +886,7 @@ HRESULT UpdateArchive( if (!NFile::NDirectory::MyGetFullPathName(ap.GetFinalPath(), arcPath)) { errorInfo.SystemError = ::GetLastError(); + errorInfo.Message = L"GetFullPathName error"; return E_FAIL; } fullPaths.Add(arcPath); diff --git a/CPP/7zip/UI/Common/Update.h b/CPP/7zip/UI/Common/Update.h index 46547bf9..b5dc21cf 100755 --- a/CPP/7zip/UI/Common/Update.h +++ b/CPP/7zip/UI/Common/Update.h @@ -122,6 +122,15 @@ struct CUpdateOptions EMailRemoveAfter(false), OpenShareForWrite(false) {}; + + void SetAddActionCommand() + { + Commands.Clear(); + CUpdateArchiveCommand c; + c.ActionSet = NUpdateArchive::kAddActionSet; + Commands.Add(c); + } + CRecordVector<UInt64> VolumesSizes; }; diff --git a/CPP/7zip/UI/Common/WorkDir.cpp b/CPP/7zip/UI/Common/WorkDir.cpp index e97275b1..164118e2 100755 --- a/CPP/7zip/UI/Common/WorkDir.cpp +++ b/CPP/7zip/UI/Common/WorkDir.cpp @@ -2,31 +2,28 @@ #include "StdAfx.h" -#include "WorkDir.h" - #include "Common/StringConvert.h" #include "Common/Wildcard.h" -#include "Windows/FileName.h" #include "Windows/FileDir.h" +#include "Windows/FileName.h" -static inline UINT GetCurrentCodePage() - { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; } +#include "WorkDir.h" using namespace NWindows; using namespace NFile; -using namespace NName; UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path) { NWorkDir::NMode::EEnum mode = workDirInfo.Mode; + #ifndef UNDER_CE if (workDirInfo.ForRemovableOnly) { mode = NWorkDir::NMode::kCurrent; UString prefix = path.Left(3); if (prefix[1] == L':' && prefix[2] == L'\\') { - UINT driveType = GetDriveType(GetSystemString(prefix, GetCurrentCodePage())); + UINT driveType = GetDriveType(GetSystemString(prefix, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP)); if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE) mode = workDirInfo.Mode; } @@ -38,6 +35,7 @@ UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path) mode = NZipSettings::NWorkDir::NMode::kCurrent; */ } + #endif switch(mode) { case NWorkDir::NMode::kCurrent: @@ -47,18 +45,15 @@ UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path) case NWorkDir::NMode::kSpecified: { UString tempDir = workDirInfo.Path; - NormalizeDirPathPrefix(tempDir); + NName::NormalizeDirPathPrefix(tempDir); return tempDir; } default: { UString tempDir; - if(!NFile::NDirectory::MyGetTempPath(tempDir)) + if (!NDirectory::MyGetTempPath(tempDir)) throw 141717; return tempDir; } } } - - - diff --git a/CPP/7zip/UI/Common/ZipRegistry.cpp b/CPP/7zip/UI/Common/ZipRegistry.cpp index 16df878f..ac178078 100755 --- a/CPP/7zip/UI/Common/ZipRegistry.cpp +++ b/CPP/7zip/UI/Common/ZipRegistry.cpp @@ -2,142 +2,101 @@ #include "StdAfx.h" -#include "ZipRegistry.h" - #include "Common/IntToString.h" #include "Common/StringConvert.h" -#include "Windows/Synchronization.h" +#include "Windows/FileDir.h" #include "Windows/Registry.h" +#include "Windows/Synchronization.h" -#include "Windows/FileDir.h" +#include "ZipRegistry.h" using namespace NWindows; using namespace NRegistry; -static const TCHAR *kCUBasePath = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP"); +static NSynchronization::CCriticalSection g_CS; +#define CS_LOCK NSynchronization::CCriticalSectionLock lock(g_CS); -static NSynchronization::CCriticalSection g_RegistryOperationsCriticalSection; +static const TCHAR *kCuPrefix = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR); -////////////////////// -// ExtractionInfo +static CSysString GetKeyPath(const CSysString &path) { return kCuPrefix + path; } -static const TCHAR *kExtractionKeyName = TEXT("Extraction"); - -static const TCHAR *kExtractionPathHistoryKeyName = TEXT("PathHistory"); -static const TCHAR *kExtractionExtractModeValueName = TEXT("ExtarctMode"); -static const TCHAR *kExtractionOverwriteModeValueName = TEXT("OverwriteMode"); -static const TCHAR *kExtractionShowPasswordValueName = TEXT("ShowPassword"); +static LONG OpenMainKey(CKey &key, LPCTSTR keyName) +{ + return key.Open(HKEY_CURRENT_USER, GetKeyPath(keyName), KEY_READ); +} -static CSysString GetKeyPath(const CSysString &path) +static LONG CreateMainKey(CKey &key, LPCTSTR keyName) { - return CSysString(kCUBasePath) + CSysString(CHAR_PATH_SEPARATOR) + path; + return key.Create(HKEY_CURRENT_USER, GetKeyPath(keyName)); } -void SaveExtractionInfo(const NExtract::CInfo &info) +namespace NExtract { - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - CKey extractionKey; - extractionKey.Create(HKEY_CURRENT_USER, GetKeyPath(kExtractionKeyName)); - extractionKey.RecurseDeleteKey(kExtractionPathHistoryKeyName); - { - CKey pathHistoryKey; - pathHistoryKey.Create(extractionKey, kExtractionPathHistoryKeyName); - for(int i = 0; i < info.Paths.Size(); i++) - { - wchar_t numberString[16]; - ConvertUInt32ToString(i, numberString); - pathHistoryKey.SetValue(numberString, info.Paths[i]); - } - } - extractionKey.SetValue(kExtractionExtractModeValueName, UInt32(info.PathMode)); - extractionKey.SetValue(kExtractionOverwriteModeValueName, UInt32(info.OverwriteMode)); - extractionKey.SetValue(kExtractionShowPasswordValueName, info.ShowPassword); + +static const TCHAR *kKeyName = TEXT("Extraction"); + +static const TCHAR *kExtractMode = TEXT("ExtractMode"); +static const TCHAR *kOverwriteMode = TEXT("OverwriteMode"); +static const TCHAR *kShowPassword = TEXT("ShowPassword"); +static const TCHAR *kPathHistory = TEXT("PathHistory"); + +void CInfo::Save() const +{ + CS_LOCK + CKey key; + CreateMainKey(key, kKeyName); + key.SetValue(kExtractMode, (UInt32)PathMode); + key.SetValue(kOverwriteMode, (UInt32)OverwriteMode); + key.SetValue(kShowPassword, ShowPassword); + key.RecurseDeleteKey(kPathHistory); + key.SetValue_Strings(kPathHistory, Paths); } -void ReadExtractionInfo(NExtract::CInfo &info) + +void CInfo::Load() { - info.Paths.Clear(); - info.PathMode = NExtract::NPathMode::kCurrentPathnames; - info.OverwriteMode = NExtract::NOverwriteMode::kAskBefore; - info.ShowPassword = false; - - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - CKey extractionKey; - if(extractionKey.Open(HKEY_CURRENT_USER, GetKeyPath(kExtractionKeyName), KEY_READ) != ERROR_SUCCESS) + PathMode = NPathMode::kCurrentPathnames; + OverwriteMode = NOverwriteMode::kAskBefore; + ShowPassword = false; + Paths.Clear(); + + CS_LOCK + CKey key; + if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS) return; - { - CKey pathHistoryKey; - if(pathHistoryKey.Open(extractionKey, kExtractionPathHistoryKeyName, KEY_READ) == - ERROR_SUCCESS) - { - for (;;) - { - wchar_t numberString[16]; - ConvertUInt32ToString(info.Paths.Size(), numberString); - UString path; - if (pathHistoryKey.QueryValue(numberString, path) != ERROR_SUCCESS) - break; - info.Paths.Add(path); - } - } - } - UInt32 extractModeIndex; - if (extractionKey.QueryValue(kExtractionExtractModeValueName, extractModeIndex) == ERROR_SUCCESS) - { - switch (extractModeIndex) - { - case NExtract::NPathMode::kFullPathnames: - case NExtract::NPathMode::kCurrentPathnames: - case NExtract::NPathMode::kNoPathnames: - info.PathMode = NExtract::NPathMode::EEnum(extractModeIndex); - break; - } - } - UInt32 overwriteModeIndex; - if (extractionKey.QueryValue(kExtractionOverwriteModeValueName, overwriteModeIndex) == ERROR_SUCCESS) - { - switch (overwriteModeIndex) - { - case NExtract::NOverwriteMode::kAskBefore: - case NExtract::NOverwriteMode::kWithoutPrompt: - case NExtract::NOverwriteMode::kSkipExisting: - case NExtract::NOverwriteMode::kAutoRename: - case NExtract::NOverwriteMode::kAutoRenameExisting: - info.OverwriteMode = NExtract::NOverwriteMode::EEnum(overwriteModeIndex); - break; - } - } - if (extractionKey.QueryValue(kExtractionShowPasswordValueName, - info.ShowPassword) != ERROR_SUCCESS) - info.ShowPassword = false; + key.GetValue_Strings(kPathHistory, Paths); + UInt32 v; + if (key.QueryValue(kExtractMode, v) == ERROR_SUCCESS && v <= NPathMode::kNoPathnames) + PathMode = (NPathMode::EEnum)v; + if (key.QueryValue(kOverwriteMode, v) == ERROR_SUCCESS && v <= NOverwriteMode::kAutoRenameExisting) + OverwriteMode = (NOverwriteMode::EEnum)v; + key.GetValue_IfOk(kShowPassword, ShowPassword); } -/////////////////////////////////// -// CompressionInfo +} -static const TCHAR *kCompressionKeyName = TEXT("Compression"); +namespace NCompression +{ -static const TCHAR *kCompressionHistoryArchivesKeyName = TEXT("ArcHistory"); -static const TCHAR *kCompressionLevelValueName = TEXT("Level"); -static const TCHAR *kCompressionLastFormatValueName = TEXT("Archiver"); -static const TCHAR *kCompressionShowPasswordValueName = TEXT("ShowPassword"); -static const TCHAR *kCompressionEncryptHeadersValueName = TEXT("EncryptHeaders"); +static const TCHAR *kKeyName = TEXT("Compression"); -static const TCHAR *kCompressionOptionsKeyName = TEXT("Options"); -// static const TCHAR *kSolid = TEXT("Solid"); -// static const TCHAR *kMultiThread = TEXT("Multithread"); +static const TCHAR *kArcHistory = TEXT("ArcHistory"); +static const WCHAR *kArchiver = L"Archiver"; +static const TCHAR *kShowPassword = TEXT("ShowPassword"); +static const TCHAR *kEncryptHeaders = TEXT("EncryptHeaders"); -static const WCHAR *kCompressionOptions = L"Options"; -static const TCHAR *kCompressionLevel = TEXT("Level"); -static const WCHAR *kCompressionMethod = L"Method"; -static const WCHAR *kEncryptionMethod = L"EncryptionMethod"; -static const TCHAR *kCompressionDictionary = TEXT("Dictionary"); -static const TCHAR *kCompressionOrder = TEXT("Order"); -static const TCHAR *kCompressionNumThreads = TEXT("NumThreads"); -static const TCHAR *kCompressionBlockSize = TEXT("BlockSize"); +static const TCHAR *kOptionsKeyName = TEXT("Options"); +static const TCHAR *kLevel = TEXT("Level"); +static const TCHAR *kDictionary = TEXT("Dictionary"); +static const TCHAR *kOrder = TEXT("Order"); +static const TCHAR *kBlockSize = TEXT("BlockSize"); +static const TCHAR *kNumThreads = TEXT("NumThreads"); +static const WCHAR *kMethod = L"Method"; +static const WCHAR *kOptions = L"Options"; +static const WCHAR *kEncryptionMethod = L"EncryptionMethod"; static void SetRegString(CKey &key, const WCHAR *name, const UString &value) { @@ -164,254 +123,171 @@ static void GetRegString(CKey &key, const WCHAR *name, UString &value) static void GetRegUInt32(CKey &key, const TCHAR *name, UInt32 &value) { if (key.QueryValue(name, value) != ERROR_SUCCESS) - value = UInt32(-1); + value = (UInt32)-1; } -void SaveCompressionInfo(const NCompression::CInfo &info) +void CInfo::Save() const { - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - - CKey compressionKey; - compressionKey.Create(HKEY_CURRENT_USER, GetKeyPath(kCompressionKeyName)); - compressionKey.RecurseDeleteKey(kCompressionHistoryArchivesKeyName); - { - CKey historyArchivesKey; - historyArchivesKey.Create(compressionKey, kCompressionHistoryArchivesKeyName); - for(int i = 0; i < info.HistoryArchives.Size(); i++) - { - wchar_t numberString[16]; - ConvertUInt32ToString(i, numberString); - historyArchivesKey.SetValue(numberString, info.HistoryArchives[i]); - } - } - - // compressionKey.SetValue(kSolid, info.Solid); - // compressionKey.SetValue(kMultiThread, info.MultiThread); - compressionKey.RecurseDeleteKey(kCompressionOptionsKeyName); + CS_LOCK + + CKey key; + CreateMainKey(key, kKeyName); + key.SetValue(kLevel, (UInt32)Level); + key.SetValue(kArchiver, ArcType); + key.SetValue(kShowPassword, ShowPassword); + key.SetValue(kEncryptHeaders, EncryptHeaders); + key.RecurseDeleteKey(kArcHistory); + key.SetValue_Strings(kArcHistory, ArcPaths); + + key.RecurseDeleteKey(kOptionsKeyName); { CKey optionsKey; - optionsKey.Create(compressionKey, kCompressionOptionsKeyName); - for(int i = 0; i < info.FormatOptionsVector.Size(); i++) + optionsKey.Create(key, kOptionsKeyName); + for (int i = 0; i < Formats.Size(); i++) { - const NCompression::CFormatOptions &fo = info.FormatOptionsVector[i]; - CKey formatKey; - formatKey.Create(optionsKey, fo.FormatID); + const CFormatOptions &fo = Formats[i]; + CKey fk; + fk.Create(optionsKey, fo.FormatID); - SetRegString(formatKey, kCompressionOptions, fo.Options); - SetRegString(formatKey, kCompressionMethod, fo.Method); - SetRegString(formatKey, kEncryptionMethod, fo.EncryptionMethod); - - SetRegUInt32(formatKey, kCompressionLevel, fo.Level); - SetRegUInt32(formatKey, kCompressionDictionary, fo.Dictionary); - SetRegUInt32(formatKey, kCompressionOrder, fo.Order); - SetRegUInt32(formatKey, kCompressionBlockSize, fo.BlockLogSize); - SetRegUInt32(formatKey, kCompressionNumThreads, fo.NumThreads); + SetRegUInt32(fk, kLevel, fo.Level); + SetRegUInt32(fk, kDictionary, fo.Dictionary); + SetRegUInt32(fk, kOrder, fo.Order); + SetRegUInt32(fk, kBlockSize, fo.BlockLogSize); + SetRegUInt32(fk, kNumThreads, fo.NumThreads); + + SetRegString(fk, kMethod, fo.Method); + SetRegString(fk, kOptions, fo.Options); + SetRegString(fk, kEncryptionMethod, fo.EncryptionMethod); } } - - compressionKey.SetValue(kCompressionLevelValueName, UInt32(info.Level)); - compressionKey.SetValue(kCompressionLastFormatValueName, GetSystemString(info.ArchiveType)); - - compressionKey.SetValue(kCompressionShowPasswordValueName, info.ShowPassword); - compressionKey.SetValue(kCompressionEncryptHeadersValueName, info.EncryptHeaders); - // compressionKey.SetValue(kCompressionMaximizeValueName, info.Maximize); } -void ReadCompressionInfo(NCompression::CInfo &info) +void CInfo::Load() { - info.HistoryArchives.Clear(); + ArcPaths.Clear(); + Formats.Clear(); - // info.Solid = true; - // info.MultiThread = IsMultiProcessor(); - info.FormatOptionsVector.Clear(); + Level = 5; + ArcType = L"7z"; + ShowPassword = false; + EncryptHeaders = false; - info.Level = 5; - info.ArchiveType = L"7z"; - // definedStatus.Maximize = false; - info.ShowPassword = false; - info.EncryptHeaders = false; + CS_LOCK + CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - CKey compressionKey; - - if(compressionKey.Open(HKEY_CURRENT_USER, - GetKeyPath(kCompressionKeyName), KEY_READ) != ERROR_SUCCESS) + if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS) return; - - { - CKey historyArchivesKey; - if(historyArchivesKey.Open(compressionKey, kCompressionHistoryArchivesKeyName, KEY_READ) == - ERROR_SUCCESS) - { - for (;;) - { - wchar_t numberString[16]; - ConvertUInt32ToString(info.HistoryArchives.Size(), numberString); - UString path; - if (historyArchivesKey.QueryValue(numberString, path) != ERROR_SUCCESS) - break; - info.HistoryArchives.Add(path); - } - } - } + key.GetValue_Strings(kArcHistory, ArcPaths); - /* - bool solid = false; - if (compressionKey.QueryValue(kSolid, solid) == ERROR_SUCCESS) - info.Solid = solid; - bool multiThread = false; - if (compressionKey.QueryValue(kMultiThread, multiThread) == ERROR_SUCCESS) - info.MultiThread = multiThread; - */ - { CKey optionsKey; - if(optionsKey.Open(compressionKey, kCompressionOptionsKeyName, KEY_READ) == - ERROR_SUCCESS) + if (optionsKey.Open(key, kOptionsKeyName, KEY_READ) == ERROR_SUCCESS) { CSysStringVector formatIDs; optionsKey.EnumKeys(formatIDs); - for(int i = 0; i < formatIDs.Size(); i++) + for (int i = 0; i < formatIDs.Size(); i++) { - CKey formatKey; - NCompression::CFormatOptions fo; + CKey fk; + CFormatOptions fo; fo.FormatID = formatIDs[i]; - if(formatKey.Open(optionsKey, fo.FormatID, KEY_READ) == ERROR_SUCCESS) + if (fk.Open(optionsKey, fo.FormatID, KEY_READ) == ERROR_SUCCESS) { - GetRegString(formatKey, kCompressionOptions, fo.Options); - GetRegString(formatKey, kCompressionMethod, fo.Method); - GetRegString(formatKey, kEncryptionMethod, fo.EncryptionMethod); + GetRegString(fk, kOptions, fo.Options); + GetRegString(fk, kMethod, fo.Method); + GetRegString(fk, kEncryptionMethod, fo.EncryptionMethod); - GetRegUInt32(formatKey, kCompressionLevel, fo.Level); - GetRegUInt32(formatKey, kCompressionDictionary, fo.Dictionary); - GetRegUInt32(formatKey, kCompressionOrder, fo.Order); - GetRegUInt32(formatKey, kCompressionBlockSize, fo.BlockLogSize); - GetRegUInt32(formatKey, kCompressionNumThreads, fo.NumThreads); + GetRegUInt32(fk, kLevel, fo.Level); + GetRegUInt32(fk, kDictionary, fo.Dictionary); + GetRegUInt32(fk, kOrder, fo.Order); + GetRegUInt32(fk, kBlockSize, fo.BlockLogSize); + GetRegUInt32(fk, kNumThreads, fo.NumThreads); - info.FormatOptionsVector.Add(fo); + Formats.Add(fo); } - } } } - UInt32 level; - if (compressionKey.QueryValue(kCompressionLevelValueName, level) == ERROR_SUCCESS) - info.Level = level; - CSysString archiveType; - if (compressionKey.QueryValue(kCompressionLastFormatValueName, archiveType) == ERROR_SUCCESS) - info.ArchiveType = GetUnicodeString(archiveType); - if (compressionKey.QueryValue(kCompressionShowPasswordValueName, - info.ShowPassword) != ERROR_SUCCESS) - info.ShowPassword = false; - if (compressionKey.QueryValue(kCompressionEncryptHeadersValueName, - info.EncryptHeaders) != ERROR_SUCCESS) - info.EncryptHeaders = false; - /* - if (compressionKey.QueryValue(kCompressionLevelValueName, info.Maximize) == ERROR_SUCCESS) - definedStatus.Maximize = true; - */ + UString a; + if (key.QueryValue(kArchiver, a) == ERROR_SUCCESS) + ArcType = a; + key.GetValue_IfOk(kLevel, Level); + key.GetValue_IfOk(kShowPassword, ShowPassword); + key.GetValue_IfOk(kEncryptHeaders, EncryptHeaders); } - -/////////////////////////////////// -// WorkDirInfo +} static const TCHAR *kOptionsInfoKeyName = TEXT("Options"); -static const TCHAR *kWorkDirTypeValueName = TEXT("WorkDirType"); -static const WCHAR *kWorkDirPathValueName = L"WorkDirPath"; -static const TCHAR *kTempRemovableOnlyValueName = TEXT("TempRemovableOnly"); -static const TCHAR *kCascadedMenuValueName = TEXT("CascadedMenu"); -static const TCHAR *kContextMenuValueName = TEXT("ContextMenu"); +namespace NWorkDir +{ +static const TCHAR *kWorkDirType = TEXT("WorkDirType"); +static const WCHAR *kWorkDirPath = L"WorkDirPath"; +static const TCHAR *kTempRemovableOnly = TEXT("TempRemovableOnly"); + -void SaveWorkDirInfo(const NWorkDir::CInfo &info) +void CInfo::Save()const { - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - CKey optionsKey; - optionsKey.Create(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName)); - optionsKey.SetValue(kWorkDirTypeValueName, UInt32(info.Mode)); - optionsKey.SetValue(kWorkDirPathValueName, info.Path); - optionsKey.SetValue(kTempRemovableOnlyValueName, info.ForRemovableOnly); + CS_LOCK + CKey key; + CreateMainKey(key, kOptionsInfoKeyName); + key.SetValue(kWorkDirType, (UInt32)Mode); + key.SetValue(kWorkDirPath, Path); + key.SetValue(kTempRemovableOnly, ForRemovableOnly); } -void ReadWorkDirInfo(NWorkDir::CInfo &info) +void CInfo::Load() { - info.SetDefault(); + SetDefault(); - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - CKey optionsKey; - if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS) + CS_LOCK + CKey key; + if (OpenMainKey(key, kOptionsInfoKeyName) != ERROR_SUCCESS) return; UInt32 dirType; - if (optionsKey.QueryValue(kWorkDirTypeValueName, dirType) != ERROR_SUCCESS) + if (key.QueryValue(kWorkDirType, dirType) != ERROR_SUCCESS) return; switch (dirType) { - case NWorkDir::NMode::kSystem: - case NWorkDir::NMode::kCurrent: - case NWorkDir::NMode::kSpecified: - info.Mode = NWorkDir::NMode::EEnum(dirType); + case NMode::kSystem: + case NMode::kCurrent: + case NMode::kSpecified: + Mode = (NMode::EEnum)dirType; } - UString sysWorkDir; - if (optionsKey.QueryValue(kWorkDirPathValueName, sysWorkDir) != ERROR_SUCCESS) + if (key.QueryValue(kWorkDirPath, Path) != ERROR_SUCCESS) { - info.Path.Empty(); - if (info.Mode == NWorkDir::NMode::kSpecified) - info.Mode = NWorkDir::NMode::kSystem; + Path.Empty(); + if (Mode == NMode::kSpecified) + Mode = NMode::kSystem; } - info.Path = GetUnicodeString(sysWorkDir); - if (optionsKey.QueryValue(kTempRemovableOnlyValueName, info.ForRemovableOnly) != ERROR_SUCCESS) - info.SetForRemovableOnlyDefault(); + key.GetValue_IfOk(kTempRemovableOnly, ForRemovableOnly); } -static void SaveOption(const TCHAR *value, bool enabled) -{ - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - CKey optionsKey; - optionsKey.Create(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName)); - optionsKey.SetValue(value, enabled); -} - -static bool ReadOption(const TCHAR *value, bool defaultValue) -{ - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - CKey optionsKey; - if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS) - return defaultValue; - bool enabled; - if (optionsKey.QueryValue(value, enabled) != ERROR_SUCCESS) - return defaultValue; - return enabled; } -void SaveCascadedMenu(bool show) - { SaveOption(kCascadedMenuValueName, show); } -bool ReadCascadedMenu() - { return ReadOption(kCascadedMenuValueName, true); } +static const TCHAR *kCascadedMenu = TEXT("CascadedMenu"); +static const TCHAR *kContextMenu = TEXT("ContextMenu"); - -static void SaveValue(const TCHAR *value, UInt32 valueToWrite) +void CContextMenuInfo::Save() const { - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - CKey optionsKey; - optionsKey.Create(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName)); - optionsKey.SetValue(value, valueToWrite); + CS_LOCK + CKey key; + CreateMainKey(key, kOptionsInfoKeyName); + key.SetValue(kCascadedMenu, Cascaded); + key.SetValue(kContextMenu, Flags); } -static bool ReadValue(const TCHAR *value, UInt32 &result) +void CContextMenuInfo::Load() { - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - CKey optionsKey; - if(optionsKey.Open(HKEY_CURRENT_USER, GetKeyPath(kOptionsInfoKeyName), KEY_READ) != ERROR_SUCCESS) - return false; - return (optionsKey.QueryValue(value, result) == ERROR_SUCCESS); + Cascaded = true; + Flags = (UInt32)-1; + CS_LOCK + CKey key; + if (OpenMainKey(key, kOptionsInfoKeyName) != ERROR_SUCCESS) + return; + key.GetValue_IfOk(kCascadedMenu, Cascaded); + key.GetValue_IfOk(kContextMenu, Flags); } - -void SaveContextMenuStatus(UInt32 value) - { SaveValue(kContextMenuValueName, value); } - -bool ReadContextMenuStatus(UInt32 &value) - { return ReadValue(kContextMenuValueName, value); } diff --git a/CPP/7zip/UI/Common/ZipRegistry.h b/CPP/7zip/UI/Common/ZipRegistry.h index 30be8d89..37835386 100755 --- a/CPP/7zip/UI/Common/ZipRegistry.h +++ b/CPP/7zip/UI/Common/ZipRegistry.h @@ -1,10 +1,11 @@ // ZipRegistry.h -#ifndef __ZIPREGISTRY_H -#define __ZIPREGISTRY_H +#ifndef __ZIP_REGISTRY_H +#define __ZIP_REGISTRY_H #include "Common/MyString.h" #include "Common/Types.h" + #include "ExtractMode.h" namespace NExtract @@ -13,49 +14,56 @@ namespace NExtract { NPathMode::EEnum PathMode; NOverwriteMode::EEnum OverwriteMode; - UStringVector Paths; bool ShowPassword; + UStringVector Paths; + + void Save() const; + void Load(); }; } -namespace NCompression { - +namespace NCompression +{ struct CFormatOptions { - CSysString FormatID; - UString Options; - UString Method; - UString EncryptionMethod; UInt32 Level; UInt32 Dictionary; UInt32 Order; UInt32 BlockLogSize; UInt32 NumThreads; + + CSysString FormatID; + UString Method; + UString Options; + UString EncryptionMethod; + void ResetForLevelChange() { BlockLogSize = NumThreads = Level = Dictionary = Order = UInt32(-1); Method.Empty(); - // EncryptionMethod.Empty(); // Options.Empty(); + // EncryptionMethod.Empty(); } CFormatOptions() { ResetForLevelChange(); } }; struct CInfo { - UStringVector HistoryArchives; UInt32 Level; - UString ArchiveType; - - CObjectVector<CFormatOptions> FormatOptionsVector; - bool ShowPassword; bool EncryptHeaders; + UString ArcType; + UStringVector ArcPaths; + + CObjectVector<CFormatOptions> Formats; + + void Save() const; + void Load(); }; } -namespace NWorkDir{ - +namespace NWorkDir +{ namespace NMode { enum EEnum @@ -70,6 +78,7 @@ namespace NWorkDir{ NMode::EEnum Mode; UString Path; bool ForRemovableOnly; + void SetForRemovableOnlyDefault() { ForRemovableOnly = true; } void SetDefault() { @@ -77,22 +86,20 @@ namespace NWorkDir{ Path.Empty(); SetForRemovableOnlyDefault(); } + + void Save() const; + void Load(); }; } -void SaveExtractionInfo(const NExtract::CInfo &info); -void ReadExtractionInfo(NExtract::CInfo &info); -void SaveCompressionInfo(const NCompression::CInfo &info); -void ReadCompressionInfo(NCompression::CInfo &info); - -void SaveWorkDirInfo(const NWorkDir::CInfo &info); -void ReadWorkDirInfo(NWorkDir::CInfo &info); - -void SaveCascadedMenu(bool enabled); -bool ReadCascadedMenu(); +struct CContextMenuInfo +{ + bool Cascaded; + UInt32 Flags; -void SaveContextMenuStatus(UInt32 value); -bool ReadContextMenuStatus(UInt32 &value); + void Save() const; + void Load(); +}; #endif diff --git a/CPP/7zip/UI/Console/Console.dsp b/CPP/7zip/UI/Console/Console.dsp index c6aeefed..05d15e65 100755 --- a/CPP/7zip/UI/Console/Console.dsp +++ b/CPP/7zip/UI/Console/Console.dsp @@ -284,6 +284,10 @@ SOURCE=..\..\..\Windows\MemoryLock.h # End Source File # Begin Source File +SOURCE=..\..\..\Windows\NtCheck.h +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\PropVariant.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/UI/Console/ConsoleClose.cpp b/CPP/7zip/UI/Console/ConsoleClose.cpp index d18b39e6..f1356a28 100755 --- a/CPP/7zip/UI/Console/ConsoleClose.cpp +++ b/CPP/7zip/UI/Console/ConsoleClose.cpp @@ -9,6 +9,7 @@ static const int kBreakAbortThreshold = 2; namespace NConsoleClose { +#ifndef UNDER_CE static BOOL WINAPI HandlerRoutine(DWORD ctrlType) { if (ctrlType == CTRL_LOGOFF_EVENT) @@ -32,14 +33,19 @@ static BOOL WINAPI HandlerRoutine(DWORD ctrlType) return FALSE; */ } +#endif bool TestBreakSignal() { + #ifdef UNDER_CE + return false; + #else /* if (g_BreakCounter > 0) return true; */ return (g_BreakCounter > 0); + #endif } void CheckCtrlBreak() @@ -50,14 +56,18 @@ void CheckCtrlBreak() CCtrlHandlerSetter::CCtrlHandlerSetter() { + #ifndef UNDER_CE if(!SetConsoleCtrlHandler(HandlerRoutine, TRUE)) throw "SetConsoleCtrlHandler fails"; + #endif } CCtrlHandlerSetter::~CCtrlHandlerSetter() { + #ifndef UNDER_CE if(!SetConsoleCtrlHandler(HandlerRoutine, FALSE)) throw "SetConsoleCtrlHandler fails"; + #endif } } diff --git a/CPP/7zip/UI/Console/List.cpp b/CPP/7zip/UI/Console/List.cpp index 4352bc71..f0f5c315 100755 --- a/CPP/7zip/UI/Console/List.cpp +++ b/CPP/7zip/UI/Console/List.cpp @@ -433,6 +433,7 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices, for (int i = 0; i < numArcs; i++) { const UString &archiveName = arcPaths[i]; + UInt64 arcPackSize = 0; if (!stdInMode) { NFile::NFind::CFileInfoW fi; @@ -442,6 +443,7 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices, numErrors++; continue; } + arcPackSize = fi.Size; } CArchiveLink archiveLink; @@ -583,6 +585,14 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices, totalPackSize += packSize; totalUnPackSize += unpackSize; } + + if (!stdInMode && totalPackSizePointer == 0) + { + if (archiveLink.VolumePaths.Size() != 0) + arcPackSize += archiveLink.VolumesSize; + totalPackSize = arcPackSize; + totalPackSizePointer = &totalPackSize; + } if (enableHeaders && !techMode) { fieldPrinter.PrintTitleLines(); diff --git a/CPP/7zip/UI/Console/Main.cpp b/CPP/7zip/UI/Console/Main.cpp index 368a9667..c8327361 100755 --- a/CPP/7zip/UI/Console/Main.cpp +++ b/CPP/7zip/UI/Console/Main.cpp @@ -2,6 +2,10 @@ #include "StdAfx.h" +#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES) +#include "../../../../C/Alloc.h" +#endif + #include "Common/MyInitGuid.h" #include "Common/CommandLineParser.h" @@ -11,17 +15,11 @@ #include "Common/StringConvert.h" #include "Common/StringToInt.h" -#include "Windows/Defs.h" #include "Windows/Error.h" -#include "Windows/FileDir.h" -#include "Windows/FileName.h" #ifdef _WIN32 #include "Windows/MemoryLock.h" #endif -#include "../../ICoder.h" -#include "../../IPassword.h" - #include "../Common/ArchiveCommandLine.h" #include "../Common/ExitCode.h" #include "../Common/Extract.h" @@ -29,8 +27,6 @@ #include "../Common/LoadCodecs.h" #endif #include "../Common/PropIDUtils.h" -#include "../Common/Update.h" -#include "../Common/UpdateAction.h" #include "../../Compress/LZMA_Alone/LzmaBenchCon.h" @@ -41,10 +37,6 @@ #include "../../MyVersion.h" -#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES) -#include "../../../../C/Alloc.h" -#endif - using namespace NWindows; using namespace NFile; using namespace NCommandLineParser; @@ -117,8 +109,9 @@ static const char *kHelpString = // exception messages static const char *kEverythingIsOk = "Everything is Ok"; -static const char *kUserErrorMessage = "Incorrect command line"; // NExitCode::kUserError +static const char *kUserErrorMessage = "Incorrect command line"; static const char *kNoFormats = "7-Zip cannot find the code that works with archives."; +static const char *kUnsupportedArcTypeMessage = "Unsupported archive type"; static const wchar_t *kDefaultSfxModule = L"7zCon.sfx"; @@ -128,19 +121,19 @@ static void ShowMessageAndThrowException(CStdOutStream &s, LPCSTR message, NExit throw code; } -static void PrintHelpAndExit(CStdOutStream &s) // yyy +static void PrintHelpAndExit(CStdOutStream &s) { s << kHelpString; ShowMessageAndThrowException(s, kUserErrorMessage, NExitCode::kUserError); } #ifndef _WIN32 -static void GetArguments(int numArguments, const char *arguments[], UStringVector &parts) +static void GetArguments(int numArgs, const char *args[], UStringVector &parts) { parts.Clear(); - for(int i = 0; i < numArguments; i++) + for (int i = 0; i < numArgs; i++) { - UString s = MultiByteToUnicodeString(arguments[i]); + UString s = MultiByteToUnicodeString(args[i]); parts.Add(s); } } @@ -177,15 +170,13 @@ static inline char GetHex(Byte value) return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10))); } -const char *kUnsupportedArcTypeMessage = "Unsupported archive type"; - int Main2( #ifndef _WIN32 - int numArguments, const char *arguments[] + int numArgs, const char *args[] #endif ) { - #ifdef _WIN32 + #if defined(_WIN32) && !defined(UNDER_CE) SetFileApisToOEM(); #endif @@ -193,7 +184,7 @@ int Main2( #ifdef _WIN32 NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings); #else - GetArguments(numArguments, arguments, commandStrings); + GetArguments(numArgs, args, commandStrings); #endif if (commandStrings.Size() == 1) diff --git a/CPP/7zip/UI/Console/MainAr.cpp b/CPP/7zip/UI/Console/MainAr.cpp index 02918d79..c54a3d09 100755 --- a/CPP/7zip/UI/Console/MainAr.cpp +++ b/CPP/7zip/UI/Console/MainAr.cpp @@ -2,85 +2,54 @@ #include "StdAfx.h" -// #include <locale.h> +#include "Common/MyException.h" +#include "Common/StdOutStream.h" #include "Windows/Error.h" +#include "Windows/NtCheck.h" -#include "Common/StdOutStream.h" -#include "Common/NewHandler.h" -#include "Common/MyException.h" -#include "Common/StringConvert.h" - -#include "../Common/ExitCode.h" #include "../Common/ArchiveCommandLine.h" +#include "../Common/ExitCode.h" + #include "ConsoleClose.h" using namespace NWindows; CStdOutStream *g_StdStream = 0; -#ifdef _WIN32 -#ifndef _UNICODE -bool g_IsNT = false; -#endif -#if !defined(_UNICODE) || !defined(_WIN64) -static inline bool IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} -#endif -#endif - extern int Main2( #ifndef _WIN32 - int numArguments, const char *arguments[] + int numArgs, const char *args[] #endif ); static const char *kExceptionErrorMessage = "\n\nError:\n"; static const char *kUserBreak = "\nBreak signaled\n"; - static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required memory!\n"; static const char *kUnknownExceptionMessage = "\n\nUnknown Error\n"; static const char *kInternalExceptionMessage = "\n\nInternal Error #"; +#define NT_CHECK_FAIL_ACTION (*g_StdStream) << "Unsupported Windows version"; return NExitCode::kFatalError; + int MY_CDECL main ( -#ifndef _WIN32 -int numArguments, const char *arguments[] -#endif + #ifndef _WIN32 + int numArgs, const char *args[] + #endif ) { g_StdStream = &g_StdOut; - #ifdef _WIN32 - - #ifdef _UNICODE - #ifndef _WIN64 - if (!IsItWindowsNT()) - { - (*g_StdStream) << "This program requires Windows NT/2000/2003/2008/XP/Vista"; - return NExitCode::kFatalError; - } - #endif - #else - g_IsNT = IsItWindowsNT(); - #endif - - #endif - // setlocale(LC_COLLATE, ".OCP"); + NT_CHECK + NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter; int res = 0; try { res = Main2( -#ifndef _WIN32 - numArguments, arguments -#endif + #ifndef _WIN32 + numArgs, args + #endif ); } catch(const CNewException &) @@ -112,8 +81,7 @@ int numArguments, const char *arguments[] } UString message; NError::MyFormatMessage(systemError.ErrorCode, message); - (*g_StdStream) << endl << endl << "System error:" << endl << - message << endl; + (*g_StdStream) << endl << endl << "System error:" << endl << message << endl; return (NExitCode::kFatalError); } catch(NExitCode::EEnum &exitCode) diff --git a/CPP/7zip/UI/Console/UserInputUtils.cpp b/CPP/7zip/UI/Console/UserInputUtils.cpp index 798486e7..0e55a868 100755 --- a/CPP/7zip/UI/Console/UserInputUtils.cpp +++ b/CPP/7zip/UI/Console/UserInputUtils.cpp @@ -23,13 +23,18 @@ static const char *kHelpQuestionMessage = NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream) { (*outStream) << kFirstQuestionMessage; - for(;;) + for (;;) { (*outStream) << kHelpQuestionMessage; AString scannedString = g_StdIn.ScanStringUntilNewLine(); scannedString.Trim(); - if(!scannedString.IsEmpty()) - switch(::MyCharUpper(scannedString[0])) + if (!scannedString.IsEmpty()) + switch( + ::MyCharUpper( + #ifdef UNDER_CE + (wchar_t) + #endif + scannedString[0])) { case kYes: return NUserAnswerMode::kYes; diff --git a/CPP/7zip/UI/Console/makefile b/CPP/7zip/UI/Console/makefile index a0d56615..467651ca 100755 --- a/CPP/7zip/UI/Console/makefile +++ b/CPP/7zip/UI/Console/makefile @@ -1,14 +1,16 @@ PROG = 7z.exe -LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib +MY_CONSOLE = 1 CFLAGS = $(CFLAGS) -I ../../../ \ -DCOMPRESS_MT \ - -DWIN_LONG_PATH \ -DEXTERNAL_LZMA \ -DEXTERNAL_CODECS \ -DBREAK_HANDLER \ -DBENCH_MT \ - -D_7ZIP_LARGE_PAGES \ - -DSUPPORT_DEVICE_FILE \ + +!IFNDEF UNDER_CE +CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -D_7ZIP_LARGE_PAGES -DSUPPORT_DEVICE_FILE +!ENDIF + CONSOLE_OBJS = \ $O\ConsoleClose.obj \ diff --git a/CPP/7zip/UI/Explorer/ContextMenu.cpp b/CPP/7zip/UI/Explorer/ContextMenu.cpp index efe8ad44..d8fd0e56 100755 --- a/CPP/7zip/UI/Explorer/ContextMenu.cpp +++ b/CPP/7zip/UI/Explorer/ContextMenu.cpp @@ -11,6 +11,7 @@ #include "Windows/FileFind.h" #include "Windows/Memory.h" #include "Windows/Menu.h" +#include "Windows/Process.h" #include "Windows/Shell.h" #include "../Common/ArchiveName.h" @@ -32,8 +33,10 @@ using namespace NWindows; -/////////////////////////////// -// IShellExtInit + +#ifndef UNDER_CE +#define EMAIL_SUPPORT 1 +#endif extern LONG g_DllRefCount; @@ -42,10 +45,11 @@ CZipContextMenu::~CZipContextMenu() { InterlockedDecrement(&g_DllRefCount); } HRESULT CZipContextMenu::GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames) { + #ifndef UNDER_CE fileNames.Clear(); - if(dataObject == NULL) + if (dataObject == NULL) return E_FAIL; - FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; + FORMATETC fmte = {CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; NCOM::CStgMedium stgMedium; HRESULT result = dataObject->GetData(&fmte, &stgMedium); if (result != S_OK) @@ -56,18 +60,20 @@ HRESULT CZipContextMenu::GetFileNames(LPDATAOBJECT dataObject, UStringVector &fi NMemory::CGlobalLock globalLock(stgMedium->hGlobal); drop.Attach((HDROP)globalLock.GetPointer()); drop.QueryFileNames(fileNames); - + #endif return S_OK; } -STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder, - LPDATAOBJECT dataObject, HKEY /* hkeyProgID */) +// IShellExtInit + +STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder, LPDATAOBJECT dataObject, HKEY /* hkeyProgID */) { // OutputDebugString(TEXT("::Initialize\r\n")); _dropMode = false; _dropPath.Empty(); if (pidlFolder != 0) { + #ifndef UNDER_CE if (NShell::GetPathFromIDList(pidlFolder, _dropPath)) { // OutputDebugString(path); @@ -76,6 +82,7 @@ STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder, _dropMode = !_dropPath.IsEmpty(); } else + #endif _dropPath.Empty(); } @@ -225,8 +232,7 @@ int FindCommand(CZipContextMenu::ECommandInternalID &id) return -1; } -void CZipContextMenu::FillCommand(ECommandInternalID id, - UString &mainString, CCommandMapItem &commandMapItem) +void CZipContextMenu::FillCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &commandMapItem) { int i = FindCommand(id); if (i < 0) @@ -299,11 +305,6 @@ static UString GetReducedString(const UString &s) return s.Left(kFirstPartSize) + UString(L" ... ") + s.Right(kMaxSize - kFirstPartSize); } -static UString GetQuotedString(const UString &s) -{ - return UString(L'\"') + s + UString(L'\"'); -} - static UString GetQuotedReducedString(const UString &s) { UString s2 = GetReducedString(s); @@ -335,31 +336,35 @@ static const char *kExtractExludeExtensions = " xml xsd xsl xslt" " "; -static bool DoNeedExtract(const UString &name) +static bool FindExt(const char *p, const UString &name) { int extPos = name.ReverseFind('.'); if (extPos < 0) - return true; + return false; UString ext = name.Mid(extPos + 1); ext.MakeLower(); AString ext2 = UnicodeStringToMultiByte(ext); - const char *p = kExtractExludeExtensions; for (int i = 0; p[i] != 0;) { int j; for (j = i; p[j] != ' '; j++); if (ext2.Length() == j - i && memcmp(p + i, (const char *)ext2, ext2.Length()) == 0) - return false; + return true; i = j + 1; } - return true; + return false; +} + +static bool DoNeedExtract(const UString &name) +{ + return !FindExt(kExtractExludeExtensions, name); } STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT commandIDFirst, UINT commandIDLast, UINT flags) { LoadLangOneTime(); - if(_fileNames.Size() == 0) + if (_fileNames.Size() == 0) return E_FAIL; UINT currentCommandID = commandIDFirst; if ((flags & 0x000F) != CMF_NORMAL && @@ -372,13 +377,14 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, CMenu popupMenu; CMenuDestroyer menuDestroyer; - bool cascadedMenu = ReadCascadedMenu(); + CContextMenuInfo ci; + ci.Load(); MENUITEMINFO menuItem; UINT subIndex = indexMenu; - if (cascadedMenu) + if (ci.Cascaded) { CCommandMapItem commandMapItem; - if(!popupMenu.CreatePopup()) + if (!popupMenu.CreatePopup()) return E_FAIL; menuDestroyer.Attach(popupMenu); commandMapItem.CommandInternalID = kCommandNULL; @@ -394,12 +400,10 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, popupMenu.Attach(hMenu); } - UINT32 contextMenuFlags; - if (!ReadContextMenuStatus(contextMenuFlags)) - contextMenuFlags = NContextMenuFlags::GetDefaultFlags(); + UInt32 contextMenuFlags = ci.Flags; UString mainString; - if(_fileNames.Size() == 1 && currentCommandID + 6 <= commandIDLast) + if (_fileNames.Size() == 1 && currentCommandID + 6 <= commandIDLast) { const UString &fileName = _fileNames.Front(); UString folderPrefix; @@ -417,11 +421,39 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, FillCommand(kOpen, mainString, commandMapItem); MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString); _commandMap.Add(commandMapItem); + + /* + if (FindExt(" exe dll ", fileInfo.Name)) + { + CMenu subMenu; + if (subMenu.CreatePopup()) + { + CMenuItem menuItem; + menuItem.fType = MFT_STRING; + menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID; + menuItem.wID = currentCommandID++; + menuItem.hSubMenu = subMenu; + menuItem.StringValue = LangString(IDS_CONTEXT_OPEN, 0x02000103); + popupMenu.InsertItem(subIndex++, true, menuItem); + const wchar_t *exts[] = { L"7z", L"cab", L"rar", L"zip", L"pe" }; + for (int i = 0; i < sizeof(exts) / sizeof(exts[0]); i++) + { + CCommandMapItem commandMapItem; + FillCommand(kOpenAs, mainString, commandMapItem); + mainString = exts[i]; + commandMapItem.ArchiveType = mainString; + MyInsertMenu(subMenu, subIndex++, currentCommandID++, mainString); + _commandMap.Add(commandMapItem); + } + subMenu.Detach(); + } + } + */ } } } - if(_fileNames.Size() > 0 && currentCommandID + 10 <= commandIDLast) + if (_fileNames.Size() > 0 && currentCommandID + 10 <= commandIDLast) { bool needExtract = false; for(int i = 0; i < _fileNames.Size(); i++) @@ -516,7 +548,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, _commandMap.Add(commandMapItem); } - + #ifdef EMAIL_SUPPORT // CompressEmail if ((contextMenuFlags & NContextMenuFlags::kCompressEmail) != 0 && !_dropMode) { @@ -526,6 +558,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString); _commandMap.Add(commandMapItem); } + #endif // CompressTo7z if (contextMenuFlags & NContextMenuFlags::kCompressTo7z) @@ -544,6 +577,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, _commandMap.Add(commandMapItem); } + #ifdef EMAIL_SUPPORT // CompressTo7zEmail if ((contextMenuFlags & NContextMenuFlags::kCompressTo7zEmail) != 0 && !_dropMode) { @@ -556,6 +590,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); _commandMap.Add(commandMapItem); } + #endif // CompressToZip if (contextMenuFlags & NContextMenuFlags::kCompressToZip) @@ -574,6 +609,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, _commandMap.Add(commandMapItem); } + #ifdef EMAIL_SUPPORT // CompressToZipEmail if ((contextMenuFlags & NContextMenuFlags::kCompressToZipEmail) != 0 && !_dropMode) { @@ -586,6 +622,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s); _commandMap.Add(commandMapItem); } + #endif } @@ -593,7 +630,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, // PRB: Duplicate Menu Items In the File Menu For a Shell Context Menu Extension // ID: Q214477 - if (cascadedMenu) + if (ci.Cascaded) { CMenuItem menuItem; menuItem.fType = MFT_STRING; @@ -614,21 +651,16 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, int CZipContextMenu::FindVerb(const UString &verb) { for(int i = 0; i < _commandMap.Size(); i++) - if(_commandMap[i].Verb.Compare(verb) == 0) + if (_commandMap[i].Verb.Compare(verb) == 0) return i; return -1; } -extern const char *kShellFolderClassIDString; - - -static UString GetProgramCommand() +static UString Get7zFmPath() { UString path; - UString folder; - if (GetProgramFolderPath(folder)) - path = folder; - return GetQuotedString(path + L"7zFM.exe"); + GetProgramFolderPath(path); + return path + L"7zFM.exe"; } STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo) @@ -638,22 +670,24 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo) // It's fix for bug: crashing in XP. See example in MSDN: "Creating Context Menu Handlers". + #ifndef UNDER_CE if (commandInfo->cbSize == sizeof(CMINVOKECOMMANDINFOEX) && (commandInfo->fMask & CMIC_MASK_UNICODE) != 0) { LPCMINVOKECOMMANDINFOEX commandInfoEx = (LPCMINVOKECOMMANDINFOEX)commandInfo; - if(HIWORD(commandInfoEx->lpVerbW) == 0) + if (HIWORD(commandInfoEx->lpVerbW) == 0) commandOffset = LOWORD(commandInfo->lpVerb); else commandOffset = FindVerb(commandInfoEx->lpVerbW); } else - if(HIWORD(commandInfo->lpVerb) == 0) + #endif + if (HIWORD(commandInfo->lpVerb) == 0) commandOffset = LOWORD(commandInfo->lpVerb); else commandOffset = FindVerb(GetUnicodeString(commandInfo->lpVerb)); - if(commandOffset < 0 || commandOffset >= _commandMap.Size()) + if (commandOffset < 0 || commandOffset >= _commandMap.Size()) return E_FAIL; const CCommandMapItem commandMapItem = _commandMap[commandOffset]; @@ -665,19 +699,15 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo) { case kOpen: { - UString params; - params = GetProgramCommand(); - params += L' '; - params += GetQuotedString(_fileNames[0]); - MyCreateProcess(params, 0, false, 0); + UString params = GetQuotedString(_fileNames[0]); + MyCreateProcess(Get7zFmPath(), params); break; } case kExtract: case kExtractHere: case kExtractTo: { - ExtractArchives(_fileNames, commandMapItem.Folder, - (commandInternalID == kExtract)); + ExtractArchives(_fileNames, commandMapItem.Folder, (commandInternalID == kExtract)); break; } case kTest: @@ -708,19 +738,19 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo) } catch(...) { - ShowErrorMessageRes(IDS_ERROR, 0x02000605); + ::MessageBoxW(0, L"Error", L"7-Zip", MB_ICONERROR); } return S_OK; } static void MyCopyString(void *dest, const wchar_t *src, bool writeInUnicode) { - if(writeInUnicode) + if (writeInUnicode) { MyStringCopy((wchar_t *)dest, src); } else - lstrcpyA((char *)dest, GetAnsiString(src)); + MyStringCopy((char *)dest, (const char *)GetAnsiString(src)); } STDMETHODIMP CZipContextMenu::GetCommandString(UINT_PTR commandOffset, UINT uType, @@ -729,23 +759,47 @@ STDMETHODIMP CZipContextMenu::GetCommandString(UINT_PTR commandOffset, UINT uTyp int cmdOffset = (int)commandOffset; switch(uType) { + #ifdef UNDER_CE + case GCS_VALIDATE: + #else case GCS_VALIDATEA: case GCS_VALIDATEW: - if(cmdOffset < 0 || cmdOffset >= _commandMap.Size()) + #endif + if (cmdOffset < 0 || cmdOffset >= _commandMap.Size()) return S_FALSE; else return S_OK; } - if(cmdOffset < 0 || cmdOffset >= _commandMap.Size()) + if (cmdOffset < 0 || cmdOffset >= _commandMap.Size()) return E_FAIL; - if(uType == GCS_HELPTEXTA || uType == GCS_HELPTEXTW) + #ifdef UNDER_CE + if (uType == GCS_HELPTEXT) + #else + if (uType == GCS_HELPTEXTA || uType == GCS_HELPTEXTW) + #endif { - MyCopyString(pszName, _commandMap[cmdOffset].HelpString, uType == GCS_HELPTEXTW); + MyCopyString(pszName, _commandMap[cmdOffset].HelpString, + #ifdef UNDER_CE + true + #else + uType == GCS_HELPTEXTW + #endif + ); return NO_ERROR; } - if(uType == GCS_VERBA || uType == GCS_VERBW) + #ifdef UNDER_CE + if (uType == GCS_VERB) + #else + if (uType == GCS_VERBA || uType == GCS_VERBW) + #endif { - MyCopyString(pszName, _commandMap[cmdOffset].Verb, uType == GCS_VERBW); + MyCopyString(pszName, _commandMap[cmdOffset].Verb, + #ifdef UNDER_CE + true + #else + uType == GCS_VERBW + #endif + ); return NO_ERROR; } return E_FAIL; diff --git a/CPP/7zip/UI/Explorer/ContextMenu.h b/CPP/7zip/UI/Explorer/ContextMenu.h index be9f9167..e0ee6376 100755 --- a/CPP/7zip/UI/Explorer/ContextMenu.h +++ b/CPP/7zip/UI/Explorer/ContextMenu.h @@ -1,7 +1,7 @@ // ContextMenu.h -#ifndef __CONTEXTMENU_H -#define __CONTEXTMENU_H +#ifndef __CONTEXT_MENU_H +#define __CONTEXT_MENU_H // {23170F69-40C1-278A-1000-000100020000} DEFINE_GUID(CLSID_CZipContextMenu, @@ -19,7 +19,6 @@ class CZipContextMenu: public IInitContextMenu, public CMyUnknownImp { - public: enum ECommandInternalID @@ -50,21 +49,13 @@ public: MY_UNKNOWN_IMP3_MT(IContextMenu, IShellExtInit, IInitContextMenu) - /////////////////////////////// // IShellExtInit + STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT dataObject, HKEY hkeyProgID); - STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, - LPDATAOBJECT dataObject, HKEY hkeyProgID); - - ///////////////////////////// // IContextMenu - - STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, - UINT idCmdFirst, UINT idCmdLast, UINT uFlags); + STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags); STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici); - STDMETHOD(GetCommandString)(UINT_PTR idCmd, UINT uType, UINT *pwReserved, - LPSTR pszName, UINT cchMax); - + STDMETHOD(GetCommandString)(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax); // IInitContextMenu STDMETHOD(InitContextMenu)(const wchar_t *folder, const wchar_t **names, UINT32 numFiles); @@ -73,11 +64,12 @@ private: bool _dropMode; UString _dropPath; CObjectVector<CCommandMapItem> _commandMap; + HRESULT GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames); + int FindVerb(const UString &verb); - void FillCommand(ECommandInternalID id, UString &mainString, - CCommandMapItem &commandMapItem); + void FillCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &commandMapItem); public: CZipContextMenu(); ~CZipContextMenu(); diff --git a/CPP/7zip/UI/Explorer/DllExports.cpp b/CPP/7zip/UI/Explorer/DllExports.cpp index 6fed7cda..5004c1ac 100755 --- a/CPP/7zip/UI/Explorer/DllExports.cpp +++ b/CPP/7zip/UI/Explorer/DllExports.cpp @@ -8,30 +8,38 @@ #include "StdAfx.h" -// #include <locale.h> +#include "Common/MyInitGuid.h" -#include <initguid.h> -#include <windows.h> #include <ShlGuid.h> #include <OleCtl.h> #include "Common/ComTry.h" #include "Common/StringConvert.h" + #include "Windows/DLL.h" +#include "Windows/Error.h" +#include "Windows/NtCheck.h" #include "Windows/Registry.h" -#include "../FileManager/LangUtils.h" #include "../FileManager/IFolder.h" +#include "../FileManager/LangUtils.h" #include "ContextMenu.h" -#include "OptionsDialog.h" using namespace NWindows; -HINSTANCE g_hInstance; -#ifndef _UNICODE -bool g_IsNT = false; -#endif +HINSTANCE g_hInstance = 0; +HWND g_HWND = 0; + +UString HResultToMessage(HRESULT errorCode) +{ + UString message; + if (!NError::MyFormatMessage(errorCode, message)) + message.Empty(); + if (message.IsEmpty()) + message = L"Error"; + return message; +} LONG g_DllRefCount = 0; // Reference count of this DLL. @@ -85,29 +93,23 @@ STDMETHODIMP CShellExtClassFactory::LockServer(BOOL /* fLock */) return S_OK; // Check it } -static bool IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} + +#define NT_CHECK_FAIL_ACTION return FALSE; extern "C" -BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID) +BOOL WINAPI DllMain( + #ifdef UNDER_CE + HANDLE hInstance + #else + HINSTANCE hInstance + #endif + , DWORD dwReason, LPVOID) { - // setlocale(LC_COLLATE, ".ACP"); if (dwReason == DLL_PROCESS_ATTACH) { - g_hInstance = hInstance; + g_hInstance = (HINSTANCE)hInstance; // ODS("In DLLMain, DLL_PROCESS_ATTACH\r\n"); - #ifdef _UNICODE - if (!IsItWindowsNT()) - return FALSE; - #else - g_IsNT = IsItWindowsNT(); - #endif + NT_CHECK } else if (dwReason == DLL_PROCESS_DETACH) { @@ -153,10 +155,16 @@ static BOOL GetStringFromIID(CLSID clsid, LPTSTR s, int size) LPWSTR pwsz; if (StringFromIID(clsid, &pwsz) != S_OK) return FALSE; - if(!pwsz) + if (!pwsz) return FALSE; #ifdef UNICODE - lstrcpyn(s, pwsz, size); + for (int i = 0; i < size; i++) + { + s[i] = pwsz[i]; + if (pwsz[i] == 0) + break; + } + s[size - 1] = 0; #else WideCharToMultiByte(CP_ACP, 0, pwsz, -1, s, size, NULL, NULL); #endif @@ -192,18 +200,20 @@ static BOOL RegisterServer(CLSID clsid, LPCWSTR title) }; //register the CLSID entries - for(int i = 0; clsidEntries[i].hRootKey; i++) + for (int i = 0; clsidEntries[i].hRootKey; i++) { TCHAR subKey[MAX_PATH]; - wsprintf(subKey, clsidEntries[i].SubKey, clsidString); + const CRegItem &r = clsidEntries[i]; + wsprintf(subKey, r.SubKey, clsidString); NRegistry::CKey key; - if (key.Create(clsidEntries[i].hRootKey, subKey, NULL, - REG_OPTION_NON_VOLATILE, KEY_WRITE) != NOERROR) + if (key.Create(r.hRootKey, subKey, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE) != NOERROR) return FALSE; key.SetValue(clsidEntries[i].ValueName, clsidEntries[i].Data); } - if(IsItWindowsNT()) + #if !defined(_WIN64) && !defined(UNDER_CE) + if (IsItWindowsNT()) + #endif { NRegistry::CKey key; if (key.Create(HKEY_LOCAL_MACHINE, kApprovedKeyPath, NULL, @@ -231,7 +241,9 @@ static BOOL UnregisterServer(CLSID clsid) wsprintf (subKey, kClsidMask, clsidString); RegDeleteKey(HKEY_CLASSES_ROOT, subKey); - if(IsItWindowsNT()) + #if !defined(_WIN64) && !defined(UNDER_CE) + if (IsItWindowsNT()) + #endif { HKEY hKey; if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, kApprovedKeyPath, 0, KEY_SET_VALUE, &hKey) == NOERROR) @@ -247,45 +259,3 @@ STDAPI DllUnregisterServer(void) { return UnregisterServer(CLSID_CZipContextMenu) ? S_OK: SELFREG_E_CLASS; } - -STDAPI CreateObject( - const GUID *classID, - const GUID *interfaceID, - void **outObject) -{ - LoadLangOneTime(); - COM_TRY_BEGIN - *outObject = 0; - if (*classID == CLSID_CSevenZipOptions) - { - if (*interfaceID == IID_IPluginOptions) - { - CMyComPtr<IPluginOptions> options = new CSevenZipOptions; - *outObject = options.Detach(); - return S_OK; - } - return E_NOINTERFACE; - } - return CLASS_E_CLASSNOTAVAILABLE; - COM_TRY_END -} - -STDAPI GetPluginProperty(PROPID propID, PROPVARIANT *value) -{ - ::VariantClear((tagVARIANT *)value); - switch(propID) - { - case NPlugin::kName: - if ((value->bstrVal = ::SysAllocString(L"7-Zip")) != 0) - value->vt = VT_BSTR; - return S_OK; - case NPlugin::kOptionsClassID: - { - if ((value->bstrVal = ::SysAllocStringByteLen( - (const char *)&CLSID_CSevenZipOptions, sizeof(GUID))) != 0) - value->vt = VT_BSTR; - return S_OK; - } - } - return S_OK; -} diff --git a/CPP/7zip/UI/Explorer/Explorer.def b/CPP/7zip/UI/Explorer/Explorer.def index 752fbb7a..034a269d 100755 --- a/CPP/7zip/UI/Explorer/Explorer.def +++ b/CPP/7zip/UI/Explorer/Explorer.def @@ -7,6 +7,3 @@ EXPORTS DllGetClassObject PRIVATE DllRegisterServer PRIVATE DllUnregisterServer PRIVATE - - CreateObject PRIVATE - GetPluginProperty PRIVATE diff --git a/CPP/7zip/UI/Explorer/Explorer.dsp b/CPP/7zip/UI/Explorer/Explorer.dsp index 832a153a..158390bb 100755 --- a/CPP/7zip/UI/Explorer/Explorer.dsp +++ b/CPP/7zip/UI/Explorer/Explorer.dsp @@ -233,34 +233,6 @@ SOURCE=.\MyMessages.cpp SOURCE=.\MyMessages.h # End Source File # End Group -# Begin Group "Dialogs" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\FoldersPage.cpp -# End Source File -# Begin Source File - -SOURCE=.\FoldersPage.h -# End Source File -# Begin Source File - -SOURCE=.\FoldersPageRes.h -# End Source File -# Begin Source File - -SOURCE=.\SystemPage.cpp -# End Source File -# Begin Source File - -SOURCE=.\SystemPage.h -# End Source File -# Begin Source File - -SOURCE=.\SystemPageRes.h -# End Source File -# End Group # Begin Group "FileManager" # PROP Default_Filter "" @@ -523,6 +495,14 @@ SOURCE=..\..\..\Windows\Menu.h # End Source File # Begin Source File +SOURCE=..\..\..\Windows\Process.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Process.h +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\Registry.cpp # End Source File # Begin Source File @@ -568,14 +548,6 @@ SOURCE=.\ContextMenuFlags.h # End Source File # Begin Source File -SOURCE=.\OptionsDialog.cpp -# End Source File -# Begin Source File - -SOURCE=.\OptionsDialog.h -# End Source File -# Begin Source File - SOURCE=.\RegistryContextMenu.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/UI/Explorer/FoldersPage.rc b/CPP/7zip/UI/Explorer/FoldersPage.rc deleted file mode 100755 index 7b2d4231..00000000 --- a/CPP/7zip/UI/Explorer/FoldersPage.rc +++ /dev/null @@ -1,36 +0,0 @@ -#include "FoldersPageRes.h" -#include "../../GuiCommon.rc" - -#define xSize2 196 -#define ySize2 140 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - -#define marg2 marg -#define marg3 10 -#define gPos (marg + marg2) -#define gSize (xSize2 - marg2 - marg2) -#define gPos2 (gPos + marg3) - - -IDD_FOLDERS DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE -CAPTION "Folders" -MY_FONT -BEGIN - GROUPBOX "&Working folder", IDC_FOLDERS_STATIC_WORKING_FOLDER, marg, marg, xSize2, 98 - CONTROL "&System temp folder", IDC_FOLDERS_WORK_RADIO_SYSTEM, "Button", BS_AUTORADIOBUTTON | WS_GROUP, - gPos, 20, gSize, 10 - CONTROL "&Current", IDC_FOLDERS_WORK_RADIO_CURRENT, "Button", BS_AUTORADIOBUTTON, - gPos, 34, gSize, 10 - CONTROL "Specified:", IDC_FOLDERS_WORK_RADIO_SPECIFIED, "Button", BS_AUTORADIOBUTTON, - gPos, 48, gSize, 10 - EDITTEXT IDC_FOLDERS_WORK_EDIT_PATH, gPos2, 63, gSize - marg3 - bDotsSize - 10, 14, ES_AUTOHSCROLL - PUSHBUTTON "...", IDC_FOLDERS_WORK_BUTTON_PATH, xSize - marg - marg2 - bDotsSize, 63, bDotsSize, bYSize - CONTROL "Use for removable drives only", IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - gPos, 87, gSize, 10 -END - -STRINGTABLE -BEGIN - IDS_FOLDERS_SET_WORK_PATH_TITLE "Specify a location for temporary archive files." -END diff --git a/CPP/7zip/UI/Explorer/OptionsDialog.cpp b/CPP/7zip/UI/Explorer/OptionsDialog.cpp index b0deaf0d..90a0c0dc 100755 --- a/CPP/7zip/UI/Explorer/OptionsDialog.cpp +++ b/CPP/7zip/UI/Explorer/OptionsDialog.cpp @@ -2,27 +2,29 @@ #include "StdAfx.h" -#include "resource.h" - -#include "OptionsDialog.h" - -#include "Common/StringConvert.h" #include "Windows/Control/PropertyPage.h" +#include "../FileManager/DialogSize.h" #include "../FileManager/LangUtils.h" + #include "FoldersPage.h" #include "FoldersPageRes.h" -#include "SystemPage.h" -#include "SystemPageRes.h" +#include "OptionsDialog.h" +#include "MenuPage.h" +#include "MenuPageRes.h" + +#include "resource.h" using namespace NWindows; static INT_PTR OptionsDialog(HWND hwndOwner) { - CSystemPage systemPage; + CMenuPage systemPage; CFoldersPage foldersPage; UINT32 langIDs[] = { 0x01000300, 0x01000200}; - UINT pageIDs[] = { IDD_SYSTEM, IDD_FOLDERS}; + + BIG_DIALOG_SIZE(200, 200); + UINT pageIDs[] = { SIZED_DIALOG(IDD_MENU), SIZED_DIALOG(IDD_FOLDERS) }; NControl::CPropertyPage *pagePinters[] = { &systemPage, &foldersPage }; CObjectVector<NControl::CPageInfo> pages; const int kNumPages = sizeof(langIDs) / sizeof(langIDs[0]); @@ -43,7 +45,7 @@ STDMETHODIMP CSevenZipOptions::PluginOptions(HWND hWnd, { /* CComBSTR programPath; - RETUEN_IF_NOT_S_OK(callback->GetProgramPath(programName))); + RINOK(callback->GetProgramPath(programName))); */ OptionsDialog(hWnd); return S_OK; @@ -67,5 +69,3 @@ STDMETHODIMP CSevenZipOptions::GetFileExtensions(BSTR * /* extensions */) */ return E_NOTIMPL; } - - diff --git a/CPP/7zip/UI/Explorer/RegistryContextMenu.cpp b/CPP/7zip/UI/Explorer/RegistryContextMenu.cpp index e8e53bb3..656d0bfa 100755 --- a/CPP/7zip/UI/Explorer/RegistryContextMenu.cpp +++ b/CPP/7zip/UI/Explorer/RegistryContextMenu.cpp @@ -2,25 +2,22 @@ #include "StdAfx.h" -#include "RegistryContextMenu.h" -#include "Windows/COM.h" -#include "Windows/Synchronization.h" #include "Windows/Registry.h" -#include "Windows/FileName.h" +#include "Windows/Synchronization.h" + +#include "RegistryContextMenu.h" using namespace NWindows; -using namespace NCOM; using namespace NRegistry; namespace NZipRootRegistry { -static NSynchronization::CCriticalSection g_RegistryOperationsCriticalSection; - -/////////////////////////// -// ContextMenu +#ifndef UNDER_CE -static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-ZIP"); -static const TCHAR *kDragDropMenuKeyName = TEXT("\\shellex\\DragDropHandlers\\7-ZIP"); +static NSynchronization::CCriticalSection g_CS; + +static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-Zip"); +static const TCHAR *kDragDropMenuKeyName = TEXT("\\shellex\\DragDropHandlers\\7-Zip"); static const TCHAR *kExtensionCLSID = TEXT("{23170F69-40C1-278A-1000-000100020000}"); @@ -37,7 +34,7 @@ static CSysString GetFullDragDropMenuKeyName(const CSysString &keyName) static bool CheckHandlerCommon(const CSysString &keyName) { - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; if (key.Open(HKEY_CLASSES_ROOT, keyName, KEY_READ) != ERROR_SUCCESS) return false; @@ -89,7 +86,7 @@ void DeleteContextMenuHandler() static void AddContextMenuHandlerCommon(const CSysString &keyName) { DeleteContextMenuHandlerCommon(keyName); - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; key.Create(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(keyName)); key.SetValue(NULL, kExtensionCLSID); @@ -98,7 +95,7 @@ static void AddContextMenuHandlerCommon(const CSysString &keyName) static void AddDragDropMenuHandlerCommon(const CSysString &keyName) { DeleteDragDropMenuHandlerCommon(keyName); - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; key.Create(HKEY_CLASSES_ROOT, GetFullDragDropMenuKeyName(keyName)); key.SetValue(NULL, kExtensionCLSID); @@ -114,4 +111,6 @@ void AddContextMenuHandler() AddDragDropMenuHandlerCommon(kRootKeyNameForDrive); } +#endif + } diff --git a/CPP/7zip/UI/Explorer/RegistryContextMenu.h b/CPP/7zip/UI/Explorer/RegistryContextMenu.h index 52b053da..139526a8 100755 --- a/CPP/7zip/UI/Explorer/RegistryContextMenu.h +++ b/CPP/7zip/UI/Explorer/RegistryContextMenu.h @@ -1,13 +1,16 @@ // RegistryContextMenu.h -#ifndef __REGISTRYCONTEXTMENU_H -#define __REGISTRYCONTEXTMENU_H +#ifndef __REGISTRY_CONTEXT_MENU_H +#define __REGISTRY_CONTEXT_MENU_H namespace NZipRootRegistry { +#ifndef UNDER_CE bool CheckContextMenuHandler(); void AddContextMenuHandler(); void DeleteContextMenuHandler(); +#endif + } #endif diff --git a/CPP/7zip/UI/Explorer/StdAfx.h b/CPP/7zip/UI/Explorer/StdAfx.h index d978a3a4..e1fe42f2 100755 --- a/CPP/7zip/UI/Explorer/StdAfx.h +++ b/CPP/7zip/UI/Explorer/StdAfx.h @@ -15,11 +15,9 @@ #include <stddef.h> #include <string.h> -#include <mbstring.h> #include <wchar.h> #include <shlguid.h> -#include <regstr.h> #include "Common/NewHandler.h" diff --git a/CPP/7zip/UI/Explorer/SystemPage.rc b/CPP/7zip/UI/Explorer/SystemPage.rc deleted file mode 100755 index 611fd58b..00000000 --- a/CPP/7zip/UI/Explorer/SystemPage.rc +++ /dev/null @@ -1,24 +0,0 @@ -#include "SystemPageRes.h" -#include "../../GuiCommon.rc" - -#define xSize2 196 -#define ySize2 164 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - -IDD_SYSTEM DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE -CAPTION "System" -MY_FONT -BEGIN - CONTROL "Integrate 7-Zip to shell context menu", IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, - "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, marg, xSize2, 10 - CONTROL "Cascaded context menu", IDC_SYSTEM_CASCADED_MENU, - "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 21, xSize2, 10 - LTEXT "Context menu items:", IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS, - marg, 37, xSize2, 8 - CONTROL "List1", IDC_SYSTEM_OPTIONS_LIST, "SysListView32", - LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP, - marg, 50, xSize2, ySize - marg - 50 -END diff --git a/CPP/7zip/UI/Explorer/makefile b/CPP/7zip/UI/Explorer/makefile index d9366ffe..89cbc642 100755 --- a/CPP/7zip/UI/Explorer/makefile +++ b/CPP/7zip/UI/Explorer/makefile @@ -1,18 +1,20 @@ PROG = 7-zip.dll DEF_FILE = Explorer.def -LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib htmlhelp.lib shell32.lib comctl32.lib ole32.lib comdlg32.lib -CFLAGS = $(CFLAGS) -I ../../../ -Ob2 \ +CFLAGS = $(CFLAGS) -I ../../../ \ -DLANG \ - -DWIN_LONG_PATH \ + +!IFDEF UNDER_CE +LIBS = $(LIBS) Commctrl.lib +!ELSE +LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib +CFLAGS = $(CFLAGS) -DWIN_LONG_PATH +!ENDIF EXPLORER_OBJS = \ $O\DllExports.obj \ $O\ContextMenu.obj \ $O\MyMessages.obj \ - $O\OptionsDialog.obj \ $O\RegistryContextMenu.obj \ - $O\SystemPage.obj \ - $O\FoldersPage.obj \ COMMON_OBJS = \ $O\IntToString.obj \ @@ -35,12 +37,20 @@ WIN_OBJS = \ $O\FileIO.obj \ $O\FileName.obj \ $O\Menu.obj \ + $O\Process.obj \ $O\Registry.obj \ $O\ResourceString.obj \ $O\Shell.obj \ $O\Synchronization.obj \ $O\Window.obj \ +!IFDEF UNDER_CE + +WIN_OBJS = $(WIN_OBJS) \ + $O\CommonDialog.obj \ + +!ENDIF + WIN_CTRL_OBJS = \ $O\Dialog.obj \ $O\ListView.obj \ diff --git a/CPP/7zip/UI/Explorer/resource.h b/CPP/7zip/UI/Explorer/resource.h index 75fa4981..3ddda8f0 100755 --- a/CPP/7zip/UI/Explorer/resource.h +++ b/CPP/7zip/UI/Explorer/resource.h @@ -26,6 +26,3 @@ #define IDS_CONTEXT_FOLDER 170 #define IDS_CONTEXT_ARCHIVE 171 - -#define IDS_ERROR 100 -#define IDS_CONFIG_DIALOG_CAPTION 102 diff --git a/CPP/7zip/UI/Explorer/resource.rc b/CPP/7zip/UI/Explorer/resource.rc index 157fa4cc..80018b45 100755 --- a/CPP/7zip/UI/Explorer/resource.rc +++ b/CPP/7zip/UI/Explorer/resource.rc @@ -1,38 +1,8 @@ #include "../../MyVersionInfo.rc" -#include "resource.h" +#include "resource2.rc" MY_VERSION_INFO_DLL("7-Zip Shell Extension", "7-zip") -1 24 "7-zip.dll.manifest" - -STRINGTABLE -BEGIN - IDS_CONTEXT_EXTRACT "Extract files..." - IDS_CONTEXT_EXTRACT_HELP "Extracts files from the selected archive." - IDS_CONTEXT_COMPRESS "Add to archive..." - IDS_CONTEXT_COMPRESS_HELP "Adds the selected items to archive." - IDS_CONTEXT_OPEN "Open archive" - IDS_CONTEXT_OPEN_HELP "Opens the selected archive." - IDS_CONTEXT_TEST "Test archive" - IDS_CONTEXT_TEST_HELP "Tests integrity of the selected archive." - IDS_CONTEXT_CAPTION_HELP "7-Zip commands" - IDS_CONTEXT_POPUP_CAPTION "7-Zip" - IDS_CONTEXT_EXTRACT_HERE "Extract Here" - IDS_CONTEXT_EXTRACT_HERE_HELP "Extracts files from the selected archive to current folder." - IDS_CONTEXT_EXTRACT_TO "Extract to {0}" - IDS_CONTEXT_EXTRACT_TO_HELP "Extracts files to subfolder." - IDS_CONTEXT_COMPRESS_TO "Add to {0}" - IDS_CONTEXT_COMPRESS_TO_HELP "Adds the selected items to archive." - IDS_CONTEXT_COMPRESS_EMAIL "Compress and email..." - IDS_CONTEXT_COMPRESS_EMAIL_HELP "Compresses the selected items to archive and sends archive via email." - IDS_CONTEXT_COMPRESS_TO_EMAIL "Compress to {0} and email" - IDS_CONTEXT_COMPRESS_TO_EMAIL_HELP "Compresses the selected items to archive and sends archive via email." - IDS_CONTEXT_FOLDER "<Folder>" - IDS_CONTEXT_ARCHIVE "<Archive>" - IDS_ERROR "Error" - IDS_CONFIG_DIALOG_CAPTION "7-Zip Options" -END - -#include "FoldersPage.rc" -#include "SystemPage.rc" - +#ifndef UNDER_CE +1 24 MOVEABLE PURE "7-zip.dll.manifest" +#endif diff --git a/CPP/7zip/UI/Explorer/resource2.rc b/CPP/7zip/UI/Explorer/resource2.rc new file mode 100755 index 00000000..08bc82bf --- /dev/null +++ b/CPP/7zip/UI/Explorer/resource2.rc @@ -0,0 +1,27 @@ +#include "resource.h" + +STRINGTABLE +BEGIN + IDS_CONTEXT_EXTRACT "Extract files..." + IDS_CONTEXT_EXTRACT_HELP "Extracts files from the selected archive." + IDS_CONTEXT_COMPRESS "Add to archive..." + IDS_CONTEXT_COMPRESS_HELP "Adds the selected items to archive." + IDS_CONTEXT_OPEN "Open archive" + IDS_CONTEXT_OPEN_HELP "Opens the selected archive." + IDS_CONTEXT_TEST "Test archive" + IDS_CONTEXT_TEST_HELP "Tests integrity of the selected archive." + IDS_CONTEXT_CAPTION_HELP "7-Zip commands" + IDS_CONTEXT_POPUP_CAPTION "7-Zip" + IDS_CONTEXT_EXTRACT_HERE "Extract Here" + IDS_CONTEXT_EXTRACT_HERE_HELP "Extracts files from the selected archive to current folder." + IDS_CONTEXT_EXTRACT_TO "Extract to {0}" + IDS_CONTEXT_EXTRACT_TO_HELP "Extracts files to subfolder." + IDS_CONTEXT_COMPRESS_TO "Add to {0}" + IDS_CONTEXT_COMPRESS_TO_HELP "Adds the selected items to archive." + IDS_CONTEXT_COMPRESS_EMAIL "Compress and email..." + IDS_CONTEXT_COMPRESS_EMAIL_HELP "Compresses the selected items to archive and sends archive via email." + IDS_CONTEXT_COMPRESS_TO_EMAIL "Compress to {0} and email" + IDS_CONTEXT_COMPRESS_TO_EMAIL_HELP "Compresses the selected items to archive and sends archive via email." + IDS_CONTEXT_FOLDER "<Folder>" + IDS_CONTEXT_ARCHIVE "<Archive>" +END diff --git a/CPP/7zip/UI/Far/FarUtils.cpp b/CPP/7zip/UI/Far/FarUtils.cpp index e06bfe3e..01de0233 100755 --- a/CPP/7zip/UI/Far/FarUtils.cpp +++ b/CPP/7zip/UI/Far/FarUtils.cpp @@ -2,13 +2,13 @@ #include "StdAfx.h" -#include "FarUtils.h" -#include "Common/DynamicBuffer.h" #include "Common/StringConvert.h" -#include "Windows/Defs.h" + #include "Windows/Console.h" #include "Windows/Error.h" +#include "FarUtils.h" + using namespace NWindows; namespace NFar { @@ -16,12 +16,12 @@ namespace NFar { CStartupInfo g_StartupInfo; void CStartupInfo::Init(const PluginStartupInfo &pluginStartupInfo, - const CSysString &pliginNameForRegestry) + const CSysString &pluginNameForRegestry) { m_Data = pluginStartupInfo; - m_RegistryPath = pluginStartupInfo.RootKey; - m_RegistryPath += '\\'; - m_RegistryPath += pliginNameForRegestry; + m_RegistryPath = GetSystemString(pluginStartupInfo.RootKey); + m_RegistryPath += TEXT('\\'); + m_RegistryPath += pluginNameForRegestry; } const char *CStartupInfo::GetMsgString(int messageId) @@ -164,7 +164,7 @@ void CStartupInfo::RestoreScreen(HANDLE handle) m_Data.RestoreScreen(handle); } -const char kRegestryKeyDelimiter = '\''; +const TCHAR kRegestryKeyDelimiter = TEXT('\''); CSysString CStartupInfo::GetFullKeyName(const CSysString &keyName) const { @@ -355,8 +355,8 @@ int CStartupInfo::Menu( item.Checked = 0; item.Separator = 0; item.Selected = (i == selectedItem); - AString reducedString = items[i].Left(sizeof(item.Text) / sizeof(item.Text[0]) - 1); - MyStringCopy(item.Text, (const char *)reducedString); + CSysString reducedString = items[i].Left(sizeof(item.Text) / sizeof(item.Text[0]) - 1); + MyStringCopy(item.Text, (const char *)GetOemString(reducedString)); farMenuItems.Add(item); } return Menu(flags, title, helpTopic, &farMenuItems.Front(), farMenuItems.Size()); @@ -396,7 +396,7 @@ static AString DWORDToString(DWORD number) void PrintErrorMessage(const char *message, int code) { - CSysString tmp = message; + AString tmp = message; tmp += " #"; tmp += DWORDToString(code); g_StartupInfo.ShowMessage(tmp); @@ -404,7 +404,7 @@ void PrintErrorMessage(const char *message, int code) void PrintErrorMessage(const char *message, const char *text) { - CSysString tmp = message; + AString tmp = message; tmp += ":\n"; tmp += text; g_StartupInfo.ShowMessageLines(tmp); @@ -442,10 +442,10 @@ bool WasEscPressed() void ShowErrorMessage(DWORD errorCode) { - AString message; + CSysString message; NError::MyFormatMessage(errorCode, message); - message.Replace("\x0D", ""); - message.Replace("\x0A", " "); + message.Replace(TEXT("\x0D"), TEXT("")); + message.Replace(TEXT("\x0A"), TEXT(" ")); g_StartupInfo.ShowMessage(SystemStringToOemString(message)); } diff --git a/CPP/7zip/UI/Far/FarUtils.h b/CPP/7zip/UI/Far/FarUtils.h index e0126cdc..a4887c9a 100755 --- a/CPP/7zip/UI/Far/FarUtils.h +++ b/CPP/7zip/UI/Far/FarUtils.h @@ -56,7 +56,7 @@ class CStartupInfo public: void Init(const PluginStartupInfo &pluginStartupInfo, - const CSysString &pliginNameForRegestry); + const CSysString &pluginNameForRegestry); const char *GetMsgString(int messageId); int ShowMessage(unsigned int flags, const char *helpTopic, const char **items, int numItems, int numButtons); diff --git a/CPP/7zip/UI/Far/Main.cpp b/CPP/7zip/UI/Far/Main.cpp index 46a16a9f..65aabea6 100755 --- a/CPP/7zip/UI/Far/Main.cpp +++ b/CPP/7zip/UI/Far/Main.cpp @@ -2,89 +2,40 @@ #include "StdAfx.h" -// #include <locale.h> -#include <initguid.h> +#include "Common/MyInitGuid.h" -#include "Plugin.h" - -#include "Common/Wildcard.h" -#include "Common/DynamicBuffer.h" #include "Common/StringConvert.h" -#include "Common/Defs.h" -#include "Windows/FileFind.h" -#include "Windows/FileIO.h" #include "Windows/FileDir.h" -#include "Windows/Defs.h" +#include "Windows/NtCheck.h" -#include "../../IPassword.h" #include "../../Common/FileStreams.h" -#include "../Common/DefaultName.h" -#include "../Common/OpenArchive.h" #include "../Agent/Agent.h" -#include "ProgressBox.h" -#include "FarUtils.h" #include "Messages.h" +#include "Plugin.h" +#include "ProgressBox.h" using namespace NWindows; using namespace NFar; static const char *kCommandPrefix = "7-zip"; - static const char *kRegisrtryMainKeyName = ""; - static const char *kRegisrtryValueNameEnabled = "UsedByDefault3"; -static bool kPluginEnabledDefault = true; - static const char *kHelpTopicConfig = "Config"; - -extern "C" -{ - void WINAPI SetStartupInfo(struct PluginStartupInfo *info); - HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char *Data, - unsigned int DataSize); - HANDLE WINAPI OpenPlugin(int openFrom, int item); - void WINAPI ClosePlugin(HANDLE plugin); - int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems, - int *itemsNumber, int OpMode); - void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems, - int itemsNumber); - int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems, - int itemsNumber, int move, char *destPath, int opMode); - int WINAPI SetDirectory(HANDLE plugin, char *dir, int opMode); - void WINAPI GetPluginInfo(struct PluginInfo *info); - int WINAPI Configure(int itemNumber); - void WINAPI GetOpenPluginInfo(HANDLE plugin, struct OpenPluginInfo *info); - int WINAPI PutFiles(HANDLE plugin, struct PluginPanelItem *panelItems, - int itemsNumber, int move, int opMode); - int WINAPI DeleteFiles(HANDLE plugin, PluginPanelItem *panelItems, - int itemsNumber, int opMode); - int WINAPI ProcessKey(HANDLE plugin, int key, unsigned int controlState); -}; +static bool kPluginEnabledDefault = true; HINSTANCE g_hInstance; -#ifndef _UNICODE -bool g_IsNT = false; -static bool IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} -#endif + +#define NT_CHECK_FAIL_ACTION return FALSE; BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID) { if (dwReason == DLL_PROCESS_ATTACH) { g_hInstance = hInstance; - #ifndef _UNICODE - g_IsNT = IsItWindowsNT(); - #endif + NT_CHECK } return TRUE; } @@ -96,7 +47,7 @@ static struct COptions static const char *kPliginNameForRegestry = "7-ZIP"; -void WINAPI SetStartupInfo(struct PluginStartupInfo *info) +EXTERN_C void WINAPI SetStartupInfo(struct PluginStartupInfo *info) { MY_TRY_BEGIN; g_StartupInfo.Init(*info, kPliginNameForRegestry); @@ -289,8 +240,7 @@ STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed) return S_OK; } -STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, - IInStream **inStream) +STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream) { if (WasEscPressed()) return E_ABORT; @@ -443,8 +393,7 @@ static HANDLE MyOpenFilePlugin(const char *name) return (HANDLE)(plugin); } -HANDLE WINAPI OpenFilePlugin(char *name, - const unsigned char * /* data */, unsigned int /* dataSize */) +EXTERN_C HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char * /* data */, unsigned int /* dataSize */) { MY_TRY_BEGIN; if (name == NULL || (!g_Options.Enabled)) @@ -456,7 +405,7 @@ HANDLE WINAPI OpenFilePlugin(char *name, MY_TRY_END2("OpenFilePlugin", INVALID_HANDLE_VALUE); } -HANDLE WINAPI OpenPlugin(int openFrom, int item) +EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, int item) { MY_TRY_BEGIN; if(openFrom == OPEN_COMMANDLINE) @@ -504,30 +453,28 @@ HANDLE WINAPI OpenPlugin(int openFrom, int item) MY_TRY_END2("OpenPlugin", INVALID_HANDLE_VALUE); } -void WINAPI ClosePlugin(HANDLE plugin) +EXTERN_C void WINAPI ClosePlugin(HANDLE plugin) { MY_TRY_BEGIN; delete (CPlugin *)plugin; MY_TRY_END1("ClosePlugin"); } -int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems, - int *itemsNumber,int opMode) +EXTERN_C int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems, int *itemsNumber, int opMode) { MY_TRY_BEGIN; return(((CPlugin *)plugin)->GetFindData(panelItems, itemsNumber, opMode)); MY_TRY_END2("GetFindData", FALSE); } -void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems, - int itemsNumber) +EXTERN_C void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems, int itemsNumber) { MY_TRY_BEGIN; ((CPlugin *)plugin)->FreeFindData(panelItems, itemsNumber); MY_TRY_END1("FreeFindData"); } -int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems, +EXTERN_C int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems, int itemsNumber, int move, char *destPath, int opMode) { MY_TRY_BEGIN; @@ -535,14 +482,14 @@ int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems, MY_TRY_END2("GetFiles", NFileOperationReturnCode::kError); } -int WINAPI SetDirectory(HANDLE plugin, char *dir, int opMode) +EXTERN_C int WINAPI SetDirectory(HANDLE plugin, char *dir, int opMode) { MY_TRY_BEGIN; return(((CPlugin *)plugin)->SetDirectory(dir, opMode)); MY_TRY_END2("SetDirectory", FALSE); } -void WINAPI GetPluginInfo(struct PluginInfo *info) +EXTERN_C void WINAPI GetPluginInfo(struct PluginInfo *info) { MY_TRY_BEGIN; @@ -564,7 +511,7 @@ void WINAPI GetPluginInfo(struct PluginInfo *info) MY_TRY_END1("GetPluginInfo"); } -int WINAPI Configure(int /* itemNumber */) +EXTERN_C int WINAPI Configure(int /* itemNumber */) { MY_TRY_BEGIN; @@ -601,30 +548,28 @@ int WINAPI Configure(int /* itemNumber */) MY_TRY_END2("Configure", FALSE); } -void WINAPI GetOpenPluginInfo(HANDLE plugin,struct OpenPluginInfo *info) +EXTERN_C void WINAPI GetOpenPluginInfo(HANDLE plugin,struct OpenPluginInfo *info) { MY_TRY_BEGIN; ((CPlugin *)plugin)->GetOpenPluginInfo(info); MY_TRY_END1("GetOpenPluginInfo"); } -int WINAPI PutFiles(HANDLE plugin, struct PluginPanelItem *panelItems, - int itemsNumber, int move, int opMode) +EXTERN_C int WINAPI PutFiles(HANDLE plugin, struct PluginPanelItem *panelItems, int itemsNumber, int move, int opMode) { MY_TRY_BEGIN; return(((CPlugin *)plugin)->PutFiles(panelItems, itemsNumber, move, opMode)); MY_TRY_END2("PutFiles", NFileOperationReturnCode::kError); } -int WINAPI DeleteFiles(HANDLE plugin, PluginPanelItem *panelItems, - int itemsNumber, int opMode) +EXTERN_C int WINAPI DeleteFiles(HANDLE plugin, PluginPanelItem *panelItems, int itemsNumber, int opMode) { MY_TRY_BEGIN; return(((CPlugin *)plugin)->DeleteFiles(panelItems, itemsNumber, opMode)); MY_TRY_END2("DeleteFiles", FALSE); } -int WINAPI ProcessKey(HANDLE plugin, int key, unsigned int controlState) +EXTERN_C int WINAPI ProcessKey(HANDLE plugin, int key, unsigned int controlState) { MY_TRY_BEGIN; return (((CPlugin *)plugin)->ProcessKey(key, controlState)); diff --git a/CPP/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp index c1e45a62..5d9b5cf0 100755 --- a/CPP/7zip/UI/Far/Plugin.cpp +++ b/CPP/7zip/UI/Far/Plugin.cpp @@ -2,40 +2,33 @@ #include "StdAfx.h" -#include "Plugin.h" - #include "Common/IntToString.h" #include "Common/StringConvert.h" #include "Common/Wildcard.h" #include "Windows/FileDir.h" -#include "Windows/FileName.h" #include "Windows/PropVariantConversions.h" #include "../Common/PropIDUtils.h" #include "FarUtils.h" #include "Messages.h" +#include "Plugin.h" using namespace NWindows; using namespace NFar; -CPlugin::CPlugin(const UString &fileName, - IInFolderArchive *archiveHandler, - UString archiveTypeName - ): - m_ArchiveHandler(archiveHandler), - m_FileName(fileName), - _archiveTypeName(archiveTypeName) +CPlugin::CPlugin(const UString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName): + m_ArchiveHandler(archiveHandler), + m_FileName(fileName), + _archiveTypeName(archiveTypeName) { if (!m_FileInfo.Find(m_FileName)) throw "error"; archiveHandler->BindToRootFolder(&_folder); } -CPlugin::~CPlugin() -{ -} +CPlugin::~CPlugin() {} static void MyGetFileTime(IFolderFolder *anArchiveFolder, UInt32 itemIndex, PROPID propID, FILETIME &fileTime) @@ -59,6 +52,17 @@ static void MyGetFileTime(IFolderFolder *anArchiveFolder, UInt32 itemIndex, #define kDotsReplaceString "[[..]]" #define kDotsReplaceStringU L"[[..]]" +static void CopyStrLimited(char *dest, const AString &src, int len) +{ + len--; + if (src.Length() < len) + len = src.Length(); + memcpy(dest, src, sizeof(dest[0]) * len); + dest[len] = 0; +} + +#define COPY_STR_LIMITED(dest, src) CopyStrLimited(dest, src, sizeof(dest) / sizeof(dest[0])) + void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) { NCOM::CPropVariant prop; @@ -69,14 +73,10 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) throw 272340; CSysString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP); - const int kFileNameSizeMax = (int)(sizeof(panelItem.FindData.cFileName) / sizeof(panelItem.FindData.cFileName[0]) - 1); - if (oemString.Length() > kFileNameSizeMax) - oemString = oemString.Left(kFileNameSizeMax); - if (oemString == "..") oemString = kDotsReplaceString; - MyStringCopy(panelItem.FindData.cFileName, (const char *)oemString); + COPY_STR_LIMITED(panelItem.FindData.cFileName, oemString); panelItem.FindData.cAlternateFileName[0] = 0; if (_folder->GetProperty(itemIndex, kpidAttrib, &prop) != S_OK) @@ -138,8 +138,7 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) panelItem.Reserved[2] = 0; } -int CPlugin::GetFindData(PluginPanelItem **panelItems, - int *itemsNumber, int opMode) +int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opMode) { // CScreenRestorer screenRestorer; if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0) @@ -177,8 +176,7 @@ int CPlugin::GetFindData(PluginPanelItem **panelItems, return(TRUE); } -void CPlugin::FreeFindData(struct PluginPanelItem *panelItems, - int itemsNumber) +void CPlugin::FreeFindData(struct PluginPanelItem *panelItems, int itemsNumber) { for (int i = 0; i < itemsNumber; i++) if (panelItems[i].Description != NULL) @@ -186,7 +184,6 @@ void CPlugin::FreeFindData(struct PluginPanelItem *panelItems, delete []panelItems; } - void CPlugin::EnterToDirectory(const UString &dirName) { CMyComPtr<IFolderFolder> newFolder; @@ -510,12 +507,10 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info) info->Flags = OPIF_USEFILTER | OPIF_USESORTGROUPS| OPIF_USEHIGHLIGHTING| OPIF_ADDDOTS | OPIF_COMPAREFATTIME; - UINT codePage = ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; - - MyStringCopy(m_FileNameBuffer, (const char *)UnicodeStringToMultiByte(m_FileName, codePage)); + COPY_STR_LIMITED(m_FileNameBuffer, UnicodeStringToMultiByte(m_FileName, CP_OEMCP)); info->HostFile = m_FileNameBuffer; // test it it is not static - MyStringCopy(m_CurrentDirBuffer, (const char *)UnicodeStringToMultiByte(m_CurrentDir, CP_OEMCP)); + COPY_STR_LIMITED(m_CurrentDirBuffer, UnicodeStringToMultiByte(m_CurrentDir, CP_OEMCP)); info->CurDir = m_CurrentDirBuffer; info->Format = kPluginFormatName; @@ -540,7 +535,7 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info) m_PannelTitle += m_CurrentDir; } - MyStringCopy(m_PannelTitleBuffer, (const char *)UnicodeStringToMultiByte(m_PannelTitle, CP_OEMCP)); + COPY_STR_LIMITED(m_PannelTitleBuffer, UnicodeStringToMultiByte(m_PannelTitle, CP_OEMCP)); info->PanelTitle = m_PannelTitleBuffer; memset(m_InfoLines, 0, sizeof(m_InfoLines)); @@ -572,8 +567,8 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info) continue; InfoPanelLine &item = m_InfoLines[numItems++]; - MyStringCopy(item.Text, (const char *)GetNameOfProp2(propID, name)); - MyStringCopy(item.Data, (const char *)PropToString2(prop, propID)); + COPY_STR_LIMITED(item.Text, GetNameOfProp2(propID, name)); + COPY_STR_LIMITED(item.Data, PropToString2(prop, propID)); } } } @@ -614,8 +609,8 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info) if (getProps->GetArchiveProperty(propID, &prop) != S_OK || prop.vt == VT_EMPTY) continue; InfoPanelLine &item = m_InfoLines[numItems++]; - MyStringCopy(item.Text, (const char *)GetNameOfProp2(propID, name)); - MyStringCopy(item.Data, (const char *)PropToString2(prop, propID)); + COPY_STR_LIMITED(item.Text, GetNameOfProp2(propID, name)); + COPY_STR_LIMITED(item.Data, PropToString2(prop, propID)); } } diff --git a/CPP/7zip/UI/Far/Plugin.h b/CPP/7zip/UI/Far/Plugin.h index 06003ba5..ab534e21 100755 --- a/CPP/7zip/UI/Far/Plugin.h +++ b/CPP/7zip/UI/Far/Plugin.h @@ -33,10 +33,8 @@ class CPlugin PanelMode PanelMode; void AddColumn(PROPID aPropID); - - void EnterToDirectory(const UString &aDirName); - - void GetPathParts(UStringVector &aPathParts); + void EnterToDirectory(const UString &dirName); + void GetPathParts(UStringVector &pathParts); void GetCurrentDir(); public: UString m_FileName; @@ -45,55 +43,46 @@ public: CMyComPtr<IInFolderArchive> m_ArchiveHandler; CMyComPtr<IFolderFolder> _folder; - // CArchiverInfo m_ArchiverInfo; UString _archiveTypeName; bool PasswordIsDefined; UString Password; - - CPlugin(const UString &fileName, - // const UString &aDefaultName, - IInFolderArchive *archiveHandler, - UString archiveTypeName - ); + CPlugin(const UString &fileName, IInFolderArchive *archiveHandler, UString archiveTypeName); ~CPlugin(); - void ReadValueSafe(PROPID aPropID, NWindows::NCOM::CPropVariant aPropVariant); - void ReadPluginPanelItem(PluginPanelItem &aPanelItem, UINT32 anItemIndex); - - int GetFindData(PluginPanelItem **pPanelItem,int *pItemsNumber,int OpMode); - void FreeFindData(PluginPanelItem *PanelItem,int ItemsNumber); - int SetDirectory(const char *aDir, int opMode); - void GetOpenPluginInfo(struct OpenPluginInfo *anInfo); - - int DeleteFiles(PluginPanelItem *aPanelItems, int itemsNumber, int opMode); + void ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex); + int GetFindData(PluginPanelItem **panelItems,int *itemsNumber,int opMode); + void FreeFindData(PluginPanelItem *panelItem,int ItemsNumber); + int SetDirectory(const char *aszDir, int opMode); + void GetOpenPluginInfo(struct OpenPluginInfo *info); + int DeleteFiles(PluginPanelItem *panelItems, int itemsNumber, int opMode); HRESULT ExtractFiles( bool decompressAllItems, - const UINT32 *indices, - UINT32 numIndices, + const UInt32 *indices, + UInt32 numIndices, bool silent, NExtract::NPathMode::EEnum pathMode, NExtract::NOverwriteMode::EEnum overwriteMode, const UString &destPath, bool passwordIsDefined, const UString &password); - NFar::NFileOperationReturnCode::EEnum GetFiles(struct PluginPanelItem *aPanelItem, int itemsNumber, - int move, char *destPath, int opMode); + NFar::NFileOperationReturnCode::EEnum GetFiles(struct PluginPanelItem *panelItem, int itemsNumber, + int move, char *destPath, int opMode); - NFar::NFileOperationReturnCode::EEnum GetFilesReal(struct PluginPanelItem *aPanelItems, - int itemsNumber, int move, const char *_aDestPath, int opMode, bool aShowBox); + NFar::NFileOperationReturnCode::EEnum GetFilesReal(struct PluginPanelItem *panelItems, + int itemsNumber, int move, const char *_aDestPath, int opMode, bool showBox); - NFar::NFileOperationReturnCode::EEnum PutFiles(struct PluginPanelItem *aPanelItems, int itemsNumber, - int move, int opMode); + NFar::NFileOperationReturnCode::EEnum PutFiles(struct PluginPanelItem *panelItems, int itemsNumber, + int move, int opMode); HRESULT ShowAttributesWindow(); - int ProcessKey(int aKey, unsigned int aControlState); + int ProcessKey(int key, unsigned int controlState); }; -HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &aPluginPanelItems); +HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems); #endif diff --git a/CPP/7zip/UI/Far/PluginDelete.cpp b/CPP/7zip/UI/Far/PluginDelete.cpp index a1dfb915..7d6f0314 100755 --- a/CPP/7zip/UI/Far/PluginDelete.cpp +++ b/CPP/7zip/UI/Far/PluginDelete.cpp @@ -2,21 +2,14 @@ #include "StdAfx.h" -#include <stdio.h> - -#include "Plugin.h" -#include "Messages.h" -#include "UpdateCallback100.h" - #include "Windows/FileDir.h" -#include "../../Common/FileStreams.h" - -#include "Common/StringConvert.h" - -#include "../Common/ZipRegistry.h" #include "../Common/WorkDir.h" +#include "Messages.h" +#include "Plugin.h" +#include "UpdateCallback100.h" + using namespace NFar; using namespace NWindows; using namespace NFile; @@ -24,8 +17,7 @@ using namespace NDirectory; static LPCWSTR kTempArchivePrefix = L"7zA"; -int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, - int opMode) +int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode) { if (numItems == 0) return FALSE; @@ -48,8 +40,7 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, char msg[1024]; if (numItems == 1) { - sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteFile), - panelItems[0].FindData.cFileName); + sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteFile), panelItems[0].FindData.cFileName); msgItems[1] = msg; } else if (numItems > 1) @@ -77,7 +68,7 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, } NWorkDir::CInfo workDirInfo; - ReadWorkDirInfo(workDirInfo); + workDirInfo.Load(); UString workDir = GetWorkDir(workDirInfo, m_FileName); CreateComplexDirectory(workDir); @@ -101,8 +92,7 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, GetPathParts(pathVector); CMyComPtr<IOutFolderArchive> outArchive; - HRESULT result = m_ArchiveHandler.QueryInterface( - IID_IOutFolderArchive, &outArchive); + HRESULT result = m_ArchiveHandler.QueryInterface(IID_IOutFolderArchive, &outArchive); if(result != S_OK) { g_StartupInfo.ShowMessage(NMessageID::kUpdateNotSupportedForThisArchive); diff --git a/CPP/7zip/UI/Far/PluginRead.cpp b/CPP/7zip/UI/Far/PluginRead.cpp index 7cf7c3c6..45f575fb 100755 --- a/CPP/7zip/UI/Far/PluginRead.cpp +++ b/CPP/7zip/UI/Far/PluginRead.cpp @@ -109,7 +109,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa { const int kPathIndex = 2; - ReadExtractionInfo(extractionInfo); + extractionInfo.Load(); const int kPathModeRadioIndex = 4; const int kOverwriteModeRadioIndex = kPathModeRadioIndex + 4; @@ -230,7 +230,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa else throw 31806; - SaveExtractionInfo(extractionInfo); + extractionInfo.Save(); if (dialogItems[kFilesModeIndex].Selected) extractSelectedFiles = true; diff --git a/CPP/7zip/UI/Far/PluginWrite.cpp b/CPP/7zip/UI/Far/PluginWrite.cpp index 44c6fecd..4226aa5c 100755 --- a/CPP/7zip/UI/Far/PluginWrite.cpp +++ b/CPP/7zip/UI/Far/PluginWrite.cpp @@ -78,7 +78,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles( const int kXMid = 38; NCompression::CInfo compressionInfo; - ReadCompressionInfo(compressionInfo); + compressionInfo.Load(); int methodIndex = 0; int i; @@ -145,16 +145,16 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles( else if (dialogItems[kModeRadioIndex + 1].Selected) actionSet = &kUpdateActionSet; else if (dialogItems[kModeRadioIndex + 2].Selected) - actionSet = &kFreshActionSet; + actionSet = &kFreshActionSet; else if (dialogItems[kModeRadioIndex + 3].Selected) - actionSet = &kSynchronizeActionSet; + actionSet = &kSynchronizeActionSet; else throw 51751; - SaveCompressionInfo(compressionInfo); + compressionInfo.Save(); NWorkDir::CInfo workDirInfo; - ReadWorkDirInfo(workDirInfo); + workDirInfo.Load(); UString workDir = GetWorkDir(workDirInfo, m_FileName); CreateComplexDirectory(workDir); @@ -425,8 +425,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) } NCompression::CInfo compressionInfo; - // CZipRegistryManager aZipRegistryManager; - ReadCompressionInfo(compressionInfo); + compressionInfo.Load(); int archiverIndex = 0; @@ -442,7 +441,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) { if (archiverIndex == -1) archiverIndex = i; - if (arcInfo.Name.CompareNoCase(compressionInfo.ArchiveType) == 0) + if (arcInfo.Name.CompareNoCase(compressionInfo.ArcType) == 0) archiverIndex = i; } } @@ -647,11 +646,11 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) } const CArcInfoEx &archiverInfoFinal = codecs->Formats[archiverIndex]; - compressionInfo.ArchiveType = archiverInfoFinal.Name; - SaveCompressionInfo(compressionInfo); + compressionInfo.ArcType = archiverInfoFinal.Name; + compressionInfo.Save(); NWorkDir::CInfo workDirInfo; - ReadWorkDirInfo(workDirInfo); + workDirInfo.Load(); UString fullArchiveName; if (!MyGetFullPathName(archiveName, fullArchiveName)) diff --git a/CPP/7zip/UI/Far/makefile b/CPP/7zip/UI/Far/makefile index 01c77ded..29d7bcf4 100755 --- a/CPP/7zip/UI/Far/makefile +++ b/CPP/7zip/UI/Far/makefile @@ -1,6 +1,5 @@ PROG = 7-ZipFar.dll DEF_FILE = Far.def -LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib ole32.lib CFLAGS = $(CFLAGS) -I ../../../ \ -DWIN_LONG_PATH \ -DEXTERNAL_CODECS diff --git a/CPP/7zip/UI/FileManager/AboutDialog.cpp b/CPP/7zip/UI/FileManager/AboutDialog.cpp index a450a765..edfa98ba 100755 --- a/CPP/7zip/UI/FileManager/AboutDialog.cpp +++ b/CPP/7zip/UI/FileManager/AboutDialog.cpp @@ -2,7 +2,6 @@ #include "StdAfx.h" -#include "AboutDialogRes.h" #include "AboutDialog.h" #include "HelpUtils.h" #include "LangUtils.h" @@ -18,15 +17,17 @@ static CIDLangPair kIDLangPairs[] = #define MY_HOME_PAGE TEXT("http://www.7-zip.org/") static LPCTSTR kHomePageURL = MY_HOME_PAGE; +/* static LPCTSTR kRegisterPageURL = MY_HOME_PAGE TEXT("register.html"); static LPCTSTR kSupportPageURL = MY_HOME_PAGE TEXT("support.html"); - +*/ static LPCWSTR kHelpTopic = L"start.htm"; bool CAboutDialog::OnInit() { LangSetWindowText(HWND(*this), 0x01000100); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + NormalizePosition(); return CModalDialog::OnInit(); } @@ -35,26 +36,29 @@ void CAboutDialog::OnHelp() ShowHelpWindow(NULL, kHelpTopic); } -static void MyShellExecute(LPCTSTR url) -{ - ::ShellExecute(NULL, NULL, url, NULL, NULL, SW_SHOWNORMAL); -} - bool CAboutDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { + LPCTSTR url; switch(buttonID) { - case IDC_ABOUT_BUTTON_HOMEPAGE: - ::MyShellExecute(kHomePageURL); - break; - case IDC_ABOUT_BUTTON_REGISTER: - ::MyShellExecute(kRegisterPageURL); - break; - case IDC_ABOUT_BUTTON_SUPPORT: - ::MyShellExecute(kSupportPageURL); - break; + case IDC_ABOUT_BUTTON_HOMEPAGE: url = kHomePageURL; break; + /* + case IDC_ABOUT_BUTTON_REGISTER: url = kRegisterPageURL; break; + case IDC_ABOUT_BUTTON_SUPPORT: url = kSupportPageURL; break; + */ default: return CModalDialog::OnButtonClicked(buttonID, buttonHWND); } + + #ifdef UNDER_CE + SHELLEXECUTEINFO s; + memset(&s, 0, sizeof(s)); + s.cbSize = sizeof(s); + s.lpFile = url; + ::ShellExecuteEx(&s); + #else + ::ShellExecute(NULL, NULL, url, NULL, NULL, SW_SHOWNORMAL); + #endif + return true; } diff --git a/CPP/7zip/UI/FileManager/AboutDialog.rc b/CPP/7zip/UI/FileManager/AboutDialog.rc index 7e2438ff..d8f923a7 100755 --- a/CPP/7zip/UI/FileManager/AboutDialog.rc +++ b/CPP/7zip/UI/FileManager/AboutDialog.rc @@ -2,40 +2,25 @@ #include "../../GuiCommon.rc" #include "../../MyVersion.h" -#define xSize2 224 -#define ySize2 158 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 144 +#define yc 144 -#define bXPos (xSize - marg - bXSize) -#define bYPos (ySize - marg - bYSize) +#define y 80 -#undef b2XSize -#undef b2XPos -#undef infoYPos -#undef infoYSize +IDI_LOGO ICON "../../UI/FileManager/7zipLogo.ico" -#define b2XSize 94 -#define b2XPos (xSize - marg - b2XSize) -#define gSpace 2 -#define gSize (xSize2 - gSpace - b2XSize) +#ifndef SS_REALSIZEIMAGE +#define SS_REALSIZEIMAGE 0x800 +#endif -#define infoYPos 91 -#define infoYSize (ySize2 - infoYPos - bYSize - 2) - -IDI_LOGO ICON "7zipLogo.ico" - -IDD_ABOUT DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_ABOUT MY_DIALOG CAPTION "About 7-Zip" -MY_FONT -BEGIN - PUSHBUTTON "OK", IDOK, bXPos, bYPos, bXSize, bYSize - PUSHBUTTON "www.7-zip.org", IDC_ABOUT_BUTTON_HOMEPAGE, b2XPos, 7, b2XSize, bYSize - PUSHBUTTON "Support", IDC_ABOUT_BUTTON_SUPPORT, b2XPos, 30, b2XSize, bYSize - PUSHBUTTON "Register", IDC_ABOUT_BUTTON_REGISTER, b2XPos, 53, b2XSize, bYSize - ICON IDI_LOGO, -1, marg, marg, 20, 20, SS_REALSIZEIMAGE - LTEXT MY_7ZIP_VERSION, -1, marg, 54, gSize, 9 - LTEXT MY_COPYRIGHT, -1, marg, 67, gSize, 17 +{ + DEFPUSHBUTTON "OK", IDOK, bx1, by, bxs, bys + PUSHBUTTON "www.7-zip.org", IDC_ABOUT_BUTTON_HOMEPAGE, bx2, by, bxs, bys + ICON IDI_LOGO, -1, m, m, 32, 32, SS_REALSIZEIMAGE + LTEXT MY_7ZIP_VERSION, -1, m, 54, xc, 8 + LTEXT MY_COPYRIGHT, -1, m, 67, xc, 8 LTEXT "7-Zip is free software. However, you can support development of 7-Zip by registering.", - IDC_ABOUT_STATIC_REGISTER_INFO, marg, infoYPos, xSize2, infoYSize -END + IDC_ABOUT_STATIC_REGISTER_INFO, m, y, xc, (by - y - 1) +} diff --git a/CPP/7zip/UI/FileManager/AboutDialogRes.h b/CPP/7zip/UI/FileManager/AboutDialogRes.h index 54475484..f7dd0602 100755 --- a/CPP/7zip/UI/FileManager/AboutDialogRes.h +++ b/CPP/7zip/UI/FileManager/AboutDialogRes.h @@ -1,4 +1,4 @@ -#define IDD_ABOUT 100 +#define IDD_ABOUT 507 #define IDI_LOGO 138 #define IDC_ABOUT_STATIC_REGISTER_INFO 1010 #define IDC_ABOUT_BUTTON_HOMEPAGE 1020 diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp index 21942065..184d6ca0 100755 --- a/CPP/7zip/UI/FileManager/App.cpp +++ b/CPP/7zip/UI/FileManager/App.cpp @@ -71,15 +71,14 @@ void CApp::SetListSettings() extendedStyle |= LVS_EX_GRIDLINES; bool mySelectionMode = ReadAlternativeSelection(); - /* if (ReadSingleClick()) { - extendedStyle |= LVS_EX_ONECLICKACTIVATE - | LVS_EX_TRACKSELECT; + extendedStyle |= LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT; + /* if (ReadUnderline()) extendedStyle |= LVS_EX_UNDERLINEHOT; + */ } - */ for (int i = 0; i < kNumPanelsMax; i++) { @@ -104,6 +103,10 @@ void CApp::SetShowSystemMenu() ShowSystemMenu = ReadShowSystemMenu(); } +#ifndef ILC_COLOR32 +#define ILC_COLOR32 0x0020 +#endif + HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted) { if (PanelsCreated[panelIndex]) @@ -124,24 +127,23 @@ HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &arch return S_OK; } -static void CreateToolbar( - HWND parent, +static void CreateToolbar(HWND parent, NWindows::NControl::CImageList &imageList, NWindows::NControl::CToolBar &toolBar, - bool LargeButtons) + bool largeButtons) { - toolBar.Attach(::CreateWindowEx(0, - TOOLBARCLASSNAME, - NULL, 0 + toolBar.Attach(::CreateWindowEx(0, TOOLBARCLASSNAME, NULL, 0 + | WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS - | WS_CHILD - | CCS_NOPARENTALIGN - | CCS_NORESIZE - | CCS_NODIVIDER + | TBSTYLE_WRAPABLE // | TBSTYLE_AUTOSIZE - // | CCS_ADJUSTABLE + // | CCS_NORESIZE + #ifdef UNDER_CE + | CCS_NODIVIDER + | CCS_NOPARENTALIGN + #endif ,0,0,0,0, parent, NULL, g_hInstance, NULL)); // TB_BUTTONSTRUCTSIZE message, which is required for @@ -149,8 +151,8 @@ static void CreateToolbar( toolBar.ButtonStructSize(); imageList.Create( - LargeButtons ? 48: 24, - LargeButtons ? 36: 24, + largeButtons ? 48: 24, + largeButtons ? 36: 24, ILC_MASK | ILC_COLOR32, 0, 0); toolBar.SetImageList(0, imageList); } @@ -162,7 +164,7 @@ struct CButtonInfo UINT Bitmap2ResID; UINT StringResID; UInt32 LangID; - UString GetText() const { return LangString(StringResID, LangID); }; + UString GetText() const { return LangString(StringResID, LangID); } }; static CButtonInfo g_StandardButtons[] = @@ -206,17 +208,13 @@ static void SetButtonText(int commandID, UString &s) static void AddButton( NControl::CImageList &imageList, NControl::CToolBar &toolBar, - CButtonInfo &butInfo, - bool showText, - bool large) + CButtonInfo &butInfo, bool showText, bool large) { TBBUTTON but; but.iBitmap = 0; but.idCommand = butInfo.CommandID; but.fsState = TBSTATE_ENABLED; - but.fsStyle = BTNS_BUTTON - // | BTNS_AUTOSIZE - ; + but.fsStyle = TBSTYLE_BUTTON; but.dwData = 0; UString s = butInfo.GetText(); @@ -241,110 +239,54 @@ static void AddButton( #endif } -static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar) -{ - SIZE size; - toolBar.GetMaxSize(&size); - - RECT rect; - toolBar.GetWindowRect(&rect); - - REBARBANDINFO rbBand; - rbBand.cbSize = sizeof(REBARBANDINFO); // Required - rbBand.fMask = RBBIM_STYLE - | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; - rbBand.fStyle = RBBS_CHILDEDGE; // RBBS_NOGRIPPER; - rbBand.cxMinChild = size.cx; // rect.right - rect.left; - rbBand.cyMinChild = size.cy; // rect.bottom - rect.top; - rbBand.cyChild = rbBand.cyMinChild; - rbBand.cx = rbBand.cxMinChild; - rbBand.cxIdeal = rbBand.cxMinChild; - rbBand.hwndChild = toolBar; - reBar.InsertBand(-1, &rbBand); -} - void CApp::ReloadToolbars() { - if (!_rebar) - return; - HWND parent = _rebar; - - while (_rebar.GetBandCount() > 0) - _rebar.DeleteBand(0); - - _archiveToolBar.Destroy(); - _archiveButtonsImageList.Destroy(); + _buttonsImageList.Destroy(); + _toolBar.Destroy(); - _standardButtonsImageList.Destroy(); - _standardToolBar.Destroy(); - if (ShowArchiveToolbar) + if (ShowArchiveToolbar || ShowStandardToolbar) { - CreateToolbar(parent, _archiveButtonsImageList, _archiveToolBar, LargeButtons); - for (int i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++) - AddButton(_archiveButtonsImageList, _archiveToolBar, g_ArchiveButtons[i], - ShowButtonsLables, LargeButtons); - AddBand(_rebar, _archiveToolBar); - } - - if (ShowStandardToolbar) - { - CreateToolbar(parent, _standardButtonsImageList, _standardToolBar, LargeButtons); - for (int i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++) - AddButton(_standardButtonsImageList, _standardToolBar, g_StandardButtons[i], - ShowButtonsLables, LargeButtons); - AddBand(_rebar, _standardToolBar); + CreateToolbar(_window, _buttonsImageList, _toolBar, LargeButtons); + int i; + if (ShowArchiveToolbar) + for (i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++) + AddButton(_buttonsImageList, _toolBar, g_ArchiveButtons[i], ShowButtonsLables, LargeButtons); + if (ShowStandardToolbar) + for (i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++) + AddButton(_buttonsImageList, _toolBar, g_StandardButtons[i], ShowButtonsLables, LargeButtons); + + _toolBar.AutoSize(); } } -void CApp::ReloadRebar(HWND hwnd) +void CApp::SaveToolbarChanges() { - _rebar.Destroy(); - if (!ShowArchiveToolbar && !ShowStandardToolbar) - return; - if (g_ComCtl32Version >= MAKELONG(71, 4)) - { - INITCOMMONCONTROLSEX icex; - icex.dwSize = sizeof(INITCOMMONCONTROLSEX); - icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES; - InitCommonControlsEx(&icex); - - _rebar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW, - REBARCLASSNAME, - NULL, - WS_VISIBLE - | WS_BORDER - | WS_CHILD - | WS_CLIPCHILDREN - | WS_CLIPSIBLINGS - // | CCS_NODIVIDER - // | CCS_NOPARENTALIGN // it's bead for moveing of two bands - // | CCS_TOP - | RBS_VARHEIGHT - | RBS_BANDBORDERS - // | RBS_AUTOSIZE - ,0,0,0,0, hwnd, NULL, g_hInstance, NULL)); - } - if (_rebar == 0) - return; - REBARINFO rbi; - rbi.cbSize = sizeof(REBARINFO); // Required when using this struct. - rbi.fMask = 0; - rbi.himl = (HIMAGELIST)NULL; - _rebar.SetBarInfo(&rbi); + SaveToolbar(); ReloadToolbars(); + MoveSubWindows(); } +void MyLoadMenu(); + HRESULT CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted) { + _window.Attach(hwnd); + #ifdef UNDER_CE + _commandBar.Create(g_hInstance, hwnd, 1); + #endif + MyLoadMenu(); + #ifdef UNDER_CE + _commandBar.AutoSize(); + #endif + ReadToolbar(); - ReloadRebar(hwnd); + ReloadToolbars(); int i; for (i = 0; i < kNumPanelsMax; i++) PanelsCreated[i] = false; - _window.Attach(hwnd); AppState.Read(); SetListSettings(); SetShowSystemMenu(); @@ -380,8 +322,6 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &ar return S_OK; } -extern void MoveSubWindows(HWND hWnd); - HRESULT CApp::SwitchOnOffOnePanel() { if (NumPanels == 1) @@ -398,7 +338,7 @@ HRESULT CApp::SwitchOnOffOnePanel() Panels[1 - LastFocusedPanel].Enable(false); Panels[1 - LastFocusedPanel].Show(SW_HIDE); } - MoveSubWindows(_window); + MoveSubWindows(); return S_OK; } @@ -647,14 +587,16 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) destPath = srcPanel._currentFolderPrefix + destPath; } + #ifndef UNDER_CE if (destPath.Length() > 0 && destPath[0] == '\\') if (destPath.Length() == 1 || destPath[1] != '\\') { srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return; } + #endif - if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind(WCHAR_PATH_SEPARATOR) == destPath.Length() - 1) || + if (indices.Size() > 1 || (!destPath.IsEmpty() && destPath.Back() == WCHAR_PATH_SEPARATOR) || NFind::DoesDirExist(destPath)) { NDirectory::CreateComplexDirectory(destPath); @@ -831,26 +773,13 @@ int CApp::GetFocusedPanelIndex() const hwnd = GetParent(hwnd); } } - */ +*/ static UString g_ToolTipBuffer; static CSysString g_ToolTipBufferSys; void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh) { - if (pnmh->hwndFrom == _rebar) - { - switch(pnmh->code) - { - case RBN_HEIGHTCHANGE: - { - MoveSubWindows(g_HWND); - return; - } - } - return ; - } - else { if (pnmh->code == TTN_GETDISPINFO) { diff --git a/CPP/7zip/UI/FileManager/App.h b/CPP/7zip/UI/FileManager/App.h index 1fc77138..d2ced9ba 100755 --- a/CPP/7zip/UI/FileManager/App.h +++ b/CPP/7zip/UI/FileManager/App.h @@ -3,10 +3,12 @@ #ifndef __APP_H #define __APP_H -#include "Panel.h" -#include "AppState.h" +#include "Windows/Control/CommandBar.h" #include "Windows/Control/ImageList.h" +#include "AppState.h" +#include "Panel.h" + class CApp; extern CApp g_App; @@ -14,8 +16,6 @@ extern HWND g_HWND; const int kNumPanelsMax = 2; -extern void MoveSubWindows(HWND hWnd); - enum { kAddCommand = kToolbarStartID, @@ -77,12 +77,10 @@ class CDropTarget: public: MY_UNKNOWN_IMP1_MT(IDropTarget) - STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState, - POINTL pt, DWORD *effect); + STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect); STDMETHOD(DragOver)(DWORD keyState, POINTL pt, DWORD * effect); STDMETHOD(DragLeave)(); - STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState, - POINTL pt, DWORD *effect); + STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect); CDropTarget(): TargetPanelIndex(-1), @@ -119,16 +117,18 @@ public: CPanel Panels[kNumPanelsMax]; bool PanelsCreated[kNumPanelsMax]; - NWindows::NControl::CImageList _archiveButtonsImageList; - NWindows::NControl::CImageList _standardButtonsImageList; + NWindows::NControl::CImageList _buttonsImageList; - NWindows::NControl::CReBar _rebar; - NWindows::NControl::CToolBar _archiveToolBar; - NWindows::NControl::CToolBar _standardToolBar; + #ifdef UNDER_CE + NWindows::NControl::CCommandBar _commandBar; + #endif + NWindows::NControl::CToolBar _toolBar; CDropTarget *_dropTargetSpec; CMyComPtr<IDropTarget> _dropTarget; + CApp(): _window(0), NumPanels(2), LastFocusedPanel(0) {} + void CreateDragTarget() { _dropTargetSpec = new CDropTarget(); @@ -165,94 +165,53 @@ public: void Save(); void Release(); - - /* - void SetFocus(int panelIndex) - { Panels[panelIndex].SetFocusToList(); } - */ - void SetFocusToLastItem() - { Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); } - + // void SetFocus(int panelIndex) { Panels[panelIndex].SetFocusToList(); } + void SetFocusToLastItem() { Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); } int GetFocusedPanelIndex() const { return LastFocusedPanel; } - bool IsPanelVisible(int index) const { return (NumPanels > 1 || index == LastFocusedPanel); } - - /* - void SetCurrentIndex() - { CurrentPanel = GetFocusedPanelIndex(); } - */ - - CApp(): NumPanels(2), LastFocusedPanel(0) {} - CPanel &GetFocusedPanel() - { return Panels[GetFocusedPanelIndex()]; } + CPanel &GetFocusedPanel() { return Panels[GetFocusedPanelIndex()]; } // File Menu - void OpenItem() - { GetFocusedPanel().OpenSelectedItems(true); } - void OpenItemInside() - { GetFocusedPanel().OpenFocusedItemAsInternal(); } - void OpenItemOutside() - { GetFocusedPanel().OpenSelectedItems(false); } - void EditItem() - { GetFocusedPanel().EditItem(); } - void Rename() - { GetFocusedPanel().RenameFile(); } - void CopyTo() - { OnCopy(false, false, GetFocusedPanelIndex()); } - void MoveTo() - { OnCopy(true, false, GetFocusedPanelIndex()); } - void Delete(bool toRecycleBin) - { GetFocusedPanel().DeleteItems(toRecycleBin); } + void OpenItem() { GetFocusedPanel().OpenSelectedItems(true); } + void OpenItemInside() { GetFocusedPanel().OpenFocusedItemAsInternal(); } + void OpenItemOutside() { GetFocusedPanel().OpenSelectedItems(false); } + void EditItem() { GetFocusedPanel().EditItem(); } + void Rename() { GetFocusedPanel().RenameFile(); } + void CopyTo() { OnCopy(false, false, GetFocusedPanelIndex()); } + void MoveTo() { OnCopy(true, false, GetFocusedPanelIndex()); } + void Delete(bool toRecycleBin) { GetFocusedPanel().DeleteItems(toRecycleBin); } void CalculateCrc(); void DiffFiles(); void Split(); void Combine(); - void Properties() - { GetFocusedPanel().Properties(); } - void Comment() - { GetFocusedPanel().ChangeComment(); } + void Properties() { GetFocusedPanel().Properties(); } + void Comment() { GetFocusedPanel().ChangeComment(); } - void CreateFolder() - { GetFocusedPanel().CreateFolder(); } - void CreateFile() - { GetFocusedPanel().CreateFile(); } + void CreateFolder() { GetFocusedPanel().CreateFolder(); } + void CreateFile() { GetFocusedPanel().CreateFile(); } // Edit - void EditCut() - { GetFocusedPanel().EditCut(); } - void EditCopy() - { GetFocusedPanel().EditCopy(); } - void EditPaste() - { GetFocusedPanel().EditPaste(); } - - void SelectAll(bool selectMode) - { GetFocusedPanel().SelectAll(selectMode); } - void InvertSelection() - { GetFocusedPanel().InvertSelection(); } - void SelectSpec(bool selectMode) - { GetFocusedPanel().SelectSpec(selectMode); } - void SelectByType(bool selectMode) - { GetFocusedPanel().SelectByType(selectMode); } - - void RefreshStatusBar() - { GetFocusedPanel().RefreshStatusBar(); } - - void SetListViewMode(UINT32 index) - { GetFocusedPanel().SetListViewMode(index); } - UINT32 GetListViewMode() - { return GetFocusedPanel().GetListViewMode(); } - - void SortItemsWithPropID(PROPID propID) - { GetFocusedPanel().SortItemsWithPropID(propID); } - - void OpenRootFolder() - { GetFocusedPanel().OpenDrivesFolder(); } - void OpenParentFolder() - { GetFocusedPanel().OpenParentFolder(); } - void FoldersHistory() - { GetFocusedPanel().FoldersHistory(); } - void RefreshView() - { GetFocusedPanel().OnReload(); } + void EditCut() { GetFocusedPanel().EditCut(); } + void EditCopy() { GetFocusedPanel().EditCopy(); } + void EditPaste() { GetFocusedPanel().EditPaste(); } + + void SelectAll(bool selectMode) { GetFocusedPanel().SelectAll(selectMode); } + void InvertSelection() { GetFocusedPanel().InvertSelection(); } + void SelectSpec(bool selectMode) { GetFocusedPanel().SelectSpec(selectMode); } + void SelectByType(bool selectMode) { GetFocusedPanel().SelectByType(selectMode); } + + void RefreshStatusBar() { GetFocusedPanel().RefreshStatusBar(); } + + void SetListViewMode(UINT32 index) { GetFocusedPanel().SetListViewMode(index); } + UINT32 GetListViewMode() { return GetFocusedPanel().GetListViewMode(); } + PROPID GetSortID() { return GetFocusedPanel().GetSortID(); } + + void SortItemsWithPropID(PROPID propID) { GetFocusedPanel().SortItemsWithPropID(propID); } + + void OpenRootFolder() { GetFocusedPanel().OpenDrivesFolder(); } + void OpenParentFolder() { GetFocusedPanel().OpenParentFolder(); } + void FoldersHistory() { GetFocusedPanel().FoldersHistory(); } + void RefreshView() { GetFocusedPanel().OnReload(); } void RefreshAllPanels() { for (int i = 0; i < NumPanels; i++) @@ -263,18 +222,29 @@ public: Panels[index].OnReload(); } } + + /* + void SysIconsWereChanged() + { + for (int i = 0; i < NumPanels; i++) + { + int index = i; + if (NumPanels == 1) + index = LastFocusedPanel; + Panels[index].SysIconsWereChanged(); + } + } + */ + void SetListSettings(); void SetShowSystemMenu(); HRESULT SwitchOnOffOnePanel(); bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); } void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); } - void OpenBookmark(int index) - { GetFocusedPanel().OpenBookmark(index); } - void SetBookmark(int index) - { GetFocusedPanel().SetBookmark(index); } + void OpenBookmark(int index) { GetFocusedPanel().OpenBookmark(index); } + void SetBookmark(int index) { GetFocusedPanel().SetBookmark(index); } - void ReloadRebar(HWND hwnd); void ReloadToolbars(); void ReadToolbar() { @@ -293,33 +263,28 @@ public: if (ShowArchiveToolbar) mask |= 8; SaveToolbarsMask(mask); } + + void SaveToolbarChanges(); + void SwitchStandardToolbar() { ShowStandardToolbar = !ShowStandardToolbar; - SaveToolbar(); - ReloadRebar(g_HWND); - MoveSubWindows(_window); + SaveToolbarChanges(); } void SwitchArchiveToolbar() { ShowArchiveToolbar = !ShowArchiveToolbar; - SaveToolbar(); - ReloadRebar(g_HWND); - MoveSubWindows(_window); + SaveToolbarChanges(); } void SwitchButtonsLables() { ShowButtonsLables = !ShowButtonsLables; - SaveToolbar(); - ReloadRebar(g_HWND); - MoveSubWindows(_window); + SaveToolbarChanges(); } void SwitchLargeButtons() { LargeButtons = !LargeButtons; - SaveToolbar(); - ReloadRebar(g_HWND); - MoveSubWindows(_window); + SaveToolbarChanges(); } void AddToArchive() { GetFocusedPanel().AddToArchive(); } @@ -332,6 +297,8 @@ public: void RefreshTitle(bool always = false); void RefreshTitleAlways() { RefreshTitle(true); } void RefreshTitle(int panelIndex, bool always = false); + + void MoveSubWindows(); }; #endif diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.cpp b/CPP/7zip/UI/FileManager/BrowseDialog.cpp new file mode 100755 index 00000000..602b12f3 --- /dev/null +++ b/CPP/7zip/UI/FileManager/BrowseDialog.cpp @@ -0,0 +1,514 @@ +// BrowseDialog.cpp + +#include "StdAfx.h" + +#ifdef UNDER_CE + +#include "Common/IntToString.h" + +#include "Windows/PropVariantConversions.h" + +#include "BrowseDialog.h" +#include "LangUtils.h" +#include "PropertyNameRes.h" + +#ifndef _SFX +#include "RegistryUtils.h" +#endif + +using namespace NWindows; +using namespace NFile; +using namespace NFind; + +extern bool g_LVN_ITEMACTIVATE_Support; + +static const int kParentIndex = -1; + +#ifdef LANG +static CIDLangPair kIDLangPairs[] = +{ + { IDOK, 0x02000702 }, + { IDCANCEL, 0x02000710 } +}; +#endif + +static bool GetParentPath(const UString &path2, UString &dest, UString &focused) +{ + UString path = path2; + dest.Empty(); + if (path.IsEmpty()) + return false; + if (path.Back() == WCHAR_PATH_SEPARATOR) + path.DeleteBack(); + if (path.IsEmpty()) + return false; + int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); + if (pos < 0 || path.Back() == WCHAR_PATH_SEPARATOR) + return false; + focused = path.Mid(pos + 1); + dest = path.Left(pos + 1); + return true; +} + +bool CBrowseDialog::OnInit() +{ + #ifdef LANG + LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + #endif + if (!Title.IsEmpty()) + SetText(Title); + _list.Attach(GetItem(IDC_BROWSE_LIST)); + + #ifndef UNDER_CE + _list.SetUnicodeFormat(true); + #endif + + #ifndef _SFX + if (ReadSingleClick()) + _list.SetExtendedListViewStyle(LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT); + _showDots = ReadShowDots(); + #endif + + _list.SetImageList(GetSysImageList(true), LVSIL_SMALL); + _list.SetImageList(GetSysImageList(false), LVSIL_NORMAL); + + _list.InsertColumn(0, LangStringSpec(IDS_PROP_NAME, 0x02000204), 100); + _list.InsertColumn(1, LangStringSpec(IDS_PROP_MTIME, 0x0200020C), 100); + { + LV_COLUMNW column; + column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + column.fmt = LVCFMT_RIGHT; + column.iSubItem = 2; + UString s = LangStringSpec(IDS_PROP_SIZE, 0x02000207); + column.pszText = (wchar_t *)(const wchar_t *)s; + _list.InsertColumn(2, &column); + + // _list.InsertColumn(2, LangStringSpec(IDS_PROP_SIZE, 0x02000207), 100); + } + + _list.InsertItem(0, L"12345678901234567"); + _list.SetSubItem(0, 1, L"2009-09-09"); + _list.SetSubItem(0, 2, L"9999 MB"); + for (int i = 0; i < 3; i++) + _list.SetColumnWidthAuto(i); + _list.DeleteAllItems(); + + UString selectedName; + if (!FolderMode) + { + int pos = Path.ReverseFind(WCHAR_PATH_SEPARATOR); + if (pos >= 0 && Path.Back() != WCHAR_PATH_SEPARATOR) + { + selectedName = Path.Mid(pos + 1); + Path = Path.Left(pos + 1); + } + } + _ascending = true; + _sortIndex = 0; + + NormalizeSize(); + + while (Reload(Path, selectedName) != S_OK) + { + UString parent; + if (!GetParentPath(Path, parent, selectedName)) + break; + selectedName.Empty(); + Path = parent; + } + + return CModalDialog::OnInit(); +} + +bool CBrowseDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + { + RECT rect; + GetClientRectOfItem(IDC_BROWSE_PARENT, rect); + mx = rect.left; + my = rect.top; + } + InvalidateRect(NULL); + + { + RECT rect; + GetClientRectOfItem(IDC_BROWSE_PATH, rect); + MoveItem(IDC_BROWSE_PATH, rect.left, rect.top, xSize - mx - rect.left, RECT_SIZE_Y(rect)); + } + + int bx1, bx2, by; + GetItemSizes(IDCANCEL, bx1, by); + GetItemSizes(IDOK, bx2, by); + int y = ySize - my - by; + int x = xSize - mx - bx1; + MoveItem(IDCANCEL, x, y, bx1, by); + MoveItem(IDOK, x - mx - bx2, y, bx2, by); + + { + RECT rect; + GetClientRectOfItem(IDC_BROWSE_LIST, rect); + _list.Move(rect.left, rect.top, xSize - mx - rect.left, y - my - rect.top); + } + return false; +} + +static UString ConvertSizeToStringShort(UInt64 value) +{ + wchar_t s[32]; + wchar_t c = L'\0', c2 = L'\0'; + if (value < (UInt64)10000) + { + c = L'\0'; + c2 = L'\0'; + } + else if (value < ((UInt64)10000 << 10)) + { + value >>= 10; + c = L'K'; + } + else if (value < ((UInt64)10000 << 20)) + { + value >>= 20; + c = L'M'; + } + else + { + value >>= 30; + c = L'G'; + } + ConvertUInt64ToString(value, s); + int p = MyStringLen(s); + if (c != 0) + s[p++] = L' '; + s[p++] = c; + s[p++] = c2; + s[p++] = L'\0'; + return s; +} + +int CBrowseDialog::CompareItems(LPARAM lParam1, LPARAM lParam2) +{ + if (lParam1 == kParentIndex) return -1; + if (lParam2 == kParentIndex) return 1; + const CFileInfoW &f1 = _files[(int)lParam1]; + const CFileInfoW &f2 = _files[(int)lParam2]; + + bool isDir1 = f1.IsDir(); + bool isDir2 = f2.IsDir(); + + if (isDir1 && !isDir2) return -1; + if (isDir2 && !isDir1) return 1; + + int result = 0; + switch(_sortIndex) + { + case 0: result = f1.Name.CompareNoCase(f2.Name); break; + case 1: result = CompareFileTime(&f1.MTime, &f2.MTime); break; + case 2: result = MyCompare(f1.Size, f2.Size); break; + } + return _ascending ? result: (-result); +} + +static int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) +{ + if (lpData == NULL) + return 0; + return ((CBrowseDialog*)lpData)->CompareItems(lParam1, lParam2); +} + +static HRESULT GetNormalizedError() +{ + HRESULT errorCode = GetLastError(); + return (errorCode == 0) ? 1 : errorCode; +} + +HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selectedName) +{ + CEnumeratorW enumerator(pathPrefix + L'*'); + CObjectVector<CFileInfoW> files; + for (;;) + { + bool found; + CFileInfoW fi; + if (!enumerator.Next(fi, found)) + return GetNormalizedError(); + if (!found) + break; + files.Add(fi); + } + + Path = pathPrefix; + + _files = files; + + SetItemText(IDC_BROWSE_PATH, Path); + _list.SetRedraw(false); + _list.DeleteAllItems(); + + if (!Path.IsEmpty() && Path.Back() != WCHAR_PATH_SEPARATOR) + Path += WCHAR_PATH_SEPARATOR; + + LVITEMW item; + + int index = 0; + int cursorIndex = -1; + + #ifndef _SFX + if (_showDots) + { + UString itemName = L".."; + item.iItem = index; + if (selectedName.IsEmpty()) + cursorIndex = item.iItem; + item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; + int subItem = 0; + item.iSubItem = subItem++; + item.lParam = kParentIndex; + item.pszText = (wchar_t *)(const wchar_t *)itemName; + item.iImage = _extToIconMap.GetIconIndex(FILE_ATTRIBUTE_DIRECTORY, Path); + if (item.iImage < 0) + item.iImage = 0; + _list.InsertItem(&item); + _list.SetSubItem(index, subItem++, L""); + _list.SetSubItem(index, subItem++, L""); + index++; + } + #endif + + for (int i = 0; i < _files.Size(); i++) + { + const CFileInfoW &fi = _files[i]; + item.iItem = index; + if (fi.Name.CompareNoCase(selectedName) == 0) + cursorIndex = item.iItem; + item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; + int subItem = 0; + item.iSubItem = subItem++; + item.lParam = i; + item.pszText = (wchar_t *)(const wchar_t *)fi.Name; + item.iImage = _extToIconMap.GetIconIndex(fi.Attrib, Path + fi.Name); + if (item.iImage < 0) + item.iImage = 0; + _list.InsertItem(&item); + { + FILETIME ft; + UString s; + if (FileTimeToLocalFileTime(&fi.MTime, &ft)) + s = ConvertFileTimeToString(ft, false, false); + _list.SetSubItem(index, subItem++, s); + } + { + UString s; + if (!fi.IsDir()) + s = ConvertSizeToStringShort(fi.Size); + _list.SetSubItem(index, subItem++, s); + } + index++; + } + + if (_list.GetItemCount() > 0 && cursorIndex >= 0) + _list.SetItemState_FocusedSelected(cursorIndex); + _list.SortItems(CompareItems2, (LPARAM)this); + if (_list.GetItemCount() > 0 && cursorIndex < 0) + _list.SetItemState(0, LVIS_FOCUSED, LVIS_FOCUSED); + _list.EnsureVisible(_list.GetFocusedItem(), false); + _list.SetRedraw(true); + return S_OK; +} + +HRESULT CBrowseDialog::Reload() +{ + UString selectedCur; + int index = _list.GetNextSelectedItem(-1); + if (index >= 0) + { + int fileIndex = GetRealItemIndex(index); + if (fileIndex != kParentIndex) + selectedCur = _files[fileIndex].Name; + } + return Reload(Path, selectedCur); +} + +void CBrowseDialog::OpenParentFolder() +{ + UString parent, selected; + if (GetParentPath(Path, parent, selected)) + Reload(parent, selected); +} + +extern UString HResultToMessage(HRESULT errorCode); + +bool CBrowseDialog::OnNotify(UINT /* controlID */, LPNMHDR header) +{ + if (header->hwndFrom != _list) + return false; + switch(header->code) + { + case LVN_ITEMACTIVATE: + if (g_LVN_ITEMACTIVATE_Support) + { + OnItemEnter(); + return true; + } + break; + case NM_DBLCLK: + case NM_RETURN: // probabably it's unused + if (!g_LVN_ITEMACTIVATE_Support) + { + OnItemEnter(); + return true; + } + break; + case LVN_COLUMNCLICK: + { + int index = LPNMLISTVIEW(header)->iSubItem; + if (index == _sortIndex) + _ascending = !_ascending; + else + { + _ascending = (index == 0); + _sortIndex = index; + } + Reload(); + return false; + } + case LVN_KEYDOWN: + { + LRESULT result; + bool boolResult = OnKeyDown(LPNMLVKEYDOWN(header), result); + return boolResult; + } + } + return false; +} + +bool CBrowseDialog::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result) +{ + bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; + result = 0; + + switch(keyDownInfo->wVKey) + { + case VK_BACK: + OpenParentFolder(); + return true; + case 'R': + if (ctrl) + { + Reload(); + return true; + } + return false; + } + return false; +} + +bool CBrowseDialog::OnButtonClicked(int buttonID, HWND buttonHWND) +{ + switch(buttonID) + { + case IDC_BROWSE_PARENT: + OpenParentFolder(); + return true; + } + return CModalDialog::OnButtonClicked(buttonID, buttonHWND); +} + +void CBrowseDialog::ShowError(LPCWSTR s) { MessageBoxW(*this, s, L"7-Zip", MB_ICONERROR); } + +void CBrowseDialog::ShowSelectError() +{ + ShowError(FolderMode ? + L"You must select some folder": + L"You must select some file"); +} + +void CBrowseDialog::FinishOnOK() +{ + int index = _list.GetNextSelectedItem(-1); + if (index < 0) + { + if (!FolderMode) + { + ShowSelectError(); + return; + } + } + else + { + int fileIndex = GetRealItemIndex(index); + if (fileIndex == kParentIndex) + { + OpenParentFolder(); + return; + } + const CFileInfoW &file = _files[fileIndex]; + if (file.IsDir() != FolderMode) + { + ShowSelectError(); + return; + } + Path += file.Name; + } + End(IDOK); +} + +void CBrowseDialog::OnItemEnter() +{ + int index = _list.GetNextSelectedItem(-1); + if (index < 0) + return; + int fileIndex = GetRealItemIndex(index); + if (fileIndex == kParentIndex) + OpenParentFolder(); + else + { + const CFileInfoW &file = _files[fileIndex]; + if (!file.IsDir()) + { + if (!FolderMode) + FinishOnOK(); + else + ShowSelectError(); + return; + } + HRESULT res = Reload(Path + file.Name + WCHAR_PATH_SEPARATOR, L""); + if (res != S_OK) + ShowError(HResultToMessage(res)); + } +} + +void CBrowseDialog::OnOK() +{ + if (GetFocus() == _list) + { + OnItemEnter(); + return; + } + FinishOnOK(); +} + +static bool MyBrowse(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath, bool folderMode) +{ + CBrowseDialog dialog; + dialog.Title = title; + dialog.Path = initialFolder; + dialog.FolderMode = folderMode; + if (dialog.Create(owner) != IDOK) + return false; + resultPath = dialog.Path; + return true; +} + +bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath) +{ + return MyBrowse(owner, title, initialFolder, resultPath, true); +} + +bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR initialFolder, LPCWSTR, UString &resultPath) +{ + return MyBrowse(owner, title, initialFolder, resultPath, false); +} + +#endif diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.h b/CPP/7zip/UI/FileManager/BrowseDialog.h new file mode 100755 index 00000000..41eb6b50 --- /dev/null +++ b/CPP/7zip/UI/FileManager/BrowseDialog.h @@ -0,0 +1,77 @@ +// BrowseDialog.h + +#ifndef __BROWSE_DIALOG_H +#define __BROWSE_DIALOG_H + +#ifdef UNDER_CE + +#include "Windows/FileFind.h" + +#include "Windows/Control/Dialog.h" +#include "Windows/Control/ListView.h" + +#include "BrowseDialogRes.h" +#include "SysIconUtils.h" + +class CBrowseDialog: public NWindows::NControl::CModalDialog +{ + NWindows::NControl::CListView _list; + CObjectVector<NWindows::NFile::NFind::CFileInfoW> _files; + CExtToIconMap _extToIconMap; + int _sortIndex; + bool _ascending; + bool _showDots; + + virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); + virtual bool OnNotify(UINT controlID, LPNMHDR header); + virtual void OnOK(); + + virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); + virtual bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result); + + void FinishOnOK(); + HRESULT Reload(const UString &pathPrefix, const UString &selectedName); + HRESULT Reload(); + void OpenParentFolder(); + + void OnItemEnter(); + + int GetRealItemIndex(int indexInListView) const + { + LPARAM param; + if (!_list.GetItemParam(indexInListView, param)) + return (int)-1; + return (int)param; + } + + void ShowError(LPCWSTR s); + void ShowSelectError(); +public: + UString Title; + UString Path; + bool FolderMode; + + CBrowseDialog(): FolderMode(true), _showDots(false) {} + + INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_BROWSE, parent); } + int CompareItems(LPARAM lParam1, LPARAM lParam2); +}; + +bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath); +bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR initialFolder, LPCWSTR s, UString &resultPath); + +#else + +#include "Windows/CommonDialog.h" +#include "Windows/Shell.h" + +#define MyBrowseForFolder(h, title, initialFolder, resultPath) \ + NShell::BrowseForFolder(h, title, initialFolder, resultPath) + +#define MyBrowseForFile(h, title, initialFolder, s, resultPath) \ + MyGetOpenFileName(h, title, initialFolder, s, resultPath) + +#endif + +#endif diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.rc b/CPP/7zip/UI/FileManager/BrowseDialog.rc new file mode 100755 index 00000000..4d7ec288 --- /dev/null +++ b/CPP/7zip/UI/FileManager/BrowseDialog.rc @@ -0,0 +1,17 @@ +#include "BrowseDialogRes.h" +#include "../../GuiCommon.rc" + +#define xc 180 +#define yc 160 + +IDD_DIALOG_BROWSE MY_RESIZE_DIALOG +CAPTION "7-Zip: Browse" +{ + LTEXT "", IDC_BROWSE_PATH, m + 20, m + 3, xc - 20, 8 + CONTROL "List1", IDC_BROWSE_LIST, "SysListView32", + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP, + m, m + 16, xc, yc - bys - m - 16 + PUSHBUTTON "OK", IDOK, bx2, by, bxs, bys + PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys + PUSHBUTTON "..", IDC_BROWSE_PARENT, m, m, 16, 14 +} diff --git a/CPP/7zip/UI/FileManager/BrowseDialogRes.h b/CPP/7zip/UI/FileManager/BrowseDialogRes.h new file mode 100755 index 00000000..79f0efdb --- /dev/null +++ b/CPP/7zip/UI/FileManager/BrowseDialogRes.h @@ -0,0 +1,4 @@ +#define IDD_DIALOG_BROWSE 509 +#define IDC_BROWSE_LIST 1000 +#define IDC_BROWSE_PATH 1001 +#define IDC_BROWSE_PARENT 1002 diff --git a/CPP/7zip/UI/FileManager/ClassDefs.cpp b/CPP/7zip/UI/FileManager/ClassDefs.cpp index 5b4401a1..99405d9b 100755 --- a/CPP/7zip/UI/FileManager/ClassDefs.cpp +++ b/CPP/7zip/UI/FileManager/ClassDefs.cpp @@ -2,16 +2,10 @@ #include "StdAfx.h" -#include <initguid.h> +#include "Common/MyInitGuid.h" -#include "IFolder.h" -#include "../../IPassword.h" #include "PluginInterface.h" -#include "ExtractCallback.h" -#include "../../ICoder.h" - #include "../Agent/Agent.h" -// {23170F69-40C1-278A-1000-000100020000} DEFINE_GUID(CLSID_CZipContextMenu, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00); diff --git a/CPP/7zip/UI/FileManager/ComboDialog.cpp b/CPP/7zip/UI/FileManager/ComboDialog.cpp index 807a5dd2..c3cc08e7 100755 --- a/CPP/7zip/UI/FileManager/ComboDialog.cpp +++ b/CPP/7zip/UI/FileManager/ComboDialog.cpp @@ -43,9 +43,28 @@ bool CComboDialog::OnInit() _comboBox.SetText(Value); for(int i = 0; i < Strings.Size(); i++) _comboBox.AddString(Strings[i]); + NormalizeSize(); return CModalDialog::OnInit(); } +bool CComboDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + GetMargins(8, mx, my); + int bx1, bx2, by; + GetItemSizes(IDCANCEL, bx1, by); + GetItemSizes(IDOK, bx2, by); + int y = ySize - my - by; + int x = xSize - mx - bx1; + + InvalidateRect(NULL); + + MoveItem(IDCANCEL, x, y, bx1, by); + MoveItem(IDOK, x - mx - bx2, y, bx2, by); + ChangeSubWindowSizeX(_comboBox, xSize - mx * 2); + return false; +} + void CComboDialog::OnOK() { _comboBox.GetText(Value); diff --git a/CPP/7zip/UI/FileManager/ComboDialog.h b/CPP/7zip/UI/FileManager/ComboDialog.h index 0a1addc5..ff111b19 100755 --- a/CPP/7zip/UI/FileManager/ComboDialog.h +++ b/CPP/7zip/UI/FileManager/ComboDialog.h @@ -1,10 +1,11 @@ // ComboDialog.h -#ifndef __COMBODIALOG_H -#define __COMBODIALOG_H +#ifndef __COMBO_DIALOG_H +#define __COMBO_DIALOG_H -#include "Windows/Control/Dialog.h" #include "Windows/Control/ComboBox.h" +#include "Windows/Control/Dialog.h" + #include "ComboDialogRes.h" class CComboDialog: public NWindows::NControl::CModalDialog @@ -12,6 +13,7 @@ class CComboDialog: public NWindows::NControl::CModalDialog NWindows::NControl::CComboBox _comboBox; virtual void OnOK(); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); public: // bool Sorted; UString Title; diff --git a/CPP/7zip/UI/FileManager/ComboDialog.rc b/CPP/7zip/UI/FileManager/ComboDialog.rc index 7005e09e..6789347a 100755 --- a/CPP/7zip/UI/FileManager/ComboDialog.rc +++ b/CPP/7zip/UI/FileManager/ComboDialog.rc @@ -1,24 +1,13 @@ #include "ComboDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 233 -#define ySize2 57 +#define xc 240 +#define yc 64 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - -#define bYPos (ySize - marg - bYSize) -#define b1XPos (xSize - marg - bXSize) -#define b2XPos (b1XPos - 10 - bXSize) - - -IDD_DIALOG_COMBO DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_COMBO MY_RESIZE_DIALOG CAPTION "Combo" -MY_FONT -BEGIN - LTEXT "", IDC_COMBO_STATIC, marg, marg, xSize2, 8 - COMBOBOX IDC_COMBO_COMBO, marg, 20, xSize2, 65, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - - DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize -END +{ + LTEXT "", IDC_COMBO_STATIC, m, m, xc, 8 + COMBOBOX IDC_COMBO_COMBO, m, 20, xc, 65, MY_COMBO_WITH_EDIT + OK_CANCEL +} diff --git a/CPP/7zip/UI/FileManager/ComboDialogRes.h b/CPP/7zip/UI/FileManager/ComboDialogRes.h index b5111ddf..7f37cb93 100755 --- a/CPP/7zip/UI/FileManager/ComboDialogRes.h +++ b/CPP/7zip/UI/FileManager/ComboDialogRes.h @@ -1,4 +1,4 @@ -#define IDD_DIALOG_COMBO 200 +#define IDD_DIALOG_COMBO 505 #define IDC_COMBO_STATIC 1000 #define IDC_COMBO_COMBO 1001 diff --git a/CPP/7zip/UI/FileManager/CopyDialog.cpp b/CPP/7zip/UI/FileManager/CopyDialog.cpp index 2bf60301..8cbaf41f 100755 --- a/CPP/7zip/UI/FileManager/CopyDialog.cpp +++ b/CPP/7zip/UI/FileManager/CopyDialog.cpp @@ -1,13 +1,13 @@ // CopyDialog.cpp #include "StdAfx.h" -#include "CopyDialog.h" -#include "Common/StringConvert.h" +#include "Windows/FileName.h" #include "Windows/Control/Static.h" -#include "Windows/Shell.h" -#include "Windows/FileName.h" + +#include "BrowseDialog.h" +#include "CopyDialog.h" #ifdef LANG #include "LangUtils.h" @@ -34,13 +34,53 @@ bool CCopyDialog::OnInit() NControl::CStatic staticContol; staticContol.Attach(GetItem(IDC_COPY_STATIC)); staticContol.SetText(Static); + #ifdef UNDER_CE + // we do it, since WinCE selects Value\something instead of Value !!!! + _path.AddString(Value); + #endif for (int i = 0; i < Strings.Size(); i++) _path.AddString(Strings[i]); _path.SetText(Value); SetItemText(IDC_COPY_INFO, Info); + NormalizeSize(true); return CModalDialog::OnInit(); } +bool CCopyDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + GetMargins(8, mx, my); + int bx1, bx2, by; + GetItemSizes(IDCANCEL, bx1, by); + GetItemSizes(IDOK, bx2, by); + int y = ySize - my - by; + int x = xSize - mx - bx1; + + InvalidateRect(NULL); + + { + RECT rect; + GetClientRectOfItem(IDC_COPY_SET_PATH, rect); + int bx = rect.right - rect.left; + MoveItem(IDC_COPY_SET_PATH, xSize - mx - bx, rect.top, bx, rect.bottom - rect.top); + ChangeSubWindowSizeX(_path, xSize - mx - mx - bx - mx); + } + + { + RECT rect; + GetClientRectOfItem(IDC_COPY_INFO, rect); + NControl::CStatic staticContol; + staticContol.Attach(GetItem(IDC_COPY_INFO)); + int yPos = rect.top; + staticContol.Move(mx, yPos, xSize - mx * 2, y - 2 - yPos); + } + + MoveItem(IDCANCEL, x, y, bx1, by); + MoveItem(IDOK, x - mx - bx2, y, bx2, by); + + return false; +} + bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) @@ -57,18 +97,10 @@ void CCopyDialog::OnButtonSetPath() UString currentPath; _path.GetText(currentPath); - /* - #ifdef LANG - UString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881); - #else - UString title = MyLoadString(IDS_EXTRACT_SET_FOLDER); - #endif - */ UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209); - // UString title = L"Specify a location for output folder"; UString resultPath; - if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath)) + if (!MyBrowseForFolder(HWND(*this), title, currentPath, resultPath)) return; NFile::NName::NormalizeDirPathPrefix(resultPath); _path.SetCurSel(-1); diff --git a/CPP/7zip/UI/FileManager/CopyDialog.h b/CPP/7zip/UI/FileManager/CopyDialog.h index 55872f1c..2c22d700 100755 --- a/CPP/7zip/UI/FileManager/CopyDialog.h +++ b/CPP/7zip/UI/FileManager/CopyDialog.h @@ -1,10 +1,11 @@ // CopyDialog.h -#ifndef __COPYDIALOG_H -#define __COPYDIALOG_H +#ifndef __COPY_DIALOG_H +#define __COPY_DIALOG_H -#include "Windows/Control/Dialog.h" #include "Windows/Control/ComboBox.h" +#include "Windows/Control/Dialog.h" + #include "CopyDialogRes.h" const int kCopyDialog_NumInfoLines = 11; @@ -14,15 +15,15 @@ class CCopyDialog: public NWindows::NControl::CModalDialog NWindows::NControl::CComboBox _path; virtual void OnOK(); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); void OnButtonSetPath(); bool OnButtonClicked(int buttonID, HWND buttonHWND); public: UString Title; UString Static; UString Value; - UStringVector Strings; - UString Info; + UStringVector Strings; INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); } }; diff --git a/CPP/7zip/UI/FileManager/CopyDialog.rc b/CPP/7zip/UI/FileManager/CopyDialog.rc index 1686adda..922dddc4 100755 --- a/CPP/7zip/UI/FileManager/CopyDialog.rc +++ b/CPP/7zip/UI/FileManager/CopyDialog.rc @@ -1,32 +1,17 @@ #include "CopyDialogRes.h" #include "../../GuiCommon.rc" -#undef infoSize -#define infoSize 100 +#define xc 320 +#define yc 144 -#define xSize2 346 -#define ySize2 (infoSize + 50) +#define y 40 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - -#define bYPos (ySize - marg - bYSize) -#define b1XPos (xSize - marg - bXSize) -#define b2XPos (b1XPos - 10 - bXSize) - -IDD_DIALOG_COPY DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_COPY MY_RESIZE_DIALOG CAPTION "Copy" -MY_FONT -BEGIN - LTEXT "", IDC_COPY_STATIC, marg, marg, xSize2, 8 - COMBOBOX IDC_COPY_COMBO, marg, 20, xSize2 - bDotsSize - 12, 65, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "...", IDC_COPY_SET_PATH, (xSize - marg - bDotsSize), 20, bDotsSize, 14, WS_GROUP - LTEXT "", IDC_COPY_INFO, marg, bYPos - (infoSize + 2), xSize2, infoSize, SS_NOPREFIX | SS_LEFTNOWORDWRAP - DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize -END - -STRINGTABLE DISCARDABLE -BEGIN - IDS_SET_FOLDER "Specify a location for output folder." -END +{ + LTEXT "", IDC_COPY_STATIC, m, m, xc, 8 + COMBOBOX IDC_COPY_COMBO, m, 20, xc - bxsDots - m, 65, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDC_COPY_SET_PATH, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP + LTEXT "", IDC_COPY_INFO, m, y, xc, by - y - 1, SS_NOPREFIX | SS_LEFTNOWORDWRAP + OK_CANCEL +} diff --git a/CPP/7zip/UI/FileManager/CopyDialogRes.h b/CPP/7zip/UI/FileManager/CopyDialogRes.h index 900bf29f..4944de84 100755 --- a/CPP/7zip/UI/FileManager/CopyDialogRes.h +++ b/CPP/7zip/UI/FileManager/CopyDialogRes.h @@ -1,4 +1,4 @@ -#define IDD_DIALOG_COPY 202 +#define IDD_DIALOG_COPY 506 #define IDC_COPY_STATIC 1000 #define IDC_COPY_COMBO 1001 diff --git a/CPP/7zip/UI/FileManager/DialogSize.h b/CPP/7zip/UI/FileManager/DialogSize.h new file mode 100755 index 00000000..f4dd1c32 --- /dev/null +++ b/CPP/7zip/UI/FileManager/DialogSize.h @@ -0,0 +1,16 @@ +// DialogSize.h + +#ifndef __DIALOG_SIZE_H +#define __DIALOG_SIZE_H + +#include "Windows/Control/Dialog.h" + +#ifdef UNDER_CE +#define BIG_DIALOG_SIZE(x, y) bool isBig = NWindows::NControl::IsDialogSizeOK(x, y); +#define SIZED_DIALOG(big) (isBig ? big : big ## _2) +#else +#define BIG_DIALOG_SIZE(x, y) +#define SIZED_DIALOG(big) big +#endif + +#endif diff --git a/CPP/7zip/UI/FileManager/EditPage.cpp b/CPP/7zip/UI/FileManager/EditPage.cpp index 69261eb6..dbc580ff 100755 --- a/CPP/7zip/UI/FileManager/EditPage.cpp +++ b/CPP/7zip/UI/FileManager/EditPage.cpp @@ -1,20 +1,14 @@ // EditPage.cpp #include "StdAfx.h" -#include "EditPageRes.h" -#include "EditPage.h" -#include "Common/StringConvert.h" - -#include "Windows/Defs.h" -#include "Windows/CommonDialog.h" -// #include "Windows/FileFind.h" -// #include "Windows/FileDir.h" +#include "EditPage.h" +#include "EditPageRes.h" -#include "RegistryUtils.h" +#include "BrowseDialog.h" #include "HelpUtils.h" #include "LangUtils.h" -#include "ProgramLocation.h" +#include "RegistryUtils.h" using namespace NWindows; @@ -38,9 +32,6 @@ bool CEditPage::OnInit() LONG CEditPage::OnApply() { - // int selectedIndex = _langCombo.GetCurSel(); - // int pathIndex = _langCombo.GetItemData(selectedIndex); - // ReloadLang(); UString editorPath; _editorEdit.GetText(editorPath); SaveRegEditor(editorPath); @@ -49,33 +40,27 @@ LONG CEditPage::OnApply() void CEditPage::OnNotifyHelp() { - ShowHelpWindow(NULL, kEditTopic); // change it + ShowHelpWindow(NULL, kEditTopic); } -bool CEditPage::OnButtonClicked(int aButtonID, HWND aButtonHWND) +bool CEditPage::OnButtonClicked(int buttonID, HWND buttonHWND) { - switch(aButtonID) + switch (buttonID) { case IDC_EDIT_BUTTON_SET: { - OnSetEditorButton(); - // if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, aResultPath)) - // return; + UString editorPath; + _editorEdit.GetText(editorPath); + UString resPath; + if (MyBrowseForFile(HWND(*this), 0, editorPath, L"*.exe", resPath)) + { + _editorEdit.SetText(resPath); + // Changed(); + } return true; } } - return CPropertyPage::OnButtonClicked(aButtonID, aButtonHWND); -} - -void CEditPage::OnSetEditorButton() -{ - UString editorPath; - _editorEdit.GetText(editorPath); - UString resPath; - if(!MyGetOpenFileName(HWND(*this), 0, editorPath, L"*.exe", resPath)) - return; - _editorEdit.SetText(resPath); - // Changed(); + return CPropertyPage::OnButtonClicked(buttonID, buttonHWND); } bool CEditPage::OnCommand(int code, int itemID, LPARAM param) @@ -87,5 +72,3 @@ bool CEditPage::OnCommand(int code, int itemID, LPARAM param) } return CPropertyPage::OnCommand(code, itemID, param); } - - diff --git a/CPP/7zip/UI/FileManager/EditPage.h b/CPP/7zip/UI/FileManager/EditPage.h index 26999dcf..cfc50658 100755 --- a/CPP/7zip/UI/FileManager/EditPage.h +++ b/CPP/7zip/UI/FileManager/EditPage.h @@ -1,7 +1,7 @@ // EditPage.h -#ifndef __EDITPAGE_H -#define __EDITPAGE_H +#ifndef __EDIT_PAGE_H +#define __EDIT_PAGE_H #include "Windows/Control/PropertyPage.h" #include "Windows/Control/Edit.h" @@ -9,13 +9,12 @@ class CEditPage: public NWindows::NControl::CPropertyPage { NWindows::NControl::CEdit _editorEdit; - void OnSetEditorButton(); public: virtual bool OnInit(); virtual void OnNotifyHelp(); virtual bool OnCommand(int code, int itemID, LPARAM param); virtual LONG OnApply(); - virtual bool OnButtonClicked(int aButtonID, HWND aButtonHWND); + virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); }; #endif diff --git a/CPP/7zip/UI/FileManager/EditPage.rc b/CPP/7zip/UI/FileManager/EditPage.rc index ea261286..eb1e8599 100755 --- a/CPP/7zip/UI/FileManager/EditPage.rc +++ b/CPP/7zip/UI/FileManager/EditPage.rc @@ -1,16 +1,13 @@ #include "EditPageRes.h" #include "../../GuiCommon.rc" -#define xSize2 196 -#define ySize2 140 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc SMALL_PAGE_SIZE_X +#define yc 60 -IDD_EDIT DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE +IDD_EDIT MY_PAGE CAPTION "Editor" -MY_FONT -BEGIN - LTEXT "&Editor:", IDC_EDIT_STATIC_EDITOR, marg, marg, xSize2, 8 - EDITTEXT IDC_EDIT_EDIT_EDITOR, marg, 20, xSize2 - 12 - bDotsSize, 14, ES_AUTOHSCROLL - PUSHBUTTON "...", IDC_EDIT_BUTTON_SET, (xSize - marg - bDotsSize), 20, bDotsSize, bYSize -END +{ + LTEXT "&Editor:", IDC_EDIT_STATIC_EDITOR, m, m, xc, 8 + EDITTEXT IDC_EDIT_EDIT_EDITOR, m, 20, xc - m - bxsDots, 14, ES_AUTOHSCROLL + PUSHBUTTON "...", IDC_EDIT_BUTTON_SET, xs - m - bxsDots, 19, bxsDots, bys +} diff --git a/CPP/7zip/UI/FileManager/EditPageRes.h b/CPP/7zip/UI/FileManager/EditPageRes.h index a2de1970..33981ae0 100755 --- a/CPP/7zip/UI/FileManager/EditPageRes.h +++ b/CPP/7zip/UI/FileManager/EditPageRes.h @@ -1,4 +1,4 @@ -#define IDD_EDIT 903 +#define IDD_EDIT 542 #define IDC_EDIT_STATIC_EDITOR 1000 #define IDC_EDIT_EDIT_EDITOR 1002 #define IDC_EDIT_BUTTON_SET 1003 diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/CPP/7zip/UI/FileManager/ExtractCallback.cpp index 9902e9a1..d27db23f 100755 --- a/CPP/7zip/UI/FileManager/ExtractCallback.cpp +++ b/CPP/7zip/UI/FileManager/ExtractCallback.cpp @@ -1,23 +1,17 @@ -// ExtractCallback.h +// ExtractCallback.cpp #include "StdAfx.h" -#include "Common/Wildcard.h" -#include "Common/StringConvert.h" - #include "Windows/Error.h" #include "Windows/FileDir.h" #include "Windows/FileFind.h" -#include "Windows/ResourceString.h" #include "../../Common/FilePathAutoRename.h" #include "../GUI/ExtractRes.h" -#include "../GUI/resource.h" #include "ExtractCallback.h" #include "FormatUtils.h" -#include "MessagesDialog.h" #include "OverwriteDialog.h" #ifndef _NO_CRYPTO #include "PasswordDialog.h" @@ -27,20 +21,12 @@ using namespace NWindows; using namespace NFile; using namespace NFind; -CExtractCallbackImp::~CExtractCallbackImp() -{ - if (ShowMessages && !Messages.IsEmpty()) - { - CMessagesDialog messagesDialog; - messagesDialog.Messages = &Messages; - messagesDialog.Create(ParentWindow); - } -} +CExtractCallbackImp::~CExtractCallbackImp() {} void CExtractCallbackImp::Init() { - Messages.Clear(); NumArchiveErrors = 0; + ThereAreMessageErrors = false; #ifndef _SFX NumFolders = NumFiles = 0; NeedAddFile = false; @@ -49,7 +35,8 @@ void CExtractCallbackImp::Init() void CExtractCallbackImp::AddErrorMessage(LPCWSTR message) { - Messages.Add(message); + ThereAreMessageErrors = true; + ProgressDialog->Sync.AddErrorMessage(message); } STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64 @@ -59,40 +46,40 @@ STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64 ) { #ifndef _SFX - ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles); + ProgressDialog->Sync.SetNumFilesTotal(numFiles); #endif return S_OK; } STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total) { - ProgressDialog.ProgressSynch.SetProgress(total, 0); + ProgressDialog->Sync.SetProgress(total, 0); return S_OK; } STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *value) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + RINOK(ProgressDialog->Sync.ProcessStopAndPause()); if (value != NULL) - ProgressDialog.ProgressSynch.SetPos(*value); + ProgressDialog->Sync.SetPos(*value); return S_OK; } HRESULT CExtractCallbackImp::Open_CheckBreak() { - return ProgressDialog.ProgressSynch.ProcessStopAndPause(); + return ProgressDialog->Sync.ProcessStopAndPause(); } HRESULT CExtractCallbackImp::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) { - // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles); + // if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesTotal(*numFiles); return S_OK; } HRESULT CExtractCallbackImp::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); - // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesCur(*numFiles); + RINOK(ProgressDialog->Sync.ProcessStopAndPause()); + // if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesCur(*numFiles); return S_OK; } @@ -126,7 +113,7 @@ void CExtractCallbackImp::Open_ClearPasswordWasAskedFlag() #ifndef _SFX STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) { - ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize); + ProgressDialog->Sync.SetRatioInfo(inSize, outSize); return S_OK; } #endif @@ -134,14 +121,14 @@ STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt6 /* STDMETHODIMP CExtractCallbackImp::SetTotalFiles(UInt64 total) { - ProgressDialog.ProgressSynch.SetNumFilesTotal(total); + ProgressDialog->Sync.SetNumFilesTotal(total); return S_OK; } STDMETHODIMP CExtractCallbackImp::SetCompletedFiles(const UInt64 *value) { if (value != NULL) - ProgressDialog.ProgressSynch.SetNumFilesCur(*value); + ProgressDialog->Sync.SetNumFilesCur(*value); return S_OK; } */ @@ -153,30 +140,16 @@ STDMETHODIMP CExtractCallbackImp::AskOverwrite( { COverwriteDialog dialog; - dialog.OldFileInfo.Time = *existTime; - dialog.OldFileInfo.SizeIsDefined = (existSize != NULL); - if (dialog.OldFileInfo.SizeIsDefined) - dialog.OldFileInfo.Size = *existSize; + dialog.OldFileInfo.SetTime(existTime); + dialog.OldFileInfo.SetSize(existSize); dialog.OldFileInfo.Name = existName; - if (newTime == 0) - dialog.NewFileInfo.TimeIsDefined = false; - else - { - dialog.NewFileInfo.TimeIsDefined = true; - dialog.NewFileInfo.Time = *newTime; - } - - dialog.NewFileInfo.SizeIsDefined = (newSize != NULL); - if (dialog.NewFileInfo.SizeIsDefined) - dialog.NewFileInfo.Size = *newSize; + dialog.NewFileInfo.SetTime(newTime); + dialog.NewFileInfo.SetSize(newSize); dialog.NewFileInfo.Name = newName; - /* - NOverwriteDialog::NResult::EEnum writeAnswer = - NOverwriteDialog::Execute(oldFileInfo, newFileInfo); - */ - INT_PTR writeAnswer = dialog.Create(ProgressDialog); // ParentWindow doesn't work with 7z + ProgressDialog->WaitCreating(); + INT_PTR writeAnswer = dialog.Create(*ProgressDialog); switch(writeAnswer) { @@ -243,7 +216,8 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool } if (_needWriteArchivePath) { - AddErrorMessage(_currentArchivePath); + if (!_currentArchivePath.IsEmpty()) + AddErrorMessage(_currentArchivePath); _needWriteArchivePath = false; } AddErrorMessage( @@ -259,7 +233,7 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool NumFolders++; else NumFiles++; - ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles); + ProgressDialog->Sync.SetNumFilesCur(NumFiles); #endif return S_OK; } @@ -270,7 +244,7 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name) { #ifndef _SFX - ProgressDialog.ProgressSynch.SetTitleFileName(name); + ProgressDialog->Sync.SetTitleFileName(name); #endif _currentArchivePath = name; return S_OK; @@ -280,7 +254,7 @@ HRESULT CExtractCallbackImp::SetCurrentFilePath2(const wchar_t *path) { _currentFilePath = path; #ifndef _SFX - ProgressDialog.ProgressSynch.SetCurrentFileName(path); + ProgressDialog->Sync.SetCurrentFileName(path); #endif return S_OK; } @@ -291,7 +265,7 @@ HRESULT CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path) if (NeedAddFile) NumFiles++; NeedAddFile = true; - ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles); + ProgressDialog->Sync.SetNumFilesCur(NumFiles); #endif return SetCurrentFilePath2(path); } @@ -365,7 +339,8 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password) if (!PasswordIsDefined) { CPasswordDialog dialog; - if (dialog.Create(ProgressDialog) == IDCANCEL) + ProgressDialog->WaitCreating(); + if (dialog.Create(*ProgressDialog) == IDCANCEL) return E_ABORT; Password = dialog.Password; PasswordIsDefined = true; diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.h b/CPP/7zip/UI/FileManager/ExtractCallback.h index ee46222a..b4e88fd5 100755 --- a/CPP/7zip/UI/FileManager/ExtractCallback.h +++ b/CPP/7zip/UI/FileManager/ExtractCallback.h @@ -1,30 +1,27 @@ // ExtractCallback.h -#ifndef __EXTRACTCALLBACK_H -#define __EXTRACTCALLBACK_H +#ifndef __EXTRACT_CALLBACK_H +#define __EXTRACT_CALLBACK_H + +#include "Common/MyCom.h" + +#include "Windows/ResourceString.h" #include "../Agent/IFolderArchive.h" -#include "Common/MyString.h" #include "../Common/ArchiveOpenCallback.h" -#ifdef _SFX -#include "ProgressDialog.h" -#else -#include "ProgressDialog2.h" +#ifndef _NO_CRYPTO +#include "../../IPassword.h" #endif -#include "Windows/ResourceString.h" +#include "IFolder.h" + +#include "ProgressDialog2.h" #ifdef LANG #include "LangUtils.h" #endif -#ifndef _NO_CRYPTO -#include "../../IPassword.h" -#endif -#include "Common/MyCom.h" -#include "IFolder.h" - class CExtractCallbackImp: public IExtractCallbackUI, public IOpenCallbackUI, @@ -99,32 +96,23 @@ public: #endif private: - // bool _extractMode; UString _currentArchivePath; bool _needWriteArchivePath; UString _currentFilePath; bool _isFolder; - // void CreateComplexDirectory(const UStringVector &aDirPathParts); - HRESULT SetCurrentFilePath2(const wchar_t *filePath); void AddErrorMessage(LPCWSTR message); public: - CProgressDialog ProgressDialog; - UStringVector Messages; - bool ShowMessages; + CProgressDialog *ProgressDialog; #ifndef _SFX UInt64 NumFolders; UInt64 NumFiles; bool NeedAddFile; #endif - HWND ParentWindow; - INT_PTR StartProgressDialog(const UString &title) - { - return ProgressDialog.Create(title, ParentWindow); - } UInt32 NumArchiveErrors; + bool ThereAreMessageErrors; NExtract::NOverwriteMode::EEnum OverwriteMode; #ifndef _NO_CRYPTO @@ -138,13 +126,13 @@ public: PasswordIsDefined(false), PasswordWasAsked(false), #endif - OverwriteMode(NExtract::NOverwriteMode::kAskBefore), - ParentWindow(0), - ShowMessages(true) + OverwriteMode(NExtract::NOverwriteMode::kAskBefore) {} ~CExtractCallbackImp(); void Init(); + + bool IsOK() const { return NumArchiveErrors == 0 && !ThereAreMessageErrors; } }; #endif diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp index e4bcc998..033e266d 100755 --- a/CPP/7zip/UI/FileManager/FM.cpp +++ b/CPP/7zip/UI/FileManager/FM.cpp @@ -6,7 +6,11 @@ #include "Windows/Error.h" #include "Windows/MemoryLock.h" +#include "Windows/NtCheck.h" + +#ifndef UNDER_CE #include "Windows/Security.h" +#endif #include "../GUI/ExtractRes.h" @@ -29,13 +33,21 @@ using namespace NFind; #define MENU_HEIGHT 26 -#ifndef _UNICODE -bool g_IsNT = false; -#endif HINSTANCE g_hInstance; HWND g_HWND; bool g_OpenArchive = false; static UString g_MainPath; +static bool g_Maximized = false; + +#ifndef UNDER_CE +DWORD g_ComCtl32Version; +#endif + +bool g_LVN_ITEMACTIVATE_Support = true; +// LVN_ITEMACTIVATE replaces both NM_DBLCLK & NM_RETURN +// Windows 2000 +// NT/98 + IE 3 (g_ComCtl32Version >= 4.70) + const int kNumDefaultPanels = 1; @@ -45,21 +57,6 @@ int kPanelSizeMin = 120; // bool OnMenuCommand(HWND hWnd, int id); -static UString GetProgramPath() -{ - UString s; - NDLL::MyGetModuleFileName(g_hInstance, s); - return s; -} - -UString GetProgramFolderPrefix() -{ - UString path = GetProgramPath(); - int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); - return path.Left(pos + 1); -} - - class CSplitterPos { int _ratio; // 10000 is max @@ -123,22 +120,18 @@ static int g_StartCaptureSplitterPos; CApp g_App; -void MoveSubWindows(HWND hWnd); -void OnSize(HWND hWnd); - LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); const wchar_t *kWindowClass = L"FM"; -#ifndef _UNICODE -static bool IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} +#ifdef UNDER_CE +#define WS_OVERLAPPEDWINDOW ( \ + WS_OVERLAPPED | \ + WS_CAPTION | \ + WS_SYSMENU | \ + WS_THICKFRAME | \ + WS_MINIMIZEBOX | \ + WS_MAXIMIZEBOX) #endif // FUNCTION: InitInstance(HANDLE, int) @@ -173,14 +166,21 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; - wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FAM)); + wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); // wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hCursor = ::LoadCursor(0, IDC_SIZEWE); // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH); wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); - wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU); + wc.lpszMenuName = + #ifdef UNDER_CE + 0 + #else + MAKEINTRESOURCEW(IDM_MENU) + #endif + ; + wc.lpszClassName = kWindowClass; MyRegisterClass(&wc); @@ -225,29 +225,37 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) if (!wnd.Create(kWindowClass, title, style, x, y, xSize, ySize, NULL, NULL, hInstance, NULL)) return FALSE; - g_HWND = (HWND)wnd; + if (nCmdShow == SW_SHOWNORMAL || + nCmdShow == SW_SHOW + #ifndef UNDER_CE + || nCmdShow == SW_SHOWDEFAULT + #endif + ) + { + if (maximized) + nCmdShow = SW_SHOWMAXIMIZED; + else + nCmdShow = SW_SHOWNORMAL; + } + + if (nCmdShow == SW_SHOWMAXIMIZED) + g_Maximized = true; + + #ifndef UNDER_CE WINDOWPLACEMENT placement; placement.length = sizeof(placement); if (wnd.GetPlacement(&placement)) { - if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW || - nCmdShow == SW_SHOWDEFAULT) - { - if (maximized) - placement.showCmd = SW_SHOWMAXIMIZED; - else - placement.showCmd = SW_SHOWNORMAL; - } - else - placement.showCmd = nCmdShow; if (windowPosIsRead) placement.rcNormalPosition = rect; + placement.showCmd = nCmdShow; wnd.SetPlacement(&placement); - // window.Show(nCmdShow); } else + #endif wnd.Show(nCmdShow); + return TRUE; } @@ -277,22 +285,23 @@ static void GetCommands(const UString &aCommandLine, UString &aCommands) } */ -DWORD GetDllVersion(LPCTSTR lpszDllName) +#ifndef UNDER_CE +static DWORD GetDllVersion(LPCTSTR lpszDllName) { HINSTANCE hinstDll; DWORD dwVersion = 0; hinstDll = LoadLibrary(lpszDllName); - if(hinstDll) + if (hinstDll) { DLLGETVERSIONPROC pDllGetVersion; - pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion"); + pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion"); /*Because some DLLs might not implement this function, you must test for it explicitly. Depending on the particular DLL, the lack of a DllGetVersion function can be a useful indicator of the version. */ - if(pDllGetVersion) + if (pDllGetVersion) { DLLVERSIONINFO dvi; HRESULT hr; @@ -302,7 +311,7 @@ DWORD GetDllVersion(LPCTSTR lpszDllName) hr = (*pDllGetVersion)(&dvi); - if(SUCCEEDED(hr)) + if (SUCCEEDED(hr)) { dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion); } @@ -311,8 +320,7 @@ DWORD GetDllVersion(LPCTSTR lpszDllName) } return dwVersion; } - -DWORD g_ComCtl32Version; +#endif /* #ifndef _WIN64 @@ -354,6 +362,7 @@ bool IsLargePageSupported() #endif } +#ifndef UNDER_CE static void SetMemoryLock() { if (!IsLargePageSupported()) @@ -364,6 +373,7 @@ static void SetMemoryLock() if (ReadLockMemoryEnable()) NSecurity::EnableLockMemoryPrivilege(); } +#endif /* static const int kNumSwitches = 1; @@ -378,34 +388,52 @@ enum Enum static const CSwitchForm kSwitchForms[kNumSwitches] = { - { L"SOA", NSwitchType::kSimple, false }, + { L"SOA", NSwitchType::kSimple, false }, }; */ // int APIENTRY WinMain2(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */); -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int nCmdShow) -{ - #ifndef _UNICODE - g_IsNT = IsItWindowsNT(); - #endif +#define NT_CHECK_FAIL_ACTION MessageBoxW(0, L"Unsupported Windows version", L"7-zip", MB_ICONERROR); return 1; +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, + #ifdef UNDER_CE + LPWSTR + #else + LPSTR + #endif + /* lpCmdLine */, int nCmdShow) +{ #ifdef _WIN32 + + NT_CHECK SetLargePageSize(); + #endif InitCommonControls(); + #ifndef UNDER_CE g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll")); + g_LVN_ITEMACTIVATE_Support = (g_ComCtl32Version >= MAKELONG(71, 4)); + #endif // OleInitialize is required for drag and drop. + #ifndef UNDER_CE OleInitialize(NULL); + #endif // Maybe needs CoInitializeEx also ? // NCOM::CComInitializer comInitializer; - UString programString, commandsString; + UString commandsString; // MessageBoxW(0, GetCommandLineW(), L"", 0); + + #ifdef UNDER_CE + commandsString = GetCommandLineW(); + #else + UString programString; SplitStringToTwoStrings(GetCommandLineW(), programString, commandsString); + #endif commandsString.Trim(); UString paramString, tailString; @@ -427,7 +455,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* { parser.ParseStrings(kSwitchForms, commandStrings); const UStringVector &nonSwitchStrings = parser.NonSwitchStrings; - if(nonSwitchStrings.Size() > 1) + if (nonSwitchStrings.Size() > 1) { g_MainPath = nonSwitchStrings[1]; // g_OpenArchive = parser[NKey::kOpenArachive].ThereIs; @@ -443,14 +471,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* */ + #ifndef UNDER_CE SetMemoryLock(); + #endif MSG msg; if (!InitInstance (hInstance, nCmdShow)) return FALSE; - MyLoadMenu(g_HWND); - #ifndef _UNICODE if (g_IsNT) { @@ -481,40 +509,39 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* } g_HWND = 0; + #ifndef UNDER_CE OleUninitialize(); + #endif return (int)msg.wParam; } static void SaveWindowInfo(HWND aWnd) { - /* + #ifdef UNDER_CE RECT rect; if (!::GetWindowRect(aWnd, &rect)) return; - */ + SaveWindowSize(rect, g_Maximized); + #else WINDOWPLACEMENT placement; placement.length = sizeof(placement); if (!::GetWindowPlacement(aWnd, &placement)) return; - SaveWindowSize(placement.rcNormalPosition, - BOOLToBool(::IsZoomed(aWnd))); - SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel, - g_Splitter.GetPos()); + SaveWindowSize(placement.rcNormalPosition, BOOLToBool(::IsZoomed(aWnd))); + #endif + SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel, g_Splitter.GetPos()); } -void ExecuteCommand(UINT commandID) +static void ExecuteCommand(UINT commandID) { + CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]); + CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]); + switch (commandID) { - case kAddCommand: - g_App.AddToArchive(); - break; - case kExtractCommand: - g_App.ExtractArchives(); - break; - case kTestCommand: - g_App.TestArchives(); - break; + case kAddCommand: g_App.AddToArchive(); break; + case kExtractCommand: g_App.ExtractArchives(); break; + case kTestCommand: g_App.TestArchives(); break; } } @@ -554,7 +581,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_CREATE: { - + g_HWND = hWnd; /* INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); @@ -679,7 +706,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos + (short)LOWORD(lParam) - g_StartCaptureMousePos); - MoveSubWindows(hWnd); + g_App.MoveSubWindows(); } break; } @@ -693,8 +720,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) g_Splitter.SetPos(hWnd, g_SplitterPos ); g_CanChangeSplitter = true; } + + g_Maximized = (wParam == SIZE_MAXIMIZED) || (wParam == SIZE_MAXSHOW); - OnSize(hWnd); + g_App.MoveSubWindows(); /* int xSize = LOWORD(lParam); int ySize = HIWORD(lParam); @@ -729,7 +758,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) */ /* case kLangWasChangedMessage: - MyLoadMenu(g_HWND); + MyLoadMenu(); return 0; */ @@ -749,71 +778,71 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return 0 ; } */ - } - #ifndef _UNICODE - if (g_IsNT) - return DefWindowProcW(hWnd, message, wParam, lParam); - else - #endif - return DefWindowProc(hWnd, message, wParam, lParam); - -} - -void OnSize(HWND hWnd) -{ - /* - if (g_App._rebar) - { - RECT rect; - ::GetClientRect(hWnd, &rect); - int xSize = rect.right; - int ySize = rect.bottom; - // rect.bottom = 0; - // g_App._rebar.SizeToRect(&rect); - // g_App._rebar.Move(0, 0, xSize, ySize); } - */ - MoveSubWindows(hWnd); + #ifndef _UNICODE + if (g_IsNT) + return DefWindowProcW(hWnd, message, wParam, lParam); + else + #endif + return DefWindowProc(hWnd, message, wParam, lParam); + } -int Window_GetRealHeight(NWindows::CWindow &w) +static int Window_GetRealHeight(NWindows::CWindow &w) { RECT rect; - WINDOWPLACEMENT placement; w.GetWindowRect(&rect); int res = rect.bottom - rect.top; + #ifndef UNDER_CE + WINDOWPLACEMENT placement; if (w.GetPlacement(&placement)) res += placement.rcNormalPosition.top; + #endif return res; } -void MoveSubWindows(HWND hWnd) +void CApp::MoveSubWindows() { + HWND hWnd = _window; RECT rect; + if (hWnd == 0) + return; ::GetClientRect(hWnd, &rect); int xSize = rect.right; + if (xSize == 0) + return; int headerSize = 0; - if (g_App._rebar) - headerSize = Window_GetRealHeight(g_App._rebar); + #ifdef UNDER_CE + _commandBar.AutoSize(); + { + _commandBar.Show(true); // maybe we need it for + headerSize += _commandBar.Height(); + } + #endif + if (_toolBar) + { + _toolBar.AutoSize(); + #ifdef UNDER_CE + int h2 = Window_GetRealHeight(_toolBar); + _toolBar.Move(0, headerSize, xSize, h2); + #endif + headerSize += Window_GetRealHeight(_toolBar); + } int ySize = MyMax((int)(rect.bottom - headerSize), 0); - // It's for such case: Minimize / Close: - if (xSize == 0 && ySize == 0) - return; - - if (g_App.NumPanels > 1) + if (NumPanels > 1) { - g_App.Panels[0].Move(0, headerSize, g_Splitter.GetPos(), ySize); + Panels[0].Move(0, headerSize, g_Splitter.GetPos(), ySize); int xWidth1 = g_Splitter.GetPos() + kSplitterWidth; - g_App.Panels[1].Move(xWidth1, headerSize, xSize - xWidth1, ySize); + Panels[1].Move(xWidth1, headerSize, xSize - xWidth1, ySize); } else { /* - int otherPanel = 1 - g_App.LastFocusedPanel; - if (g_App.PanelsCreated[otherPanel]) - g_App.Panels[otherPanel].Move(0, headerSize, 0, ySize); + int otherPanel = 1 - LastFocusedPanel; + if (PanelsCreated[otherPanel]) + Panels[otherPanel].Move(0, headerSize, 0, ySize); */ - g_App.Panels[g_App.LastFocusedPanel].Move(0, headerSize, xSize, ySize); + Panels[LastFocusedPanel].Move(0, headerSize, xSize, ySize); } } diff --git a/CPP/7zip/UI/FileManager/FM.dsp b/CPP/7zip/UI/FileManager/FM.dsp index 2c3ab6c8..615043b5 100755 --- a/CPP/7zip/UI/FileManager/FM.dsp +++ b/CPP/7zip/UI/FileManager/FM.dsp @@ -404,25 +404,21 @@ SOURCE=.\PanelSplitFile.cpp # Begin Group "Options" # PROP Default_Filter "" -# Begin Group "Settings" - -# PROP Default_Filter "" # Begin Source File -SOURCE=.\SettingsPage.cpp +SOURCE=.\EditPage.cpp # End Source File # Begin Source File -SOURCE=.\SettingsPage.h +SOURCE=.\EditPage.h # End Source File -# End Group # Begin Source File -SOURCE=.\EditPage.cpp +SOURCE=.\FoldersPage.cpp # End Source File # Begin Source File -SOURCE=.\EditPage.h +SOURCE=.\FoldersPage.h # End Source File # Begin Source File @@ -434,48 +430,41 @@ SOURCE=.\LangPage.h # End Source File # Begin Source File -SOURCE=.\PluginsPage.cpp +SOURCE=.\MenuPage.cpp # End Source File # Begin Source File -SOURCE=.\PluginsPage.h +SOURCE=.\MenuPage.h # End Source File # Begin Source File -SOURCE=.\SystemPage.cpp +SOURCE=.\OptionsDialog.cpp # End Source File # Begin Source File -SOURCE=.\SystemPage.h +SOURCE=.\PluginsPage.cpp # End Source File -# End Group -# Begin Group "Password" - -# PROP Default_Filter "" # Begin Source File -SOURCE=.\PasswordDialog.cpp +SOURCE=.\PluginsPage.h # End Source File # Begin Source File -SOURCE=.\PasswordDialog.h +SOURCE=.\SettingsPage.cpp # End Source File -# End Group -# Begin Group "Progress" +# Begin Source File -# PROP Default_Filter "" +SOURCE=.\SettingsPage.h +# End Source File # Begin Source File -SOURCE=.\ProgressDialog2.cpp +SOURCE=.\SystemPage.cpp # End Source File # Begin Source File -SOURCE=.\ProgressDialog2.h +SOURCE=.\SystemPage.h # End Source File # End Group -# Begin Group "About" - -# PROP Default_Filter "" # Begin Source File SOURCE=.\AboutDialog.cpp @@ -484,19 +473,14 @@ SOURCE=.\AboutDialog.cpp SOURCE=.\AboutDialog.h # End Source File -# End Group -# Begin Group "Split" - -# PROP Default_Filter "" # Begin Source File -SOURCE=.\SplitDialog.cpp +SOURCE=.\BrowseDialog.cpp # End Source File # Begin Source File -SOURCE=.\SplitDialog.h +SOURCE=.\BrowseDialog.h # End Source File -# End Group # Begin Source File SOURCE=.\ComboDialog.cpp @@ -515,6 +499,10 @@ SOURCE=CopyDialog.h # End Source File # Begin Source File +SOURCE=.\DialogSize.h +# End Source File +# Begin Source File + SOURCE=.\ListViewDialog.cpp # End Source File # Begin Source File @@ -537,6 +525,30 @@ SOURCE=OverwriteDialog.cpp SOURCE=OverwriteDialog.h # End Source File +# Begin Source File + +SOURCE=.\PasswordDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\PasswordDialog.h +# End Source File +# Begin Source File + +SOURCE=.\ProgressDialog2.cpp +# End Source File +# Begin Source File + +SOURCE=.\ProgressDialog2.h +# End Source File +# Begin Source File + +SOURCE=.\SplitDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\SplitDialog.h +# End Source File # End Group # Begin Group "FM Common" @@ -855,6 +867,10 @@ SOURCE=..\..\..\Windows\FileIO.h # End Source File # Begin Source File +SOURCE=..\..\..\Windows\FileMapping.h +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\FileName.cpp # End Source File # Begin Source File @@ -907,6 +923,10 @@ SOURCE=..\..\..\Windows\Net.h # End Source File # Begin Source File +SOURCE=..\..\..\Windows\Process.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\Process.h # End Source File # Begin Source File @@ -1190,10 +1210,6 @@ SOURCE=..\Common\ExtractMode.h # End Source File # Begin Source File -SOURCE=..\Common\HandlerLoader.h -# End Source File -# Begin Source File - SOURCE=..\Common\IFileExtractCallback.h # End Source File # Begin Source File @@ -1333,6 +1349,26 @@ SOURCE=..\Agent\UpdateCallbackAgent.cpp SOURCE=..\Agent\UpdateCallbackAgent.h # End Source File # End Group +# Begin Group "Explorer" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\Explorer\ContextMenu.cpp +# End Source File +# Begin Source File + +SOURCE=..\Explorer\ContextMenu.h +# End Source File +# Begin Source File + +SOURCE=..\Explorer\RegistryContextMenu.cpp +# End Source File +# Begin Source File + +SOURCE=..\Explorer\RegistryContextMenu.h +# End Source File +# End Group # End Group # Begin Group "Compress" @@ -1436,10 +1472,6 @@ SOURCE=.\OpenCallback.h # End Source File # Begin Source File -SOURCE=.\OptionsDialog.cpp -# End Source File -# Begin Source File - SOURCE=.\PluginInterface.h # End Source File # Begin Source File diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp index 5951fc09..1b3837cf 100755 --- a/CPP/7zip/UI/FileManager/FSFolder.cpp +++ b/CPP/7zip/UI/FileManager/FSFolder.cpp @@ -14,7 +14,11 @@ #include "FSDrives.h" #include "FSFolder.h" + +#ifndef UNDER_CE #include "NetFolder.h" +#endif + #include "SysIconUtils.h" namespace NWindows { @@ -61,8 +65,8 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder) { DWORD lastError = GetLastError(); CFindFile findFile; - CFileInfoW fileInfo; - if (!findFile.FindFirst(_path + UString(L"*"), fileInfo)) + CFileInfoW fi; + if (!findFile.FindFirst(_path + UString(L"*"), fi)) return lastError; } return S_OK; @@ -73,13 +77,13 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, RINOK(progress->SetCompleted(NULL)); numFiles = numFolders = size = 0; CEnumeratorW enumerator(path + UString(WSTRING_PATH_SEPARATOR L"*")); - CFileInfoW fileInfo; - while (enumerator.Next(fileInfo)) + CFileInfoW fi; + while (enumerator.Next(fi)) { - if (fileInfo.IsDir()) + if (fi.IsDir()) { UInt64 subFolders, subFiles, subSize; - RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fileInfo.Name, subFolders, subFiles, subSize, progress)); + RINOK(GetFolderSize(path + UString(WCHAR_PATH_SEPARATOR) + fi.Name, subFolders, subFiles, subSize, progress)); numFolders += subFolders; numFolders++; numFiles += subFiles; @@ -88,7 +92,7 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, else { numFiles++; - size += fileInfo.Size; + size += fi.Size; } } return S_OK; @@ -98,21 +102,23 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path) { { CEnumeratorW enumerator(path + L"*"); - CDirItem fileInfo; - while (enumerator.Next(fileInfo)) + CDirItem fi; + while (enumerator.Next(fi)) { - fileInfo.CompressedSizeIsDefined = false; + #ifndef UNDER_CE + fi.CompressedSizeIsDefined = false; /* - if (!GetCompressedFileSize(_path + fileInfo.Name, - fileInfo.CompressedSize)) - fileInfo.CompressedSize = fileInfo.Size; + if (!GetCompressedFileSize(_path + fi.Name, + fi.CompressedSize)) + fi.CompressedSize = fi.Size; */ - if (fileInfo.IsDir()) + #endif + if (fi.IsDir()) { - // fileInfo.Size = GetFolderSize(_path + fileInfo.Name); - fileInfo.Size = 0; + // fi.Size = GetFolderSize(_path + fi.Name); + fi.Size = 0; } - dirItem.Files.Add(fileInfo); + dirItem.Files.Add(fi); } } if (!_flatMode) @@ -237,7 +243,8 @@ STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders) } */ -bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size) +#ifndef UNDER_CE +static bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size) { DWORD highPart; DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart); @@ -256,46 +263,49 @@ bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size) size = (UInt64(highPart) << 32) | lowPart; return true; } +#endif STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) { NCOM::CPropVariant prop; if (itemIndex >= (UInt32)_refs.Size()) return E_INVALIDARG; - CDirItem &fileInfo = *_refs[itemIndex]; + CDirItem &fi = *_refs[itemIndex]; switch(propID) { - case kpidIsDir: prop = fileInfo.IsDir(); break; - case kpidName: prop = fileInfo.Name; break; - case kpidSize: if (!fileInfo.IsDir()) prop = fileInfo.Size; break; + case kpidIsDir: prop = fi.IsDir(); break; + case kpidName: prop = fi.Name; break; + case kpidSize: if (!fi.IsDir()) prop = fi.Size; break; case kpidPackSize: - if (!fileInfo.CompressedSizeIsDefined) + #ifdef UNDER_CE + prop = fi.Size; + #else + if (!fi.CompressedSizeIsDefined) { - fileInfo.CompressedSizeIsDefined = true; - if (fileInfo.IsDir () || - !MyGetCompressedFileSizeW(_path + GetRelPath(fileInfo), fileInfo.CompressedSize)) - fileInfo.CompressedSize = fileInfo.Size; + fi.CompressedSizeIsDefined = true; + if (fi.IsDir () || + !MyGetCompressedFileSizeW(_path + GetRelPath(fi), fi.CompressedSize)) + fi.CompressedSize = fi.Size; } - prop = fileInfo.CompressedSize; + prop = fi.CompressedSize; + #endif break; - case kpidAttrib: prop = (UInt32)fileInfo.Attrib; break; - case kpidCTime: prop = fileInfo.CTime; break; - case kpidATime: prop = fileInfo.ATime; break; - case kpidMTime: prop = fileInfo.MTime; break; + case kpidAttrib: prop = (UInt32)fi.Attrib; break; + case kpidCTime: prop = fi.CTime; break; + case kpidATime: prop = fi.ATime; break; + case kpidMTime: prop = fi.MTime; break; case kpidComment: { LoadComments(); UString comment; - if (_comments.GetValue(GetRelPath(fileInfo), comment)) + if (_comments.GetValue(GetRelPath(fi), comment)) prop = comment; break; } case kpidPrefix: { if (_flatMode) - { - prop = GetPrefix(fileInfo); - } + prop = GetPrefix(fi); break; } } @@ -333,10 +343,10 @@ UString CFSFolder::GetRelPath(const CDirItem &item) const STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder) { *resultFolder = 0; - const CDirItem &fileInfo = *_refs[index]; - if (!fileInfo.IsDir()) + const CDirItem &fi = *_refs[index]; + if (!fi.IsDir()) return E_INVALIDARG; - return BindToFolderSpec(GetRelPath(fileInfo), resultFolder); + return BindToFolderSpec(GetRelPath(fi), resultFolder); } STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) @@ -362,15 +372,19 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) pos = parentPath.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos < 0) { - parentPath.Empty(); + #ifdef UNDER_CE + *resultFolder = 0; + #else CFSDrives *drivesFolderSpec = new CFSDrives; CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec; drivesFolderSpec->Init(); *resultFolder = drivesFolder.Detach(); + #endif return S_OK; } UString parentPathReduced = parentPath.Left(pos); parentPath = parentPath.Left(pos + 1); + #ifndef UNDER_CE pos = parentPathReduced.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos == 1) { @@ -382,6 +396,7 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) *resultFolder = netFolder.Detach(); return S_OK; } + #endif CFSFolder *parentFolderSpec = new CFSFolder; CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec; RINOK(parentFolderSpec->Init(parentPath, 0)); @@ -457,11 +472,11 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, int index = indices[i]; if (index >= _refs.Size()) return E_INVALIDARG; - const CDirItem &fileInfo = *_refs[index]; - if (fileInfo.IsDir()) + const CDirItem &fi = *_refs[index]; + if (fi.IsDir()) { UInt64 subFolders, subFiles, subSize; - RINOK(GetFolderSize(_path + GetRelPath(fileInfo), subFolders, subFiles, subSize, progress)); + RINOK(GetFolderSize(_path + GetRelPath(fi), subFolders, subFiles, subSize, progress)); numFolders += subFolders; numFolders++; numFiles += subFiles; @@ -470,7 +485,7 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, else { numFiles++; - size += fileInfo.Size; + size += fi.Size; } } return S_OK; @@ -478,8 +493,8 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress) { - const CDirItem &fileInfo = *_refs[index]; - if (fileInfo.IsDir()) + const CDirItem &fi = *_refs[index]; + if (fi.IsDir()) { /* CMyComPtr<IFolderFolder> subFolder; @@ -499,9 +514,9 @@ HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress) } */ UInt64 numFolders, numFiles; - return GetFolderSize(_path + GetRelPath(fileInfo), numFolders, numFiles, size, progress); + return GetFolderSize(_path + GetRelPath(fi), numFolders, numFiles, size, progress); } - size = fileInfo.Size; + size = fi.Size; return S_OK; } @@ -560,9 +575,9 @@ STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */) { - const CDirItem &fileInfo = *_refs[index]; - const UString fullPrefix = _path + GetPrefix(fileInfo); - if (!NDirectory::MyMoveFile(fullPrefix + fileInfo.Name, fullPrefix + newName)) + const CDirItem &fi = *_refs[index]; + const UString fullPrefix = _path + GetPrefix(fi); + if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + newName)) return GetLastError(); return S_OK; } @@ -572,10 +587,10 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress RINOK(progress->SetTotal(numItems)); for (UInt32 i = 0; i < numItems; i++) { - const CDirItem &fileInfo = *_refs[indices[i]]; - const UString fullPath = _path + GetRelPath(fileInfo); + const CDirItem &fi = *_refs[indices[i]]; + const UString fullPath = _path + GetRelPath(fi); bool result; - if (fileInfo.IsDir()) + if (fi.IsDir()) result = NDirectory::RemoveDirectoryWithSubItems(fullPath); else result = NDirectory::DeleteFileAlways(fullPath); @@ -592,14 +607,14 @@ STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID, { if (index >= (UInt32)_refs.Size()) return E_INVALIDARG; - CDirItem &fileInfo = *_refs[index]; - if (fileInfo.Parent->Parent != 0) + CDirItem &fi = *_refs[index]; + if (fi.Parent->Parent != 0) return E_NOTIMPL; switch(propID) { case kpidComment: { - UString filename = fileInfo.Name; + UString filename = fi.Name; filename.Trim(); if (value->vt == VT_EMPTY) _comments.DeletePair(filename); @@ -630,10 +645,10 @@ STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) { if (index >= (UInt32)_refs.Size()) return E_INVALIDARG; - const CDirItem &fileInfo = *_refs[index]; + const CDirItem &fi = *_refs[index]; *iconIndex = 0; int iconIndexTemp; - if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attrib, iconIndexTemp) != 0) + if (GetRealIconIndex(_path + GetRelPath(fi), fi.Attrib, iconIndexTemp) != 0) { *iconIndex = iconIndexTemp; return S_OK; diff --git a/CPP/7zip/UI/FileManager/FSFolder.h b/CPP/7zip/UI/FileManager/FSFolder.h index 95f40bb3..42e33242 100755 --- a/CPP/7zip/UI/FileManager/FSFolder.h +++ b/CPP/7zip/UI/FileManager/FSFolder.h @@ -3,7 +3,6 @@ #ifndef __FSFOLDER_H #define __FSFOLDER_H -#include "Common/MyString.h" #include "Common/MyCom.h" #include "Windows/FileFind.h" @@ -17,8 +16,10 @@ class CFSFolder; struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW { + #ifndef UNDER_CE bool CompressedSizeIsDefined; UInt64 CompressedSize; + #endif }; struct CDirItem; @@ -98,6 +99,9 @@ private: void AddRefs(CDirItem &dirItem); public: HRESULT Init(const UString &path, IFolderFolder *parentFolder); + #ifdef UNDER_CE + HRESULT InitToRoot() { return Init(L"\\", NULL); } + #endif CFSFolder() : _flatMode(false) {} diff --git a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp index 9711616c..b6ffd574 100755 --- a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp +++ b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp @@ -6,8 +6,9 @@ #include "Common/StringConvert.h" -#include "Windows/FileDir.h" +#include "Windows/DLL.h" #include "Windows/Error.h" +#include "Windows/FileDir.h" #include "../../Common/FilePathAutoRename.h" @@ -41,6 +42,29 @@ struct CProgressInfo IProgress *Progress; }; +#ifndef PROGRESS_CONTINUE + +#define PROGRESS_CONTINUE 0 +#define PROGRESS_CANCEL 1 + +#define COPY_FILE_FAIL_IF_EXISTS 0x00000001 + +typedef +DWORD +(WINAPI* LPPROGRESS_ROUTINE)( + LARGE_INTEGER TotalFileSize, + LARGE_INTEGER TotalBytesTransferred, + LARGE_INTEGER StreamSize, + LARGE_INTEGER StreamBytesTransferred, + DWORD dwStreamNumber, + DWORD dwCallbackReason, + HANDLE hSourceFile, + HANDLE hDestinationFile, + LPVOID lpData + ); + +#endif + static DWORD CALLBACK CopyProgressRoutine( LARGE_INTEGER /* TotalFileSize */, // file size LARGE_INTEGER TotalBytesTransferred, // bytes transferred @@ -94,11 +118,17 @@ static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres if (g_IsNT) #endif { + const wchar_t *k_DllName = + #ifdef UNDER_CE + L"coredll.dll" + #else + L"kernel32.dll" + #endif + ; CopyFileExPointerW copyFunctionW = (CopyFileExPointerW) - ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"), - "CopyFileExW"); + My_GetProcAddress(::GetModuleHandleW(k_DllName), "CopyFileExW"); if (copyFunctionW == 0) - return false; + return BOOLToBool(::CopyFileW(existingFile, newFile, TRUE)); if (copyFunctionW(existingFile, newFile, CopyProgressRoutine, &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS)) return true; @@ -141,6 +171,7 @@ typedef BOOL (WINAPI * MoveFileWithProgressPointer)( static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize) { + #ifndef UNDER_CE // if (IsItWindows2000orHigher()) // { CProgressInfo progressInfo; @@ -148,7 +179,7 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres progressInfo.StartPos = completedSize; MoveFileWithProgressPointer moveFunction = (MoveFileWithProgressPointer) - ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), + My_GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "MoveFileWithProgressW"); if (moveFunction != 0) { @@ -172,6 +203,7 @@ static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progres } // } // else + #endif return NDirectory::MyMoveFile(existingFile, newFile); } diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp index 992fbd8c..310b890c 100755 --- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp +++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp @@ -30,9 +30,12 @@ struct CThreadArchiveOpen void Process() { - OpenCallbackSpec->ProgressDialog.WaitCreating(); - Result = FolderManager->OpenFolderFile(InStream, Path, &Folder, OpenCallback); - OpenCallbackSpec->ProgressDialog.MyClose(); + try + { + CProgressCloser closer(OpenCallbackSpec->ProgressDialog); + Result = FolderManager->OpenFolderFile(InStream, Path, &Folder, OpenCallback); + } + catch(...) { Result = E_FAIL; } } static THREAD_FUNC_DECL MyThreadFunction(void *param) @@ -42,14 +45,15 @@ struct CThreadArchiveOpen } }; -static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, - const UString &pluginName) +/* +static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, const UString &pluginName) { for (int i = 0; i < plugins.Size(); i++) if (plugins[i].Name.CompareNoCase(pluginName) == 0) return i; return -1; } +*/ HRESULT OpenFileFolderPlugin( IInStream *inStream, @@ -77,6 +81,7 @@ HRESULT OpenFileFolderPlugin( NFile::NName::SplitNameToPureNameAndExtension(fileName, pureName, dot, extension); + /* if (!extension.IsEmpty()) { CExtInfo extInfo; @@ -94,6 +99,7 @@ HRESULT OpenFileFolderPlugin( } } } + */ for (int i = 0; i < plugins.Size(); i++) { @@ -127,11 +133,13 @@ HRESULT OpenFileFolderPlugin( t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow; t.OpenCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); t.OpenCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" "); + t.OpenCallbackSpec->ProgressDialog.WaitMode = true; - NWindows::CThread thread; - if (thread.Create(CThreadArchiveOpen::MyThreadFunction, &t) != S_OK) - throw 271824; - t.OpenCallbackSpec->StartProgressDialog(progressTitle); + { + NWindows::CThread thread; + RINOK(thread.Create(CThreadArchiveOpen::MyThreadFunction, &t)); + t.OpenCallbackSpec->StartProgressDialog(progressTitle, thread); + } if (t.Result == E_ABORT) return t.Result; diff --git a/CPP/7zip/UI/FileManager/FilePlugins.cpp b/CPP/7zip/UI/FileManager/FilePlugins.cpp index 173eeffa..22993383 100755 --- a/CPP/7zip/UI/FileManager/FilePlugins.cpp +++ b/CPP/7zip/UI/FileManager/FilePlugins.cpp @@ -2,14 +2,13 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" #include "Common/MyCom.h" -#include "IFolder.h" +#include "../Agent/Agent.h" + #include "FilePlugins.h" -#include "StringUtils.h" #include "PluginLoader.h" -#include "../Agent/Agent.h" +#include "StringUtils.h" using namespace NRegistryAssociations; @@ -31,9 +30,12 @@ int CExtDatabase::FindPlugin(const UString &plugin) void CExtDatabase::Read() { + /* CObjectVector<CExtInfo> extItems; ReadInternalAssociations(extItems); + */ ReadFileFolderPluginInfoList(Plugins); + /* for (int i = 0; i < extItems.Size(); i++) { const CExtInfo &extInfo = extItems[i]; @@ -48,6 +50,7 @@ void CExtDatabase::Read() } ExtBigItems.Add(extInfoBig); } + */ for (int pluginIndex = 0; pluginIndex < Plugins.Size(); pluginIndex++) { const CPluginInfo &pluginInfo = Plugins[pluginIndex]; @@ -69,6 +72,10 @@ void CExtDatabase::Read() for (int i = 0; i < exts.Size(); i++) { const UString &ext = exts[i]; + #ifdef UNDER_CE + if (ext == L"cab") + continue; + #endif int index = FindExtInfoBig(ext); if (index < 0) { @@ -91,6 +98,7 @@ void CExtDatabase::Read() void CExtDatabase::Save() { + /* CObjectVector<CExtInfo> extItems; for (int i = 0; i < ExtBigItems.Size(); i++) { @@ -107,6 +115,5 @@ void CExtDatabase::Save() extItems.Add(extInfo); } WriteInternalAssociations(extItems); + */ } - - diff --git a/CPP/7zip/UI/Explorer/FoldersPage.cpp b/CPP/7zip/UI/FileManager/FoldersPage.cpp index 67d5e867..068b9d47 100755 --- a/CPP/7zip/UI/Explorer/FoldersPage.cpp +++ b/CPP/7zip/UI/FileManager/FoldersPage.cpp @@ -5,13 +5,7 @@ #include "FoldersPageRes.h" #include "FoldersPage.h" -#include "Common/StringConvert.h" -#include "Windows/Defs.h" -#include "Windows/Shell.h" -#include "Windows/ResourceString.h" - -#include "../Common/ZipRegistry.h" - +#include "../FileManager/BrowseDialog.h" #include "../FileManager/HelpUtils.h" #include "../FileManager/LangUtils.h" @@ -38,7 +32,7 @@ static const int kNumWorkModeButtons = sizeof(kWorkModeButtons) / sizeof(kWorkMo bool CFoldersPage::OnInit() { LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); - ReadWorkDirInfo(m_WorkDirInfo); + m_WorkDirInfo.Load(); CheckButton(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, m_WorkDirInfo.ForRemovableOnly); @@ -138,14 +132,14 @@ void CFoldersPage::OnFoldersWorkButtonPath() m_WorkPath.GetText(currentPath); UString title = LangString(IDS_FOLDERS_SET_WORK_PATH_TITLE, 0x01000281); UString resultPath; - if (NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath)) + if (MyBrowseForFolder(HWND(*this), title, currentPath, resultPath)) m_WorkPath.SetText(resultPath); } LONG CFoldersPage::OnApply() { GetWorkDir(m_WorkDirInfo); - SaveWorkDirInfo(m_WorkDirInfo); + m_WorkDirInfo.Save(); return PSNRET_NOERROR; } diff --git a/CPP/7zip/UI/Explorer/FoldersPage.h b/CPP/7zip/UI/FileManager/FoldersPage.h index be8a362f..d8456a40 100755 --- a/CPP/7zip/UI/Explorer/FoldersPage.h +++ b/CPP/7zip/UI/FileManager/FoldersPage.h @@ -1,7 +1,7 @@ // FoldersPage.h -#ifndef __FOLDERSPAGE_H -#define __FOLDERSPAGE_H +#ifndef __FOLDERS_PAGE_H +#define __FOLDERS_PAGE_H #include "Windows/Control/PropertyPage.h" @@ -19,7 +19,6 @@ class CFoldersPage : public NWindows::NControl::CPropertyPage int GetWorkMode() const; void GetWorkDir(NWorkDir::CInfo &workDirInfo); // bool WasChanged(); -public: virtual bool OnInit(); virtual bool OnCommand(int code, int itemID, LPARAM lParam); virtual void OnNotifyHelp(); diff --git a/CPP/7zip/UI/FileManager/FoldersPage.rc b/CPP/7zip/UI/FileManager/FoldersPage.rc new file mode 100755 index 00000000..fb48ee6e --- /dev/null +++ b/CPP/7zip/UI/FileManager/FoldersPage.rc @@ -0,0 +1,23 @@ +#include "FoldersPageRes.h" +#include "../../GuiCommon.rc" + +#define xc 196 +#define yc 100 + +IDD_FOLDERS MY_PAGE +#include "FoldersPage2.rc" + +#ifdef UNDER_CE + +#undef xc +#define xc SMALL_PAGE_SIZE_X + +IDD_FOLDERS_2 MY_PAGE +#include "FoldersPage2.rc" + +#endif + +STRINGTABLE +BEGIN + IDS_FOLDERS_SET_WORK_PATH_TITLE "Specify a location for temporary archive files." +END diff --git a/CPP/7zip/UI/FileManager/FoldersPage2.rc b/CPP/7zip/UI/FileManager/FoldersPage2.rc new file mode 100755 index 00000000..0b73ec9f --- /dev/null +++ b/CPP/7zip/UI/FileManager/FoldersPage2.rc @@ -0,0 +1,16 @@ +CAPTION "Folders" +BEGIN + // GROUPBOX "&Working folder", IDC_FOLDERS_STATIC_WORKING_FOLDER, m, m, xc, 98 + + LTEXT "&Working folder", IDC_FOLDERS_STATIC_WORKING_FOLDER, m, m, xc, 8 + CONTROL "&System temp folder", IDC_FOLDERS_WORK_RADIO_SYSTEM, "Button", BS_AUTORADIOBUTTON | WS_GROUP, + m, 20, xc, 10 + CONTROL "&Current", IDC_FOLDERS_WORK_RADIO_CURRENT, "Button", BS_AUTORADIOBUTTON, + m, 34, xc, 10 + CONTROL "Specified:", IDC_FOLDERS_WORK_RADIO_SPECIFIED, "Button", BS_AUTORADIOBUTTON, + m, 48, xc, 10 + EDITTEXT IDC_FOLDERS_WORK_EDIT_PATH, m + m, 62, xc - m - m - bxsDots, 14, ES_AUTOHSCROLL + PUSHBUTTON "...", IDC_FOLDERS_WORK_BUTTON_PATH, xs - m - bxsDots, 61, bxsDots, bys + CONTROL "Use for removable drives only", IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, MY_CHECKBOX, + m, 86, xc, 10 +END diff --git a/CPP/7zip/UI/Explorer/FoldersPageRes.h b/CPP/7zip/UI/FileManager/FoldersPageRes.h index 3052409b..896f197a 100755 --- a/CPP/7zip/UI/Explorer/FoldersPageRes.h +++ b/CPP/7zip/UI/FileManager/FoldersPageRes.h @@ -1,6 +1,7 @@ -#define IDD_FOLDERS 900 +#define IDD_FOLDERS 571 +#define IDD_FOLDERS_2 671 -#define IDS_FOLDERS_SET_WORK_PATH_TITLE 103 +#define IDS_FOLDERS_SET_WORK_PATH_TITLE 877 #define IDC_FOLDERS_STATIC_WORKING_FOLDER 1001 diff --git a/CPP/7zip/UI/FileManager/HelpUtils.cpp b/CPP/7zip/UI/FileManager/HelpUtils.cpp index c2bf49a5..a1c17399 100755 --- a/CPP/7zip/UI/FileManager/HelpUtils.cpp +++ b/CPP/7zip/UI/FileManager/HelpUtils.cpp @@ -10,6 +10,11 @@ static LPCWSTR kHelpFileName = L"7-zip.chm::/"; +#ifdef UNDER_CE +void ShowHelpWindow(HWND, LPCWSTR) +{ +} +#else void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile) { UString path; @@ -19,5 +24,4 @@ void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile) path += topicFile; HtmlHelp(hwnd, GetSystemString(path), HH_DISPLAY_TOPIC, NULL); } - - +#endif diff --git a/CPP/7zip/UI/FileManager/LangPage.cpp b/CPP/7zip/UI/FileManager/LangPage.cpp index 264872f6..85829368 100755 --- a/CPP/7zip/UI/FileManager/LangPage.cpp +++ b/CPP/7zip/UI/FileManager/LangPage.cpp @@ -1,16 +1,16 @@ // LangPage.cpp #include "StdAfx.h" -#include "LangPageRes.h" -#include "LangPage.h" #include "Common/StringConvert.h" #include "Windows/ResourceString.h" -#include "RegistryUtils.h" #include "HelpUtils.h" +#include "LangPage.h" +#include "LangPageRes.h" #include "LangUtils.h" +#include "RegistryUtils.h" static CIDLangPair kIDLangPairs[] = { @@ -19,17 +19,19 @@ static CIDLangPair kIDLangPairs[] = static LPCWSTR kLangTopic = L"fm/options.htm#language"; +static UString NativeLangString(const UString &s) +{ + return L" (" + s + L')'; +} + bool CLangPage::OnInit() { - _langWasChanged = false; LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); _langCombo.Attach(GetItem(IDC_LANG_COMBO_LANG)); - UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH); - s += L" ("; - s += NWindows::MyLoadStringW(IDS_LANG_NATIVE); - s += L")"; + UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH) + + NativeLangString(NWindows::MyLoadStringW(IDS_LANG_NATIVE)); int index = (int)_langCombo.AddString(s); _langCombo.SetItemData(index, _paths.Size()); _paths.Add(L"-"); @@ -40,21 +42,12 @@ bool CLangPage::OnInit() for (int i = 0; i < langs.Size(); i++) { const CLangEx &lang = langs[i]; - UString name; - UString englishName, nationalName; - if (lang.Lang.GetMessage(0x00000000, englishName)) - name = englishName; - else + UString name, nationalName; + if (!lang.Lang.GetMessage(0, name)) name = lang.ShortName; - if (lang.Lang.GetMessage(0x00000001, nationalName)) - { - if (!nationalName.IsEmpty()) - { - name += L" ("; - name += nationalName; - name += L")"; - } - } + if (lang.Lang.GetMessage(1, nationalName) && !nationalName.IsEmpty()) + name += NativeLangString(nationalName); + index = (int)_langCombo.AddString(name); _langCombo.SetItemData(index, _paths.Size()); _paths.Add(lang.ShortName); @@ -70,13 +63,13 @@ LONG CLangPage::OnApply() int pathIndex = (int)_langCombo.GetItemData(selectedIndex); SaveRegLang(_paths[pathIndex]); ReloadLang(); - _langWasChanged = true; + LangWasChanged = true; return PSNRET_NOERROR; } void CLangPage::OnNotifyHelp() { - ShowHelpWindow(NULL, kLangTopic); // change it + ShowHelpWindow(NULL, kLangTopic); } bool CLangPage::OnCommand(int code, int itemID, LPARAM param) diff --git a/CPP/7zip/UI/FileManager/LangPage.h b/CPP/7zip/UI/FileManager/LangPage.h index 64825b8e..e58f5098 100755 --- a/CPP/7zip/UI/FileManager/LangPage.h +++ b/CPP/7zip/UI/FileManager/LangPage.h @@ -1,7 +1,7 @@ // LangPage.h -#ifndef __LANGPAGE_H -#define __LANGPAGE_H +#ifndef __LANG_PAGE_H +#define __LANG_PAGE_H #include "Windows/Control/PropertyPage.h" #include "Windows/Control/ComboBox.h" @@ -11,7 +11,8 @@ class CLangPage: public NWindows::NControl::CPropertyPage NWindows::NControl::CComboBox _langCombo; UStringVector _paths; public: - bool _langWasChanged; + bool LangWasChanged; + CLangPage() { LangWasChanged = false; } virtual bool OnInit(); virtual void OnNotifyHelp(); virtual bool OnCommand(int code, int itemID, LPARAM param); diff --git a/CPP/7zip/UI/FileManager/LangPage.rc b/CPP/7zip/UI/FileManager/LangPage.rc index bd4d83d8..327b33e2 100755 --- a/CPP/7zip/UI/FileManager/LangPage.rc +++ b/CPP/7zip/UI/FileManager/LangPage.rc @@ -1,18 +1,34 @@ #include "LangPageRes.h" #include "../../GuiCommon.rc" -#define xSize2 196 -#define ySize2 140 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 148 +#define yc 100 -IDD_LANG DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE +IDD_LANG MY_PAGE CAPTION "Language" -MY_FONT -BEGIN - LTEXT "Language:", IDC_LANG_STATIC_LANG, marg, marg, xSize2, 8 - COMBOBOX IDC_LANG_COMBO_LANG, marg, 20, 146, ySize2 - 12, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP -END +{ + LTEXT "Language:", IDC_LANG_STATIC_LANG, m, m, xc, 8 + COMBOBOX IDC_LANG_COMBO_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED +} + + +#ifdef UNDER_CE + +#undef m +#undef xc + +#define m 4 +#define xc (SMALL_PAGE_SIZE_X + 8) + +IDD_LANG_2 MY_PAGE +CAPTION "Language" +{ + LTEXT "Language:", IDC_LANG_STATIC_LANG, m, m, xc, 8 + COMBOBOX IDC_LANG_COMBO_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED +} + +#endif + STRINGTABLE BEGIN diff --git a/CPP/7zip/UI/FileManager/LangPageRes.h b/CPP/7zip/UI/FileManager/LangPageRes.h index 39571e53..eb704dbf 100755 --- a/CPP/7zip/UI/FileManager/LangPageRes.h +++ b/CPP/7zip/UI/FileManager/LangPageRes.h @@ -1,4 +1,6 @@ -#define IDD_LANG 900 +#define IDD_LANG 544 +#define IDD_LANG_2 644 + #define IDS_LANG_ENGLISH 995 #define IDS_LANG_NATIVE 996 diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.cpp b/CPP/7zip/UI/FileManager/ListViewDialog.cpp index e8001cf6..bec08e0d 100755 --- a/CPP/7zip/UI/FileManager/ListViewDialog.cpp +++ b/CPP/7zip/UI/FileManager/ListViewDialog.cpp @@ -1,7 +1,9 @@ // ListViewDialog.cpp #include "StdAfx.h" + #include "ListViewDialog.h" +#include "RegistryUtils.h" #ifdef LANG #include "LangUtils.h" @@ -18,13 +20,17 @@ bool CListViewDialog::OnInit() LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif _listView.Attach(GetItem(IDC_LISTVIEW_LIST)); + + if (ReadSingleClick()) + _listView.SetExtendedListViewStyle(LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT); + SetText(Title); LVCOLUMN columnInfo; columnInfo.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM; columnInfo.fmt = LVCFMT_LEFT; columnInfo.iSubItem = 0; - columnInfo.cx = 1000; + columnInfo.cx = 200; _listView.InsertColumn(0, &columnInfo); @@ -32,20 +38,67 @@ bool CListViewDialog::OnInit() _listView.InsertItem(i, Strings[i]); if (Strings.Size() > 0) - _listView.SetItemState(0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); + _listView.SetItemState_FocusedSelected(0); + + _listView.SetColumnWidthAuto(0); StringsWereChanged = false; + + NormalizeSize(); return CModalDialog::OnInit(); } +bool CListViewDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + GetMargins(8, mx, my); + int bx1, bx2, by; + GetItemSizes(IDCANCEL, bx1, by); + GetItemSizes(IDOK, bx2, by); + int y = ySize - my - by; + int x = xSize - mx - bx1; + + /* + RECT rect; + GetClientRect(&rect); + rect.top = y - my; + InvalidateRect(&rect); + */ + InvalidateRect(NULL); + + MoveItem(IDCANCEL, x, y, bx1, by); + MoveItem(IDOK, x - mx - bx2, y, bx2, by); + /* + if (wParam == SIZE_MAXSHOW || wParam == SIZE_MAXIMIZED || wParam == SIZE_MAXHIDE) + mx = 0; + */ + _listView.Move(mx, my, xSize - mx * 2, y - my * 2); + return false; +} + +extern bool g_LVN_ITEMACTIVATE_Support; + bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header) { if (header->hwndFrom != _listView) return false; switch(header->code) { + case LVN_ITEMACTIVATE: + if (g_LVN_ITEMACTIVATE_Support) + { + OnOK(); + return true; + } + break; case NM_DBLCLK: - OnOK(); - return true; + case NM_RETURN: // probabably it's unused + if (!g_LVN_ITEMACTIVATE_Support) + { + OnOK(); + return true; + } + break; + case LVN_KEYDOWN: { LPNMLVKEYDOWN keyDownInfo = LPNMLVKEYDOWN(header); @@ -55,9 +108,6 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header) { if (!DeleteIsAllowed) return false; - int focusedIndex = _listView.GetFocusedItem(); - if (focusedIndex < 0) - focusedIndex = 0; for (;;) { int index = _listView.GetNextSelectedItem(-1); @@ -67,10 +117,10 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header) _listView.DeleteItem(index); Strings.Delete(index); } - if (focusedIndex >= _listView.GetItemCount()) - focusedIndex = _listView.GetItemCount() - 1; + int focusedIndex = _listView.GetFocusedItem(); if (focusedIndex >= 0) - _listView.SetItemState(focusedIndex, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); + _listView.SetItemState_FocusedSelected(focusedIndex); + _listView.SetColumnWidthAuto(0); return true; } case 'A': diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.h b/CPP/7zip/UI/FileManager/ListViewDialog.h index 57375c8b..6be51c7e 100755 --- a/CPP/7zip/UI/FileManager/ListViewDialog.h +++ b/CPP/7zip/UI/FileManager/ListViewDialog.h @@ -1,10 +1,11 @@ // ListViewDialog.h -#ifndef __LISTVIEWDIALOG_H -#define __LISTVIEWDIALOG_H +#ifndef __LISTVIEW_DIALOG_H +#define __LISTVIEW_DIALOG_H #include "Windows/Control/Dialog.h" #include "Windows/Control/ListView.h" + #include "ListViewDialogRes.h" class CListViewDialog: public NWindows::NControl::CModalDialog @@ -12,19 +13,18 @@ class CListViewDialog: public NWindows::NControl::CModalDialog NWindows::NControl::CListView _listView; virtual void OnOK(); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); virtual bool OnNotify(UINT controlID, LPNMHDR header); - public: UString Title; bool DeleteIsAllowed; - UStringVector Strings; bool StringsWereChanged; + UStringVector Strings; int FocusedItemIndex; INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_LISTVIEW, wndParent); } CListViewDialog(): DeleteIsAllowed(false) {} - }; #endif diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.rc b/CPP/7zip/UI/FileManager/ListViewDialog.rc index cb456534..8f963bf1 100755 --- a/CPP/7zip/UI/FileManager/ListViewDialog.rc +++ b/CPP/7zip/UI/FileManager/ListViewDialog.rc @@ -1,26 +1,14 @@ #include "ListViewDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 342 -#define ySize2 220 +#define xc 320 +#define yc 240 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - -#define bYPos (ySize - marg - bYSize) -#define b1XPos (xSize - marg - bXSize) -#define b2XPos (b1XPos - 10 - bXSize) - - -IDD_DIALOG_LISTVIEW DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_LISTVIEW MY_RESIZE_DIALOG CAPTION "ListView" -MY_FONT -BEGIN +{ CONTROL "List1", IDC_LISTVIEW_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP, - marg, marg, xSize2, ySize2 - bYSize - 10 - DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize -END - - + m, m, xc, yc - bys - m + OK_CANCEL +} diff --git a/CPP/7zip/UI/FileManager/ListViewDialogRes.h b/CPP/7zip/UI/FileManager/ListViewDialogRes.h index 440d14b0..aaa6521f 100755 --- a/CPP/7zip/UI/FileManager/ListViewDialogRes.h +++ b/CPP/7zip/UI/FileManager/ListViewDialogRes.h @@ -1,3 +1,2 @@ -#define IDD_DIALOG_LISTVIEW 201 - -#define IDC_LISTVIEW_LIST 1000 +#define IDD_DIALOG_LISTVIEW 508 +#define IDC_LISTVIEW_LIST 1000 diff --git a/CPP/7zip/UI/Explorer/SystemPage.cpp b/CPP/7zip/UI/FileManager/MenuPage.cpp index 602e4387..719c86ad 100755 --- a/CPP/7zip/UI/Explorer/SystemPage.cpp +++ b/CPP/7zip/UI/FileManager/MenuPage.cpp @@ -1,23 +1,18 @@ -// SystemPage.cpp +// MenuPage.cpp #include "StdAfx.h" -#include "resource.h" -#include "SystemPageRes.h" -#include "SystemPage.h" - -#include "Common/StringConvert.h" -#include "Windows/Defs.h" -#include "Windows/Control/ListView.h" - #include "../Common/ZipRegistry.h" -#include "../FileManager/HelpUtils.h" -#include "../FileManager/LangUtils.h" -#include "../FileManager/FormatUtils.h" +#include "../Explorer/ContextMenuFlags.h" +#include "../Explorer/RegistryContextMenu.h" +#include "../Explorer/resource.h" -#include "RegistryContextMenu.h" -#include "ContextMenuFlags.h" +#include "HelpUtils.h" +#include "LangUtils.h" +#include "MenuPage.h" +#include "MenuPageRes.h" +#include "FormatUtils.h" using namespace NContextMenuFlags; @@ -47,40 +42,41 @@ static CContextMenuItem kMenuItems[] = { IDS_CONTEXT_TEST, 0x02000109, kTest}, { IDS_CONTEXT_COMPRESS, 0x02000107, kCompress }, + { IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressTo7z }, + { IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressToZip } + + #ifndef UNDER_CE + , { IDS_CONTEXT_COMPRESS_EMAIL, 0x02000111, kCompressEmail }, - { IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressTo7z }, - { IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressTo7zEmail}, - { IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressToZip }, - { IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressToZipEmail} + { IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressTo7zEmail }, + { IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressToZipEmail } + #endif }; const int kNumMenuItems = sizeof(kMenuItems) / sizeof(kMenuItems[0]); -bool CSystemPage::OnInit() +bool CMenuPage::OnInit() { _initMode = true; LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); - CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, - NZipRootRegistry::CheckContextMenuHandler()); - - CheckButton(IDC_SYSTEM_CASCADED_MENU, ReadCascadedMenu()); + #ifdef UNDER_CE + EnableItem(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, false); + #else + CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, NZipRootRegistry::CheckContextMenuHandler()); + #endif - UInt32 contextMenuFlags; - if (!ReadContextMenuStatus(contextMenuFlags)) - contextMenuFlags = NContextMenuFlags::GetDefaultFlags(); + CContextMenuInfo ci; + ci.Load(); - m_ListView.Attach(GetItem(IDC_SYSTEM_OPTIONS_LIST)); + CheckButton(IDC_SYSTEM_CASCADED_MENU, ci.Cascaded); - /* - CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, - NRegistryAssociations::CheckContextMenuHandler()); - */ + _listView.Attach(GetItem(IDC_SYSTEM_OPTIONS_LIST)); UInt32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT; - m_ListView.SetExtendedListViewStyle(newFlags, newFlags); + _listView.SetExtendedListViewStyle(newFlags, newFlags); - m_ListView.InsertColumn(0, L"", 270); + _listView.InsertColumn(0, L"", 100); for (int i = 0; i < kNumMenuItems; i++) { @@ -115,19 +111,25 @@ bool CSystemPage::OnInit() } } - int itemIndex = m_ListView.InsertItem(i, s); - m_ListView.SetCheckState(itemIndex, ((contextMenuFlags & menuItem.Flag) != 0)); + int itemIndex = _listView.InsertItem(i, s); + _listView.SetCheckState(itemIndex, ((ci.Flags & menuItem.Flag) != 0)); } + _listView.SetColumnWidthAuto(0); _initMode = false; return CPropertyPage::OnInit(); } +#ifndef UNDER_CE STDAPI DllRegisterServer(void); STDAPI DllUnregisterServer(void); +HWND g_MenuPageHWND = 0; +#endif -LONG CSystemPage::OnApply() +LONG CMenuPage::OnApply() { + #ifndef UNDER_CE + g_MenuPageHWND = *this; if (IsButtonCheckedBool(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU)) { DllRegisterServer(); @@ -138,23 +140,25 @@ LONG CSystemPage::OnApply() DllUnregisterServer(); NZipRootRegistry::DeleteContextMenuHandler(); } - SaveCascadedMenu(IsButtonCheckedBool(IDC_SYSTEM_CASCADED_MENU)); + #endif - UInt32 flags = 0; + CContextMenuInfo ci; + ci.Cascaded = IsButtonCheckedBool(IDC_SYSTEM_CASCADED_MENU); + ci.Flags = 0; for (int i = 0; i < kNumMenuItems; i++) - if (m_ListView.GetCheckState(i)) - flags |= kMenuItems[i].Flag; - SaveContextMenuStatus(flags); + if (_listView.GetCheckState(i)) + ci.Flags |= kMenuItems[i].Flag; + ci.Save(); return PSNRET_NOERROR; } -void CSystemPage::OnNotifyHelp() +void CMenuPage::OnNotifyHelp() { ShowHelpWindow(NULL, kSystemTopic); } -bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND) +bool CMenuPage::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) { @@ -167,9 +171,9 @@ bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND) } -bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam) +bool CMenuPage::OnNotify(UINT controlID, LPNMHDR lParam) { - if (lParam->hwndFrom == HWND(m_ListView)) + if (lParam->hwndFrom == HWND(_listView)) { switch(lParam->code) { @@ -181,7 +185,7 @@ bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam) } -bool CSystemPage::OnItemChanged(const NMLISTVIEW *info) +bool CMenuPage::OnItemChanged(const NMLISTVIEW *info) { if (_initMode) return true; @@ -192,7 +196,5 @@ bool CSystemPage::OnItemChanged(const NMLISTVIEW *info) if (oldState != newState) Changed(); } - // PostMessage(kRefreshpluginsListMessage, 0); - // RefreshPluginsList(); return true; } diff --git a/CPP/7zip/UI/Explorer/SystemPage.h b/CPP/7zip/UI/FileManager/MenuPage.h index 75fdeb2b..5005ea9c 100755 --- a/CPP/7zip/UI/Explorer/SystemPage.h +++ b/CPP/7zip/UI/FileManager/MenuPage.h @@ -1,25 +1,25 @@ -// SystemPage.h +// MenuPage.h -#ifndef __SYSTEMPAGE_H -#define __SYSTEMPAGE_H +#ifndef __MENU_PAGE_H +#define __MENU_PAGE_H #include "Windows/Control/PropertyPage.h" #include "Windows/Control/ListView.h" #include "../Common/LoadCodecs.h" -class CSystemPage: public NWindows::NControl::CPropertyPage +class CMenuPage: public NWindows::NControl::CPropertyPage { bool _initMode; - CObjectVector<CArcInfoEx> m_Archivers; - NWindows::NControl::CListView m_ListView; -public: + NWindows::NControl::CListView _listView; + virtual bool OnInit(); virtual void OnNotifyHelp(); virtual bool OnNotify(UINT controlID, LPNMHDR lParam); virtual bool OnItemChanged(const NMLISTVIEW *info); virtual LONG OnApply(); virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); +public: }; #endif diff --git a/CPP/7zip/UI/FileManager/MenuPage.rc b/CPP/7zip/UI/FileManager/MenuPage.rc new file mode 100755 index 00000000..bb4281d8 --- /dev/null +++ b/CPP/7zip/UI/FileManager/MenuPage.rc @@ -0,0 +1,24 @@ +#include "MenuPageRes.h" +#include "../../GuiCommon.rc" + +#define xc 196 +#define yc 164 + +IDD_MENU MY_PAGE +#include "MenuPage2.rc" + +#ifdef UNDER_CE + +#undef m +#undef xc +#undef yc + +#define m 4 +#define xc (SMALL_PAGE_SIZE_X + 8) + +#define yc 112 + +IDD_MENU_2 MY_PAGE +#include "MenuPage2.rc" + +#endif diff --git a/CPP/7zip/UI/FileManager/MenuPage2.rc b/CPP/7zip/UI/FileManager/MenuPage2.rc new file mode 100755 index 00000000..1862aa06 --- /dev/null +++ b/CPP/7zip/UI/FileManager/MenuPage2.rc @@ -0,0 +1,14 @@ +#define y 40 + +CAPTION "7-Zip" +BEGIN + CONTROL "Integrate 7-Zip to shell context menu", IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, + MY_CHECKBOX, m, m, xc, 10 + CONTROL "Cascaded context menu", IDC_SYSTEM_CASCADED_MENU, + MY_CHECKBOX, m, m + 14, xc, 10 + LTEXT "Context menu items:", IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS, + m, m + 28, xc, 8 + CONTROL "List", IDC_SYSTEM_OPTIONS_LIST, "SysListView32", + LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP, + m, m + y, xc, yc - y +END diff --git a/CPP/7zip/UI/Explorer/SystemPageRes.h b/CPP/7zip/UI/FileManager/MenuPageRes.h index b125849c..f1220bfd 100755 --- a/CPP/7zip/UI/Explorer/SystemPageRes.h +++ b/CPP/7zip/UI/FileManager/MenuPageRes.h @@ -1,4 +1,5 @@ -#define IDD_SYSTEM 102 +#define IDD_MENU 570 +#define IDD_MENU_2 670 #define IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU 1010 #define IDC_SYSTEM_CASCADED_MENU 1011 diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.cpp b/CPP/7zip/UI/FileManager/MessagesDialog.cpp index 201c0bae..3d73ade1 100755 --- a/CPP/7zip/UI/FileManager/MessagesDialog.cpp +++ b/CPP/7zip/UI/FileManager/MessagesDialog.cpp @@ -1,11 +1,13 @@ // MessagesDialog.cpp #include "StdAfx.h" -#include "MessagesDialog.h" -#include "Common/StringConvert.h" + #include "Common/IntToString.h" + #include "Windows/ResourceString.h" +#include "MessagesDialog.h" + #ifdef LANG #include "LangUtils.h" #endif @@ -49,9 +51,12 @@ bool CMessagesDialog::OnInit() LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif _messageList.Attach(GetItem(IDC_MESSAGE_LIST)); + + #ifndef UNDER_CE _messageList.SetUnicodeFormat(true); + #endif - _messageList.InsertColumn(0, L"#", 30); + _messageList.InsertColumn(0, L"", 30); const UString s = #ifdef LANG @@ -62,15 +67,27 @@ bool CMessagesDialog::OnInit() _messageList.InsertColumn(1, s, 600); - for(int i = 0; i < Messages->Size(); i++) + for (int i = 0; i < Messages->Size(); i++) AddMessage((*Messages)[i]); - /* - if(_messageList.GetItemCount() > 0) - { - UINT aState = LVIS_SELECTED | LVIS_FOCUSED; - _messageList.SetItemState(0, aState, aState); - } - */ + _messageList.SetColumnWidthAuto(0); + _messageList.SetColumnWidthAuto(1); + NormalizeSize(); return CModalDialog::OnInit(); } + +bool CMessagesDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + GetMargins(8, mx, my); + int bx, by; + GetItemSizes(IDOK, bx, by); + int y = ySize - my - by; + int x = xSize - mx - bx; + + InvalidateRect(NULL); + + MoveItem(IDOK, x, y, bx, by); + _messageList.Move(mx, my, xSize - mx * 2, y - my * 2); + return false; +} diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.h b/CPP/7zip/UI/FileManager/MessagesDialog.h index 6df0d46c..1304d516 100755 --- a/CPP/7zip/UI/FileManager/MessagesDialog.h +++ b/CPP/7zip/UI/FileManager/MessagesDialog.h @@ -1,19 +1,20 @@ // MessagesDialog.h -#ifndef __MESSAGESDIALOG_H -#define __MESSAGESDIALOG_H - -#include "MessagesDialogRes.h" +#ifndef __MESSAGES_DIALOG_H +#define __MESSAGES_DIALOG_H #include "Windows/Control/Dialog.h" #include "Windows/Control/ListView.h" +#include "MessagesDialogRes.h" + class CMessagesDialog: public NWindows::NControl::CModalDialog { NWindows::NControl::CListView _messageList; void AddMessageDirect(LPCWSTR message); void AddMessage(LPCWSTR message); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); public: const UStringVector *Messages; INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_MESSAGES, parent); } diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.rc b/CPP/7zip/UI/FileManager/MessagesDialog.rc index bf1c56b0..fb2f0f7d 100755 --- a/CPP/7zip/UI/FileManager/MessagesDialog.rc +++ b/CPP/7zip/UI/FileManager/MessagesDialog.rc @@ -1,25 +1,14 @@ #include "MessagesDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 430 -#define ySize2 140 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) -#define bXPos (xSize - marg - bXSize) -#define bYPos (ySize - marg - bYSize) +#define xc 440 +#define yc 160 - -IDD_DIALOG_MESSAGES DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_MESSAGES MY_RESIZE_DIALOG CAPTION "7-Zip: Diagnostic messages" -MY_FONT -BEGIN - DEFPUSHBUTTON "&Close", IDOK, bXPos, bYPos, bXSize, bYSize - CONTROL "List1",IDC_MESSAGE_LIST,"SysListView32", +{ + DEFPUSHBUTTON "&Close", IDOK, bx, by, bxs, bys + CONTROL "List1", IDC_MESSAGE_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, - marg, marg, xSize2, ySize2 - bYSize - 6 -END - -STRINGTABLE -BEGIN - IDS_MESSAGES_DIALOG_MESSAGE_COLUMN "Message" -END + m, m, xc, yc - bys - m +} diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp index f98325a0..ebd41fd9 100755 --- a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp +++ b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp @@ -3,6 +3,7 @@ #include "StdAfx.h" #include "Windows/Menu.h" +#include "Windows/Control/Dialog.h" #include "../../PropID.h" @@ -16,6 +17,8 @@ #include "resource.h" +using namespace NWindows; + static const UINT kOpenBookmarkMenuID = 730; static const UINT kSetBookmarkMenuID = 740; @@ -25,44 +28,28 @@ static LPCWSTR kFMHelpTopic = L"FM/index.htm"; extern void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance); -using namespace NWindows; - -static const int kFileMenuIndex = 0; -static const int kEditMenuIndex = 1; -static const int kViewMenuIndex = 2; -static const int kBookmarksMenuIndex = kViewMenuIndex + 1; - -struct CStringLangPair +enum { - wchar_t *String; - UINT32 LangID; + kMenuIndex_File = 0, + kMenuIndex_Edit, + kMenuIndex_View, + kMenuIndex_Bookmarks }; -static CStringLangPair kStringLangPairs[] = +static const UInt32 kTopMenuLangIDs[] = { - { L"&File", 0x03000102 }, - { L"&Edit", 0x03000103 }, - { L"&View", 0x03000104 }, - { L"&Bookmarks", 0x03000107 }, - { L"&Tools", 0x03000105 }, - { L"&Help", 0x03000106 }, + 0x03000102, + 0x03000103, + 0x03000104, + 0x03000107, + 0x03000105, + 0x03000106 }; -UINT32 kAddToFavoritesLangID = 0x03000710; -UINT32 kToolbarsLangID = 0x03000451; +static const UInt32 kAddToFavoritesLangID = 0x03000710; +static const UInt32 kToolbarsLangID = 0x03000451; -/* -static int FindStringLangItem(const UString &anItem) -{ - for (int i = 0; i < sizeof(kStringLangPairs) / - sizeof(kStringLangPairs[0]); i++) - if (anItem.CompareNoCase(kStringLangPairs[i].String) == 0) - return i; - return -1; -} -*/ - -static CIDLangPair kIDLangPairs[] = +static const CIDLangPair kIDLangPairs[] = { // File { IDM_FILE_OPEN, 0x03000210 }, @@ -136,6 +123,18 @@ static int FindLangItem(int ControlID) return -1; } +static int GetSortControlID(PROPID propID) +{ + switch(propID) + { + case kpidName: return IDM_VIEW_ARANGE_BY_NAME; + case kpidExtension: return IDM_VIEW_ARANGE_BY_TYPE; + case kpidMTime: return IDM_VIEW_ARANGE_BY_DATE; + case kpidSize: return IDM_VIEW_ARANGE_BY_SIZE; + case kpidNoProperty: return IDM_VIEW_ARANGE_NO_SORT; + } + return -1; +} /* static bool g_IsNew_fMask = true; @@ -177,50 +176,38 @@ static UINT Get_fMaskForFTypeAndString() } */ -static UINT Get_fMaskForString() -{ - return MIIM_TYPE; -} - -static UINT Get_fMaskForFTypeAndString() -{ - return MIIM_TYPE; -} - - +static inline UINT Get_fMaskForString() { return MIIM_TYPE; } +static inline UINT Get_fMaskForFTypeAndString() { return MIIM_TYPE; } static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex) { CMenu menu; menu.Attach(menuLoc); - for (int i = 0; i < menu.GetItemCount(); i++) + for (int i = 0;; i++) { CMenuItem item; item.fMask = Get_fMaskForString() | MIIM_SUBMENU | MIIM_ID; item.fType = MFT_STRING; - if (menu.GetItem(i, true, item)) + if (!menu.GetItem(i, true, item)) + break; { UString newString; if (item.hSubMenu) { - if (level == 1 && menuIndex == kBookmarksMenuIndex) - newString = LangString(kAddToFavoritesLangID); + UInt32 langID = 0; + if (level == 1 && menuIndex == kMenuIndex_Bookmarks) + langID = kAddToFavoritesLangID; else { MyChangeMenu(item.hSubMenu, level + 1, i); - if (level == 1 && menuIndex == kViewMenuIndex) - { - newString = LangString(kToolbarsLangID); - } + if (level == 1 && menuIndex == kMenuIndex_View) + langID = kToolbarsLangID; + else if (level == 0 && i < sizeof(kTopMenuLangIDs) / sizeof(kTopMenuLangIDs[0])) + langID = kTopMenuLangIDs[i]; else - { - if (level == 0 && i < sizeof(kStringLangPairs) / - sizeof(kStringLangPairs[0])) - newString = LangString(kStringLangPairs[i].LangID); - else - continue; - } + continue; } + newString = LangString(langID); if (newString.IsEmpty()) continue; } @@ -247,41 +234,14 @@ static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex) } } -CMenu g_FileMenu; +static CMenu g_FileMenu; -class CFileMenuDestroyer +struct CFileMenuDestroyer { -public: - ~CFileMenuDestroyer() - { - if ((HMENU)g_FileMenu != 0) - g_FileMenu.Destroy(); - } + ~CFileMenuDestroyer() { if ((HMENU)g_FileMenu != 0) g_FileMenu.Destroy(); } } g_FileMenuDestroyer; -void MyLoadMenu(HWND hWnd) -{ - if ((HMENU)g_FileMenu != 0) - g_FileMenu.Destroy(); - HMENU oldMenu = ::GetMenu(hWnd); - HMENU baseMenu = ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU)); - ::SetMenu(hWnd, baseMenu); - ::DestroyMenu(oldMenu); - if (!g_LangID.IsEmpty()) - { - HMENU menuOld = ::GetMenu(hWnd); - MyChangeMenu(menuOld, 0, 0); - } - ::DrawMenuBar(hWnd); -} - -extern HWND g_HWND; -void MyLoadMenu() -{ - MyLoadMenu(g_HWND); -} - static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec) { CMenu srcMenu; @@ -289,39 +249,74 @@ static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec) CMenu destMenu; destMenu.Attach(destMenuSpec); int startPos = 0; - for (int i = 0; i < srcMenu.GetItemCount(); i++) + for (int i = 0;; i++) { CMenuItem item; item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString(); item.fType = MFT_STRING; if (srcMenu.GetItem(i, true, item)) + { if (destMenu.InsertItem(startPos, true, item)) startPos++; + } + else + break; } } +void MyLoadMenu() +{ + HMENU baseMenu; + + #ifdef UNDER_CE + + HMENU oldMenu = g_App._commandBar.GetMenu(0); + if (oldMenu) + ::DestroyMenu(oldMenu); + BOOL b = g_App._commandBar.InsertMenubar(g_hInstance, IDM_MENU, 0); + baseMenu = g_App._commandBar.GetMenu(0); + if (!g_LangID.IsEmpty()) + MyChangeMenu(baseMenu, 0, 0); + g_App._commandBar.DrawMenuBar(0); + + #else + + HWND hWnd = g_HWND; + HMENU oldMenu = ::GetMenu(hWnd); + ::SetMenu(hWnd, ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU))); + ::DestroyMenu(oldMenu); + baseMenu = ::GetMenu(hWnd); + if (!g_LangID.IsEmpty()) + MyChangeMenu(baseMenu, 0, 0); + ::DrawMenuBar(hWnd); + + #endif + + if ((HMENU)g_FileMenu != 0) + g_FileMenu.Destroy(); + g_FileMenu.CreatePopup(); + CopyMenu(::GetSubMenu(baseMenu, 0), g_FileMenu); +} + void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) { - if (::GetSubMenu(::GetMenu(g_HWND), position) != hMenu) + HMENU mainMenu = + #ifdef UNDER_CE + g_App._commandBar.GetMenu(0); + #else + ::GetMenu(g_HWND) + #endif + ; + if (::GetSubMenu(mainMenu, position) != hMenu) return; - if (position == kFileMenuIndex) + if (position == kMenuIndex_File) { - if ((HMENU)g_FileMenu == 0) - { - g_FileMenu.CreatePopup(); - CopyMenu(hMenu, g_FileMenu); - } CMenu menu; menu.Attach(hMenu); - while (menu.GetItemCount() > 0) - { - if (!menu.RemoveItem(0, MF_BYPOSITION)) - break; - } - // CopyMenu(g_FileMenu, hMenu); + menu.RemoveAllItems(); g_App.GetFocusedPanel().CreateFileMenu(hMenu); } - else if (position == kEditMenuIndex) + else if (position == kMenuIndex_Edit) { /* CMenu menu; @@ -331,35 +326,32 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) menu.EnableItem(IDM_EDIT_PASTE, IsClipboardFormatAvailableHDROP() ? MF_ENABLED : MF_GRAYED); */ } - else if (position == kViewMenuIndex) + else if (position == kMenuIndex_View) { // View; CMenu menu; menu.Attach(hMenu); menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, IDM_VIEW_LARGE_ICONS + g_App.GetListViewMode(), MF_BYCOMMAND); - menu.CheckItem(IDM_VIEW_TWO_PANELS, MF_BYCOMMAND | - ((g_App.NumPanels == 2) ? MF_CHECKED : MF_UNCHECKED)); - menu.CheckItem(IDM_VIEW_FLAT_VIEW, MF_BYCOMMAND | - ((g_App.GetFlatMode()) ? MF_CHECKED : MF_UNCHECKED)); - menu.CheckItem(IDM_VIEW_ARCHIVE_TOOLBAR, MF_BYCOMMAND | - (g_App.ShowArchiveToolbar ? MF_CHECKED : MF_UNCHECKED)); - menu.CheckItem(IDM_VIEW_STANDARD_TOOLBAR, MF_BYCOMMAND | - (g_App.ShowStandardToolbar ? MF_CHECKED : MF_UNCHECKED)); - menu.CheckItem(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, MF_BYCOMMAND | - (g_App.LargeButtons ? MF_CHECKED : MF_UNCHECKED)); - menu.CheckItem(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, MF_BYCOMMAND | - (g_App.ShowButtonsLables ? MF_CHECKED : MF_UNCHECKED)); + + menu.CheckRadioItem(IDM_VIEW_ARANGE_BY_NAME, IDM_VIEW_ARANGE_NO_SORT, + GetSortControlID(g_App.GetSortID()), MF_BYCOMMAND); + + menu.CheckItemByID(IDM_VIEW_TWO_PANELS, g_App.NumPanels == 2); + menu.CheckItemByID(IDM_VIEW_FLAT_VIEW, g_App.GetFlatMode()); + menu.CheckItemByID(IDM_VIEW_ARCHIVE_TOOLBAR, g_App.ShowArchiveToolbar); + menu.CheckItemByID(IDM_VIEW_STANDARD_TOOLBAR, g_App.ShowStandardToolbar); + menu.CheckItemByID(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, g_App.LargeButtons); + menu.CheckItemByID(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, g_App.ShowButtonsLables); } - else if (position == kBookmarksMenuIndex) + else if (position == kMenuIndex_Bookmarks) { CMenu menu; menu.Attach(hMenu); CMenu subMenu; subMenu.Attach(menu.GetSubMenu(0)); - while (subMenu.GetItemCount() > 0) - subMenu.RemoveItem(subMenu.GetItemCount() - 1, MF_BYPOSITION); + subMenu.RemoveAllItems(); int i; for (i = 0; i < 10; i++) { @@ -372,8 +364,7 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s); } - while (menu.GetItemCount() > 2) - menu.RemoveItem(menu.GetItemCount() - 1, MF_BYPOSITION); + menu.RemoveAllItemsFrom(2); for (i = 0; i < 10; i++) { @@ -401,84 +392,51 @@ void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id) { if (::GetSubMenu(::GetMenu(g_HWND), 0) != hMenu) return; - // g_App.GetFocusedPanel()._contextMenu.Release(); -} - -void OnMenuUnActivating(HWND hWnd) -{ } */ - void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu, bool isFsFolder, int numItems, bool allAreFiles) { - { - CMenu srcMenu; - srcMenu.Attach(::GetSubMenu(::GetMenu(g_HWND), 0)); - if ((HMENU)g_FileMenu == 0) - { - g_FileMenu.CreatePopup(); - CopyMenu(srcMenu, g_FileMenu); - } - } - CMenu destMenu; destMenu.Attach(hMenu); UString diffPath; ReadRegDiff(diffPath); - for (int i = 0; i < g_FileMenu.GetItemCount(); i++) + int numRealItems = startPos; + for (int i = 0;; i++) { CMenuItem item; item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString(); item.fType = MFT_STRING; - if (g_FileMenu.GetItem(i, true, item)) + if (!g_FileMenu.GetItem(i, true, item)) + break; { - if (!programMenu) - if (item.wID == IDCLOSE) - continue; + if (!programMenu && item.wID == IDCLOSE) + continue; if (item.wID == IDM_FILE_DIFF && diffPath.IsEmpty()) continue; bool isOneFsFile = (isFsFolder && numItems == 1 && allAreFiles); - if ((item.wID == IDM_FILE_SPLIT || item.wID == IDM_FILE_COMBINE) && !isOneFsFile) - item.fState |= MFS_DISABLED; + bool disable = ((item.wID == IDM_FILE_SPLIT || item.wID == IDM_FILE_COMBINE) && !isOneFsFile); - /* - bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE); - if (forFileMode) - { - if (createItem) - continue; - } - else - { - if (!createItem) - continue; - } - */ + bool isBigScreen = NControl::IsDialogSizeOK(40, 200); + + if (!isBigScreen && (disable || item.IsSeparator())) + continue; if (destMenu.InsertItem(startPos, true, item)) startPos++; + if (disable) + destMenu.EnableItem(startPos - 1, MF_BYPOSITION | MF_GRAYED); + + if (!item.IsSeparator()) + numRealItems = startPos; } } - while (destMenu.GetItemCount() > 0) - { - CMenuItem item; - item.fMask = MIIM_TYPE; - item.fType = 0; - // item.dwTypeData = 0; - int lastIndex = destMenu.GetItemCount() - 1; - if (!destMenu.GetItem(lastIndex, true, item)) - break; - if(item.fType != MFT_SEPARATOR) - break; - if (!destMenu.RemoveItem(lastIndex, MF_BYPOSITION)) - break; - } + destMenu.RemoveAllItemsFrom(numRealItems); } bool ExecuteFileCommand(int id) @@ -618,7 +576,7 @@ bool OnMenuCommand(HWND hWnd, int id) g_App.SetListViewMode(index); /* CMenu menu; - menu.Attach(::GetSubMenu(::GetMenu(hWnd), kViewMenuIndex)); + menu.Attach(::GetSubMenu(::GetMenu(hWnd), kMenuIndex_View)); menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, id, MF_BYCOMMAND); */ @@ -688,8 +646,12 @@ bool OnMenuCommand(HWND hWnd, int id) break; case IDM_BENCHMARK: + { + CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]); + CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]); Benchmark(); break; + } // Help case IDM_HELP_CONTENTS: ShowHelpWindow(NULL, kFMHelpTopic); @@ -717,4 +679,3 @@ bool OnMenuCommand(HWND hWnd, int id) } return true; } - diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.h b/CPP/7zip/UI/FileManager/MyLoadMenu.h index 83c1d24f..53e9d0ef 100755 --- a/CPP/7zip/UI/FileManager/MyLoadMenu.h +++ b/CPP/7zip/UI/FileManager/MyLoadMenu.h @@ -1,13 +1,12 @@ // MyLoadMenu.h -#ifndef __MYLOADMENU_H -#define __MYLOADMENU_H +#ifndef __MY_LOAD_MENU_H +#define __MY_LOAD_MENU_H void OnMenuActivating(HWND hWnd, HMENU hMenu, int position); // void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id); // void OnMenuUnActivating(HWND hWnd); -void MyLoadMenu(HWND hWnd); bool OnMenuCommand(HWND hWnd, int id); void MyLoadMenu(); void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu, diff --git a/CPP/7zip/UI/FileManager/OpenCallback.cpp b/CPP/7zip/UI/FileManager/OpenCallback.cpp index a275f89b..72245ac4 100755 --- a/CPP/7zip/UI/FileManager/OpenCallback.cpp +++ b/CPP/7zip/UI/FileManager/OpenCallback.cpp @@ -15,43 +15,43 @@ using namespace NWindows; STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + RINOK(ProgressDialog.Sync.ProcessStopAndPause()); { NSynchronization::CCriticalSectionLock lock(_criticalSection); if (numFiles != NULL) { - ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles); - ProgressDialog.ProgressSynch.SetBytesProgressMode(false); + ProgressDialog.Sync.SetNumFilesTotal(*numFiles); + ProgressDialog.Sync.SetBytesProgressMode(false); } if (numBytes != NULL) - ProgressDialog.ProgressSynch.SetNumBytesTotal(*numBytes); + ProgressDialog.Sync.SetNumBytesTotal(*numBytes); } return S_OK; } STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + RINOK(ProgressDialog.Sync.ProcessStopAndPause()); NSynchronization::CCriticalSectionLock lock(_criticalSection); if (numFiles != NULL) - ProgressDialog.ProgressSynch.SetNumFilesCur(*numFiles); + ProgressDialog.Sync.SetNumFilesCur(*numFiles); if (numBytes != NULL) - ProgressDialog.ProgressSynch.SetPos(*numBytes); + ProgressDialog.Sync.SetPos(*numBytes); return S_OK; } STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 total) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); - ProgressDialog.ProgressSynch.SetNumBytesTotal(total); + RINOK(ProgressDialog.Sync.ProcessStopAndPause()); + ProgressDialog.Sync.SetNumBytesTotal(total); return S_OK; } STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + RINOK(ProgressDialog.Sync.ProcessStopAndPause()); if (completed != NULL) - ProgressDialog.ProgressSynch.SetPos(*completed); + ProgressDialog.Sync.SetPos(*completed); return S_OK; } @@ -112,6 +112,7 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password) { CPasswordDialog dialog; + ProgressDialog.WaitCreating(); if (dialog.Create(ProgressDialog) == IDCANCEL) return E_ABORT; diff --git a/CPP/7zip/UI/FileManager/OpenCallback.h b/CPP/7zip/UI/FileManager/OpenCallback.h index 5f0fbefc..559eb8fc 100755 --- a/CPP/7zip/UI/FileManager/OpenCallback.h +++ b/CPP/7zip/UI/FileManager/OpenCallback.h @@ -75,7 +75,7 @@ public: _subArchiveMode = false; } */ - void LoadFileInfo(const UString &folderPrefix, const UString &fileName) + void LoadFileInfo(const UString &folderPrefix, const UString &fileName) { _folderPrefix = folderPrefix; if (!_fileInfo.Find(_folderPrefix + fileName)) @@ -83,9 +83,9 @@ public: } void ShowMessage(const UInt64 *completed); - INT_PTR StartProgressDialog(const UString &title) + INT_PTR StartProgressDialog(const UString &title, NWindows::CThread &thread) { - return ProgressDialog.Create(title, ParentWindow); + return ProgressDialog.Create(title, thread, ParentWindow); } }; diff --git a/CPP/7zip/UI/FileManager/OptionsDialog.cpp b/CPP/7zip/UI/FileManager/OptionsDialog.cpp index 09d74705..1b44461f 100755 --- a/CPP/7zip/UI/FileManager/OptionsDialog.cpp +++ b/CPP/7zip/UI/FileManager/OptionsDialog.cpp @@ -2,42 +2,114 @@ #include "StdAfx.h" -#include "resource.h" - -#include "Common/StringConvert.h" - +#include "Windows/Control/Dialog.h" #include "Windows/Control/PropertyPage.h" -#include "Windows/Error.h" -#include "LangPage.h" -#include "LangPageRes.h" -#include "PluginsPage.h" -#include "PluginsPageRes.h" -#include "SystemPage.h" -#include "SystemPageRes.h" +#include "DialogSize.h" #include "EditPage.h" #include "EditPageRes.h" +#include "FoldersPage.h" +#include "FoldersPageRes.h" +#include "LangPage.h" +#include "LangPageRes.h" +#include "MenuPage.h" +#include "MenuPageRes.h" +// #include "PluginsPage.h" +// #include "PluginsPageRes.h" #include "SettingsPage.h" #include "SettingsPageRes.h" +#include "SystemPage.h" +#include "SystemPageRes.h" +#include "App.h" #include "LangUtils.h" #include "MyLoadMenu.h" -#include "App.h" +#include "ProgramLocation.h" + +#include "resource.h" using namespace NWindows; +#ifndef UNDER_CE +typedef UINT32 (WINAPI * DllRegisterServerPtr)(); + +extern HWND g_MenuPageHWND; + +static void ShowMenuErrorMessage(const wchar_t *m) +{ + MessageBoxW(g_MenuPageHWND, m, L"7-Zip", MB_ICONERROR); +} + +static int DllRegisterServer2(const char *name) +{ + NWindows::NDLL::CLibrary lib; + + UString prefix; + GetProgramFolderPath(prefix); + if (!lib.Load(prefix + L"7-zip.dll")) + { + ShowMenuErrorMessage(L"7-Zip cannot load 7-zip.dll"); + return E_FAIL; + } + DllRegisterServerPtr f = (DllRegisterServerPtr)lib.GetProc(name); + if (f == NULL) + { + ShowMenuErrorMessage(L"Incorrect plugin"); + return E_FAIL; + } + HRESULT res = f(); + if (res != S_OK) + ShowMenuErrorMessage(HResultToMessage(res)); + return (int)res; +} + +STDAPI DllRegisterServer(void) +{ + #ifdef UNDER_CE + return S_OK; + #else + return DllRegisterServer2("DllRegisterServer"); + #endif +} + +STDAPI DllUnregisterServer(void) +{ + #ifdef UNDER_CE + return S_OK; + #else + return DllRegisterServer2("DllUnregisterServer"); + #endif +} + +#endif + void OptionsDialog(HWND hwndOwner, HINSTANCE /* hInstance */) { CSystemPage systemPage; - CPluginsPage pluginsPage; + // CPluginsPage pluginsPage; CEditPage editPage; CSettingsPage settingsPage; CLangPage langPage; + CMenuPage menuPage; + CFoldersPage foldersPage; CObjectVector<NControl::CPageInfo> pages; - UINT32 langIDs[] = { 0x03010300, 0x03010100, 0x03010200, 0x03010400, 0x01000400}; - UINT pageIDs[] = { IDD_SYSTEM, IDD_PLUGINS, IDD_EDIT, IDD_SETTINGS, IDD_LANG}; - NControl::CPropertyPage *pagePinters[] = { &systemPage, &pluginsPage, &editPage, &settingsPage, &langPage }; + UINT32 langIDs[] = { 0x03010300, + // 0x03010100, + 0xFFFFFFFF, + 0x01000200, 0x03010200, 0x03010400, 0x01000400}; + + BIG_DIALOG_SIZE(200, 200); + + UINT pageIDs[] = { + SIZED_DIALOG(IDD_SYSTEM), + // IDD_PLUGINS, + SIZED_DIALOG(IDD_MENU), + SIZED_DIALOG(IDD_FOLDERS), + IDD_EDIT, + SIZED_DIALOG(IDD_SETTINGS), + SIZED_DIALOG(IDD_LANG) }; + NControl::CPropertyPage *pagePinters[] = { &systemPage, &menuPage, &foldersPage, &editPage, &settingsPage, &langPage }; const int kNumPages = sizeof(langIDs) / sizeof(langIDs[0]); for (int i = 0; i < kNumPages; i++) { @@ -51,15 +123,23 @@ void OptionsDialog(HWND hwndOwner, HINSTANCE /* hInstance */) INT_PTR res = NControl::MyPropertySheet(pages, hwndOwner, LangString(IDS_OPTIONS, 0x03010000)); if (res != -1 && res != 0) { - if (langPage._langWasChanged) + if (langPage.LangWasChanged) { g_App._window.SetText(LangString(IDS_APP_TITLE, 0x03000000)); MyLoadMenu(); + g_App.ReloadToolbars(); + g_App.MoveSubWindows(); + } + /* + if (systemPage.WasChanged) + { + // probably it doesn't work, since image list is locked? + g_App.SysIconsWereChanged(); } + */ g_App.SetListSettings(); g_App.SetShowSystemMenu(); g_App.RefreshAllPanels(); - g_App.ReloadToolbars(); // ::PostMessage(hwndOwner, kLangWasChangedMessage, 0 , 0); } } diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp index 42c63266..5f072daf 100755 --- a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp @@ -2,9 +2,8 @@ #include "StdAfx.h" -#include "OverwriteDialog.h" - #include "Common/StringConvert.h" + #include "Windows/FileName.h" #include "Windows/Defs.h" #include "Windows/ResourceString.h" @@ -12,6 +11,7 @@ #include "Windows/PropVariantConversions.h" #include "FormatUtils.h" +#include "OverwriteDialog.h" // #include "../resource.h" @@ -36,6 +36,16 @@ static CIDLangPair kIDLangPairs[] = }; #endif +static const int kCurrentFileNameSizeLimit = 82; +static const int kCurrentFileNameSizeLimit2 = 30; + +void COverwriteDialog::ReduceString(UString &s) +{ + int size = _isBig ? kCurrentFileNameSizeLimit : kCurrentFileNameSizeLimit2; + if (s.Length() > size) + s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2); +} + void COverwriteDialog::SetFileInfoControl(int textID, int iconID, const NOverwriteDialog::CFileInfo &fileInfo) { @@ -47,19 +57,23 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID, #endif NumberToString(fileInfo.Size)); - UString reducedName; - const int kLineSize = 88; - for (int i = 0; i < fileInfo.Name.Length();) + const UString &fileName = fileInfo.Name; + int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR); + UString s1, s2; + if (slashPos >= 0) { - reducedName += fileInfo.Name.Mid(i, kLineSize); - reducedName += L" "; - i += kLineSize; + s1 = fileName.Left(slashPos + 1); + s2 = fileName.Mid(slashPos + 1); } - - UString fullString = reducedName; - fullString += L"\n"; + else + s2 = fileName; + ReduceString(s1); + ReduceString(s2); + + UString fullString = s1 + L'\n' + s2; + fullString += L'\n'; fullString += sizeString; - fullString += L"\n"; + fullString += L'\n'; if (fileInfo.TimeIsDefined) { @@ -101,10 +115,9 @@ bool COverwriteDialog::OnInit() LangSetWindowText(HWND(*this), 0x02000900); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif - SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, - IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo); - SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, - IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo); + SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo); + SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo); + NormalizePosition(); return CModalDialog::OnInit(); } diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.h b/CPP/7zip/UI/FileManager/OverwriteDialog.h index d206fb01..f760611e 100755 --- a/CPP/7zip/UI/FileManager/OverwriteDialog.h +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.h @@ -1,31 +1,68 @@ // OverwriteDialog.h -#ifndef __OVERWRITEDIALOG_H -#define __OVERWRITEDIALOG_H +#ifndef __OVERWRITE_DIALOG_H +#define __OVERWRITE_DIALOG_H + +#include "Common/Types.h" -#include "OverwriteDialogRes.h" #include "Windows/Control/Dialog.h" +#include "DialogSize.h" +#include "OverwriteDialogRes.h" + namespace NOverwriteDialog { struct CFileInfo { bool SizeIsDefined; - UINT64 Size; bool TimeIsDefined; + UInt64 Size; FILETIME Time; UString Name; + + void SetTime(const FILETIME *t) + { + if (t == 0) + TimeIsDefined = false; + else + { + TimeIsDefined = true; + Time = *t; + } + } + void SetSize(const UInt64 *size) + { + if (size == 0) + SizeIsDefined = false; + else + { + SizeIsDefined = true; + Size = *size; + } + } }; } class COverwriteDialog: public NWindows::NControl::CModalDialog { - void SetFileInfoControl(int textID, int iconID, - const NOverwriteDialog::CFileInfo &fileInfo); + bool _isBig; + + void SetFileInfoControl(int textID, int iconID, const NOverwriteDialog::CFileInfo &fileInfo); virtual bool OnInit(); bool OnButtonClicked(int buttonID, HWND buttonHWND); + void ReduceString(UString &s); + public: - INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_OVERWRITE, parent); } + INT_PTR Create(HWND parent = 0) + { + BIG_DIALOG_SIZE(280, 200); + #ifdef UNDER_CE + _isBig = isBig; + #else + _isBig = true; + #endif + return CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_OVERWRITE), parent); + } NOverwriteDialog::CFileInfo OldFileInfo; NOverwriteDialog::CFileInfo NewFileInfo; diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.rc b/CPP/7zip/UI/FileManager/OverwriteDialog.rc index 1cce0876..8961d28b 100755 --- a/CPP/7zip/UI/FileManager/OverwriteDialog.rc +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.rc @@ -1,44 +1,89 @@ #include "OverwriteDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 357 -#define ySize2 204 - -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 280 +#define yc 200 #undef iconSize -#define iconSize 20 +#define iconSize 24 + +#undef x +#undef fx +#undef fy +#define x (m + iconSize + m) +#define fx (xc - iconSize - m) +#define fy 50 + +#define bSizeBig 104 +#undef bx1 +#define bx1 (xs - m - bSizeBig) + +IDD_DIALOG_OVERWRITE MY_DIALOG +CAPTION "Confirm File Replace" +BEGIN + LTEXT "Destination folder already contains processed file.", IDC_STATIC_OVERWRITE_HEADER, m, 7, xc, 8 + LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, m, 28, xc, 8 + + ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, m, 44, iconSize, iconSize + LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, x, 44, fx, fy, SS_NOPREFIX + + LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, m, 98, xc, 8 + + ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, m, 114, iconSize, iconSize + LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, x, 114, fx, fy, SS_NOPREFIX + + PUSHBUTTON "&Yes", IDYES, bx3, by2, bxs, bys + PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, bx2, by2, bxs, bys + PUSHBUTTON "A&uto Rename", IDC_BUTTON_OVERWRITE_AUTO_RENAME, bx1, by2, bSizeBig, bys + PUSHBUTTON "&No", IDNO, bx3, by1, bxs, bys + PUSHBUTTON "No to A&ll", IDC_BUTTON_OVERWRITE_NO_TO_ALL, bx2, by1, bxs, bys + PUSHBUTTON "&Cancel", IDCANCEL, xs - m - bxs, by1, bxs, bys +END -#undef fiXPos -#undef fiXSize -#undef fiYSize -#define fiXPos (iconSize + 12) -#define fiXSize (xSize2 - fiXPos) -#define fiYSize 50 -#define b1YPos (ySize - marg - bYSize) -#define b2YPos (b1YPos - bYSize - 10) +#ifdef UNDER_CE -IDD_DIALOG_OVERWRITE DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +#undef m +#undef xc +#undef yc + +#define m 4 +#define xc 152 +#define yc 144 + +#undef fy +#define fy 40 + +#undef bxs +#define bxs 48 + +#undef bx1 + +#define bx1 (xs - m - bxs) + +IDD_DIALOG_OVERWRITE_2 MY_DIALOG CAPTION "Confirm File Replace" -MY_FONT BEGIN - LTEXT "Destination folder already contains processed file.", IDC_STATIC_OVERWRITE_HEADER, marg, 7, xSize2, 8 - LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, marg, 28, xSize2, 8 - ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, marg, 44, iconSize, iconSize - LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, fiXPos, 44, fiXSize, fiYSize, SS_NOPREFIX - LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, marg, 98, xSize2, 8 - ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, marg, 114, iconSize, iconSize - LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, fiXPos, 114, fiXSize, fiYSize, SS_NOPREFIX - PUSHBUTTON "&Yes", IDYES, 78, b2YPos, bXSize, bYSize - PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, 152, b2YPos, bXSize, bYSize - PUSHBUTTON "&No", IDNO, 226, b2YPos, bXSize, bYSize - PUSHBUTTON "No to A&ll", IDC_BUTTON_OVERWRITE_NO_TO_ALL, 300, b2YPos, bXSize, bYSize - PUSHBUTTON "A&uto Rename", IDC_BUTTON_OVERWRITE_AUTO_RENAME, 181, b1YPos, 109, bYSize - PUSHBUTTON "&Cancel", IDCANCEL, 300, b1YPos, bXSize, bYSize + LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, m, m, xc, 8 + + ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, m, 20, iconSize, iconSize + LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, x, 20, fx, fy, SS_NOPREFIX + + LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, m, 60, xc, 8 + + ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, m, 72, iconSize, iconSize + LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, x, 72, fx, fy, SS_NOPREFIX + + PUSHBUTTON "&Yes", IDYES, bx3, by2, bxs, bys + PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, bx2, by2, bxs, bys + PUSHBUTTON "A&uto Rename", IDC_BUTTON_OVERWRITE_AUTO_RENAME, bx1, by2, bxs, bys + PUSHBUTTON "&No", IDNO, bx3, by1, bxs, bys + PUSHBUTTON "No to A&ll", IDC_BUTTON_OVERWRITE_NO_TO_ALL, bx2, by1, bxs, bys + PUSHBUTTON "&Cancel", IDCANCEL, bx1, by1, bxs, bys END +#endif + STRINGTABLE BEGIN diff --git a/CPP/7zip/UI/FileManager/OverwriteDialogRes.h b/CPP/7zip/UI/FileManager/OverwriteDialogRes.h index 66710f84..3bc6900d 100755 --- a/CPP/7zip/UI/FileManager/OverwriteDialogRes.h +++ b/CPP/7zip/UI/FileManager/OverwriteDialogRes.h @@ -1,8 +1,9 @@ +#define IDD_DIALOG_OVERWRITE 502 +#define IDD_DIALOG_OVERWRITE_2 602 + #define IDS_FILE_MODIFIED 600 #define IDS_FILE_SIZE 601 -#define IDD_DIALOG_OVERWRITE 502 - #define IDC_STATIC_OVERWRITE_HEADER 1000 #define IDC_STATIC_OVERWRITE_QUESTION_BEGIN 1001 diff --git a/CPP/7zip/UI/FileManager/Panel.cpp b/CPP/7zip/UI/FileManager/Panel.cpp index 9255b117..3988f1f3 100755 --- a/CPP/7zip/UI/FileManager/Panel.cpp +++ b/CPP/7zip/UI/FileManager/Panel.cpp @@ -118,6 +118,9 @@ LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) case kRefreshStatusBar: OnRefreshStatusBar(); return 0; + case kRefreshHeaderComboBox: + LoadFullPathAndShow(); + return 0; case WM_TIMER: OnTimer(); return 0; @@ -184,6 +187,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; switch(wParam) { + /* case VK_RETURN: { if (shift && !alt && !ctrl) @@ -193,6 +197,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) } break; } + */ case VK_NEXT: { if (ctrl && !alt && !shift) @@ -210,6 +215,17 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) } } } + #ifdef UNDER_CE + else if (message == WM_KEYUP) + { + if (wParam == VK_F2) // it's VK_TSOFT2 + { + // Activate Menu + ::PostMessage(g_HWND, WM_SYSCOMMAND, SC_KEYMENU, 0); + return 0; + } + } + #endif else if (message == WM_SETFOCUS) { _panel->_lastFocusedIsList = true; @@ -310,15 +326,6 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) return CallWindowProc(_origWindowProc, *this, message, wParam, lParam); } -static HIMAGELIST GetSysImageList(bool smallIcons) -{ - SHFILEINFO shellInfo; - return (HIMAGELIST)SHGetFileInfo(TEXT(""), - FILE_ATTRIBUTE_NORMAL |FILE_ATTRIBUTE_DIRECTORY, - &shellInfo, sizeof(shellInfo), - SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON)); -} - bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) { // _virtualMode = false; @@ -356,7 +363,9 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL)) return false; + #ifndef UNDER_CE _listView.SetUnicodeFormat(true); + #endif _listView.SetUserDataLongPtr(LONG_PTR(&_listView)); _listView._panel = this; @@ -398,7 +407,9 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) // {VIEW_NEWFOLDER, kCreateFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0}, }; + #ifndef UNDER_CE if (g_ComCtl32Version >= MAKELONG(71, 4)) + #endif { icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES; @@ -409,7 +420,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) NULL, WS_VISIBLE | WS_BORDER | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER - | CCS_NOPARENTALIGN + // | CCS_NOPARENTALIGN | CCS_TOP | RBS_VARHEIGHT | RBS_BANDBORDERS @@ -437,17 +448,27 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]), 0, 0, 0, 0, sizeof (TBBUTTON))); + #ifndef UNDER_CE + // Load ComboBoxEx class icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_USEREX_CLASSES; InitCommonControlsEx(&icex); + #endif - _headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL, + _headerComboBox.CreateEx(0, + #ifdef UNDER_CE + WC_COMBOBOXW + #else + WC_COMBOBOXEXW + #endif + , NULL, WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL, 0, 0, 100, 520, ((_headerReBar == 0) ? HWND(*this) : _headerToolBar), (HMENU)(UINT_PTR)(_comboBoxID), g_hInstance, NULL); - _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0); + #ifndef UNDER_CE + _headerComboBox.SetUnicodeFormat(true); _headerComboBox.SetImageList(GetSysImageList(true)); @@ -475,6 +496,8 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) _comboBoxEdit._origWindowProc = (WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc)); + #endif + if (_headerReBar) { REBARINFO rbi; @@ -491,7 +514,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) REBARBANDINFO rbBand; rbBand.cbSize = sizeof(REBARBANDINFO); // Required - rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; + rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE; rbBand.fStyle = RBBS_NOGRIPPER; rbBand.cxMinChild = size.cx; rbBand.cyMinChild = size.cy; @@ -540,6 +563,8 @@ void CPanel::OnDestroy() void CPanel::ChangeWindowSize(int xSize, int ySize) { + if ((HWND)*this == 0) + return; int kHeaderSize; int kStatusBarSize; // int kStatusBar2Size; @@ -577,6 +602,8 @@ void CPanel::ChangeWindowSize(int xSize, int ySize) bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize) { + if ((HWND)*this == 0) + return true; if (_headerReBar) _headerReBar.Move(0, 0, xSize, 0); ChangeWindowSize(xSize, ySize); @@ -611,7 +638,7 @@ bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result) return OnNotifyList(header, result); else if (::GetParent(header->hwndFrom) == _listView && header->code == NM_RCLICK) - return OnRightClick((LPNMITEMACTIVATE)header, result); + return OnRightClick((MY_NMLISTVIEW_NMITEMACTIVATE *)header, result); return false; } @@ -647,15 +674,11 @@ void CPanel::MessageBox(LPCWSTR message) { MessageBox(message, L"7-Zip"); } void CPanel::MessageBoxMyError(LPCWSTR message) { MessageBox(message, L"Error"); } + + void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption) { - UString message; - if (errorCode == E_OUTOFMEMORY) - message = LangString(IDS_MEM_ERROR, 0x0200060B); - else - if (!NError::MyFormatMessage(errorCode, message)) - message = L"Error"; - MessageBox(message, caption); + MessageBox(HResultToMessage(errorCode), caption); } void CPanel::MessageBoxError(HRESULT errorCode) @@ -791,26 +814,19 @@ void CPanel::AddToArchive() UString destCurDirPrefix = _currentFolderPrefix; if (IsFSDrivesFolder()) { - destCurDirPrefix = L"C:\\"; + destCurDirPrefix = ROOT_FS_FOLDER; if (!IsDeviceDrivesPrefix()) curPrefix.Empty(); } for (int i = 0; i < indices.Size(); i++) - { - int index = indices[i]; - names.Add(curPrefix + GetItemRelPath(index)); - } - const UString archiveName = CreateArchiveName( - names.Front(), (names.Size() > 1), false); - + names.Add(curPrefix + GetItemRelPath(indices[i])); + const UString archiveName = CreateArchiveName(names.Front(), (names.Size() > 1), false); HRESULT res = CompressFiles(destCurDirPrefix, archiveName, L"", names, false, true, false); if (res != S_OK) { - if (_currentFolderPrefix.Length() >= MAX_PATH) + if (destCurDirPrefix.Length() >= MAX_PATH) MessageBoxErrorLang(IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER, 0x03020A01); - else - MessageBoxError(res); } // KillSelection(); } @@ -866,40 +882,45 @@ void CPanel::ExtractArchives() ::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(WCHAR_PATH_SEPARATOR), true); } -struct CThreadTest +static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) { + wchar_t sz[32]; + s += LangString(resourceID, langID); + s += L' '; + ConvertUInt64ToString(value, sz); + s += sz; + s += L'\n'; +} + +class CThreadTest: public CProgressThreadVirt +{ + HRESULT ProcessVirt(); +public: CRecordVector<UInt32> Indices; CExtractCallbackImp *ExtractCallbackSpec; CMyComPtr<IFolderArchiveExtractCallback> ExtractCallback; CMyComPtr<IArchiveFolder> ArchiveFolder; - HRESULT Result; +}; - void Test() - { - ExtractCallbackSpec->ProgressDialog.WaitCreating(); - Result = ArchiveFolder->Extract(&Indices[0], Indices.Size(), - NExtract::NPathMode::kFullPathnames, NExtract::NOverwriteMode::kAskBefore, - NULL, BoolToInt(true), ExtractCallback); - ExtractCallbackSpec->ProgressDialog.MyClose(); - } - - static THREAD_FUNC_DECL MyThreadFunction(void *param) +HRESULT CThreadTest::ProcessVirt() +{ + RINOK(ArchiveFolder->Extract(&Indices[0], Indices.Size(), + NExtract::NPathMode::kFullPathnames, NExtract::NOverwriteMode::kAskBefore, + NULL, BoolToInt(true), ExtractCallback)); + if (ExtractCallbackSpec->IsOK()) { - ((CThreadTest*)param)->Test(); - return 0; + UString s; + AddValuePair(IDS_FOLDERS_COLON, 0x02000321, ExtractCallbackSpec->NumFolders, s); + AddValuePair(IDS_FILES_COLON, 0x02000320, ExtractCallbackSpec->NumFiles, s); + // AddSizePair(IDS_SIZE_COLON, 0x02000322, Stat.UnpackSize, s); + // AddSizePair(IDS_COMPRESSED_COLON, 0x02000323, Stat.PackSize, s); + s += L'\n'; + s += LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608); + OkMessage = s; } + return S_OK; }; -static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) -{ - wchar_t sz[32]; - s += LangString(resourceID, langID); - s += L" "; - ConvertUInt64ToString(value, sz); - s += sz; - s += L"\n"; -} - /* static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) { @@ -912,7 +933,7 @@ static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s s += L" ("; s += sz; s += L" MB)"; - s += L"\n"; + s += L'\n'; } */ @@ -930,8 +951,7 @@ void CPanel::TestArchives() extracter.ArchiveFolder = archiveFolder; extracter.ExtractCallbackSpec = new CExtractCallbackImp; extracter.ExtractCallback = extracter.ExtractCallbackSpec; - extracter.ExtractCallbackSpec->ParentWindow = GetParent(); - extracter.ExtractCallbackSpec->ShowMessages = true; + extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog; if (indices.IsEmpty()) return; @@ -941,35 +961,17 @@ void CPanel::TestArchives() UString title = LangString(IDS_PROGRESS_TESTING, 0x02000F90); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); - extracter.ExtractCallbackSpec->ProgressDialog.CompressingMode = false; - extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent(); - extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle; - extracter.ExtractCallbackSpec->ProgressDialog.MainAddTitle = title + L" "; + extracter.ProgressDialog.CompressingMode = false; + extracter.ProgressDialog.MainWindow = GetParent(); + extracter.ProgressDialog.MainTitle = progressWindowTitle; + extracter.ProgressDialog.MainAddTitle = title + L" "; extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore; extracter.ExtractCallbackSpec->Init(); - NWindows::CThread extractThread; - if (extractThread.Create(CThreadTest::MyThreadFunction, &extracter) != S_OK) + if (extracter.Create(title, GetParent()) != S_OK) return; - extracter.ExtractCallbackSpec->StartProgressDialog(title); - if (extracter.ExtractCallbackSpec->Messages.IsEmpty() && extracter.Result == S_OK) - { - UString s; - AddValuePair(IDS_FOLDERS_COLON, 0x02000321, extracter.ExtractCallbackSpec->NumFolders, s); - AddValuePair(IDS_FILES_COLON, 0x02000320, extracter.ExtractCallbackSpec->NumFiles, s); - // AddSizePair(IDS_SIZE_COLON, 0x02000322, extracter.Stat.UnpackSize, s); - // AddSizePair(IDS_COMPRESSED_COLON, 0x02000323, extracter.Stat.PackSize, s); - s += L"\n"; - s += LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608); - MessageBoxInfo(s, LangString(IDS_PROGRESS_TESTING, 0x02000F90)); - } - else - { - if (extracter.Result != S_OK && extracter.Result != E_ABORT) - MessageBoxError(extracter.Result, L"Testing Error"); - } } RefreshTitleAlways(); return; @@ -986,4 +988,3 @@ void CPanel::TestArchives() return; ::TestArchives(paths); } - diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h index ed157634..ead12d2e 100755 --- a/CPP/7zip/UI/FileManager/Panel.h +++ b/CPP/7zip/UI/FileManager/Panel.h @@ -3,6 +3,8 @@ #ifndef __PANEL_H #define __PANEL_H +#include "../../../../C/Alloc.h" + #include "Common/MyCom.h" #include "Windows/DLL.h" @@ -23,6 +25,7 @@ #include "AppState.h" #include "IFolder.h" #include "MyCom2.h" +#include "ProgressDialog2.h" #include "SysIconUtils.h" const int kParentFolderID = 100; @@ -31,6 +34,12 @@ const int kToolbarStartID = 2000; const int kParentIndex = -1; +#ifdef UNDER_CE +#define ROOT_FS_FOLDER L"\\" +#else +#define ROOT_FS_FOLDER L"C:\\\\" +#endif + struct CPanelCallback { virtual void OnTab() = 0; @@ -118,11 +127,12 @@ struct CFolderLink: public CTempFileInfo enum MyMessages { - kShiftSelectMessage = WM_USER + 1, + kShiftSelectMessage = WM_USER + 1, kReLoadMessage, kSetFocusToListView, kOpenItemChanged, - kRefreshStatusBar + kRefreshStatusBar, + kRefreshHeaderComboBox }; UString GetFolderPath(IFolderFolder * folder); @@ -163,6 +173,12 @@ struct CSelectedState CSelectedState(): FocusedItem(-1), SelectFocused(false) {} }; +#ifdef UNDER_CE +#define MY_NMLISTVIEW_NMITEMACTIVATE NMLISTVIEW +#else +#define MY_NMLISTVIEW_NMITEMACTIVATE NMITEMACTIVATE +#endif + class CPanel: public NWindows::NControl::CWindow2 { CExtToIconMap _extToIconMap; @@ -183,14 +199,20 @@ class CPanel: public NWindows::NControl::CWindow2 bool OnComboBoxCommand(UINT code, LPARAM param, LRESULT &result); + #ifndef UNDER_CE + LRESULT OnNotifyComboBoxEnter(const UString &s); bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result); #ifndef _UNICODE bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result); #endif + + #endif + bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result); bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result); void OnItemChanged(NMLISTVIEW *item); + void OnNotifyActivateItems(); bool OnNotifyList(LPNMHDR lParam, LRESULT &result); void OnDrag(LPNMLISTVIEW nmListView); bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result); @@ -203,6 +225,8 @@ public: HWND _mainWindow; CPanelCallback *_panelCallback; + void SysIconsWereChanged() { _extToIconMap.Clear(); } + void DeleteItems(bool toRecycleBin); void DeleteItemsInternal(CRecordVector<UInt32> &indices); void CreateFolder(); @@ -242,7 +266,13 @@ private: public: NWindows::NControl::CReBar _headerReBar; NWindows::NControl::CToolBar _headerToolBar; - NWindows::NControl::CComboBoxEx _headerComboBox; + NWindows::NControl:: + #ifdef UNDER_CE + CComboBox + #else + CComboBoxEx + #endif + _headerComboBox; UStringVector ComboBoxPaths; // CMyComboBox _headerComboBox; CMyComboBoxEdit _comboBoxEdit; @@ -383,8 +413,9 @@ public: void Release(); ~CPanel(); - void OnLeftClick(LPNMITEMACTIVATE itemActivate); - bool OnRightClick(LPNMITEMACTIVATE itemActivate, LRESULT &result); + void OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate); + bool OnRightClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate, LRESULT &result); + void ShowColumnsContextMenu(int x, int y); void OnTimer(); void OnReload(); @@ -494,6 +525,8 @@ public: void MessageBoxLastError(LPCWSTR caption); void MessageBoxLastError(); + void MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID, UInt32 langID); + void MessageBoxErrorLang(UINT resourceID, UInt32 langID); void OpenFocusedItemAsInternal(); @@ -522,10 +555,11 @@ public: void ChangeComment(); void SetListViewMode(UInt32 index); - UInt32 GetListViewMode() const { return _ListViewMode; }; + UInt32 GetListViewMode() const { return _ListViewMode; } + PROPID GetSortID() const { return _sortID; } void ChangeFlatMode(); - bool GetFlatMode() const { return _flatMode; }; + bool GetFlatMode() const { return _flatMode; } void RefreshStatusBar(); void OnRefreshStatusBar(); @@ -572,4 +606,20 @@ public: UString GetItemsInfoString(const CRecordVector<UInt32> &indices); }; +class CMyBuffer +{ + void *_data; +public: + CMyBuffer(): _data(0) {} + operator void *() { return _data; } + bool Allocate(size_t size) + { + if (_data != 0) + return false; + _data = ::MidAlloc(size); + return _data != 0; + } + ~CMyBuffer() { ::MidFree(_data); } +}; + #endif diff --git a/CPP/7zip/UI/FileManager/PanelCopy.cpp b/CPP/7zip/UI/FileManager/PanelCopy.cpp index 8ad3d4c9..8c27ef2f 100755 --- a/CPP/7zip/UI/FileManager/PanelCopy.cpp +++ b/CPP/7zip/UI/FileManager/PanelCopy.cpp @@ -13,8 +13,10 @@ using namespace NWindows; -struct CThreadExtractInArchive2 +class CPanelCopyThread: public CProgressThreadVirt { + HRESULT ProcessVirt(); +public: CMyComPtr<IFolderOperations> FolderOperations; CRecordVector<UInt32> Indices; UString DestPath; @@ -23,26 +25,17 @@ struct CThreadExtractInArchive2 HRESULT Result; bool MoveMode; - CThreadExtractInArchive2(): MoveMode(false) {} - - DWORD Extract() - { - ExtractCallbackSpec->ProgressDialog.WaitCreating(); - if (MoveMode) - Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(), - DestPath, ExtractCallback); - else - Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(), - DestPath, ExtractCallback); - ExtractCallbackSpec->ProgressDialog.MyClose(); - return 0; - } - - static THREAD_FUNC_DECL MyThreadFunction(void *param) - { - return ((CThreadExtractInArchive2 *)param)->Extract(); - } + CPanelCopyThread(): MoveMode(false), Result(E_FAIL) {} }; + +HRESULT CPanelCopyThread::ProcessVirt() +{ + if (MoveMode) + Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(), DestPath, ExtractCallback); + else + Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(), DestPath, ExtractCallback); + return Result; +} HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &folder, bool moveMode, bool showErrorMessages, UStringVector *messages, @@ -61,22 +54,22 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold HRESULT res; { - CThreadExtractInArchive2 extracter; + CPanelCopyThread extracter; + extracter.ExtractCallbackSpec = new CExtractCallbackImp; extracter.ExtractCallback = extracter.ExtractCallbackSpec; - extracter.ExtractCallbackSpec->ParentWindow = GetParent(); - extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages; - extracter.ExtractCallbackSpec->ProgressDialog.CompressingMode = false; + extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog; + extracter.ProgressDialog.CompressingMode = false; UString title = moveMode ? LangString(IDS_MOVING, 0x03020206): LangString(IDS_COPYING, 0x03020205); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); - extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent(); - extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle; - extracter.ExtractCallbackSpec->ProgressDialog.MainAddTitle = title + L" "; + extracter.ProgressDialog.MainWindow = GetParent(); + extracter.ProgressDialog.MainTitle = progressWindowTitle; + extracter.ProgressDialog.MainAddTitle = title + L" "; extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore; extracter.ExtractCallbackSpec->Init(); @@ -88,15 +81,13 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold extracter.ExtractCallbackSpec->PasswordIsDefined = usePassword; extracter.ExtractCallbackSpec->Password = password; - NWindows::CThread extractThread; - RINOK(extractThread.Create(CThreadExtractInArchive2::MyThreadFunction, &extracter)); - extracter.ExtractCallbackSpec->StartProgressDialog(title); + RINOK(extracter.Create(title, GetParent())); if (messages != 0) - *messages = extracter.ExtractCallbackSpec->Messages; + *messages = extracter.ProgressDialog.Sync.Messages; res = extracter.Result; - if (res == S_OK && extracter.ExtractCallbackSpec->Messages.IsEmpty()) + if (res == S_OK && extracter.ExtractCallbackSpec->IsOK()) { usePassword = extracter.ExtractCallbackSpec->PasswordIsDefined; password = extracter.ExtractCallbackSpec->Password; @@ -113,57 +104,55 @@ struct CThreadUpdate UString FolderPrefix; UStringVector FileNames; CRecordVector<const wchar_t *> FileNamePointers; + CProgressDialog ProgressDialog; CMyComPtr<IFolderArchiveUpdateCallback> UpdateCallback; CUpdateCallback100Imp *UpdateCallbackSpec; HRESULT Result; - DWORD Process() + void Process() { - UpdateCallbackSpec->ProgressDialog.WaitCreating(); - Result = FolderOperations->CopyFrom( + try + { + CProgressCloser closer(ProgressDialog); + Result = FolderOperations->CopyFrom( FolderPrefix, &FileNamePointers.Front(), FileNamePointers.Size(), UpdateCallback); - UpdateCallbackSpec->ProgressDialog.MyClose(); - return 0; + } + catch(...) { Result = E_FAIL; } } - static THREAD_FUNC_DECL MyThreadFunction(void *param) { - return ((CThreadUpdate *)param)->Process(); + ((CThreadUpdate *)param)->Process(); + return 0; } }; - HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &filePaths, bool showErrorMessages, UStringVector *messages) { CMyComPtr<IFolderOperations> folderOperations; - if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) - { - UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); - if (showErrorMessages) - MessageBox(errorMessage); - else if (messages != 0) - messages->Add(errorMessage); - return E_FAIL; - } - + _folder.QueryInterface(IID_IFolderOperations, &folderOperations); HRESULT res; + if (!folderOperations) + res = E_NOINTERFACE; + else { CThreadUpdate updater; updater.UpdateCallbackSpec = new CUpdateCallback100Imp; updater.UpdateCallback = updater.UpdateCallbackSpec; + updater.UpdateCallbackSpec->ProgressDialog = &updater.ProgressDialog; + UString title = LangString(IDS_COPYING, 0x03020205); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); - updater.UpdateCallbackSpec->ProgressDialog.MainWindow = GetParent(); - updater.UpdateCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle; - updater.UpdateCallbackSpec->ProgressDialog.MainAddTitle = title + UString(L" "); + updater.ProgressDialog.MainWindow = GetParent(); + updater.ProgressDialog.MainTitle = progressWindowTitle; + updater.ProgressDialog.MainAddTitle = title + UString(L" "); - updater.UpdateCallbackSpec->Init((HWND)*this, false, L""); + updater.UpdateCallbackSpec->Init(false, L""); updater.FolderOperations = folderOperations; updater.FolderPrefix = folderPrefix; updater.FileNames.Reserve(filePaths.Size()); @@ -176,13 +165,24 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP NWindows::CThread thread; RINOK(thread.Create(CThreadUpdate::MyThreadFunction, &updater)); - updater.UpdateCallbackSpec->StartProgressDialog(title); + updater.ProgressDialog.Create(title, thread, GetParent()); if (messages != 0) - *messages = updater.UpdateCallbackSpec->Messages; + *messages = updater.ProgressDialog.Sync.Messages; res = updater.Result; } + + if (res == E_NOINTERFACE) + { + UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + if (showErrorMessages) + MessageBox(errorMessage); + else if (messages != 0) + messages->Add(errorMessage); + return E_ABORT; + } + RefreshTitleAlways(); return res; } @@ -219,10 +219,9 @@ void CPanel::CopyFromAsk(const UStringVector &filePaths) message += L"\n\'"; message += _currentFolderPrefix; message += L"\' ?"; - int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION | MB_SYSTEMMODAL); + int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION); if (res != IDYES) return; CopyFromNoAsk(filePaths); } - diff --git a/CPP/7zip/UI/FileManager/PanelCrc.cpp b/CPP/7zip/UI/FileManager/PanelCrc.cpp index aaa645cf..6b00a9b5 100755 --- a/CPP/7zip/UI/FileManager/PanelCrc.cpp +++ b/CPP/7zip/UI/FileManager/PanelCrc.cpp @@ -3,19 +3,15 @@ #include "StdAfx.h" #include "../../../../C/7zCrc.h" -#include "../../../../C/Alloc.h" #include "../../../../C/Sha256.h" #include "Common/IntToString.h" -#include "Windows/Error.h" #include "Windows/FileFind.h" #include "Windows/FileIO.h" #include "Windows/FileName.h" -#include "Windows/Thread.h" #include "OverwriteDialogRes.h" -#include "ProgressDialog2.h" #include "App.h" #include "FormatUtils.h" @@ -27,7 +23,6 @@ using namespace NWindows; using namespace NFile; -using namespace NName; static const UInt32 kBufSize = (1 << 15); @@ -40,7 +35,7 @@ struct CDirEnumerator CObjectVector<NFind::CEnumeratorW> Enumerators; UStringVector Prefixes; int Index; - bool GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath, DWORD &errorCode); + HRESULT GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath); void Init(); CDirEnumerator(): FlatMode(false) {}; @@ -53,7 +48,13 @@ void CDirEnumerator::Init() Index = 0; } -bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath, DWORD &errorCode) +static HRESULT GetNormalizedError() +{ + HRESULT errorCode = GetLastError(); + return (errorCode == 0) ? E_FAIL : errorCode; +} + +HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath) { filled = false; for (;;) @@ -61,7 +62,7 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr if (Enumerators.IsEmpty()) { if (Index >= FileNames.Size()) - return true; + return S_OK; const UString &path = FileNames[Index]; int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); resPath.Empty(); @@ -80,9 +81,9 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr #endif if (!fileInfo.Find(BasePrefix + path)) { - errorCode = ::GetLastError(); + WRes errorCode = GetNormalizedError(); resPath = path; - return false; + return errorCode; } Index++; break; @@ -90,9 +91,9 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr bool found; if (!Enumerators.Back().Next(fileInfo, found)) { - errorCode = ::GetLastError(); + HRESULT errorCode = GetNormalizedError(); resPath = Prefixes.Back(); - return false; + return errorCode; } if (found) { @@ -105,36 +106,26 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr resPath += fileInfo.Name; if (!FlatMode && fileInfo.IsDir()) { - UString prefix = resPath + (UString)(wchar_t)kDirDelimiter; - Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)kAnyStringWildcard)); + UString prefix = resPath + WCHAR_PATH_SEPARATOR; + Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)NName::kAnyStringWildcard)); Prefixes.Add(prefix); } filled = true; - return true; + return S_OK; } -struct CThreadCrc +static void ConvertByteToHex(unsigned value, wchar_t *s) { - class CMyBuffer + for (int i = 0; i < 2; i++) { - void *_data; - public: - CMyBuffer(): _data(0) {} - operator void *() { return _data; } - bool Allocate(size_t size) - { - if (_data != 0) - return false; - _data = ::MidAlloc(size); - return _data != 0; - } - ~CMyBuffer() { ::MidFree(_data); } - }; - - CProgressDialog *ProgressDialog; + unsigned t = value & 0xF; + value >>= 4; + s[1 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10))); + } +} - CDirEnumerator DirEnumerator; - +class CThreadCrc: public CProgressThreadVirt +{ UInt64 NumFilesScan; UInt64 NumFiles; UInt64 NumFolders; @@ -143,155 +134,176 @@ struct CThreadCrc Byte Sha256Sum[SHA256_DIGEST_SIZE]; UInt32 DataNameCrcSum; - HRESULT Result; - DWORD ErrorCode; - UString ErrorPath; - UString Error; - bool ThereIsError; + UString GetResultMessage() const; + HRESULT ProcessVirt(); +public: + CDirEnumerator Enumerator; + +}; + +UString CThreadCrc::GetResultMessage() const +{ + UString s; + wchar_t sz[32]; + + s += LangString(IDS_FILES_COLON, 0x02000320); + s += L' '; + ConvertUInt64ToString(NumFiles, sz); + s += sz; + s += L'\n'; + + s += LangString(IDS_FOLDERS_COLON, 0x02000321); + s += L' '; + ConvertUInt64ToString(NumFolders, sz); + s += sz; + s += L'\n'; - void Process2() + s += LangString(IDS_SIZE_COLON, 0x02000322); + s += L' '; + ConvertUInt64ToString(DataSize, sz); + s += MyFormatNew(IDS_FILE_SIZE, 0x02000982, sz); + s += L'\n'; + + s += LangString(IDS_CHECKSUM_CRC_DATA, 0x03020721); + s += L' '; + ConvertUInt32ToHex(DataCrcSum, sz); + s += sz; + s += L'\n'; + + s += LangString(IDS_CHECKSUM_CRC_DATA_NAMES, 0x03020722); + s += L' '; + ConvertUInt32ToHex(DataNameCrcSum, sz); + s += sz; + s += L'\n'; + + if (NumFiles == 1 && NumFilesScan == 1) { - DataSize = NumFolders = NumFiles = NumFilesScan = DataCrcSum = DataNameCrcSum = 0; - memset(Sha256Sum, 0, SHA256_DIGEST_SIZE); - ProgressDialog->WaitCreating(); - - CMyBuffer bufferObject; - if (!bufferObject.Allocate(kBufSize)) + s += L"SHA-256: "; + for (int i = 0; i < SHA256_DIGEST_SIZE; i++) { - Error = L"Can not allocate memory"; - ThereIsError = true; - return; + wchar_t s2[4]; + ConvertByteToHex(Sha256Sum[i], s2); + s2[2] = 0; + s += s2; } - Byte *buffer = (Byte *)(void *)bufferObject; - - UInt64 totalSize = 0; - - DirEnumerator.Init(); + } + return s; +} - UString scanningStr = LangString(IDS_SCANNING, 0x03020800); - scanningStr += L" "; +HRESULT CThreadCrc::ProcessVirt() +{ + DataSize = NumFolders = NumFiles = NumFilesScan = DataCrcSum = DataNameCrcSum = 0; + memset(Sha256Sum, 0, SHA256_DIGEST_SIZE); + // ProgressDialog.WaitCreating(); + + CMyBuffer bufferObject; + if (!bufferObject.Allocate(kBufSize)) + return E_OUTOFMEMORY; + Byte *buffer = (Byte *)(void *)bufferObject; + + UInt64 totalSize = 0; + + Enumerator.Init(); + + UString scanningStr = LangString(IDS_SCANNING, 0x03020800); + scanningStr += L' '; + + CProgressSync &sync = ProgressDialog.Sync; - for (;;) + for (;;) + { + NFind::CFileInfoW fileInfo; + bool filled; + UString resPath; + HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath); + if (errorCode != 0) { - NFile::NFind::CFileInfoW fileInfo; - bool filled; - UString resPath; - if (!DirEnumerator.GetNextFile(fileInfo, filled, resPath, ErrorCode)) - { - ThereIsError = true; - ErrorPath = resPath; - return; - } - if (!filled) - break; - if (!fileInfo.IsDir()) - { - totalSize += fileInfo.Size; - NumFilesScan++; - } - ProgressDialog->ProgressSynch.SetCurrentFileName(scanningStr + resPath); - ProgressDialog->ProgressSynch.SetProgress(totalSize, 0); - Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(0); - if (Result != S_OK) - return; + ErrorPath1 = resPath; + return errorCode; } - ProgressDialog->ProgressSynch.SetNumFilesTotal(NumFilesScan); - ProgressDialog->ProgressSynch.SetProgress(totalSize, 0); - - DirEnumerator.Init(); - - for (;;) + if (!filled) + break; + if (!fileInfo.IsDir()) + { + totalSize += fileInfo.Size; + NumFilesScan++; + } + sync.SetCurrentFileName(scanningStr + resPath); + sync.SetProgress(totalSize, 0); + RINOK(sync.SetPosAndCheckPaused(0)); + } + sync.SetNumFilesTotal(NumFilesScan); + sync.SetProgress(totalSize, 0); + + Enumerator.Init(); + + for (;;) + { + NFind::CFileInfoW fileInfo; + bool filled; + UString resPath; + HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath); + if (errorCode != 0) { - NFile::NFind::CFileInfoW fileInfo; - bool filled; - UString resPath; - if (!DirEnumerator.GetNextFile(fileInfo, filled, resPath, ErrorCode)) + ErrorPath1 = resPath; + return errorCode; + } + if (!filled) + break; + + UInt32 crc = CRC_INIT_VAL; + CSha256 sha256; + Sha256_Init(&sha256); + + if (fileInfo.IsDir()) + NumFolders++; + else + { + NIO::CInFile inFile; + if (!inFile.Open(Enumerator.BasePrefix + resPath)) { - ThereIsError = true; - ErrorPath = resPath; - return; + errorCode = GetNormalizedError(); + ErrorPath1 = resPath; + return errorCode; } - if (!filled) - break; - - UInt32 crc = CRC_INIT_VAL; - CSha256 sha256; - Sha256_Init(&sha256); - - if (fileInfo.IsDir()) - NumFolders++; - else + sync.SetCurrentFileName(resPath); + sync.SetNumFilesCur(NumFiles); + NumFiles++; + for (;;) { - NFile::NIO::CInFile inFile; - if (!inFile.Open(DirEnumerator.BasePrefix + resPath)) + UInt32 processedSize; + if (!inFile.Read(buffer, kBufSize, processedSize)) { - ErrorCode = ::GetLastError(); - ThereIsError = true; - ErrorPath = resPath; - return; + errorCode = GetNormalizedError(); + ErrorPath1 = resPath; + return errorCode; } - ProgressDialog->ProgressSynch.SetCurrentFileName(resPath); - ProgressDialog->ProgressSynch.SetNumFilesCur(NumFiles); - NumFiles++; - for (;;) - { - UInt32 processedSize; - if (!inFile.Read(buffer, kBufSize, processedSize)) - { - ErrorCode = ::GetLastError(); - ThereIsError = true; - ErrorPath = resPath; - return; - } - if (processedSize == 0) - break; - crc = CrcUpdate(crc, buffer, processedSize); - if (NumFilesScan == 1) - Sha256_Update(&sha256, buffer, processedSize); - - DataSize += processedSize; - Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize); - if (Result != S_OK) - return; - } - DataCrcSum += CRC_GET_DIGEST(crc); + if (processedSize == 0) + break; + crc = CrcUpdate(crc, buffer, processedSize); if (NumFilesScan == 1) - Sha256_Final(&sha256, Sha256Sum); - } - for (int i = 0; i < resPath.Length(); i++) - { - wchar_t c = resPath[i]; - crc = CRC_UPDATE_BYTE(crc, ((Byte)(c & 0xFF))); - crc = CRC_UPDATE_BYTE(crc, ((Byte)((c >> 8) & 0xFF))); + Sha256_Update(&sha256, buffer, processedSize); + + DataSize += processedSize; + RINOK(sync.SetPosAndCheckPaused(DataSize)); } - DataNameCrcSum += CRC_GET_DIGEST(crc); - Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize); - if (Result != S_OK) - return; + DataCrcSum += CRC_GET_DIGEST(crc); + if (NumFilesScan == 1) + Sha256_Final(&sha256, Sha256Sum); } + for (int i = 0; i < resPath.Length(); i++) + { + wchar_t c = resPath[i]; + crc = CRC_UPDATE_BYTE(crc, ((Byte)(c & 0xFF))); + crc = CRC_UPDATE_BYTE(crc, ((Byte)((c >> 8) & 0xFF))); + } + DataNameCrcSum += CRC_GET_DIGEST(crc); + RINOK(sync.SetPosAndCheckPaused(DataSize)); } - DWORD Process() - { - try { Process2(); } - catch(...) { Error = L"Error"; ThereIsError = true;} - ProgressDialog->MyClose(); - return 0; - } - - static THREAD_FUNC_DECL MyThreadFunction(void *param) - { - return ((CThreadCrc *)param)->Process(); - } -}; - -static void ConvertByteToHex(unsigned value, wchar_t *s) -{ - for (int i = 0; i < 2; i++) - { - unsigned t = value & 0xF; - value >>= 4; - s[1 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10))); - } + sync.SetNumFilesCur(NumFiles); + OkMessage = GetResultMessage(); + OkMessageTitle = LangString(IDS_CHECKSUM_INFORMATION, 0x03020720); + return S_OK; } void CApp::CalculateCrc() @@ -308,98 +320,23 @@ void CApp::CalculateCrc() if (indices.IsEmpty()) return; - CThreadCrc combiner; + { + CThreadCrc t; for (int i = 0; i < indices.Size(); i++) - combiner.DirEnumerator.FileNames.Add(srcPanel.GetItemRelPath(indices[i])); - combiner.DirEnumerator.BasePrefix = srcPanel.GetFsPath(); - combiner.DirEnumerator.FlatMode = GetFlatMode(); + t.Enumerator.FileNames.Add(srcPanel.GetItemRelPath(indices[i])); + t.Enumerator.BasePrefix = srcPanel.GetFsPath(); + t.Enumerator.FlatMode = GetFlatMode(); - { - CProgressDialog progressDialog; - combiner.ProgressDialog = &progressDialog; - combiner.ErrorCode = 0; - combiner.Result = S_OK; - combiner.ThereIsError = false; + t.ProgressDialog.ShowCompressionInfo = false; - UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); UString title = LangString(IDS_CHECKSUM_CALCULATING, 0x03020710); - progressDialog.MainWindow = _window; - progressDialog.MainTitle = progressWindowTitle; - progressDialog.MainAddTitle = title + UString(L" "); + t.ProgressDialog.MainWindow = _window; + t.ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); + t.ProgressDialog.MainAddTitle = title + UString(L' '); - NWindows::CThread thread; - if (thread.Create(CThreadCrc::MyThreadFunction, &combiner) != S_OK) + if (t.Create(title, _window) != S_OK) return; - progressDialog.Create(title, _window); - - if (combiner.Result != S_OK) - { - if (combiner.Result != E_ABORT) - srcPanel.MessageBoxError(combiner.Result); - } - else if (combiner.ThereIsError) - { - if (combiner.Error.IsEmpty()) - { - UString message = combiner.DirEnumerator.BasePrefix + combiner.ErrorPath; - message += L"\n"; - message += NError::MyFormatMessageW(combiner.ErrorCode); - srcPanel.MessageBoxMyError(message); - } - else - srcPanel.MessageBoxMyError(combiner.Error); - } - else - { - UString s; - { - wchar_t sz[32]; - - s += LangString(IDS_FILES_COLON, 0x02000320); - s += L" "; - ConvertUInt64ToString(combiner.NumFiles, sz); - s += sz; - s += L"\n"; - - s += LangString(IDS_FOLDERS_COLON, 0x02000321); - s += L" "; - ConvertUInt64ToString(combiner.NumFolders, sz); - s += sz; - s += L"\n"; - - s += LangString(IDS_SIZE_COLON, 0x02000322); - s += L" "; - ConvertUInt64ToString(combiner.DataSize, sz); - s += MyFormatNew(IDS_FILE_SIZE, 0x02000982, sz);; - s += L"\n"; - - s += LangString(IDS_CHECKSUM_CRC_DATA, 0x03020721); - s += L" "; - ConvertUInt32ToHex(combiner.DataCrcSum, sz); - s += sz; - s += L"\n"; - - s += LangString(IDS_CHECKSUM_CRC_DATA_NAMES, 0x03020722); - s += L" "; - ConvertUInt32ToHex(combiner.DataNameCrcSum, sz); - s += sz; - s += L"\n"; - - if (combiner.NumFiles == 1 && combiner.NumFilesScan == 1) - { - s += L"SHA-256: "; - for (int i = 0; i < SHA256_DIGEST_SIZE; i++) - { - wchar_t s2[4]; - ConvertByteToHex(combiner.Sha256Sum[i], s2); - s2[2] = 0; - s += s2; - } - } - } - srcPanel.MessageBoxInfo(s, LangString(IDS_CHECKSUM_INFORMATION, 0x03020720)); - } } RefreshTitleAlways(); } diff --git a/CPP/7zip/UI/FileManager/PanelDrag.cpp b/CPP/7zip/UI/FileManager/PanelDrag.cpp index 6d1c9a29..eb5ad871 100755 --- a/CPP/7zip/UI/FileManager/PanelDrag.cpp +++ b/CPP/7zip/UI/FileManager/PanelDrag.cpp @@ -2,6 +2,10 @@ #include "StdAfx.h" +#ifdef UNDER_CE +#include <winuserm.h> +#endif + #include "Common/StringConvert.h" #include "Windows/Memory.h" @@ -413,6 +417,10 @@ void CDropTarget::RemoveSelection() m_SelectionIndex = -1; } +#ifdef UNDER_CE +#define ChildWindowFromPointEx(hwndParent, pt, uFlags) ChildWindowFromPoint(hwndParent, pt) +#endif + void CDropTarget::PositionCursor(POINTL ptl) { m_SubFolderIndex = -1; @@ -767,8 +775,6 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo { if (fileNames.Size() == 0) return; - const UString archiveName = CreateArchiveName(fileNames.Front(), - (fileNames.Size() > 1), false); bool createNewArchive = true; if (!IsFSFolder()) createNewArchive = !DoesItSupportOperations(); @@ -780,8 +786,9 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo { NFile::NDirectory::GetOnlyDirPrefix(fileNames.Front(), folderPath2); if (IsFolderInTemp(folderPath2)) - folderPath2 = L"C:\\"; // fix it + folderPath2 = ROOT_FS_FOLDER; } + const UString archiveName = CreateArchiveName(fileNames.Front(), (fileNames.Size() > 1), false); CompressFiles(folderPath2, archiveName, L"", fileNames, false, // email true, // showDialog diff --git a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp index e6336f31..41ffe9da 100755 --- a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp +++ b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp @@ -9,7 +9,11 @@ #include "../../PropID.h" +#ifdef UNDER_CE +#include "FSFolder.h" +#else #include "FSDrives.h" +#endif #include "LangUtils.h" #include "ListViewDialog.h" #include "Panel.h" @@ -193,6 +197,8 @@ void CPanel::LoadFullPathAndShow() _appState->FolderHistory.AddString(_currentFolderPrefix); _headerComboBox.SetText(_currentFolderPrefix); + + #ifndef UNDER_CE COMBOBOXEXITEM item; item.mask = 0; @@ -220,10 +226,12 @@ void CPanel::LoadFullPathAndShow() } item.iItem = -1; _headerComboBox.SetItem(&item); + #endif RefreshTitle(); } +#ifndef UNDER_CE LRESULT CPanel::OnNotifyComboBoxEnter(const UString &s) { if (BindToPathAndRefresh(GetUnicodeString(s)) == S_OK) @@ -262,6 +270,7 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result) } return false; } +#endif #ifndef _UNICODE bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result) @@ -295,6 +304,16 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result) void CPanel::AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList) { + #ifdef UNDER_CE + + UString s; + iconIndex = iconIndex; + for (int i = 0; i < indent; i++) + s += L" "; + _headerComboBox.AddString(s + name); + + #else + COMBOBOXEXITEMW item; item.mask = CBEIF_TEXT | CBEIF_INDENT; item.iSelectedImage = item.iImage = iconIndex; @@ -304,6 +323,9 @@ void CPanel::AddComboBoxItem(const UString &name, int iconIndex, int indent, boo item.iIndent = indent; item.pszText = (LPWSTR)(LPCWSTR)name; _headerComboBox.InsertItem(&item); + + #endif + if (addToList) ComboBoxPaths.Add(name); } @@ -322,32 +344,30 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) ComboBoxPaths.Clear(); _headerComboBox.ResetContent(); - int iconIndex; - UString name; - int i; UStringVector pathParts; SplitPathToParts(_currentFolderPrefix, pathParts); UString sumPass; + if (!pathParts.IsEmpty()) + pathParts.DeleteBack(); for (i = 0; i < pathParts.Size(); i++) { UString name = pathParts[i]; - if (name.IsEmpty()) - continue; sumPass += name; - UString curName = sumPass; - if (i == 0) - curName += WCHAR_PATH_SEPARATOR; + sumPass += WCHAR_PATH_SEPARATOR; CFileInfoW info; DWORD attrib = FILE_ATTRIBUTE_DIRECTORY; if (info.Find(sumPass)) attrib = info.Attrib; - sumPass += WCHAR_PATH_SEPARATOR; - AddComboBoxItem(name, GetRealIconIndex(curName, attrib), i, false); + AddComboBoxItem(name.IsEmpty() ? L"\\" : name, GetRealIconIndex(sumPass, attrib), i, false); ComboBoxPaths.Add(sumPass); } + #ifndef UNDER_CE + + int iconIndex; + UString name; name = RootFolder_GetName_Documents(iconIndex); AddComboBoxItem(name, iconIndex, 0, true); @@ -369,7 +389,7 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) name = RootFolder_GetName_Network(iconIndex); AddComboBoxItem(name, iconIndex, 0, true); - // UStringVector strings; _appState->FolderHistory.GetList(strings); + #endif return false; } @@ -382,10 +402,14 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) { UString pass = ComboBoxPaths[index]; _headerComboBox.SetCurSel(-1); - _headerComboBox.SetText(pass); // it's fix for seclecting by mouse. + // _headerComboBox.SetText(pass); // it's fix for seclecting by mouse. if (BindToPathAndRefresh(pass) == S_OK) { PostMessage(kSetFocusToListView); + #ifdef UNDER_CE + PostMessage(kRefreshHeaderComboBox); + #endif + return true; } } @@ -410,6 +434,7 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result) { + #ifndef UNDER_CE switch(header->code) { case CBEN_BEGINEDIT: @@ -429,6 +454,7 @@ bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result) return OnNotifyComboBoxEndEdit((PNMCBEENDEDITW)header, result); } } + #endif return false; } @@ -463,16 +489,17 @@ void CPanel::OpenParentFolder() { LoadFullPath(); // Maybe we don't need it ?? UString focucedName; - if (!_currentFolderPrefix.IsEmpty()) + if (!_currentFolderPrefix.IsEmpty() && + _currentFolderPrefix.Back() == WCHAR_PATH_SEPARATOR) { - UString string = _currentFolderPrefix; - string.Delete(string.Length() - 1); - int pos = string.ReverseFind(WCHAR_PATH_SEPARATOR); - if (pos < 0) - pos = 0; - else - pos++; - focucedName = string.Mid(pos); + focucedName = _currentFolderPrefix; + focucedName.DeleteBack(); + if (focucedName != L"\\\\.") + { + int pos = focucedName.ReverseFind(WCHAR_PATH_SEPARATOR); + if (pos >= 0) + focucedName = focucedName.Mid(pos + 1); + } } CDisableTimerProcessing disableTimerProcessing1(*this); @@ -553,9 +580,15 @@ void CPanel::OpenRootFolder() void CPanel::OpenDrivesFolder() { CloseOpenFolders(); - CFSDrives *fsFolderSpec = new CFSDrives; - _folder = fsFolderSpec; - fsFolderSpec->Init(); + #ifdef UNDER_CE + NFsFolder::CFSFolder *folderSpec = new NFsFolder::CFSFolder; + _folder = folderSpec; + folderSpec->InitToRoot(); + #else + CFSDrives *folderSpec = new CFSDrives; + _folder = folderSpec; + folderSpec->Init(); + #endif RefreshListCtrl(); } diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp index 2aab2aae..2deea0af 100755 --- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp +++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp @@ -8,22 +8,19 @@ #include "Windows/Error.h" #include "Windows/FileDir.h" #include "Windows/FileFind.h" -#include "Windows/Synchronization.h" +#include "Windows/Process.h" #include "Windows/Thread.h" -#include "ExtractCallback.h" +#include "../Common/ExtractingFilePath.h" + +#include "App.h" + #include "FileFolderPluginOpen.h" #include "FormatUtils.h" -#include "IFolder.h" #include "LangUtils.h" -#include "Panel.h" #include "RegistryUtils.h" #include "UpdateCallback100.h" -#include "App.h" - -#include "../Common/ExtractingFilePath.h" - #include "resource.h" using namespace NWindows; @@ -31,7 +28,6 @@ using namespace NSynchronization; using namespace NFile; using namespace NDirectory; -extern HWND g_HWND; #ifndef _UNICODE extern bool g_IsNT; #endif @@ -167,6 +163,9 @@ HRESULT CPanel::OpenParentArchiveFolder() static const wchar_t *kStartExtensions[] = { + #ifdef UNDER_CE + L"cab", + #endif L"exe", L"bat", L"com", L"chm", L"msi", L"doc", L"xls", L"ppt", L"pps", L"wps", L"wpt", L"wks", L"xlr", L"wdb", @@ -175,7 +174,9 @@ static const wchar_t *kStartExtensions[] = L"xlam", L"pptx", L"pptm", L"potx", L"potm", L"ppam", L"ppsx", L"ppsm", L"xsn", L"dwf", - + + L"flv", L"swf", + L"odt", L"ods", L"wb3", L"pdf" @@ -194,81 +195,31 @@ static bool DoItemAlwaysStart(const UString &name) return false; } -static HRESULT MyCreateProcess(const UString &command, HANDLE *hProcess) +static UString GetQuotedString(const UString &s) { - PROCESS_INFORMATION processInformation; - BOOL result; - #ifndef _UNICODE - if (!g_IsNT) - { - STARTUPINFOA startupInfo; - startupInfo.cb = sizeof(startupInfo); - startupInfo.lpReserved = 0; - startupInfo.lpDesktop = 0; - startupInfo.lpTitle = 0; - startupInfo.dwFlags = 0; - startupInfo.cbReserved2 = 0; - startupInfo.lpReserved2 = 0; - - result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command), - NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation); - } - else - #endif - { - STARTUPINFOW startupInfo; - startupInfo.cb = sizeof(startupInfo); - startupInfo.lpReserved = 0; - startupInfo.lpDesktop = 0; - startupInfo.lpTitle = 0; - startupInfo.dwFlags = 0; - startupInfo.cbReserved2 = 0; - startupInfo.lpReserved2 = 0; - - result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command, - NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation); - } - - if (result == 0) - return ::GetLastError(); - - ::CloseHandle(processInformation.hThread); - *hProcess = processInformation.hProcess; - return S_OK; + return UString(L'\"') + s + UString(L'\"'); } -static HRESULT MyCreateProcess(const UString &command) -{ - HANDLE hProcess; - HRESULT res = MyCreateProcess(command, &hProcess); - if (res == SZ_OK) - ::CloseHandle(hProcess); - return res; -} - -static HANDLE StartEditApplication(const UString &path, HWND window) +static HRESULT StartEditApplication(const UString &path, HWND window, CProcess &process) { UString command; ReadRegEditor(command); if (command.IsEmpty()) { + #ifdef UNDER_CE + command = L"\\Windows\\"; + #else if (!MyGetWindowsDirectory(command)) return 0; NFile::NName::NormalizeDirPathPrefix(command); + #endif command += L"notepad.exe"; } - command = UString(L"\"") + command + UString(L"\""); - command += L" \""; - command += path; - command += L"\""; - HANDLE hProcess; - HRESULT res = MyCreateProcess(command, &hProcess); - if (res == SZ_OK) - return hProcess; - ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282), - L"7-Zip", MB_OK | MB_ICONSTOP); - return 0; + HRESULT res = process.Create(command, GetQuotedString(path), NULL); + if (res != SZ_OK) + ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282), L"7-Zip", MB_OK | MB_ICONSTOP); + return res; } void CApp::DiffFiles() @@ -304,16 +255,9 @@ void CApp::DiffFiles() if (command.IsEmpty()) return; - command = UString(L"\"") + command + UString(L"\""); - command += L" \""; - command += path1; - command += L"\""; - - command += L" \""; - command += path2; - command += L"\""; + UString param = GetQuotedString(path1) + L' ' + GetQuotedString(path2); - HRESULT res = MyCreateProcess(command); + HRESULT res = MyCreateProcess(command, param); if (res == SZ_OK) return; ::MessageBoxW(_window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282), L"7-Zip", MB_OK | MB_ICONSTOP); @@ -323,10 +267,9 @@ void CApp::DiffFiles() typedef BOOL (WINAPI * ShellExecuteExWP)(LPSHELLEXECUTEINFOW lpExecInfo); #endif -static HANDLE StartApplication(const UString &dir, const UString &path, HWND window) +static HRESULT StartApplication(const UString &dir, const UString &path, HWND window, CProcess &process) { UINT32 result; - HANDLE hProcess; #ifndef _UNICODE if (g_IsNT) { @@ -346,28 +289,38 @@ static HANDLE StartApplication(const UString &dir, const UString &path, HWND win return 0; shellExecuteExW(&execInfo); result = (UINT32)(UINT_PTR)execInfo.hInstApp; - hProcess = execInfo.hProcess; + process.Attach(execInfo.hProcess); } else #endif { SHELLEXECUTEINFO execInfo; execInfo.cbSize = sizeof(execInfo); - execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT; + execInfo.fMask = SEE_MASK_NOCLOSEPROCESS + #ifndef UNDER_CE + | SEE_MASK_FLAG_DDEWAIT + #endif + ; execInfo.hwnd = NULL; execInfo.lpVerb = NULL; const CSysString sysPath = GetSystemString(path); const CSysString sysDir = GetSystemString(dir); execInfo.lpFile = sysPath; execInfo.lpParameters = NULL; - execInfo.lpDirectory = sysDir.IsEmpty() ? NULL : (LPCTSTR)sysDir; + execInfo.lpDirectory = + #ifdef UNDER_CE + NULL + #else + sysDir.IsEmpty() ? NULL : (LPCTSTR)sysDir + #endif + ; execInfo.nShow = SW_SHOWNORMAL; execInfo.hProcess = 0; ::ShellExecuteEx(&execInfo); result = (UINT32)(UINT_PTR)execInfo.hInstApp; - hProcess = execInfo.hProcess; + process.Attach(execInfo.hProcess); } - if(result <= 32) + if (result <= 32) { switch(result) { @@ -378,7 +331,13 @@ static HANDLE StartApplication(const UString &dir, const UString &path, HWND win L"7-Zip", MB_OK | MB_ICONSTOP); } } - return hProcess; + return S_OK; +} + +static void StartApplicationDontWait(const UString &dir, const UString &path, HWND window) +{ + CProcess process; + StartApplication(dir, path, window, process); } void CPanel::EditItem(int index) @@ -388,18 +347,29 @@ void CPanel::EditItem(int index) OpenItemInArchive(index, false, true, true); return; } - HANDLE hProcess = StartEditApplication(GetItemFullPath(index), (HWND)*this); - if (hProcess != 0) - ::CloseHandle(hProcess); + CProcess process; + StartEditApplication(GetItemFullPath(index), (HWND)*this, process); } void CPanel::OpenFolderExternal(int index) { UString fsPrefix = GetFsPath(); - HANDLE hProcess = StartApplication(fsPrefix, - fsPrefix + GetItemRelPath(index) + WCHAR_PATH_SEPARATOR, (HWND)*this); - if (hProcess != 0) - ::CloseHandle(hProcess); + UString name; + if (index == kParentIndex) + { + int pos = fsPrefix.ReverseFind(WCHAR_PATH_SEPARATOR); + if (pos >= 0 && pos == fsPrefix.Length() - 1) + { + UString s = fsPrefix.Left(pos); + pos = s.ReverseFind(WCHAR_PATH_SEPARATOR); + if (pos >= 0) + fsPrefix = s.Left(pos + 1); + } + name = fsPrefix; + } + else + name = fsPrefix + GetItemRelPath(index) + WCHAR_PATH_SEPARATOR; + StartApplicationDontWait(fsPrefix, name, (HWND)*this); } void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal) @@ -416,7 +386,8 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal) MessageBoxErrorLang(IDS_VIRUS, 0x03020284); return; } - UString fullPath = _currentFolderPrefix + name; + UString prefix = GetFsPath(); + UString fullPath = prefix + name; if (tryInternal) if (!tryExternal || !DoItemAlwaysStart(name)) { @@ -432,12 +403,31 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal) if (tryExternal) { // SetCurrentDirectory opens HANDLE to folder!!! - // NDirectory::MySetCurrentDirectory(_currentFolderPrefix); - HANDLE hProcess = StartApplication(_currentFolderPrefix, fullPath, (HWND)*this); - if (hProcess != 0) - ::CloseHandle(hProcess); + // NDirectory::MySetCurrentDirectory(prefix); + StartApplicationDontWait(prefix, fullPath, (HWND)*this); } } + +class CThreadCopyFrom: public CProgressThreadVirt +{ + HRESULT ProcessVirt(); +public: + UString PathPrefix; + UString Name; + + CMyComPtr<IFolderOperations> FolderOperations; + CMyComPtr<IProgress> UpdateCallback; + CUpdateCallback100Imp *UpdateCallbackSpec; +}; + +HRESULT CThreadCopyFrom::ProcessVirt() +{ + UStringVector fileNames; + CRecordVector<const wchar_t *> fileNamePointers; + fileNames.Add(Name); + fileNamePointers.Add(fileNames[0]); + return FolderOperations->CopyFrom(PathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), UpdateCallback); +}; HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName, bool usePassword, const UString &password) @@ -448,19 +438,18 @@ HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &item MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); return E_FAIL; } - UStringVector fileNames; - CRecordVector<const wchar_t *> fileNamePointers; - fileNames.Add(itemName); - fileNamePointers.Add(fileNames[0]); - - UString pathPrefix = folderPath; - NName::NormalizeDirPathPrefix(pathPrefix); - - CUpdateCallback100Imp *callbackSpec = new CUpdateCallback100Imp; - CMyComPtr<IProgress> callback = callbackSpec; - callbackSpec->Init((HWND)*this, usePassword, password); - return folderOperations->CopyFrom(pathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), callback); + CThreadCopyFrom t; + t.UpdateCallbackSpec = new CUpdateCallback100Imp; + t.UpdateCallback = t.UpdateCallbackSpec; + t.UpdateCallbackSpec->ProgressDialog = &t.ProgressDialog; + t.Name = itemName; + t.PathPrefix = folderPath; + NName::NormalizeDirPathPrefix(t.PathPrefix); + t.FolderOperations = folderOperations; + t.UpdateCallbackSpec->Init(usePassword, password); + RINOK(t.Create(itemName, (HWND)*this)); + return t.Result; } LRESULT CPanel::OnOpenItemChanged(LPARAM lParam) @@ -658,19 +647,20 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo if (!tryExternal) return; - HANDLE hProcess; + CProcess process; + HRESULT res; if (editMode) - hProcess = StartEditApplication(tempFilePath, (HWND)*this); + res = StartEditApplication(tempFilePath, (HWND)*this, process); else - hProcess = StartApplication(tempDirNorm, tempFilePath, (HWND)*this); + res = StartApplication(tempDirNorm, tempFilePath, (HWND)*this, process); - if (hProcess == 0) + if ((HANDLE)process == 0) return; tmpProcessInfo->Window = (HWND)(*this); tmpProcessInfo->FullPathFolderPrefix = _currentFolderPrefix; tmpProcessInfo->ItemName = name; - tmpProcessInfo->ProcessHandle = hProcess; + tmpProcessInfo->ProcessHandle = process.Detach(); NWindows::CThread thread; if (thread.Create(MyThreadFunction, tmpProcessInfo) != S_OK) diff --git a/CPP/7zip/UI/FileManager/PanelItems.cpp b/CPP/7zip/UI/FileManager/PanelItems.cpp index 7ea9585a..626d4309 100755 --- a/CPP/7zip/UI/FileManager/PanelItems.cpp +++ b/CPP/7zip/UI/FileManager/PanelItems.cpp @@ -716,13 +716,20 @@ void CPanel::SaveListViewInfo() } } -bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result) + +bool CPanel::OnRightClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActiveate, LRESULT &result) { if(itemActiveate->hdr.hwndFrom == HWND(_listView)) return false; - POINT point; ::GetCursorPos(&point); + ShowColumnsContextMenu(point.x, point.y); + result = TRUE; + return true; +} + +void CPanel::ShowColumnsContextMenu(int x, int y) +{ CMenu menu; CMenuDestroyer menuDestroyer(menu); @@ -740,8 +747,7 @@ bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result) flags |= MF_GRAYED; menu.AppendItem(flags, kCommandStart + i, prop.Name); } - int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, - point.x, point.y, _listView); + int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, x, y, _listView); if (menuResult >= kCommandStart && menuResult <= kCommandStart + _properties.Size()) { int index = menuResult - kCommandStart; @@ -775,8 +781,6 @@ bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result) _listView.DeleteColumn(visibleIndex); } } - result = TRUE; - return true; } void CPanel::OnReload() diff --git a/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/CPP/7zip/UI/FileManager/PanelListNotify.cpp index aee4759e..43d7981b 100755 --- a/CPP/7zip/UI/FileManager/PanelListNotify.cpp +++ b/CPP/7zip/UI/FileManager/PanelListNotify.cpp @@ -180,7 +180,9 @@ LRESULT CPanel::SetItemText(LVITEMW &item) return 0; } +#ifndef UNDER_CE extern DWORD g_ComCtl32Version; +#endif void CPanel::OnItemChanged(NMLISTVIEW *item) { @@ -194,11 +196,23 @@ void CPanel::OnItemChanged(NMLISTVIEW *item) _selectedStatusVector[index] = newSelected; } +extern bool g_LVN_ITEMACTIVATE_Support; + +void CPanel::OnNotifyActivateItems() +{ + // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0; + // bool rightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0; + bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; + bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; + bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; + if (!shift && alt && !ctrl) + Properties(); + else + OpenSelectedItems(!shift || alt || ctrl); +} + bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result) { - // bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; - // bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - // bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; switch(header->code) { case LVN_ITEMCHANGED: @@ -240,33 +254,23 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result) case LVN_COLUMNCLICK: OnColumnClick(LPNMLISTVIEW(header)); return false; - /* - case LVN_ITEMACTIVATE: - RefreshStatusBar(); - if (!alt && !ctrl && !shift) - OpenSelectedItems(true); - return false; - */ + case LVN_ITEMACTIVATE: + if (g_LVN_ITEMACTIVATE_Support) + { + OnNotifyActivateItems(); + return false; + } + break; case NM_DBLCLK: - RefreshStatusBar(); - OpenSelectedItems(true); - return false; case NM_RETURN: - { - bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; - bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0; - // bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0; - bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; - if (!shift && alt && !ctrl) + if (!g_LVN_ITEMACTIVATE_Support) { - Properties(); + OnNotifyActivateItems(); return false; } - OpenSelectedItems(true); - return false; - } + break; + case NM_RCLICK: RefreshStatusBar(); break; @@ -298,8 +302,10 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result) SetFocusToList(); RefreshStatusBar(); if (_mySelectMode) + #ifndef UNDER_CE if (g_ComCtl32Version >= MAKELONG(71, 4)) - OnLeftClick((LPNMITEMACTIVATE)header); + #endif + OnLeftClick((MY_NMLISTVIEW_NMITEMACTIVATE *)header); return false; } case LVN_BEGINLABELEDITW: diff --git a/CPP/7zip/UI/FileManager/PanelMenu.cpp b/CPP/7zip/UI/FileManager/PanelMenu.cpp index 2672f694..093f02f0 100755 --- a/CPP/7zip/UI/FileManager/PanelMenu.cpp +++ b/CPP/7zip/UI/FileManager/PanelMenu.cpp @@ -8,8 +8,9 @@ #include "Windows/PropVariant.h" #include "Windows/PropVariantConversions.h" -#include "../Common/PropIDUtils.h" #include "../../PropID.h" +#include "../Common/PropIDUtils.h" +#include "../Explorer/ContextMenu.h" #include "App.h" #include "LangUtils.h" @@ -22,9 +23,12 @@ using namespace NWindows; +LONG g_DllRefCount = 0; +/* // {23170F69-40C1-278A-1000-000100020000} DEFINE_GUID(CLSID_CZipContextMenu, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00); +*/ static const UINT kSevenZipStartMenuID = kPluginMenuStartID ; static const UINT kSystemStartMenuID = kPluginMenuStartID + 100; @@ -50,7 +54,7 @@ void CPanel::InvokeSystemCommand(const char *command) contextMenu->InvokeCommand(&ci); } -static const wchar_t *kSeparator = L"--------------------------------------\n"; +static const wchar_t *kSeparator = L"----------------------------\n"; static const wchar_t *kPropValueSeparator = L": "; extern UString ConvertSizeToString(UInt64 value); @@ -442,7 +446,8 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec, bool sevenZipMenuCreated = false; CMyComPtr<IContextMenu> contextMenu; - if (contextMenu.CoCreateInstance(CLSID_CZipContextMenu, IID_IContextMenu) == S_OK) + contextMenu = new CZipContextMenu; + // if (contextMenu.CoCreateInstance(CLSID_CZipContextMenu, IID_IContextMenu) == S_OK) { CMyComPtr<IInitContextMenu> initContextMenu; if (contextMenu.QueryInterface(IID_IInitContextMenu, &initContextMenu) != S_OK) @@ -489,8 +494,10 @@ void CPanel::CreateFileMenu(HMENU menuSpec, if (g_App.ShowSystemMenu) CreateSystemMenu(menu, operatedIndices, systemContextMenu); + /* if (menu.GetItemCount() > 0) menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0); + */ int i; for (i = 0; i < operatedIndices.Size(); i++) @@ -516,18 +523,28 @@ bool CPanel::InvokePluginCommand(int id, else offset = id - kSevenZipStartMenuID; - CMINVOKECOMMANDINFOEX commandInfo; + #ifdef UNDER_CE + CMINVOKECOMMANDINFO + #else + CMINVOKECOMMANDINFOEX + #endif + commandInfo; commandInfo.cbSize = sizeof(commandInfo); - commandInfo.fMask = CMIC_MASK_UNICODE; + commandInfo.fMask = 0 + #ifndef UNDER_CE + | CMIC_MASK_UNICODE + #endif + ; commandInfo.hwnd = GetParent(); commandInfo.lpVerb = (LPCSTR)(MAKEINTRESOURCE(offset)); commandInfo.lpParameters = NULL; CSysString currentFolderSys = GetSystemString(_currentFolderPrefix); commandInfo.lpDirectory = (LPCSTR)(LPCTSTR)(currentFolderSys); commandInfo.nShow = SW_SHOW; + commandInfo.lpParameters = NULL; + #ifndef UNDER_CE commandInfo.lpTitle = ""; commandInfo.lpVerbW = (LPCWSTR)(MAKEINTRESOURCEW(offset)); - commandInfo.lpParameters = NULL; UString currentFolderUnicode = _currentFolderPrefix; commandInfo.lpDirectoryW = currentFolderUnicode; commandInfo.lpTitleW = L""; @@ -535,6 +552,7 @@ bool CPanel::InvokePluginCommand(int id, // commandInfo.ptInvoke.y = yPos; commandInfo.ptInvoke.x = 0; commandInfo.ptInvoke.y = 0; + #endif HRESULT result; if (isSystemMenu) result = systemContextMenu->InvokeCommand(LPCMINVOKECOMMANDINFO(&commandInfo)); @@ -550,6 +568,12 @@ bool CPanel::InvokePluginCommand(int id, bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos) { + if (::GetParent((HWND)windowHandle) == _listView) + { + ShowColumnsContextMenu(xPos, yPos); + return true; + } + if (windowHandle != _listView) return false; /* @@ -599,7 +623,11 @@ bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos) CMyComPtr<IContextMenu> systemContextMenu; CreateFileMenu(menu, sevenZipContextMenu, systemContextMenu, false); - int result = menu.Track(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY, + int result = menu.Track(TPM_LEFTALIGN + #ifndef UNDER_CE + | TPM_RIGHTBUTTON + #endif + | TPM_RETURNCMD | TPM_NONOTIFY, xPos, yPos, _listView); if (result == 0) diff --git a/CPP/7zip/UI/FileManager/PanelOperations.cpp b/CPP/7zip/UI/FileManager/PanelOperations.cpp index 9a60fb1a..579208d2 100755 --- a/CPP/7zip/UI/FileManager/PanelOperations.cpp +++ b/CPP/7zip/UI/FileManager/PanelOperations.cpp @@ -35,8 +35,10 @@ enum EFolderOpType FOLDER_TYPE_RENAME = 2 }; -struct CThreadFolderOperations +class CThreadFolderOperations: public CProgressThreadVirt { + HRESULT ProcessVirt(); +public: EFolderOpType OpType; UString Name; UInt32 Index; @@ -45,45 +47,43 @@ struct CThreadFolderOperations CMyComPtr<IFolderOperations> FolderOperations; CMyComPtr<IProgress> UpdateCallback; CUpdateCallback100Imp *UpdateCallbackSpec; - HRESULT Result; - - CThreadFolderOperations(EFolderOpType opType); - void Process() - { - NCOM::CComInitializer comInitializer; - UpdateCallbackSpec->ProgressDialog.WaitCreating(); + HRESULT Result; - switch(OpType) - { - case FOLDER_TYPE_CREATE_FOLDER: - Result = FolderOperations->CreateFolder(Name, UpdateCallback); - break; - case FOLDER_TYPE_DELETE: - Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback); - break; - case FOLDER_TYPE_RENAME: - Result = FolderOperations->Rename(Index, Name, UpdateCallback); - break; - default: - Result = E_FAIL; - } - UpdateCallbackSpec->ProgressDialog.MyClose(); - } + CThreadFolderOperations(EFolderOpType opType): OpType(opType), Result(E_FAIL) {}; + HRESULT DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError); +}; - static THREAD_FUNC_DECL MyThreadFunction(void *param) +HRESULT CThreadFolderOperations::ProcessVirt() +{ + NCOM::CComInitializer comInitializer; + switch(OpType) { - ((CThreadFolderOperations *)param)->Process(); - return 0; + case FOLDER_TYPE_CREATE_FOLDER: + Result = FolderOperations->CreateFolder(Name, UpdateCallback); + break; + case FOLDER_TYPE_DELETE: + Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback); + break; + case FOLDER_TYPE_RENAME: + Result = FolderOperations->Rename(Index, Name, UpdateCallback); + break; + default: + Result = E_FAIL; } + return Result; }; -CThreadFolderOperations::CThreadFolderOperations(EFolderOpType opType): OpType(opType) {}; -static void DoOperation(CThreadFolderOperations &op, CPanel &panel, const UString &progressTitle) +HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError) { - op.UpdateCallbackSpec = new CUpdateCallback100Imp; - op.UpdateCallback = op.UpdateCallbackSpec; + UpdateCallbackSpec = new CUpdateCallback100Imp; + UpdateCallback = UpdateCallbackSpec; + UpdateCallbackSpec->ProgressDialog = &ProgressDialog; + + ProgressDialog.WaitMode = true; + ProgressDialog.Sync.SetErrorMessageTitle(titleError); + Result = S_OK; bool usePassword = false; UString password; @@ -94,21 +94,14 @@ static void DoOperation(CThreadFolderOperations &op, CPanel &panel, const UStrin password = fl.Password; } - op.UpdateCallbackSpec->Init(panel.GetParent(), usePassword, password); - - op.UpdateCallbackSpec->ProgressDialog.MainWindow = panel._mainWindow; - op.UpdateCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); - op.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" "); + UpdateCallbackSpec->Init(usePassword, password); - // op.FolderOperations = folderOperations; - // op.Index = realIndex; - // op.Name = newName; - // HRESULT result = folderOperations->Rename(realIndex, newName, 0); + ProgressDialog.MainWindow = panel._mainWindow; // panel.GetParent() + ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); + ProgressDialog.MainAddTitle = progressTitle + UString(L" "); - NWindows::CThread thread; - if (thread.Create(CThreadFolderOperations::MyThreadFunction, &op) != S_OK) - throw 271824; - op.UpdateCallbackSpec->StartProgressDialog(progressTitle); + RINOK(Create(progressTitle, ProgressDialog.MainWindow)); + return Result; } #ifndef _UNICODE @@ -124,6 +117,9 @@ void CPanel::DeleteItems(bool toRecycleBin) return; CSelectedState state; SaveSelectedState(state); + + #ifndef UNDER_CE + // WM6 / SHFileOperationW doesn't ask user! So we use internal delete bool useInternalDelete = false; if (IsFSFolder() && toRecycleBin) { @@ -218,16 +214,25 @@ void CPanel::DeleteItems(bool toRecycleBin) else useInternalDelete = true; if (useInternalDelete) + #endif DeleteItemsInternal(indices); RefreshListCtrl(state); } +void CPanel::MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID, UInt32 langID) +{ + if (errorCode == E_NOINTERFACE) + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + else + MessageBoxError(errorCode, LangString(resourceID, langID)); +} + void CPanel::DeleteItemsInternal(CRecordVector<UInt32> &indices) { CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_DELETING, 0x03020217); return; } @@ -261,9 +266,9 @@ void CPanel::DeleteItemsInternal(CRecordVector<UInt32> &indices) CThreadFolderOperations op(FOLDER_TYPE_DELETE); op.FolderOperations = folderOperations; op.Indices = indices; - DoOperation(op, *this, LangString(IDS_DELETING, 0x03020216)); - if (op.Result != S_OK) - MessageBoxError(op.Result, LangString(IDS_ERROR_DELETING, 0x03020217)); + op.DoOperation(*this, + LangString(IDS_DELETING, 0x03020216), + LangString(IDS_ERROR_DELETING, 0x03020217)); } RefreshTitleAlways(); } @@ -286,7 +291,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh) CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_RENAMING, 0x03020221); return FALSE; } const UString newName = lpnmh->item.pszText; @@ -305,12 +310,11 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh) op.FolderOperations = folderOperations; op.Index = realIndex; op.Name = newName; - DoOperation(op, *this, LangString(IDS_RENAMING, 0x03020220)); - if (op.Result != S_OK) - { - MessageBoxError(op.Result, LangString(IDS_ERROR_RENAMING, 0x03020221)); + HRESULT res = op.DoOperation(*this, + LangString(IDS_RENAMING, 0x03020220), + LangString(IDS_ERROR_RENAMING, 0x03020221)); + if (res != S_OK) return FALSE; - } } // Can't use RefreshListCtrl here. @@ -335,7 +339,7 @@ void CPanel::CreateFolder() CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FOLDER_ERROR, 0x03020233); return; } CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); @@ -354,13 +358,11 @@ void CPanel::CreateFolder() CThreadFolderOperations op(FOLDER_TYPE_CREATE_FOLDER); op.FolderOperations = folderOperations; op.Name = newName; - DoOperation(op, *this, LangString(IDS_CREATE_FOLDER, 0x03020230)); - - if (op.Result != S_OK) - { - MessageBoxError(op.Result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233)); + HRESULT res = op.DoOperation(*this, + LangString(IDS_CREATE_FOLDER, 0x03020230), + LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233)); + if (res != S_OK) return; - } } int pos = newName.Find(WCHAR_PATH_SEPARATOR); if (pos >= 0) @@ -378,7 +380,7 @@ void CPanel::CreateFile() CMyComPtr<IFolderOperations> folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FILE_ERROR, 0x03020243); return; } CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); @@ -394,7 +396,7 @@ void CPanel::CreateFile() HRESULT result = folderOperations->CreateFile(newName, 0); if (result != S_OK) { - MessageBoxError(result, LangString(IDS_CREATE_FILE_ERROR, 0x03020243)); + MessageBoxErrorForUpdate(result, IDS_CREATE_FILE_ERROR, 0x03020243); return; } int pos = newName.Find(WCHAR_PATH_SEPARATOR); @@ -454,8 +456,10 @@ void CPanel::ChangeComment() HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL); if (result != S_OK) { - MessageBoxError(result, L"Set Comment Error"); + if (result == E_NOINTERFACE) + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + else + MessageBoxError(result, L"Set Comment Error"); } RefreshListCtrl(state); } - diff --git a/CPP/7zip/UI/FileManager/PanelSelect.cpp b/CPP/7zip/UI/FileManager/PanelSelect.cpp index bbd4a187..64cef433 100755 --- a/CPP/7zip/UI/FileManager/PanelSelect.cpp +++ b/CPP/7zip/UI/FileManager/PanelSelect.cpp @@ -97,8 +97,7 @@ void CPanel::OnInsert() int nextIndex = focusedItem + 1; if (nextIndex < _listView.GetItemCount()) { - _listView.SetItemState(nextIndex, LVIS_FOCUSED | LVIS_SELECTED, - LVIS_FOCUSED | LVIS_SELECTED); + _listView.SetItemState_FocusedSelected(nextIndex); _listView.EnsureVisible(nextIndex, false); } } @@ -250,14 +249,15 @@ void CPanel::KillSelection() } } -void CPanel::OnLeftClick(LPNMITEMACTIVATE itemActivate) +void CPanel::OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate) { - if(itemActivate->hdr.hwndFrom != HWND(_listView)) + if (itemActivate->hdr.hwndFrom != HWND(_listView)) return; // It will be work only for Version 4.71 (IE 4); int indexInList = itemActivate->iItem; if (indexInList < 0) return; + #ifndef UNDER_CE if ((itemActivate->uKeyFlags & LVKF_SHIFT) != 0) { // int focusedIndex = _listView.GetFocusedItem(); @@ -280,8 +280,10 @@ void CPanel::OnLeftClick(LPNMITEMACTIVATE itemActivate) } } else + #endif { _startGroupSelect = indexInList; + #ifndef UNDER_CE if ((itemActivate->uKeyFlags & LVKF_CONTROL) != 0) { int realIndex = GetRealItemIndex(indexInList); @@ -291,6 +293,7 @@ void CPanel::OnLeftClick(LPNMITEMACTIVATE itemActivate) _listView.RedrawItem(indexInList); } } + #endif } return; } diff --git a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp index d1531957..150c71b1 100755 --- a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp +++ b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp @@ -2,13 +2,11 @@ #include "StdAfx.h" -#include "../../../../C/Alloc.h" - #include "Common/IntToString.h" +#include "Windows/Error.h" #include "Windows/FileIO.h" #include "Windows/FileFind.h" -#include "Windows/Thread.h" #include "../GUI/ExtractRes.h" @@ -18,27 +16,12 @@ #include "CopyDialog.h" #include "FormatUtils.h" #include "LangUtils.h" -#include "ProgressDialog2.h" #include "SplitDialog.h" #include "SplitUtils.h" using namespace NWindows; -class CMyBuffer -{ - void *_data; -public: - CMyBuffer(): _data(0) {} - operator void *() { return _data; } - bool Allocate(size_t size) - { - if (_data != 0) - return false; - _data = ::MidAlloc(size); - return _data != 0; - } - ~CMyBuffer() { ::MidFree(_data); } -}; +static const wchar_t *g_Message_FileWriteError = L"File write error"; struct CVolSeqName { @@ -92,95 +75,85 @@ struct CVolSeqName static const UInt32 kBufSize = (1 << 20); -struct CThreadSplit +class CThreadSplit: public CProgressThreadVirt { - // HRESULT Result; - // CPanel *Panel; - CProgressDialog *ProgressDialog; + HRESULT ProcessVirt(); +public: UString FilePath; UString VolBasePath; CRecordVector<UInt64> VolumeSizes; - UString Error; +}; + +HRESULT CThreadSplit::ProcessVirt() +{ + NFile::NIO::CInFile inFile; + if (!inFile.Open(FilePath)) + return GetLastError(); + NFile::NIO::COutFile outFile; + CMyBuffer bufferObject; + if (!bufferObject.Allocate(kBufSize)) + return E_OUTOFMEMORY; + Byte *buffer = (Byte *)(void *)bufferObject; + UInt64 curVolSize = 0; + CVolSeqName seqName; + UInt64 length; + if (!inFile.GetLength(length)) + return GetLastError(); + + CProgressSync &sync = ProgressDialog.Sync; + sync.SetProgress(length, 0); + UInt64 pos = 0; + + UInt64 numFiles = 0; + int volIndex = 0; - void Process2() + for (;;) { - // NCOM::CComInitializer comInitializer; - ProgressDialog->WaitCreating(); - NFile::NIO::CInFile inFile; - if (!inFile.Open(FilePath)) - throw L"Can not open file"; - NFile::NIO::COutFile outFile; - CMyBuffer bufferObject; - if (!bufferObject.Allocate(kBufSize)) - throw L"Can not allocate buffer"; - Byte *buffer = (Byte *)(void *)bufferObject; - UInt64 curVolSize = 0; - CVolSeqName seqName; - UInt64 length; - if (!inFile.GetLength(length)) - throw "error"; - - ProgressDialog->ProgressSynch.SetProgress(length, 0); - UInt64 pos = 0; - - int volIndex = 0; - - for (;;) + UInt64 volSize; + if (volIndex < VolumeSizes.Size()) + volSize = VolumeSizes[volIndex]; + else + volSize = VolumeSizes.Back(); + + UInt32 needSize = (UInt32)(MyMin((UInt64)kBufSize, volSize - curVolSize)); + UInt32 processedSize; + if (!inFile.Read(buffer, needSize, processedSize)) + return GetLastError(); + if (processedSize == 0) + break; + needSize = processedSize; + if (curVolSize == 0) { - UInt64 volSize; - if (volIndex < VolumeSizes.Size()) - volSize = VolumeSizes[volIndex]; - else - volSize = VolumeSizes.Back(); - - UInt32 needSize = (UInt32)(MyMin((UInt64)kBufSize, volSize - curVolSize)); - UInt32 processedSize; - if (!inFile.Read(buffer, needSize, processedSize)) - throw L"Can not read input file"; - if (processedSize == 0) - break; - needSize = processedSize; - if (curVolSize == 0) - { - UString name = VolBasePath; - name += L"."; - name += seqName.GetNextName(); - if (!outFile.Create(name, false)) - throw L"Can not create output file"; - ProgressDialog->ProgressSynch.SetCurrentFileName(name); - } - if (!outFile.Write(buffer, needSize, processedSize)) - throw L"Can not write output file"; - if (needSize != processedSize) - throw L"Can not write output file"; - curVolSize += processedSize; - if (curVolSize == volSize) + UString name = VolBasePath; + name += L'.'; + name += seqName.GetNextName(); + sync.SetCurrentFileName(name); + sync.SetNumFilesCur(numFiles++); + if (!outFile.Create(name, false)) { - outFile.Close(); - if (volIndex < VolumeSizes.Size()) - volIndex++; - curVolSize = 0; + HRESULT res = GetLastError(); + ErrorPath1 = name; + return res; } - pos += processedSize; - HRESULT res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos); - if (res != S_OK) - return; } + if (!outFile.Write(buffer, needSize, processedSize)) + return GetLastError(); + if (needSize != processedSize) + throw g_Message_FileWriteError; + curVolSize += processedSize; + if (curVolSize == volSize) + { + outFile.Close(); + if (volIndex < VolumeSizes.Size()) + volIndex++; + curVolSize = 0; + } + pos += processedSize; + RINOK(sync.SetPosAndCheckPaused(pos)); } - void Process() - { - try { Process2(); } - catch(const wchar_t *s) { Error = s; } - catch(...) { Error = L"Error"; } - ProgressDialog->MyClose(); - } - - static THREAD_FUNC_DECL MyThreadFunction(void *param) - { - ((CThreadSplit *)param)->Process(); - return 0; - } -}; + sync.SetNumFilesCur(numFiles); + return S_OK; +} void CApp::Split() { @@ -239,7 +212,7 @@ void CApp::Split() ConvertUInt64ToString(numVolumes, s); if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, 0x03020521, s), LangString(IDS_SPLIT_CONFIRM_TITLE, 0x03020520), - MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES) + MB_YESNOCANCEL | MB_ICONQUESTION) != IDYES) return; } @@ -251,20 +224,20 @@ void CApp::Split() return; } + { CThreadSplit spliter; - // spliter.Panel = this; - { - CProgressDialog progressDialog; - spliter.ProgressDialog = &progressDialog; + CProgressDialog &progressDialog = spliter.ProgressDialog; UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); UString title = LangString(IDS_SPLITTING, 0x03020510); + progressDialog.ShowCompressionInfo = false; + progressDialog.MainWindow = _window; progressDialog.MainTitle = progressWindowTitle; progressDialog.MainAddTitle = title + UString(L" "); - progressDialog.ProgressSynch.SetTitleFileName(itemName); + progressDialog.Sync.SetTitleFileName(itemName); spliter.FilePath = srcPath + itemName; @@ -276,16 +249,12 @@ void CApp::Split() // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel); // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel); - NWindows::CThread thread; - if (thread.Create(CThreadSplit::MyThreadFunction, &spliter) != S_OK) - throw 271824; - progressDialog.Create(title, _window); + if (spliter.Create(title, _window) != 0) + return; } RefreshTitleAlways(); - if (!spliter.Error.IsEmpty()) - srcPanel.MessageBoxMyError(spliter.Error); // disableTimerProcessing1.Restore(); // disableTimerProcessing2.Restore(); // srcPanel.SetFocusToList(); @@ -293,78 +262,71 @@ void CApp::Split() } -struct CThreadCombine +class CThreadCombine: public CProgressThreadVirt { - CProgressDialog *ProgressDialog; - + HRESULT ProcessVirt(); +public: UString InputDirPrefix; UStringVector Names; UString OutputPath; UInt64 TotalSize; +}; - UString Error; - HRESULT Res; +HRESULT CThreadCombine::ProcessVirt() +{ + NFile::NIO::COutFile outFile; + if (!outFile.Create(OutputPath, false)) + { + HRESULT res = GetLastError(); + ErrorPath1 = OutputPath; + return res; + } + + CProgressSync &sync = ProgressDialog.Sync; + sync.SetProgress(TotalSize, 0); - void Process2() + CMyBuffer bufferObject; + if (!bufferObject.Allocate(kBufSize)) + return E_OUTOFMEMORY; + Byte *buffer = (Byte *)(void *)bufferObject; + UInt64 pos = 0; + for (int i = 0; i < Names.Size(); i++) { - NFile::NIO::COutFile outFile; - if (!outFile.Create(OutputPath, false)) + NFile::NIO::CInFile inFile; + const UString nextName = InputDirPrefix + Names[i]; + if (!inFile.Open(nextName)) { - Error = L"Can create open output file:\n" + OutputPath; - return; + HRESULT res = GetLastError(); + ErrorPath1 = nextName; + return res; } - - ProgressDialog->ProgressSynch.SetProgress(TotalSize, 0); - - CMyBuffer bufferObject; - if (!bufferObject.Allocate(kBufSize)) - throw L"Can not allocate buffer"; - Byte *buffer = (Byte *)(void *)bufferObject; - UInt64 pos = 0; - for (int i = 0; i < Names.Size(); i++) + sync.SetCurrentFileName(nextName); + for (;;) { - NFile::NIO::CInFile inFile; - const UString nextName = InputDirPrefix + Names[i]; - if (!inFile.Open(nextName)) + UInt32 processedSize; + if (!inFile.Read(buffer, kBufSize, processedSize)) { - Error = L"Can not open input file:\n" + nextName; - return; + HRESULT res = GetLastError(); + ErrorPath1 = nextName; + return res; } - ProgressDialog->ProgressSynch.SetCurrentFileName(nextName); - for (;;) + if (processedSize == 0) + break; + UInt32 needSize = processedSize; + if (!outFile.Write(buffer, needSize, processedSize)) { - UInt32 processedSize; - if (!inFile.Read(buffer, kBufSize, processedSize)) - throw L"Can not read input file"; - if (processedSize == 0) - break; - UInt32 needSize = processedSize; - if (!outFile.Write(buffer, needSize, processedSize) || needSize != processedSize) - throw L"Can not write output file"; - pos += processedSize; - Res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos); - if (Res != S_OK) - return; + HRESULT res = GetLastError(); + ErrorPath1 = OutputPath; + return res; } + if (needSize != processedSize) + throw g_Message_FileWriteError; + pos += processedSize; + RINOK(sync.SetPosAndCheckPaused(pos)); } } - - void Process() - { - Res = S_OK; - ProgressDialog->WaitCreating(); - try { Process2(); } - catch(const wchar_t *s) { Error = s; } - catch(...) { Error = L"Error";} - ProgressDialog->MyClose(); - } - - static THREAD_FUNC_DECL MyThreadFunction(void *param) - { - ((CThreadCombine *)param)->Process(); - return 0; - } -}; + return S_OK; +} extern void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s); @@ -410,6 +372,7 @@ void CApp::Combine() return; } + { CThreadCombine combiner; UString nextName = itemName; @@ -491,10 +454,9 @@ void CApp::Combine() return; } - { - CProgressDialog progressDialog; - combiner.ProgressDialog = &progressDialog; - + CProgressDialog &progressDialog = combiner.ProgressDialog; + progressDialog.ShowCompressionInfo = false; + UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); UString title = LangString(IDS_COMBINING, 0x03020610); @@ -507,15 +469,11 @@ void CApp::Combine() // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel); // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel); - NWindows::CThread thread; - if (thread.Create(CThreadCombine::MyThreadFunction, &combiner) != S_OK) - throw 271824; - progressDialog.Create(title, _window); + if (combiner.Create(title, _window) != 0) + return; } RefreshTitleAlways(); - if (!combiner.Error.IsEmpty()) - srcPanel.MessageBoxMyError(combiner.Error); // disableTimerProcessing1.Restore(); // disableTimerProcessing2.Restore(); // srcPanel.SetFocusToList(); diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.cpp b/CPP/7zip/UI/FileManager/PasswordDialog.cpp index 94e8219d..eaf90a24 100755 --- a/CPP/7zip/UI/FileManager/PasswordDialog.cpp +++ b/CPP/7zip/UI/FileManager/PasswordDialog.cpp @@ -1,6 +1,7 @@ // PasswordDialog.cpp #include "StdAfx.h" + #include "PasswordDialog.h" #ifdef LANG @@ -12,7 +13,8 @@ static CIDLangPair kIDLangPairs[] = { { IDC_STATIC_PASSWORD_HEADER, 0x02000B01 }, { IDC_CHECK_PASSWORD_SHOW, 0x02000B02 }, - + { IDOK, 0x02000702 }, + { IDCANCEL, 0x02000710 } }; #endif @@ -33,8 +35,7 @@ bool CPasswordDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { if (buttonID == IDC_CHECK_PASSWORD_SHOW) { - _passwordControl.SetPasswordChar((IsButtonChecked( - IDC_CHECK_PASSWORD_SHOW) == BST_CHECKED) ? 0: TEXT('*')); + _passwordControl.SetPasswordChar(IsButtonCheckedBool(IDC_CHECK_PASSWORD_SHOW) ? 0: TEXT('*')); UString password; _passwordControl.GetText(password); _passwordControl.SetText(password); diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.rc b/CPP/7zip/UI/FileManager/PasswordDialog.rc index 64381aff..2328ac56 100755 --- a/CPP/7zip/UI/FileManager/PasswordDialog.rc +++ b/CPP/7zip/UI/FileManager/PasswordDialog.rc @@ -1,26 +1,14 @@ #include "PasswordDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 172 -#define ySize2 68 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 140 +#define yc 72 -#define bYPos (ySize - marg - bYSize) -#define b1XPos (xSize - marg - bXSize) -#define b2XPos (b1XPos - 10 - bXSize) - - -IDD_DIALOG_PASSWORD DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_PASSWORD MY_DIALOG CAPTION "Enter password" -MY_FONT BEGIN - LTEXT "&Enter password:", IDC_STATIC_PASSWORD_HEADER, marg, marg, xSize2, 8 - EDITTEXT IDC_EDIT_PASSWORD, marg , 19, xSize2, 14, ES_PASSWORD | ES_AUTOHSCROLL - - CONTROL "&Show password", IDC_CHECK_PASSWORD_SHOW, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 41, xSize2, 10 - - DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize + LTEXT "&Enter password:", IDC_STATIC_PASSWORD_HEADER, m, m, xc, 8 + EDITTEXT IDC_EDIT_PASSWORD, m, 20, xc, 14, ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "&Show password", IDC_CHECK_PASSWORD_SHOW, MY_CHECKBOX, m, 42, xc, 10 + OK_CANCEL END diff --git a/CPP/7zip/UI/FileManager/PluginLoader.h b/CPP/7zip/UI/FileManager/PluginLoader.h index f48c9e97..3cf15aa5 100755 --- a/CPP/7zip/UI/FileManager/PluginLoader.h +++ b/CPP/7zip/UI/FileManager/PluginLoader.h @@ -1,22 +1,18 @@ // PluginLoader.h -#ifndef __PLUGINLOADER_H -#define __PLUGINLOADER_H +#ifndef __PLUGIN_LOADER_H +#define __PLUGIN_LOADER_H #include "Windows/DLL.h" -typedef UINT32 (WINAPI * CreateObjectPointer)( - const GUID *clsID, - const GUID *interfaceID, - void **outObject); +typedef UINT32 (WINAPI * CreateObjectPointer)(const GUID *clsID, const GUID *interfaceID, void **outObject); class CPluginLibrary: public NWindows::NDLL::CLibrary { public: HRESULT CreateManager(REFGUID clsID, IFolderManager **manager) { - CreateObjectPointer createObject = (CreateObjectPointer) - GetProcAddress("CreateObject"); + CreateObjectPointer createObject = (CreateObjectPointer)GetProc("CreateObject"); if (createObject == NULL) return GetLastError(); return createObject(&clsID, &IID_IFolderManager, (void **)manager); diff --git a/CPP/7zip/UI/FileManager/PluginsPage.cpp b/CPP/7zip/UI/FileManager/PluginsPage.cpp index d79e78d8..0eeec9d6 100755 --- a/CPP/7zip/UI/FileManager/PluginsPage.cpp +++ b/CPP/7zip/UI/FileManager/PluginsPage.cpp @@ -1,22 +1,16 @@ // PluginsPage.cpp #include "StdAfx.h" -#include "PluginsPageRes.h" -#include "PluginsPage.h" -#include "Common/StringConvert.h" #include "Common/MyCom.h" -#include "Windows/Defs.h" #include "Windows/DLL.h" -#include "Windows/Control/ListView.h" -#include "Windows/FileFind.h" -#include "RegistryUtils.h" #include "HelpUtils.h" #include "LangUtils.h" +#include "PluginsPage.h" +#include "PluginsPageRes.h" #include "ProgramLocation.h" - #include "PluginInterface.h" static CIDLangPair kIDLangPairs[] = @@ -33,16 +27,16 @@ bool CPluginsPage::OnInit() _listView.Attach(GetItem(IDC_PLUGINS_LIST)); - UINT32 newFlags = /*LVS_EX_CHECKBOXES | */ LVS_EX_FULLROWSELECT; + UINT32 newFlags = /* LVS_EX_CHECKBOXES | */ LVS_EX_FULLROWSELECT; _listView.SetExtendedListViewStyle(newFlags, newFlags); - _listView.InsertColumn(0, L"Plugins", 160); + _listView.InsertColumn(0, L"Plugins", 50); ReadFileFolderPluginInfoList(_plugins); _listView.SetRedraw(false); // _listView.DeleteAllItems(); - for(int i = 0; i < _plugins.Size(); i++) + for (int i = 0; i < _plugins.Size(); i++) { const CPluginInfo &p = _plugins[i]; if (!p.OptionsClassIDDefined) @@ -59,11 +53,12 @@ bool CPluginsPage::OnInit() _listView.SetCheckState(i, true); } _listView.SetRedraw(true); - if(_listView.GetItemCount() > 0) + if (_listView.GetItemCount() > 0) { UINT state = LVIS_SELECTED | LVIS_FOCUSED; _listView.SetItemState(0, state, state); } + _listView.SetColumnWidthAuto(0); return CPropertyPage::OnInit(); } @@ -156,17 +151,15 @@ void CPluginsPage::OnButtonOptions() MessageBoxW(HWND(*this), L"There are no options", L"7-Zip", 0); return; } - NWindows::NDLL::CLibrary library; + NWindows::NDLL::CLibrary lib; CMyComPtr<IPluginOptions> pluginOptions; - if (!library.Load(pluginInfo.FilePath)) + if (!lib.Load(pluginInfo.FilePath)) { MessageBoxW(HWND(*this), L"Can't load plugin", L"7-Zip", 0); return; } - typedef UINT32 (WINAPI * CreateObjectPointer)( - const GUID *clsID, const GUID *interfaceID, void **outObject); - CreateObjectPointer createObject = (CreateObjectPointer) - library.GetProcAddress("CreateObject"); + typedef UINT32 (WINAPI * CreateObjectPointer)(const GUID *clsID, const GUID *interfaceID, void **outObject); + CreateObjectPointer createObject = (CreateObjectPointer)lib.GetProc("CreateObject"); if (createObject == NULL) { MessageBoxW(HWND(*this), L"Incorrect plugin", L"7-Zip", 0); @@ -211,4 +204,4 @@ bool CPluginsPage::OnCommand(int code, int itemID, LPARAM lParam) return CPropertyPage::OnCommand(code, itemID, lParam); } -*/
\ No newline at end of file +*/ diff --git a/CPP/7zip/UI/FileManager/PluginsPage.rc b/CPP/7zip/UI/FileManager/PluginsPage.rc index b4868aa3..18e5dfc8 100755 --- a/CPP/7zip/UI/FileManager/PluginsPage.rc +++ b/CPP/7zip/UI/FileManager/PluginsPage.rc @@ -1,19 +1,15 @@ #include "PluginsPageRes.h" #include "../../GuiCommon.rc" -#define xSize2 196 -#define ySize2 140 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 96 +#define yc 80 - -IDD_PLUGINS DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE +IDD_PLUGINS MY_PAGE CAPTION "Plugins" -MY_FONT BEGIN - LTEXT "&Plugins:", IDC_PLUGINS_STATIC_PLUGINS, marg, marg, xSize2, 8 - CONTROL "List1", IDC_PLUGINS_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | - LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, - marg, 20, xSize2 - bXSize - 12, ySize2 - 12 - PUSHBUTTON "Options...", IDC_PLUGINS_BUTTON_OPTIONS, (xSize - marg - bXSize), 20, bXSize, bYSize + LTEXT "&Plugins:", IDC_PLUGINS_STATIC_PLUGINS, m, m, xc, 8 + CONTROL "List1", IDC_PLUGINS_LIST, "SysListView32", + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, + m, 20, xc, 40 + PUSHBUTTON "Options...", IDC_PLUGINS_BUTTON_OPTIONS, m, by, bxs, bys END diff --git a/CPP/7zip/UI/FileManager/PluginsPageRes.h b/CPP/7zip/UI/FileManager/PluginsPageRes.h index 8fc923ee..ca07ca5c 100755 --- a/CPP/7zip/UI/FileManager/PluginsPageRes.h +++ b/CPP/7zip/UI/FileManager/PluginsPageRes.h @@ -1,4 +1,4 @@ -#define IDD_PLUGINS 901 +#define IDD_PLUGINS 541 #define IDC_PLUGINS_STATIC_PLUGINS 1000 #define IDC_PLUGINS_LIST 1001 #define IDC_PLUGINS_BUTTON_OPTIONS 1002 diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.cpp b/CPP/7zip/UI/FileManager/ProgramLocation.cpp index fc7b40db..04c2c98c 100755 --- a/CPP/7zip/UI/FileManager/ProgramLocation.cpp +++ b/CPP/7zip/UI/FileManager/ProgramLocation.cpp @@ -1,10 +1,9 @@ -// ProgramLocation.h +// ProgramLocation.cpp #include "StdAfx.h" #include "ProgramLocation.h" -#include "Windows/FileName.h" #include "Windows/DLL.h" using namespace NWindows; diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.h b/CPP/7zip/UI/FileManager/ProgramLocation.h index 38317b45..55c56144 100755 --- a/CPP/7zip/UI/FileManager/ProgramLocation.h +++ b/CPP/7zip/UI/FileManager/ProgramLocation.h @@ -1,7 +1,7 @@ // ProgramLocation.h -#ifndef __PROGRAMLOCATION_H -#define __PROGRAMLOCATION_H +#ifndef __PROGRAM_LOCATION_H +#define __PROGRAM_LOCATION_H #include "Common/MyString.h" diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.cpp b/CPP/7zip/UI/FileManager/ProgressDialog.cpp index 5be77a8f..cdb8399e 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog.cpp +++ b/CPP/7zip/UI/FileManager/ProgressDialog.cpp @@ -1,15 +1,19 @@ // ProgressDialog.cpp #include "StdAfx.h" + +#include "Common/IntToString.h" + #include "resource.h" + #include "ProgressDialog.h" -#include "Common/IntToString.h" -#include "Common/IntToString.h" using namespace NWindows; +extern HINSTANCE g_hInstance; + static const UINT_PTR kTimerID = 3; -static const UINT kTimerElapse = 50; +static const UINT kTimerElapse = 100; #ifdef LANG #include "LangUtils.h" @@ -22,7 +26,7 @@ static CIDLangPair kIDLangPairs[] = }; #endif -HRESULT CProgressSynch::ProcessStopAndPause() +HRESULT CProgressSync::ProcessStopAndPause() { for (;;) { @@ -48,30 +52,37 @@ void CProgressDialog::AddToTitle(LPCWSTR s) #endif - bool CProgressDialog::OnInit() { - _range = UINT64(-1); + _range = (UInt64)-1; _prevPercentValue = -1; + _wasCreated = true; + _dialogCreatedEvent.Set(); + #ifdef LANG // LangSetWindowText(HWND(*this), 0x02000C00); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif m_ProgressBar.Attach(GetItem(IDC_PROGRESS1)); + + if (IconID >= 0) + { + HICON icon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IconID)); + SetIcon(ICON_BIG, icon); + } + _timer = SetTimer(kTimerID, kTimerElapse); - _dialogCreatedEvent.Set(); SetText(_title); + CheckNeedClose(); return CModalDialog::OnInit(); } -void CProgressDialog::OnCancel() -{ - ProgressSynch.SetStopped(true); -} +void CProgressDialog::OnCancel() { Sync.SetStopped(true); } +void CProgressDialog::OnOK() { } -void CProgressDialog::SetRange(UINT64 range) +void CProgressDialog::SetRange(UInt64 range) { _range = range; _peviousPos = (UInt64)(Int64)-1; @@ -79,16 +90,16 @@ void CProgressDialog::SetRange(UINT64 range) m_ProgressBar.SetRange32(0 , _converter.Count(range)); // Test it for 100% } -void CProgressDialog::SetPos(UINT64 pos) +void CProgressDialog::SetPos(UInt64 pos) { bool redraw = true; if (pos < _range && pos > _peviousPos) { - UINT64 posDelta = pos - _peviousPos; + UInt64 posDelta = pos - _peviousPos; if (posDelta < (_range >> 10)) redraw = false; } - if(redraw) + if (redraw) { m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100% _peviousPos = pos; @@ -97,10 +108,13 @@ void CProgressDialog::SetPos(UINT64 pos) bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { - if (ProgressSynch.GetPaused()) + if (Sync.GetPaused()) return true; - UINT64 total, completed; - ProgressSynch.GetProgress(total, completed); + + CheckNeedClose(); + + UInt64 total, completed; + Sync.GetProgress(total, completed); if (total != _range) SetRange(total); SetPos(completed); @@ -124,29 +138,6 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) return true; } - -//////////////////// -// CU64ToI32Converter - -static const UINT64 kMaxIntValue = 0x7FFFFFFF; - -void CU64ToI32Converter::Init(UINT64 range) -{ - _numShiftBits = 0; - while(range > kMaxIntValue) - { - range >>= 1; - _numShiftBits++; - } -} - -int CU64ToI32Converter::Count(UINT64 aValue) -{ - return int(aValue >> _numShiftBits); -} - -const UINT CProgressDialog::kCloseMessage = WM_USER + 1; - bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) @@ -155,14 +146,20 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { KillTimer(_timer); _timer = 0; - End(0); - return true; + if (_inCancelMessageBox) + { + _externalCloseMessageWasReceived = true; + break; + } + return OnExternalCloseMessage(); } + /* case WM_SETTEXT: { if (_timer == 0) return true; } + */ } return CModalDialog::OnMessage(message, wParam, lParam); } @@ -173,16 +170,35 @@ bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { case IDCANCEL: { - bool paused = ProgressSynch.GetPaused();; - ProgressSynch.SetPaused(true); - int res = ::MessageBoxW(HWND(*this), - L"Are you sure you want to cancel?", - _title, MB_YESNOCANCEL); - ProgressSynch.SetPaused(paused); + bool paused = Sync.GetPaused(); + Sync.SetPaused(true); + _inCancelMessageBox = true; + int res = ::MessageBoxW(HWND(*this), L"Are you sure you want to cancel?", _title, MB_YESNOCANCEL); + _inCancelMessageBox = false; + Sync.SetPaused(paused); if (res == IDCANCEL || res == IDNO) + { + if (_externalCloseMessageWasReceived) + OnExternalCloseMessage(); return true; + } break; } } return CModalDialog::OnButtonClicked(buttonID, buttonHWND); } + +void CProgressDialog::CheckNeedClose() +{ + if (_needClose) + { + PostMessage(kCloseMessage); + _needClose = false; + } +} + +bool CProgressDialog::OnExternalCloseMessage() +{ + End(0); + return true; +} diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.h b/CPP/7zip/UI/FileManager/ProgressDialog.h index 201aead7..429ed740 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog.h +++ b/CPP/7zip/UI/FileManager/ProgressDialog.h @@ -1,59 +1,61 @@ // ProgressDialog.h -#ifndef __PROGRESSDIALOG_H -#define __PROGRESSDIALOG_H +#ifndef __PROGRESS_DIALOG_H +#define __PROGRESS_DIALOG_H -#include "ProgressDialogRes.h" +#include "Windows/Synchronization.h" +#include "Windows/Thread.h" #include "Windows/Control/Dialog.h" #include "Windows/Control/ProgressBar.h" -#include "Windows/Synchronization.h" -class CProgressSynch +#include "ProgressDialogRes.h" + +class CProgressSync { - NWindows::NSynchronization::CCriticalSection _criticalSection; + NWindows::NSynchronization::CCriticalSection _cs; bool _stopped; bool _paused; - UINT64 _total; - UINT64 _completed; + UInt64 _total; + UInt64 _completed; public: - CProgressSynch(): _stopped(false), _paused(false), _total(1), _completed(0) {} + CProgressSync(): _stopped(false), _paused(false), _total(1), _completed(0) {} HRESULT ProcessStopAndPause(); bool GetStopped() { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); return _stopped; } void SetStopped(bool value) { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); _stopped = value; } bool GetPaused() { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); return _paused; } void SetPaused(bool value) { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); _paused = value; } - void SetProgress(UINT64 total, UINT64 completed) + void SetProgress(UInt64 total, UInt64 completed) { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); _total = total; _completed = completed; } - void SetPos(UINT64 completed) + void SetPos(UInt64 completed) { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); _completed = completed; } - void GetProgress(UINT64 &total, UINT64 &completed) + void GetProgress(UInt64 &total, UInt64 &completed) { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); total = _total; completed = _completed; } @@ -61,14 +63,17 @@ public: class CU64ToI32Converter { - UINT64 _numShiftBits; + UInt64 _numShiftBits; public: - void Init(UINT64 _range); - int Count(UINT64 aValue); + void Init(UInt64 range) + { + // Windows CE doesn't like big number here. + for (_numShiftBits = 0; range > (1 << 15); _numShiftBits++) + range >>= 1; + } + int Count(UInt64 value) { return int(value >> _numShiftBits); } }; -// class CProgressDialog: public NWindows::NControl::CModelessDialog - class CProgressDialog: public NWindows::NControl::CModalDialog { private: @@ -76,24 +81,35 @@ private: UString _title; CU64ToI32Converter _converter; - UINT64 _peviousPos; - UINT64 _range; + UInt64 _peviousPos; + UInt64 _range; NWindows::NControl::CProgressBar m_ProgressBar; int _prevPercentValue; + bool _wasCreated; + bool _needClose; + bool _inCancelMessageBox; + bool _externalCloseMessageWasReceived; + bool OnTimer(WPARAM timerID, LPARAM callback); - void SetRange(UINT64 range); - void SetPos(UINT64 pos); + void SetRange(UInt64 range); + void SetPos(UInt64 pos); virtual bool OnInit(); virtual void OnCancel(); + virtual void OnOK(); NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent; #ifndef _SFX void AddToTitle(LPCWSTR string); #endif bool OnButtonClicked(int buttonID, HWND buttonHWND); + + void WaitCreating() { _dialogCreatedEvent.Lock(); } + void CheckNeedClose(); + bool OnExternalCloseMessage(); public: - CProgressSynch ProgressSynch; + CProgressSync Sync; + int IconID; #ifndef _SFX HWND MainWindow; @@ -107,27 +123,48 @@ public: ,MainWindow(0) #endif { + IconID = -1; + _wasCreated = false; + _needClose = false; + _inCancelMessageBox = false; + _externalCloseMessageWasReceived = false; + if (_dialogCreatedEvent.Create() != S_OK) throw 1334987; } - void WaitCreating() { _dialogCreatedEvent.Lock(); } - - - INT_PTR Create(const UString &title, HWND wndParent = 0) + INT_PTR Create(const UString &title, NWindows::CThread &thread, HWND wndParent = 0) { _title = title; - return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); + INT_PTR res = CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); + thread.Wait(); + return res; } - static const UINT kCloseMessage; + enum + { + kCloseMessage = WM_USER + 1 + }; virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); - void MyClose() + void ProcessWasFinished() { - PostMessage(kCloseMessage); + WaitCreating(); + if (_wasCreated) + PostMessage(kCloseMessage); + else + _needClose = true; }; }; + +class CProgressCloser +{ + CProgressDialog *_p; +public: + CProgressCloser(CProgressDialog &p) : _p(&p) {} + ~CProgressCloser() { _p->ProcessWasFinished(); } +}; + #endif diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.rc b/CPP/7zip/UI/FileManager/ProgressDialog.rc index e5cdd7e8..3a65338f 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog.rc +++ b/CPP/7zip/UI/FileManager/ProgressDialog.rc @@ -1,20 +1,12 @@ #include "ProgressDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 172 -#define ySize2 42 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 172 +#define yc 44 -#define bYPos (ySize - marg - bYSize) -#define bXPos (xSize - marg - bXSize) - - -IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_PROGRESS MY_DIALOG CAPTION "Progress" -MY_FONT BEGIN - PUSHBUTTON "Cancel", IDCANCEL, bXPos, bYPos , bXSize, bYSize - CONTROL "Progress1", IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH | WS_BORDER, - marg,marg, xSize2, 14 + PUSHBUTTON "Cancel", IDCANCEL, bx, by, bxs, bys + CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, m, m, xc, 14 END diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp index 87a1521d..2c9996ab 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp @@ -3,17 +3,35 @@ #include "StdAfx.h" #include "Common/IntToString.h" +#include "Common/StringConvert.h" + +#include "Windows/Control/Static.h" +#include "Windows/Error.h" #include "ProgressDialog2.h" +#include "DialogSize.h" + +#include "ProgressDialog2Res.h" + +#include "../GUI/ExtractRes.h" using namespace NWindows; +extern HINSTANCE g_hInstance; + static const UINT_PTR kTimerID = 3; -static const UINT kTimerElapse = 100; -#ifdef LANG +static const UINT kCloseMessage = WM_USER + 1; + +static const UINT kTimerElapse = + #ifdef UNDER_CE + 500 + #else + 100 + #endif + ; + #include "LangUtils.h" -#endif #ifdef LANG static CIDLangPair kIDLangPairs[] = @@ -34,7 +52,7 @@ static CIDLangPair kIDLangPairs[] = }; #endif -HRESULT CProgressSynch::ProcessStopAndPause() +HRESULT CProgressSync::ProcessStopAndPause() { for (;;) { @@ -47,13 +65,38 @@ HRESULT CProgressSynch::ProcessStopAndPause() return S_OK; } -HRESULT CProgressSynch::SetPosAndCheckPaused(UInt64 completed) +HRESULT CProgressSync::SetPosAndCheckPaused(UInt64 completed) { RINOK(ProcessStopAndPause()); SetPos(completed); return S_OK; } + +CProgressDialog::CProgressDialog(): _timer(0), CompressingMode(true) + #ifndef _SFX + , MainWindow(0) + #endif + { + IconID = -1; + MessagesDisplayed = false; + _wasCreated = false; + _needClose = false; + _inCancelMessageBox = false; + _externalCloseMessageWasReceived = false; + + _numPostedMessages = 0; + _errorsWereDisplayed = false; + _waitCloseByCancelButton = false; + _cancelWasPressed = false; + ShowCompressionInfo = true; + WaitMode = false; + if (_dialogCreatedEvent.Create() != S_OK) + throw 1334987; + if (_createDialogEvent.Create() != S_OK) + throw 1334987; + } + #ifndef _SFX CProgressDialog::~CProgressDialog() { @@ -68,7 +111,9 @@ void CProgressDialog::AddToTitle(LPCWSTR s) } } -static const int kTitleFileNameSizeLimit = 40; +#endif + +static const int kTitleFileNameSizeLimit = 36; static const int kCurrentFileNameSizeLimit = 82; static void ReduceString(UString &s, int size) @@ -76,22 +121,34 @@ static void ReduceString(UString &s, int size) if (s.Length() > size) s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2); } -#endif + +void CProgressDialog::EnableErrorsControls(bool enable) +{ + int cmdShow = enable ? SW_SHOW : SW_HIDE; + ShowItem(IDC_PROGRESS_ERRORS, cmdShow); + ShowItem(IDC_PROGRESS_ERRORS_VALUE, cmdShow); + ShowItem(IDC_PROGRESS_LIST, cmdShow); +} bool CProgressDialog::OnInit() { - _range = (UInt64)(Int64)(-1); - _prevPercentValue = UInt32(-1); - _prevElapsedSec = UInt32(-1); - _prevRemainingSec = UInt32(-1); - _prevSpeed = UInt32(-1); + _range = (UInt64)(Int64)-1; + _prevPercentValue = (UInt32)-1; + _prevElapsedSec = (UInt32)-1; + _prevRemainingSec = (UInt32)-1; + _prevSpeed = (UInt32)-1; _prevMode = kSpeedBytes; _prevTime = ::GetTickCount(); _elapsedTime = 0; _foreground = true; + m_ProgressBar.Attach(GetItem(IDC_PROGRESS1)); + _messageList.Attach(GetItem(IDC_PROGRESS_LIST)); + + _wasCreated = true; + _dialogCreatedEvent.Set(); + #ifdef LANG - // LangSetWindowText(HWND(*this), 0x02000C00); LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif @@ -104,24 +161,197 @@ bool CProgressDialog::OnInit() window = GetItem(IDC_BUTTON_PAUSE); window.GetText(pauseString); - foregroundString = LangString(IDS_PROGRESS_FOREGROUND, 0x02000C11); - continueString = LangString(IDS_PROGRESS_CONTINUE, 0x02000C13); - pausedString = LangString(IDS_PROGRESS_PAUSED, 0x02000C20); + foregroundString = LangStringSpec(IDS_PROGRESS_FOREGROUND, 0x02000C11); + continueString = LangStringSpec(IDS_PROGRESS_CONTINUE, 0x02000C13); + pausedString = LangStringSpec(IDS_PROGRESS_PAUSED, 0x02000C20); - m_ProgressBar.Attach(GetItem(IDC_PROGRESS1)); - _timer = SetTimer(kTimerID, kTimerElapse); - _dialogCreatedEvent.Set(); SetText(_title); SetPauseText(); SetPriorityText(); + + + #ifndef UNDER_CE + _messageList.SetUnicodeFormat(true); + #endif + + _messageList.InsertColumn(0, L"", 30); + + const UString s = LangStringSpec(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80); + + _messageList.InsertColumn(1, s, 600); + + _messageList.SetColumnWidthAuto(0); + _messageList.SetColumnWidthAuto(1); + + + EnableErrorsControls(false); + + GetItemSizes(IDCANCEL, buttonSizeX, buttonSizeY); + _numReduceSymbols = kCurrentFileNameSizeLimit; + NormalizeSize(true); + + if (!ShowCompressionInfo) + { + HideItem(IDC_PROGRESS_PACKED); + HideItem(IDC_PROGRESS_PACKED_VALUE); + HideItem(IDC_PROGRESS_RATIO); + HideItem(IDC_PROGRESS_RATIO_VALUE); + } + + if (IconID >= 0) + { + HICON icon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IconID)); + // SetIcon(ICON_SMALL, icon); + SetIcon(ICON_BIG, icon); + } + _timer = SetTimer(kTimerID, kTimerElapse); + #ifdef UNDER_CE + Foreground(); + #endif + + CheckNeedClose(); + return CModalDialog::OnInit(); } -void CProgressDialog::OnCancel() +bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) { - ProgressSynch.SetStopped(true); + int sY; + int sStep; + int mx, my; + { + RECT rect; + GetClientRectOfItem(IDC_PROGRESS_ELAPSED, rect); + mx = rect.left; + my = rect.top; + sY = rect.bottom - rect.top; + GetClientRectOfItem(IDC_PROGRESS_REMAINING, rect); + sStep = rect.top - my; + } + + + InvalidateRect(NULL); + + int xSizeClient = xSize - mx * 2; + + { + int i; + for (i = 800; i > 40; i = i * 9 / 10) + if (Units_To_Pixels_X(i) <= xSizeClient) + break; + _numReduceSymbols = i / 4; + } + + int yPos = ySize - my - buttonSizeY; + + ChangeSubWindowSizeX(GetItem(IDC_PROGRESS_FILE_NAME), xSize - mx * 2); + ChangeSubWindowSizeX(GetItem(IDC_PROGRESS1), xSize - mx * 2); + + int bSizeX = buttonSizeX; + int mx2 = mx; + for (;; mx2--) + { + int bSize2 = bSizeX * 3 + mx2 * 2; + if (bSize2 <= xSizeClient) + break; + if (mx2 < 5) + { + bSizeX = (xSizeClient - mx2 * 2) / 3; + break; + } + } + if (bSizeX < 2) + bSizeX = 2; + + { + RECT rect; + GetClientRectOfItem(IDC_PROGRESS_LIST, rect); + int y = rect.top; + int ySize2 = yPos - my - y; + const int kMinYSize = buttonSizeY + buttonSizeY * 3 / 4; + int xx = xSize - mx * 2; + if (ySize2 < kMinYSize) + { + ySize2 = kMinYSize; + if (xx > bSizeX * 2) + xx -= bSizeX; + } + + _messageList.Move(mx, y, xx, ySize2); + } + + { + int xPos = xSize - mx; + xPos -= bSizeX; + MoveItem(IDCANCEL, xPos, yPos, bSizeX, buttonSizeY); + xPos -= (mx2 + bSizeX); + MoveItem(IDC_BUTTON_PAUSE, xPos, yPos, bSizeX, buttonSizeY); + xPos -= (mx2 + bSizeX); + MoveItem(IDC_BUTTON_PROGRESS_PRIORITY, xPos, yPos, bSizeX, buttonSizeY); + } + + int valueSize; + int labelSize; + int padSize; + + labelSize = Units_To_Pixels_X(MY_PROGRESS_LABEL_UNITS_MIN); + valueSize = Units_To_Pixels_X(MY_PROGRESS_VALUE_UNITS); + padSize = Units_To_Pixels_X(MY_PROGRESS_PAD_UNITS); + int requiredSize = (labelSize + valueSize) * 2 + padSize; + + int gSize; + { + if (requiredSize < xSizeClient) + { + int incr = (xSizeClient - requiredSize) / 3; + labelSize += incr; + } + else + labelSize = (xSizeClient - valueSize * 2 - padSize) / 2; + if (labelSize < 0) + labelSize = 0; + + gSize = labelSize + valueSize; + padSize = xSizeClient - gSize * 2; + } + + labelSize = gSize - valueSize; + + UINT IDs[] = + { + IDC_PROGRESS_ELAPSED, IDC_PROGRESS_ELAPSED_VALUE, + IDC_PROGRESS_REMAINING, IDC_PROGRESS_REMAINING_VALUE, + IDC_PROGRESS_FILES, IDC_PROGRESS_FILES_VALUE, + IDC_PROGRESS_RATIO, IDC_PROGRESS_RATIO_VALUE, + IDC_PROGRESS_ERRORS, IDC_PROGRESS_ERRORS_VALUE, + + IDC_PROGRESS_TOTAL, IDC_PROGRESS_TOTAL_VALUE, + IDC_PROGRESS_SPEED, IDC_PROGRESS_SPEED_VALUE, + IDC_PROGRESS_UNPACKED, IDC_PROGRESS_UNPACKED_VALUE, + IDC_PROGRESS_PACKED, IDC_PROGRESS_PACKED_VALUE + }; + + yPos = my; + for (int i = 0; i < sizeof(IDs) / sizeof(IDs[0]); i += 2) + { + int x = mx; + const int kNumColumn1Items = 5 * 2; + if (i >= kNumColumn1Items) + { + if (i == kNumColumn1Items) + yPos = my; + x = mx + gSize + padSize; + } + MoveItem(IDs[i], x, yPos, labelSize, sY); + MoveItem(IDs[i + 1], x + labelSize, yPos, valueSize, sY); + yPos += sStep; + } + return false; } +void CProgressDialog::OnCancel() { Sync.SetStopped(true); } +void CProgressDialog::OnOK() { } + static void ConvertSizeToString(UInt64 value, wchar_t *s) { const wchar_t *kModif = L" KM"; @@ -144,7 +374,7 @@ void CProgressDialog::SetRange(UInt64 range) _range = range; _previousPos = (UInt64)(Int64)-1; _converter.Init(range); - m_ProgressBar.SetRange32(0, _converter.Count(range)); // Test it for 100% + m_ProgressBar.SetRange32(0, _converter.Count(range)); } void CProgressDialog::SetPos(UInt64 pos) @@ -157,7 +387,7 @@ void CProgressDialog::SetPos(UInt64 pos) } if(redraw) { - m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100% + m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100% _previousPos = pos; } } @@ -179,13 +409,11 @@ void CProgressDialog::ShowSize(int id, UInt64 value) SetItemText(id, s); } -bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) +void CProgressDialog::UpdateStatInfo(bool showAll) { - if (ProgressSynch.GetPaused()) - return true; UInt64 total, completed, totalFiles, completedFiles, inSize, outSize; bool bytesProgressMode; - ProgressSynch.GetProgress(total, completed, totalFiles, completedFiles, inSize, outSize, bytesProgressMode); + Sync.GetProgress(total, completed, totalFiles, completedFiles, inSize, outSize, bytesProgressMode); UInt32 curTime = ::GetTickCount(); @@ -222,8 +450,29 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) elapsedChanged = true; } - if (elapsedChanged) + if (elapsedChanged || showAll) { + { + UInt64 numErrors; + + { + NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs); + numErrors = Sync.Messages.Size(); + } + if (numErrors > 0) + { + UpdateMessagesDialog(); + TCHAR s[40]; + ConvertUInt64ToString(numErrors, s); + SetItemText(IDC_PROGRESS_ERRORS_VALUE, s); + if (!_errorsWereDisplayed) + { + _errorsWereDisplayed = true; + EnableErrorsControls(true); + } + } + } + if (completed != 0) { @@ -245,7 +494,6 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) _prevRemainingSec = remainingSec; } } - // if (elapsedChanged) { UInt32 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime; UInt64 speedB = (completed * 1000) / elapsedTime; @@ -296,7 +544,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) total = 1; UInt32 percentValue = (UInt32)(completed * 100 / total); UString titleName; - ProgressSynch.GetTitleFileName(titleName); + Sync.GetTitleFileName(titleName); if (percentValue != _prevPercentValue || _prevTitleName != titleName) { _prevPercentValue = percentValue; @@ -339,7 +587,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) UString fileName; - ProgressSynch.GetCurrentFileName(fileName); + Sync.GetCurrentFileName(fileName); if (_prevFileName != fileName) { int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR); @@ -351,38 +599,127 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) } else s2 = fileName; - ReduceString(s1, kCurrentFileNameSizeLimit); - ReduceString(s2, kCurrentFileNameSizeLimit); + ReduceString(s1, _numReduceSymbols); + ReduceString(s2, _numReduceSymbols); UString s = s1 + L"\n" + s2; SetItemText(IDC_PROGRESS_FILE_NAME, s); _prevFileName == fileName; } - - return true; } +bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) +{ + if (Sync.GetPaused()) + return true; -//////////////////// -// CU64ToI32Converter + CheckNeedClose(); -static const UInt64 kMaxIntValue = 0x7FFFFFFF; + UpdateStatInfo(false); + return true; +} -void CU64ToI32Converter::Init(UInt64 range) +struct CWaitCursor { - _numShiftBits = 0; - while(range > kMaxIntValue) + HCURSOR _waitCursor; + HCURSOR _oldCursor; + CWaitCursor() { - range >>= 1; - _numShiftBits++; + _waitCursor = LoadCursor(NULL, IDC_WAIT); + if (_waitCursor != NULL) + _oldCursor = SetCursor(_waitCursor); } -} + ~CWaitCursor() + { + if (_waitCursor != NULL) + SetCursor(_oldCursor); + } +}; -int CU64ToI32Converter::Count(UInt64 aValue) +INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread, HWND wndParent) { - return int(aValue >> _numShiftBits); + INT_PTR res = 0; + try + { + if (WaitMode) + { + CWaitCursor waitCursor; + HANDLE h[] = { thread, _createDialogEvent }; + + WRes res = WaitForMultipleObjects(sizeof(h) / sizeof(h[0]), h, FALSE, + #ifdef UNDER_CE + 2500 + #else + 1000 + #endif + ); + if (res == WAIT_OBJECT_0 && !Sync.ThereIsMessage()) + return 0; + } + _title = title; + BIG_DIALOG_SIZE(360, 192); + res = CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_PROGRESS), wndParent); + } + catch(...) + { + _wasCreated = true; + _dialogCreatedEvent.Set(); + res = res; + } + thread.Wait(); + if (!MessagesDisplayed) + MessageBoxW(wndParent, L"Progress Error", L"7-Zip", MB_ICONERROR | MB_OK); + return res; } -const UINT CProgressDialog::kCloseMessage = WM_USER + 1; +bool CProgressDialog::OnExternalCloseMessage() +{ + UpdateStatInfo(true); + + HideItem(IDC_BUTTON_PROGRESS_PRIORITY); + HideItem(IDC_BUTTON_PAUSE); + SetItemText(IDCANCEL, LangStringSpec(IDS_CLOSE, 0x02000713)); + + bool thereAreMessages; + UString okMessage; + UString okMessageTitle; + UString errorMessage; + UString errorMessageTitle; + { + NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs); + errorMessage = Sync.ErrorMessage; + errorMessageTitle = Sync.ErrorMessageTitle; + okMessage = Sync.OkMessage; + okMessageTitle = Sync.OkMessageTitle; + thereAreMessages = !Sync.Messages.IsEmpty(); + } + if (!errorMessage.IsEmpty()) + { + MessagesDisplayed = true; + if (errorMessageTitle.IsEmpty()) + errorMessageTitle = L"7-Zip"; + MessageBoxW(*this, errorMessage, errorMessageTitle, MB_ICONERROR | MB_OK); + } + else if (!thereAreMessages) + { + MessagesDisplayed = true; + if (!okMessage.IsEmpty()) + { + if (okMessageTitle.IsEmpty()) + okMessageTitle = L"7-Zip"; + MessageBoxW(*this, okMessage, okMessageTitle, MB_OK); + } + } + + if (thereAreMessages && !_cancelWasPressed) + { + _waitCloseByCancelButton = true; + UpdateMessagesDialog(); + return true; + } + + End(0); + return true; +} bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { @@ -392,14 +729,21 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { KillTimer(_timer); _timer = 0; - End(0); - return true; + if (_inCancelMessageBox) + { + _externalCloseMessageWasReceived = true; + break; + } + return OnExternalCloseMessage(); } + /* case WM_SETTEXT: { if (_timer == 0) return true; + break; } + */ } return CModalDialog::OnMessage(message, wParam, lParam); } @@ -407,31 +751,31 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) void CProgressDialog::SetTitleText() { UString title; - if (ProgressSynch.GetPaused()) + if (Sync.GetPaused()) { title = pausedString; - title += L" "; + title += L' '; } - if (_prevPercentValue != UInt32(-1)) + if (_prevPercentValue != (UInt32)-1) { wchar_t s[64]; ConvertUInt64ToString(_prevPercentValue, s); title += s; - title += L"%"; + title += L'%'; } if (!_foreground) { - title += L" "; + title += L' '; title += backgroundedString; } - title += L" "; + title += L' '; UString totalTitle = title + _title; UString fileName; - ProgressSynch.GetTitleFileName(fileName); + Sync.GetTitleFileName(fileName); if (!fileName.IsEmpty()) { ReduceString(fileName, kTitleFileNameSizeLimit); - totalTitle += L" "; + totalTitle += L' '; totalTitle += fileName; } SetText(totalTitle); @@ -442,15 +786,15 @@ void CProgressDialog::SetTitleText() void CProgressDialog::SetPauseText() { - SetItemText(IDC_BUTTON_PAUSE, ProgressSynch.GetPaused() ? + SetItemText(IDC_BUTTON_PAUSE, Sync.GetPaused() ? continueString : pauseString); SetTitleText(); } void CProgressDialog::OnPauseButton() { - bool paused = !ProgressSynch.GetPaused(); - ProgressSynch.SetPaused(paused); + bool paused = !Sync.GetPaused(); + Sync.SetPaused(paused); UInt32 curTime = ::GetTickCount(); if (paused) _elapsedTime += (curTime - _prevTime); @@ -469,39 +813,188 @@ void CProgressDialog::SetPriorityText() void CProgressDialog::OnPriorityButton() { _foreground = !_foreground; + #ifndef UNDER_CE SetPriorityClass(GetCurrentProcess(), _foreground ? NORMAL_PRIORITY_CLASS: IDLE_PRIORITY_CLASS); + #endif SetPriorityText(); } +void CProgressDialog::AddMessageDirect(LPCWSTR message) +{ + int itemIndex = _messageList.GetItemCount(); + wchar_t sz[32]; + ConvertInt64ToString(itemIndex, sz); + _messageList.InsertItem(itemIndex, sz); + _messageList.SetSubItem(itemIndex, 1, message); +} + +void CProgressDialog::AddMessage(LPCWSTR message) +{ + UString s = message; + while (!s.IsEmpty()) + { + int pos = s.Find(L'\n'); + if (pos < 0) + break; + AddMessageDirect(s.Left(pos)); + s.Delete(0, pos + 1); + } + AddMessageDirect(s); +} + +void CProgressDialog::UpdateMessagesDialog() +{ + int numMessages; + UStringVector messages; + { + NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs); + numMessages = _numPostedMessages; + for (int i = _numPostedMessages; i < Sync.Messages.Size(); i++) + messages.Add(Sync.Messages[i]); + _numPostedMessages = Sync.Messages.Size(); + } + if (!messages.IsEmpty()) + { + for (int i = 0; i < messages.Size(); i++) + AddMessage(messages[i]); + if (numMessages < 128) + { + _messageList.SetColumnWidthAuto(0); + _messageList.SetColumnWidthAuto(1); + } + } +} + + bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) { + // case IDOK: // if IDCANCEL is not DEFPUSHBUTTON case IDCANCEL: { - bool paused = ProgressSynch.GetPaused();; - // ProgressSynch.SetPaused(true); + if (_waitCloseByCancelButton) + { + MessagesDisplayed = true; + End(IDCLOSE); + break; + } + + bool paused = Sync.GetPaused(); if (!paused) OnPauseButton(); + _inCancelMessageBox = true; int res = ::MessageBoxW(HWND(*this), - LangString(IDS_PROGRESS_ASK_CANCEL, 0x02000C30), + LangStringSpec(IDS_PROGRESS_ASK_CANCEL, 0x02000C30), _title, MB_YESNOCANCEL); - // ProgressSynch.SetPaused(paused); + _inCancelMessageBox = false; if (!paused) OnPauseButton(); if (res == IDCANCEL || res == IDNO) + { + if (_externalCloseMessageWasReceived) + OnExternalCloseMessage(); return true; + } + + _cancelWasPressed = true; + MessagesDisplayed = true; break; } + case IDC_BUTTON_PAUSE: OnPauseButton(); return true; case IDC_BUTTON_PROGRESS_PRIORITY: - { OnPriorityButton(); return true; - } } return CModalDialog::OnButtonClicked(buttonID, buttonHWND); } + +void CProgressDialog::CheckNeedClose() +{ + if (_needClose) + { + PostMessage(kCloseMessage); + _needClose = false; + } +} + +void CProgressDialog::ProcessWasFinished() +{ + // Set Window title here. + if (!WaitMode) + WaitCreating(); + + if (_wasCreated) + PostMessage(kCloseMessage); + else + _needClose = true; +}; + + +HRESULT CProgressThreadVirt::Create(const UString &title, HWND parentWindow) +{ + NWindows::CThread thread; + RINOK(thread.Create(MyThreadFunction, this)); + ProgressDialog.Create(title, thread, parentWindow); + return S_OK; +} + +UString HResultToMessage(HRESULT errorCode) +{ + UString message; + if (errorCode == E_OUTOFMEMORY) + message = LangStringSpec(IDS_MEM_ERROR, 0x0200060B); + else if (!NError::MyFormatMessage(errorCode, message)) + message.Empty(); + if (message.IsEmpty()) + message = L"Error"; + return message; +} + +static void AddMessageToString(UString &dest, const UString &src) +{ + if (!src.IsEmpty()) + { + if (!dest.IsEmpty()) + dest += L'\n'; + dest += src; + } +} + +void CProgressThreadVirt::Process() +{ + CProgressCloser closer(ProgressDialog); + UString m; + try { Result = ProcessVirt(); } + catch(const wchar_t *s) { m = s; } + catch(const UString &s) { m = s; } + catch(const char *s) { m = GetUnicodeString(s); } + catch(...) { m = L"Error"; } + if (Result != E_ABORT) + { + if (m.IsEmpty() && Result != S_OK) + m = HResultToMessage(Result); + } + AddMessageToString(m, ErrorMessage); + AddMessageToString(m, ErrorPath1); + AddMessageToString(m, ErrorPath2); + + if (m.IsEmpty()) + { + if (!OkMessage.IsEmpty()) + { + ProgressDialog.Sync.SetOkMessageTitle(OkMessageTitle); + ProgressDialog.Sync.SetOkMessage(OkMessage); + } + } + else + { + ProgressDialog.Sync.SetErrorMessage(m); + if (Result == S_OK) + Result = E_FAIL; + } +} diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.h b/CPP/7zip/UI/FileManager/ProgressDialog2.h index 3ab9f4c0..bbdc5afa 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.h +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.h @@ -3,17 +3,15 @@ #ifndef __PROGRESS_DIALOG2_H #define __PROGRESS_DIALOG2_H -#include "Common/Types.h" +#include "Windows/Synchronization.h" +#include "Windows/Thread.h" #include "Windows/Control/Dialog.h" +#include "Windows/Control/ListView.h" #include "Windows/Control/ProgressBar.h" -#include "Windows/Synchronization.h" - -#include "ProgressDialog2Res.h" -class CProgressSynch +class CProgressSync { - NWindows::NSynchronization::CCriticalSection _cs; bool _stopped; bool _paused; bool _bytesProgressMode; @@ -25,11 +23,20 @@ class CProgressSynch UInt64 _inSize; UInt64 _outSize; - UString TitleFileName; - UString CurrentFileName; + UString _titleFileName; + UString _currentFileName; public: - CProgressSynch(): + UStringVector Messages; + UString ErrorMessage; + UString ErrorMessageTitle; + + UString OkMessage; + UString OkMessageTitle; + + NWindows::NSynchronization::CCriticalSection _cs; + + CProgressSync(): _stopped(false), _paused(false), _totalBytes((UInt64)(Int64)-1), _curBytes(0), _totalFiles((UInt64)(Int64)-1), _curFiles(0), @@ -116,22 +123,57 @@ public: void SetTitleFileName(const UString &fileName) { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - TitleFileName = fileName; + _titleFileName = fileName; } void GetTitleFileName(UString &fileName) { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - fileName = TitleFileName; + fileName = _titleFileName; } void SetCurrentFileName(const UString &fileName) { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - CurrentFileName = fileName; + _currentFileName = fileName; } void GetCurrentFileName(UString &fileName) { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - fileName = CurrentFileName; + fileName = _currentFileName; + } + + void AddErrorMessage(LPCWSTR message) + { + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); + Messages.Add(message); + } + + void SetErrorMessage(const UString &message) + { + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); + ErrorMessage = message; + } + + void SetOkMessage(const UString &message) + { + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); + OkMessage = message; + } + + void SetOkMessageTitle(const UString &title) + { + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); + OkMessageTitle = title; + } + + void SetErrorMessageTitle(const UString &title) + { + NWindows::NSynchronization::CCriticalSectionLock lock(_cs); + ErrorMessageTitle = title; + } + + bool ThereIsMessage() const + { + return !Messages.IsEmpty() || !ErrorMessage.IsEmpty() || !OkMessage.IsEmpty(); } }; @@ -139,12 +181,15 @@ class CU64ToI32Converter { UInt64 _numShiftBits; public: - void Init(UInt64 _range); - int Count(UInt64 aValue); + void Init(UInt64 range) + { + // Windows CE doesn't like big number here. + for (_numShiftBits = 0; range > (1 << 15); _numShiftBits++) + range >>= 1; + } + int Count(UInt64 value) { return int(value >> _numShiftBits); } }; -// class CProgressDialog: public NWindows::NControl::CModelessDialog - enum ESpeedMode { kSpeedBytes, @@ -164,7 +209,8 @@ private: UString continueString; UString pausedString; - + int buttonSizeX; + int buttonSizeY; UINT_PTR _timer; @@ -173,6 +219,7 @@ private: UInt64 _previousPos; UInt64 _range; NWindows::NControl::CProgressBar m_ProgressBar; + NWindows::NControl::CListView _messageList; UInt32 _prevPercentValue; UInt32 _prevTime; @@ -184,11 +231,30 @@ private: bool _foreground; + int _numReduceSymbols; + + bool _wasCreated; + bool _needClose; + + UInt32 _numPostedMessages; + + bool _errorsWereDisplayed; + + bool _waitCloseByCancelButton; + bool _cancelWasPressed; + + bool _inCancelMessageBox; + bool _externalCloseMessageWasReceived; + + void UpdateStatInfo(bool showAll); bool OnTimer(WPARAM timerID, LPARAM callback); void SetRange(UInt64 range); void SetPos(UInt64 pos); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); virtual void OnCancel(); + virtual void OnOK(); + NWindows::NSynchronization::CManualResetEvent _createDialogEvent; NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent; #ifndef _SFX void AddToTitle(LPCWSTR string); @@ -203,10 +269,25 @@ private: void SetTitleText(); void ShowSize(int id, UInt64 value); + void UpdateMessagesDialog(); + + void AddMessageDirect(LPCWSTR message); + void AddMessage(LPCWSTR message); + + bool OnExternalCloseMessage(); + void EnableErrorsControls(bool enable); + + void ShowAfterMessages(HWND wndParent); + + void CheckNeedClose(); public: - CProgressSynch ProgressSynch; + CProgressSync Sync; bool CompressingMode; - + bool WaitMode; + bool ShowCompressionInfo; + bool MessagesDisplayed; // = true if user pressed OK on all messages or there are no messages. + int IconID; + #ifndef _SFX HWND MainWindow; UString MainTitle; @@ -214,29 +295,64 @@ public: ~CProgressDialog(); #endif - CProgressDialog(): _timer(0), CompressingMode(true) - #ifndef _SFX - ,MainWindow(0) - #endif + CProgressDialog(); + void WaitCreating() { - if (_dialogCreatedEvent.Create() != S_OK) - throw 1334987; + _createDialogEvent.Set(); + _dialogCreatedEvent.Lock(); } - void WaitCreating() { _dialogCreatedEvent.Lock(); } + INT_PTR Create(const UString &title, NWindows::CThread &thread, HWND wndParent = 0); - INT_PTR Create(const UString &title, HWND wndParent = 0) - { - _title = title; - return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); - } - - static const UINT kCloseMessage; virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); - void MyClose() { PostMessage(kCloseMessage); }; + void ProcessWasFinished(); +}; + + +class CProgressCloser +{ + CProgressDialog *_p; +public: + CProgressCloser(CProgressDialog &p) : _p(&p) {} + ~CProgressCloser() { _p->ProcessWasFinished(); } +}; + +class CProgressThreadVirt +{ +protected: + UString ErrorMessage; + UString ErrorPath1; + UString ErrorPath2; + UString OkMessage; + UString OkMessageTitle; + + // error if any of HRESULT, ErrorMessage, ErrorPath + virtual HRESULT ProcessVirt() = 0; + void Process(); +public: + HRESULT Result; + bool ThreadFinishedOK; // if there is no fatal exception + CProgressDialog ProgressDialog; + + static THREAD_FUNC_DECL MyThreadFunction(void *param) + { + CProgressThreadVirt *p = (CProgressThreadVirt *)param; + try + { + p->Process(); + p->ThreadFinishedOK = true; + } + catch (...) { p->Result = E_FAIL; } + return 0; + } + + HRESULT Create(const UString &title, HWND parentWindow = 0); + CProgressThreadVirt(): Result(E_FAIL), ThreadFinishedOK(false) {} }; +UString HResultToMessage(HRESULT errorCode); + #endif diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.rc b/CPP/7zip/UI/FileManager/ProgressDialog2.rc index 2b707451..703dbb1f 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.rc +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.rc @@ -1,77 +1,41 @@ #include "ProgressDialog2Res.h" #include "../../GuiCommon.rc" -#define xSize2 350 -#define ySize2 110 +#undef DIALOG_ID +#define DIALOG_ID IDD_DIALOG_PROGRESS +#define xc 360 +#define k 11 +#define z1s 16 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#include "ProgressDialog2a.rc" -#define bYPos (ySize - marg - bYSize) - -#undef bXSize -#define bXSize 80 - -#define bXPos1 (xSize - marg - bXSize) -#define bXPos2 (bXPos1 - 10 - bXSize) -#define bXPos3 (bXPos2 - 10 - bXSize) - -#define x0Size 90 -#define x1 (marg + x0Size) -#define x1Size 70 - -#define x3Size 60 -#define x3 (xSize - marg - x3Size) - -#define x2Size 90 -#define x2 (x3 - x2Size) - -#undef y0 -#undef y1 -#undef y2 -#undef y3 -#define y0 marg -#define y1 (y0 + 11) -#define y2 (y1 + 11) -#define y3 (y2 + 11) +#ifdef UNDER_CE +#include "../../GuiCommon.rc" -IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX -CAPTION "Progress" -MY_FONT -BEGIN - PUSHBUTTON "&Background", IDC_BUTTON_PROGRESS_PRIORITY, bXPos3, bYPos, bXSize, bYSize - PUSHBUTTON "&Pause", IDC_BUTTON_PAUSE, bXPos2, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize - LTEXT "Elapsed time:", IDC_PROGRESS_ELAPSED, marg, y0, x0Size, 8 - LTEXT "Remaining time:", IDC_PROGRESS_REMAINING, marg, y1, x0Size, 8 - LTEXT "Files:", IDC_PROGRESS_FILES, marg, y2, x0Size, 8 - LTEXT "Compression ratio:",IDC_PROGRESS_RATIO, marg, y3, x0Size, 8 - LTEXT "Total size:", IDC_PROGRESS_TOTAL, x2, y0, x2Size, 8 - LTEXT "Speed:", IDC_PROGRESS_SPEED, x2, y1, x2Size, 8 - LTEXT "Processed:", IDC_PROGRESS_UNPACKED, x2, y2, x2Size, 8 - LTEXT "Compressed size:", IDC_PROGRESS_PACKED, x2, y3, x2Size, 8 +#undef DIALOG_ID +#undef m +#undef k +#undef z1s - RTEXT "00:00:00", IDC_PROGRESS_ELAPSED_VALUE, x1, y0, x1Size, 8 - RTEXT "", IDC_PROGRESS_REMAINING_VALUE, x1, y1, x1Size, 8 - RTEXT "", IDC_PROGRESS_FILES_VALUE, x1, y2, x1Size, 8 - RTEXT "", IDC_PROGRESS_RATIO_VALUE, x1, y3, x1Size, 8 +#define DIALOG_ID IDD_DIALOG_PROGRESS_2 +#define m 4 +#define k 8 +#define z1s 12 - RTEXT "", IDC_PROGRESS_TOTAL_VALUE, x3, y0, x3Size, 8 - RTEXT "", IDC_PROGRESS_SPEED_VALUE, x3, y1, x3Size, 8 - RTEXT "", IDC_PROGRESS_UNPACKED_VALUE, x3, y2, x3Size, 8 - RTEXT "", IDC_PROGRESS_PACKED_VALUE, x3, y3, x3Size, 8 +#define xc 280 - LTEXT "", IDC_PROGRESS_FILE_NAME, marg, bYPos - 42, xSize2, 21, SS_NOPREFIX | SS_LEFTNOWORDWRAP - CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, marg, bYPos - 20, xSize2, 13 -END +#include "ProgressDialog2a.rc" +#endif STRINGTABLE DISCARDABLE -BEGIN +{ IDS_PROGRESS_PAUSED "Paused" IDS_PROGRESS_FOREGROUND "&Foreground" IDS_PROGRESS_CONTINUE "&Continue" IDS_PROGRESS_ASK_CANCEL "Are you sure you want to cancel?" -END + IDS_CLOSE "&Close" + IDS_MESSAGES_DIALOG_MESSAGE_COLUMN "Message" +} diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2Res.h b/CPP/7zip/UI/FileManager/ProgressDialog2Res.h index 16bf2634..21ac03c2 100755 --- a/CPP/7zip/UI/FileManager/ProgressDialog2Res.h +++ b/CPP/7zip/UI/FileManager/ProgressDialog2Res.h @@ -1,10 +1,16 @@ -#define IDC_BUTTON_PAUSE 3 -#define IDC_BUTTON_PROGRESS_PRIORITY 4 #define IDD_DIALOG_PROGRESS 500 +#define IDD_DIALOG_PROGRESS_2 600 + +#define IDC_BUTTON_PAUSE 50 +#define IDC_BUTTON_PROGRESS_PRIORITY 51 + #define IDS_PROGRESS_PAUSED 700 #define IDS_PROGRESS_FOREGROUND 701 #define IDS_PROGRESS_CONTINUE 702 #define IDS_PROGRESS_ASK_CANCEL 703 +#define IDS_CLOSE 704 +#define IDS_MESSAGES_DIALOG_MESSAGE_COLUMN 503 + #define IDC_PROGRESS1 1000 #define IDC_PROGRESS_ELAPSED 1002 #define IDC_PROGRESS_ELAPSED_VALUE 1003 @@ -24,3 +30,12 @@ #define IDC_PROGRESS_PACKED_VALUE 1017 #define IDC_PROGRESS_UNPACKED 1018 #define IDC_PROGRESS_UNPACKED_VALUE 1019 + +#define IDC_PROGRESS_ERRORS 1030 +#define IDC_PROGRESS_ERRORS_VALUE 1031 +#define IDC_PROGRESS_LIST 1032 + +#define MY_PROGRESS_VALUE_UNITS 44 +#define MY_PROGRESS_LABEL_UNITS_MIN 60 +#define MY_PROGRESS_LABEL_UNITS_START 90 +#define MY_PROGRESS_PAD_UNITS 4 diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2a.rc b/CPP/7zip/UI/FileManager/ProgressDialog2a.rc new file mode 100755 index 00000000..8eba4148 --- /dev/null +++ b/CPP/7zip/UI/FileManager/ProgressDialog2a.rc @@ -0,0 +1,78 @@ +#undef bxs +#define bxs 80 + +#define x0s MY_PROGRESS_LABEL_UNITS_START +#define x1s MY_PROGRESS_VALUE_UNITS +#define x2s MY_PROGRESS_LABEL_UNITS_START +#define x3s MY_PROGRESS_VALUE_UNITS + +#define x1 (m + x0s) +#define x3 (xs - m - x3s) +#define x2 (x3 - x2s) + +#undef y0 +#undef y1 +#undef y2 +#undef y3 +#undef y4 + +#undef z0 +#undef z0z +#undef z1 +#undef z2 +#undef z2 + +#define y0 m +#define y1 (y0 + k) +#define y2 (y1 + k) +#define y3 (y2 + k) +#define y4 (y3 + k) + +#define z2 (y4 + k + 1) +#define z2s 24 + +#define z1 (z2 + z2s) + +#define z0 (z1 + z1s + m) +#define z0s 48 + +#define yc (z0 + z0s + bys) + + +DIALOG_ID MY_RESIZE_DIALOG +CAPTION "Progress" +{ + PUSHBUTTON "&Background", IDC_BUTTON_PROGRESS_PRIORITY, bx3, by, bxs, bys + PUSHBUTTON "&Pause", IDC_BUTTON_PAUSE, bx2, by, bxs, bys + DEFPUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys + + LTEXT "Elapsed time:", IDC_PROGRESS_ELAPSED, m, y0, x0s, 8 + LTEXT "Remaining time:", IDC_PROGRESS_REMAINING, m, y1, x0s, 8 + LTEXT "Files:", IDC_PROGRESS_FILES, m, y2, x0s, 8 + LTEXT "Compression ratio:",IDC_PROGRESS_RATIO, m, y3, x0s, 8 + LTEXT "Errors:", IDC_PROGRESS_ERRORS, m, y4, x0s, 8 + + LTEXT "Total size:", IDC_PROGRESS_TOTAL, x2, y0, x2s, 8 + LTEXT "Speed:", IDC_PROGRESS_SPEED, x2, y1, x2s, 8 + LTEXT "Processed:", IDC_PROGRESS_UNPACKED, x2, y2, x2s, 8 + LTEXT "Compressed size:", IDC_PROGRESS_PACKED, x2, y3, x2s, 8 + + RTEXT "", IDC_PROGRESS_ELAPSED_VALUE, x1, y0, x1s, 8 + RTEXT "", IDC_PROGRESS_REMAINING_VALUE, x1, y1, x1s, 8 + RTEXT "", IDC_PROGRESS_FILES_VALUE, x1, y2, x1s, 8 + RTEXT "", IDC_PROGRESS_RATIO_VALUE, x1, y3, x1s, 8 + RTEXT "", IDC_PROGRESS_ERRORS_VALUE, x1, y4, x1s, 8 + + RTEXT "", IDC_PROGRESS_TOTAL_VALUE, x3, y0, x3s, 8 + RTEXT "", IDC_PROGRESS_SPEED_VALUE, x3, y1, x3s, 8 + RTEXT "", IDC_PROGRESS_UNPACKED_VALUE, x3, y2, x3s, 8 + RTEXT "", IDC_PROGRESS_PACKED_VALUE, x3, y3, x3s, 8 + + LTEXT "", IDC_PROGRESS_FILE_NAME, m, z2, xc, z2s, SS_NOPREFIX | SS_LEFTNOWORDWRAP + CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, m, z1, xc, z1s + + + CONTROL "List1", IDC_PROGRESS_LIST, "SysListView32", + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, + m, z0, xc, z0s +} diff --git a/CPP/7zip/UI/FileManager/PropertyName.cpp b/CPP/7zip/UI/FileManager/PropertyName.cpp index 48090d38..79b09300 100755 --- a/CPP/7zip/UI/FileManager/PropertyName.cpp +++ b/CPP/7zip/UI/FileManager/PropertyName.cpp @@ -26,7 +26,7 @@ static CPropertyIDNamePair kPropertyIDNamePairs[] = { kpidPath, IDS_PROP_PATH, 0x02000203 }, { kpidName, IDS_PROP_NAME, 0x02000204 }, { kpidExtension, IDS_PROP_EXTENSION, 0x02000205 }, - { kpidIsDir, IDS_PROP_IS_FOLDER, 0x02000206}, + { kpidIsDir, IDS_PROP_IS_FOLDER, 0x02000206}, { kpidSize, IDS_PROP_SIZE, 0x02000207}, { kpidPackSize, IDS_PROP_PACKED_SIZE, 0x02000208 }, { kpidAttrib, IDS_PROP_ATTRIBUTES, 0x02000209 }, @@ -40,7 +40,7 @@ static CPropertyIDNamePair kPropertyIDNamePairs[] = { kpidSplitAfter, IDS_PROP_SPLIT_AFTER, 0x02000211 }, { kpidDictionarySize, IDS_PROP_DICTIONARY_SIZE, 0x02000212 }, { kpidCRC, IDS_PROP_CRC, 0x02000213 }, - { kpidType, IDS_PROP_FILE_TYPE, 0x02000214}, + { kpidType, IDS_PROP_FILE_TYPE, 0x02000214}, { kpidIsAnti, IDS_PROP_ANTI, 0x02000215 }, { kpidMethod, IDS_PROP_METHOD, 0x02000216 }, { kpidHostOS, IDS_PROP_HOST_OS, 0x02000217 }, diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp index d4fbfe13..f7edbb4b 100755 --- a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp +++ b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp @@ -20,7 +20,9 @@ namespace NRegistryAssociations { static NSynchronization::CCriticalSection g_CriticalSection; -#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") TEXT(STRING_PATH_SEPARATOR) TEXT("FM") +#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR) TEXT("FM") + +/* static const TCHAR *kCUKeyPath = REG_PATH_FM; static const WCHAR *kExtPlugins = L"Plugins"; @@ -64,10 +66,8 @@ void ReadInternalAssociations(CObjectVector<CExtInfo> &items) UString pluginsString; key.QueryValue(kExtPlugins, pluginsString); SplitString(pluginsString, extInfo.Plugins); - /* - if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS) - extInfo.Enabled = false; - */ + // if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS) + // extInfo.Enabled = false; items.Add(extInfo); } } @@ -89,6 +89,7 @@ void WriteInternalAssociations(const CObjectVector<CExtInfo> &items) // key.SetValue(kExtEnabled, extInfo.Enabled); } } +*/ /////////////////////////////////// // External @@ -100,6 +101,7 @@ static const TCHAR *kDefaultIconKeyName = TEXT("DefaultIcon"); static const TCHAR *kShellKeyName = TEXT("shell"); static const TCHAR *kOpenKeyName = TEXT("open"); static const TCHAR *kCommandKeyName = TEXT("command"); +static const TCHAR *k7zipPrefix = TEXT("7-Zip."); static CSysString GetExtensionKeyName(const CSysString &extension) { @@ -108,10 +110,11 @@ static CSysString GetExtensionKeyName(const CSysString &extension) static CSysString GetExtProgramKeyName(const CSysString &extension) { - return CSysString(TEXT("7-Zip.")) + extension; + return CSysString(k7zipPrefix) + extension; } -static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconPath, int &iconIndex) +static bool CheckShellExtensionInfo2(const CSysString &extension, + CSysString programKeyName, UString &iconPath, int &iconIndex) { iconIndex = -1; iconPath.Empty(); @@ -119,15 +122,13 @@ static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconP CKey extKey; if (extKey.Open(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension), KEY_READ) != ERROR_SUCCESS) return false; - CSysString programNameValue; - if (extKey.QueryValue(NULL, programNameValue) != ERROR_SUCCESS) + if (extKey.QueryValue(NULL, programKeyName) != ERROR_SUCCESS) return false; - CSysString extProgramKeyName = GetExtProgramKeyName(extension); - UString programNameValueU = GetUnicodeString(programNameValue); - if (programNameValueU.CompareNoCase(GetUnicodeString(extProgramKeyName)) != 0) + UString s = GetUnicodeString(k7zipPrefix); + if (s.CompareNoCase(GetUnicodeString(programKeyName.Left(s.Length()))) != 0) return false; CKey iconKey; - if (extKey.Open(HKEY_CLASSES_ROOT, extProgramKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS) + if (extKey.Open(HKEY_CLASSES_ROOT, programKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS) return false; UString value; if (extKey.QueryValue(NULL, value) == ERROR_SUCCESS) @@ -151,10 +152,11 @@ static bool CheckShellExtensionInfo2(const CSysString &extension, UString &iconP bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex) { NSynchronization::CCriticalSectionLock lock(g_CriticalSection); - if (!CheckShellExtensionInfo2(extension, iconPath, iconIndex)) + CSysString programKeyName; + if (!CheckShellExtensionInfo2(extension, programKeyName, iconPath, iconIndex)) return false; CKey extProgKey; - return (extProgKey.Open(HKEY_CLASSES_ROOT, GetExtProgramKeyName(extension), KEY_READ) == ERROR_SUCCESS); + return (extProgKey.Open(HKEY_CLASSES_ROOT, programKeyName, KEY_READ) == ERROR_SUCCESS); } static void DeleteShellExtensionKey(const CSysString &extension) @@ -177,9 +179,10 @@ static void DeleteShellExtensionProgramKey(const CSysString &extension) void DeleteShellExtensionInfo(const CSysString &extension) { + CSysString programKeyName; UString iconPath; int iconIndex; - if (CheckShellExtensionInfo2(extension, iconPath, iconIndex)) + if (CheckShellExtensionInfo2(extension, programKeyName, iconPath, iconIndex)) DeleteShellExtensionKey(extension); DeleteShellExtensionProgramKey(extension); } @@ -193,7 +196,13 @@ void AddShellExtensionInfo(const CSysString &extension, DeleteShellExtensionKey(extension); DeleteShellExtensionProgramKey(extension); NSynchronization::CCriticalSectionLock lock(g_CriticalSection); - CSysString programKeyName = GetExtProgramKeyName(extension); + CSysString programKeyName; + { + CSysString ext = extension; + if (iconIndex < 0) + ext = TEXT("*"); + programKeyName = GetExtProgramKeyName(ext); + } { CKey extKey; extKey.Create(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension)); @@ -212,7 +221,9 @@ void AddShellExtensionInfo(const CSysString &extension, CKey iconKey; iconKey.Create(programKey, kDefaultIconKeyName); UString iconPathFull = iconPath; - if (iconIndex >= 0) + if (iconIndex < 0) + iconIndex = 0; + // if (iconIndex >= 0) { iconPathFull += L","; wchar_t s[16]; @@ -240,7 +251,7 @@ void AddShellExtensionInfo(const CSysString &extension, // ContextMenu /* -static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-ZIP"); +static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-Zip"); static const TCHAR *kContextMenuHandlerCLASSIDValue = TEXT("{23170F69-40C1-278A-1000-000100020000}"); static const TCHAR *kRootKeyNameForFile = TEXT("*"); diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.h b/CPP/7zip/UI/FileManager/RegistryAssociations.h index 2516fd2b..5390b9db 100755 --- a/CPP/7zip/UI/FileManager/RegistryAssociations.h +++ b/CPP/7zip/UI/FileManager/RegistryAssociations.h @@ -7,6 +7,7 @@ namespace NRegistryAssociations { + /* struct CExtInfo { UString Ext; @@ -16,6 +17,7 @@ namespace NRegistryAssociations { bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo); void ReadInternalAssociations(CObjectVector<CExtInfo> &items); void WriteInternalAssociations(const CObjectVector<CExtInfo> &items); + */ bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex); diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp index 61cceb5f..d49eaa6e 100755 --- a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp +++ b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp @@ -2,21 +2,16 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" -// #include "Windows/Registry.h" -// #include "Windows/Synchronization.h" - #include "Windows/DLL.h" #include "Windows/PropVariant.h" #include "Windows/FileFind.h" +#include "ProgramLocation.h" #include "RegistryPlugins.h" #include "IFolder.h" using namespace NWindows; using namespace NFile; -// using namespace NRegistry; -// using namespace NCOM; /* static const TCHAR *kLMBasePath = TEXT("Software\\7-Zip\\FM"); @@ -32,66 +27,65 @@ static CSysString GetFileFolderPluginsKeyName() CSysString(kPluginsKeyName); } -static NSynchronization::CCriticalSection g_CriticalSection; */ -typedef UINT32 (WINAPI * GetPluginPropertyFunc)( - PROPID propID, PROPVARIANT *value); -static bool ReadPluginInfo(CPluginInfo &pluginInfo) +typedef UINT32 (WINAPI * GetPluginPropertyFunc)(PROPID propID, PROPVARIANT *value); + +static bool ReadPluginInfo(CPluginInfo &pluginInfo, bool needCheckDll) { + if (needCheckDll) { - NDLL::CLibrary library; - if (!library.LoadEx(pluginInfo.FilePath, LOAD_LIBRARY_AS_DATAFILE)) + NDLL::CLibrary lib; + if (!lib.LoadEx(pluginInfo.FilePath, LOAD_LIBRARY_AS_DATAFILE)) return false; } - NDLL::CLibrary library; - if (!library.Load(pluginInfo.FilePath)) + NDLL::CLibrary lib; + if (!lib.Load(pluginInfo.FilePath)) return false; - GetPluginPropertyFunc getPluginProperty = (GetPluginPropertyFunc) - library.GetProcAddress("GetPluginProperty"); + GetPluginPropertyFunc getPluginProperty = (GetPluginPropertyFunc)lib.GetProc("GetPluginProperty"); if (getPluginProperty == NULL) return false; - NCOM::CPropVariant propVariant; - if (getPluginProperty(NPlugin::kName, &propVariant) != S_OK) + NCOM::CPropVariant prop; + if (getPluginProperty(NPlugin::kName, &prop) != S_OK) return false; - if (propVariant.vt != VT_BSTR) + if (prop.vt != VT_BSTR) return false; - pluginInfo.Name = propVariant.bstrVal; - propVariant.Clear(); + pluginInfo.Name = prop.bstrVal; + prop.Clear(); - if (getPluginProperty(NPlugin::kClassID, &propVariant) != S_OK) + if (getPluginProperty(NPlugin::kClassID, &prop) != S_OK) return false; - if (propVariant.vt == VT_EMPTY) + if (prop.vt == VT_EMPTY) pluginInfo.ClassIDDefined = false; - else if (propVariant.vt != VT_BSTR) + else if (prop.vt != VT_BSTR) return false; else { pluginInfo.ClassIDDefined = true; - pluginInfo.ClassID = *(const GUID *)propVariant.bstrVal; + pluginInfo.ClassID = *(const GUID *)prop.bstrVal; } - propVariant.Clear(); + prop.Clear(); - if (getPluginProperty(NPlugin::kOptionsClassID, &propVariant) != S_OK) + if (getPluginProperty(NPlugin::kOptionsClassID, &prop) != S_OK) return false; - if (propVariant.vt == VT_EMPTY) + if (prop.vt == VT_EMPTY) pluginInfo.OptionsClassIDDefined = false; - else if (propVariant.vt != VT_BSTR) + else if (prop.vt != VT_BSTR) return false; else { pluginInfo.OptionsClassIDDefined = true; - pluginInfo.OptionsClassID = *(const GUID *)propVariant.bstrVal; + pluginInfo.OptionsClassID = *(const GUID *)prop.bstrVal; } - propVariant.Clear(); + prop.Clear(); - if (getPluginProperty(NPlugin::kType, &propVariant) != S_OK) + if (getPluginProperty(NPlugin::kType, &prop) != S_OK) return false; - if (propVariant.vt == VT_EMPTY) + if (prop.vt == VT_EMPTY) pluginInfo.Type = kPluginTypeFF; - else if (propVariant.vt == VT_UI4) - pluginInfo.Type = (EPluginType)propVariant.ulVal; + else if (prop.vt == VT_UI4) + pluginInfo.Type = (EPluginType)prop.ulVal; else return false; return true; @@ -103,11 +97,12 @@ void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins) { plugins.Clear(); - UString baseFolderPrefix = GetProgramFolderPrefix(); + UString baseFolderPrefix; + GetProgramFolderPath(baseFolderPrefix); { CPluginInfo pluginInfo; pluginInfo.FilePath = baseFolderPrefix + L"7-zip.dll"; - if (::ReadPluginInfo(pluginInfo)) + if (::ReadPluginInfo(pluginInfo, false)) plugins.Add(pluginInfo); } UString folderPath = baseFolderPrefix + L"Plugins" WSTRING_PATH_SEPARATOR; @@ -119,7 +114,7 @@ void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins) continue; CPluginInfo pluginInfo; pluginInfo.FilePath = folderPath + fileInfo.Name; - if (::ReadPluginInfo(pluginInfo)) + if (::ReadPluginInfo(pluginInfo, true)) plugins.Add(pluginInfo); } } diff --git a/CPP/7zip/UI/FileManager/RegistryUtils.cpp b/CPP/7zip/UI/FileManager/RegistryUtils.cpp index bd1248a2..6697169b 100755 --- a/CPP/7zip/UI/FileManager/RegistryUtils.cpp +++ b/CPP/7zip/UI/FileManager/RegistryUtils.cpp @@ -11,7 +11,7 @@ using namespace NWindows; using namespace NRegistry; -#define REG_PATH_7Z TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") +#define REG_PATH_7Z TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") static const TCHAR *kCUBasePath = REG_PATH_7Z; static const TCHAR *kCU_FMPath = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("FM"); @@ -29,7 +29,7 @@ static const TCHAR *kShowGrid = TEXT("ShowGrid"); static const TCHAR *kAlternativeSelection = TEXT("AlternativeSelection"); // static const TCHAR *kLockMemoryAdd = TEXT("LockMemoryAdd"); static const TCHAR *kLargePagesEnable = TEXT("LargePages"); -// static const TCHAR *kSingleClick = TEXT("SingleClick"); +static const TCHAR *kSingleClick = TEXT("SingleClick"); // static const TCHAR *kUnderline = TEXT("Underline"); static const TCHAR *kFlatViewName = TEXT("FlatViewArc"); @@ -135,10 +135,10 @@ bool ReadShowGrid(){ return ReadOption(kShowGrid, false); } void SaveAlternativeSelection(bool enable) { SaveOption(kAlternativeSelection, enable); } bool ReadAlternativeSelection(){ return ReadOption(kAlternativeSelection, false); } -/* void SaveSingleClick(bool enable) { SaveOption(kSingleClick, enable); } bool ReadSingleClick(){ return ReadOption(kSingleClick, false); } +/* void SaveUnderline(bool enable) { SaveOption(kUnderline, enable); } bool ReadUnderline(){ return ReadOption(kUnderline, false); } */ diff --git a/CPP/7zip/UI/FileManager/RegistryUtils.h b/CPP/7zip/UI/FileManager/RegistryUtils.h index 5469f401..3bf06617 100755 --- a/CPP/7zip/UI/FileManager/RegistryUtils.h +++ b/CPP/7zip/UI/FileManager/RegistryUtils.h @@ -4,6 +4,7 @@ #define __REGISTRY_UTILS_H #include "Common/MyString.h" +#include "Common/Types.h" void SaveRegLang(const UString &path); void ReadRegLang(UString &path); @@ -38,10 +39,10 @@ bool ReadAlternativeSelection(); bool ReadLockMemoryEnable(); void SaveLockMemoryEnable(bool enable); -/* void SaveSingleClick(bool enable); bool ReadSingleClick(); +/* void SaveUnderline(bool enable); bool ReadUnderline(); */ diff --git a/CPP/7zip/UI/FileManager/RootFolder.cpp b/CPP/7zip/UI/FileManager/RootFolder.cpp index ea6f5080..1f4886d2 100755 --- a/CPP/7zip/UI/FileManager/RootFolder.cpp +++ b/CPP/7zip/UI/FileManager/RootFolder.cpp @@ -4,14 +4,17 @@ #include "Common/StringConvert.h" +#include "Windows/DLL.h" #include "Windows/PropVariant.h" #include "../../PropID.h" -#include "FSDrives.h" #include "FSFolder.h" #include "LangUtils.h" +#ifndef UNDER_CE #include "NetFolder.h" +#include "FSDrives.h" +#endif #include "RootFolder.h" #include "SysIconUtils.h" @@ -26,7 +29,11 @@ static const STATPROPSTG kProps[] = UString RootFolder_GetName_Computer(int &iconIndex) { + #ifdef UNDER_CE + GetRealIconIndex(L"\\", FILE_ATTRIBUTE_DIRECTORY, iconIndex); + #else iconIndex = GetIconIndexForCSIDL(CSIDL_DRIVES); + #endif return LangString(IDS_COMPUTER, 0x03020300); } @@ -42,20 +49,29 @@ UString RootFolder_GetName_Documents(int &iconIndex) return LangString(IDS_DOCUMENTS, 0x03020302); ; } -const int ROOT_INDEX_COMPUTER = 0; -const int ROOT_INDEX_DOCUMENTS = 1; -const int ROOT_INDEX_NETWORK = 2; -const int ROOT_INDEX_VOLUMES = 3; +enum +{ + ROOT_INDEX_COMPUTER = 0 + #ifndef UNDER_CE + , ROOT_INDEX_DOCUMENTS + , ROOT_INDEX_NETWORK + , ROOT_INDEX_VOLUMES + #endif +}; -static const wchar_t *kVolPrefix = L"\\\\.\\"; +#ifndef UNDER_CE +static const wchar_t *kVolPrefix = L"\\\\."; +#endif void CRootFolder::Init() { _names[ROOT_INDEX_COMPUTER] = RootFolder_GetName_Computer(_iconIndices[ROOT_INDEX_COMPUTER]); + #ifndef UNDER_CE _names[ROOT_INDEX_DOCUMENTS] = RootFolder_GetName_Documents(_iconIndices[ROOT_INDEX_DOCUMENTS]); _names[ROOT_INDEX_NETWORK] = RootFolder_GetName_Network(_iconIndices[ROOT_INDEX_NETWORK]); _names[ROOT_INDEX_VOLUMES] = kVolPrefix; _iconIndices[ROOT_INDEX_VOLUMES] = GetIconIndexForCSIDL(CSIDL_DRIVES); + #endif }; STDMETHODIMP CRootFolder::LoadItems() @@ -90,7 +106,11 @@ UString GetMyDocsPath() UString us; WCHAR s[MAX_PATH + 1]; SHGetSpecialFolderPathWp getW = (SHGetSpecialFolderPathWp) - ::GetProcAddress(::GetModuleHandleA("shell32.dll"), "SHGetSpecialFolderPathW"); + #ifdef UNDER_CE + My_GetProcAddress(GetModuleHandle(TEXT("coredll.dll")), "SHGetSpecialFolderPath"); + #else + My_GetProcAddress(GetModuleHandle(TEXT("shell32.dll")), "SHGetSpecialFolderPathW"); + #endif if (getW && getW(0, s, CSIDL_PERSONAL, FALSE)) us = s; #ifndef _UNICODE @@ -112,6 +132,14 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde { *resultFolder = NULL; CMyComPtr<IFolderFolder> subFolder; + #ifdef UNDER_CE + if (index == ROOT_INDEX_COMPUTER) + { + NFsFolder::CFSFolder *fsFolder = new NFsFolder::CFSFolder; + subFolder = fsFolder; + fsFolder->InitToRoot(); + } + #else if (index == ROOT_INDEX_COMPUTER || index == ROOT_INDEX_VOLUMES) { CFSDrives *fsDrivesSpec = new CFSDrives; @@ -134,6 +162,7 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde RINOK(fsFolderSpec->Init(s, NULL)); } } + #endif else return E_INVALIDARG; *resultFolder = subFolder.Detach(); @@ -161,9 +190,14 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu for (int i = 0; i < kNumRootFolderItems; i++) if (AreEqualNames(name2, _names[i])) return BindToFolder((UInt32)i, resultFolder); + #ifdef UNDER_CE + if (name2 == L"\\") + return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder); + #else if (AreEqualNames(name2, L"My Documents") || AreEqualNames(name2, L"Documents")) return BindToFolder((UInt32)ROOT_INDEX_DOCUMENTS, resultFolder); + #endif if (AreEqualNames(name2, L"My Computer") || AreEqualNames(name2, L"Computer")) return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder); @@ -179,6 +213,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu CMyComPtr<IFolderFolder> subFolder; + #ifndef UNDER_CE if (name2.Left(4) == kVolPrefix) { CFSDrives *folderSpec = new CFSDrives; @@ -186,6 +221,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu folderSpec->Init(true); } else + #endif { if (name2[name2.Length () - 1] != WCHAR_PATH_SEPARATOR) name2 += WCHAR_PATH_SEPARATOR; @@ -193,6 +229,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu subFolder = fsFolderSpec; if (fsFolderSpec->Init(name2, 0) != S_OK) { + #ifndef UNDER_CE if (name2[0] == WCHAR_PATH_SEPARATOR) { CNetFolder *netFolderSpec = new CNetFolder; @@ -200,6 +237,7 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu netFolderSpec->Init(name2); } else + #endif return E_INVALIDARG; } } diff --git a/CPP/7zip/UI/FileManager/RootFolder.h b/CPP/7zip/UI/FileManager/RootFolder.h index 9f08e601..21d74db8 100755 --- a/CPP/7zip/UI/FileManager/RootFolder.h +++ b/CPP/7zip/UI/FileManager/RootFolder.h @@ -7,7 +7,13 @@ #include "IFolder.h" -const int kNumRootFolderItems = 4; +const int kNumRootFolderItems = + #ifdef UNDER_CE + 1 + #else + 4 + #endif + ; class CRootFolder: public IFolderFolder, diff --git a/CPP/7zip/UI/FileManager/SettingsPage.cpp b/CPP/7zip/UI/FileManager/SettingsPage.cpp index 8b2eb836..f6694c56 100755 --- a/CPP/7zip/UI/FileManager/SettingsPage.cpp +++ b/CPP/7zip/UI/FileManager/SettingsPage.cpp @@ -1,18 +1,20 @@ // SettingsPage.cpp #include "StdAfx.h" -#include "SettingsPageRes.h" -#include "SettingsPage.h" #include "Common/StringConvert.h" -#include "Windows/Defs.h" +#ifndef UNDER_CE #include "Windows/MemoryLock.h" +#endif -#include "RegistryUtils.h" #include "HelpUtils.h" #include "LangUtils.h" #include "ProgramLocation.h" +#include "RegistryUtils.h" +#include "SettingsPage.h" + +#include "SettingsPageRes.h" using namespace NWindows; @@ -48,7 +50,7 @@ bool CSettingsPage::OnInit() CheckButton(IDC_SETTINGS_LARGE_PAGES, ReadLockMemoryEnable()); else EnableItem(IDC_SETTINGS_LARGE_PAGES, false); - // CheckButton(IDC_SETTINGS_SINGLE_CLICK, ReadSingleClick()); + CheckButton(IDC_SETTINGS_SINGLE_CLICK, ReadSingleClick()); // CheckButton(IDC_SETTINGS_UNDERLINE, ReadUnderline()); // EnableSubItems(); @@ -72,14 +74,16 @@ LONG CSettingsPage::OnApply() SaveFullRow(IsButtonCheckedBool(IDC_SETTINGS_FULL_ROW)); SaveShowGrid(IsButtonCheckedBool(IDC_SETTINGS_SHOW_GRID)); SaveAlternativeSelection(IsButtonCheckedBool(IDC_SETTINGS_ALTERNATIVE_SELECTION)); + #ifndef UNDER_CE if (IsLargePageSupported()) { bool enable = IsButtonCheckedBool(IDC_SETTINGS_LARGE_PAGES); NSecurity::EnableLockMemoryPrivilege(enable); SaveLockMemoryEnable(enable); } + #endif - // SaveSingleClick(IsButtonCheckedBool(IDC_SETTINGS_SINGLE_CLICK)); + SaveSingleClick(IsButtonCheckedBool(IDC_SETTINGS_SINGLE_CLICK)); // SaveUnderline(IsButtonCheckedBool(IDC_SETTINGS_UNDERLINE)); return PSNRET_NOERROR; @@ -94,8 +98,8 @@ bool CSettingsPage::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) { - /* case IDC_SETTINGS_SINGLE_CLICK: + /* EnableSubItems(); break; */ diff --git a/CPP/7zip/UI/FileManager/SettingsPage.rc b/CPP/7zip/UI/FileManager/SettingsPage.rc index 1d0e709b..3e4a611e 100755 --- a/CPP/7zip/UI/FileManager/SettingsPage.rc +++ b/CPP/7zip/UI/FileManager/SettingsPage.rc @@ -1,35 +1,22 @@ #include "SettingsPageRes.h" #include "../../GuiCommon.rc" -#define xSize2 196 -#define ySize2 140 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - - -IDD_SETTINGS DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE -CAPTION "Settings" -MY_FONT -BEGIN - CONTROL "Show "".."" item", IDC_SETTINGS_SHOW_DOTS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, marg, xSize2, 10 - CONTROL "Show real file &icons", IDC_SETTINGS_SHOW_REAL_FILE_ICONS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 21, xSize2, 10 - CONTROL "Show system &menu", IDC_SETTINGS_SHOW_SYSTEM_MENU, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 35, xSize2, 10 - CONTROL "&Full row select", IDC_SETTINGS_FULL_ROW, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 63, xSize2, 10 - CONTROL "Show &grid lines", IDC_SETTINGS_SHOW_GRID, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 77, xSize2, 10 - CONTROL "&Single-click to open an item", IDC_SETTINGS_SINGLE_CLICK, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP, - marg, 91, xSize2, 10 - CONTROL "&Underline current name", IDC_SETTINGS_UNDERLINE, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP, - marg + 12, 105, xSize2 - 12, 10 - - CONTROL "&Alternative selection mode", IDC_SETTINGS_ALTERNATIVE_SELECTION, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 122, xSize2, 10 - - CONTROL "Use &large memory pages", IDC_SETTINGS_LARGE_PAGES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - marg, 142, xSize2, 10 - -END +#define xc 200 +#define yc 120 + +IDD_SETTINGS MY_PAGE +#include "SettingsPage2.rc" + + +#ifdef UNDER_CE + +#undef m +#undef xc + +#define m 4 +#define xc (SMALL_PAGE_SIZE_X + 8) + +IDD_SETTINGS_2 MY_PAGE +#include "SettingsPage2.rc" + +#endif diff --git a/CPP/7zip/UI/FileManager/SettingsPage2.rc b/CPP/7zip/UI/FileManager/SettingsPage2.rc new file mode 100755 index 00000000..c920120e --- /dev/null +++ b/CPP/7zip/UI/FileManager/SettingsPage2.rc @@ -0,0 +1,24 @@ +CAPTION "Settings" +BEGIN + CONTROL "Show "".."" item", IDC_SETTINGS_SHOW_DOTS, MY_CHECKBOX, + m, 8, xc, 10 + CONTROL "Show real file &icons", IDC_SETTINGS_SHOW_REAL_FILE_ICONS, MY_CHECKBOX, + m, 22, xc, 10 + CONTROL "Show system &menu", IDC_SETTINGS_SHOW_SYSTEM_MENU, MY_CHECKBOX, + m, 36, xc, 10 + CONTROL "&Full row select", IDC_SETTINGS_FULL_ROW, MY_CHECKBOX, + m, 50, xc, 10 + CONTROL "Show &grid lines", IDC_SETTINGS_SHOW_GRID, MY_CHECKBOX, + m, 64, xc, 10 + CONTROL "&Single-click to open an item", IDC_SETTINGS_SINGLE_CLICK, MY_CHECKBOX, + m, 78, xc, 10 + /* + CONTROL "&Underline current name", IDC_SETTINGS_UNDERLINE, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP, + m + 12, 92, xc - 12, 10 + */ + + CONTROL "&Alternative selection mode", IDC_SETTINGS_ALTERNATIVE_SELECTION, MY_CHECKBOX, + m, 92, xc, 10 + CONTROL "Use &large memory pages", IDC_SETTINGS_LARGE_PAGES, MY_CHECKBOX, + m, 106, xc, 10 +END diff --git a/CPP/7zip/UI/FileManager/SettingsPageRes.h b/CPP/7zip/UI/FileManager/SettingsPageRes.h index 8932dc0e..b6c7f5cc 100755 --- a/CPP/7zip/UI/FileManager/SettingsPageRes.h +++ b/CPP/7zip/UI/FileManager/SettingsPageRes.h @@ -1,4 +1,6 @@ -#define IDD_SETTINGS 904 +#define IDD_SETTINGS 543 +#define IDD_SETTINGS_2 643 + #define IDC_SETTINGS_SHOW_DOTS 1000 #define IDC_SETTINGS_SHOW_REAL_FILE_ICONS 1001 diff --git a/CPP/7zip/UI/FileManager/SplitDialog.cpp b/CPP/7zip/UI/FileManager/SplitDialog.cpp index bab319d1..5dca8e48 100755 --- a/CPP/7zip/UI/FileManager/SplitDialog.cpp +++ b/CPP/7zip/UI/FileManager/SplitDialog.cpp @@ -1,18 +1,18 @@ // SplitDialog.cpp #include "StdAfx.h" -#include "SplitDialog.h" -#include "Common/StringToInt.h" -#include "Windows/Shell.h" #include "Windows/FileName.h" -#include "SplitUtils.h" #ifdef LANG #include "LangUtils.h" #endif +#include "BrowseDialog.h" #include "CopyDialogRes.h" +#include "SplitDialog.h" +#include "SplitUtils.h" +#include "resourceGui.h" using namespace NWindows; @@ -45,9 +45,36 @@ bool CSplitDialog::OnInit() _pathCombo.SetText(Path); AddVolumeItems(_volumeCombo); _volumeCombo.SetCurSel(0); + NormalizeSize(); return CModalDialog::OnInit(); } +bool CSplitDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + GetMargins(8, mx, my); + int bx1, bx2, by; + GetItemSizes(IDCANCEL, bx1, by); + GetItemSizes(IDOK, bx2, by); + int yPos = ySize - my - by; + int xPos = xSize - mx - bx1; + + InvalidateRect(NULL); + + { + RECT rect; + GetClientRectOfItem(IDC_BUTTON_SPLIT_PATH, rect); + int bx = rect.right - rect.left; + MoveItem(IDC_BUTTON_SPLIT_PATH, xSize - mx - bx, rect.top, bx, rect.bottom - rect.top); + ChangeSubWindowSizeX(_pathCombo, xSize - mx - mx - bx - mx); + } + + MoveItem(IDCANCEL, xPos, yPos, bx1, by); + MoveItem(IDOK, xPos - mx - bx2, yPos, bx2, by); + + return false; +} + bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) @@ -67,7 +94,7 @@ void CSplitDialog::OnButtonSetPath() UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209); UString resultPath; - if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath)) + if (!MyBrowseForFolder(HWND(*this), title, currentPath, resultPath)) return; NFile::NName::NormalizeDirPathPrefix(resultPath); _pathCombo.SetCurSel(-1); @@ -82,7 +109,7 @@ void CSplitDialog::OnOK() volumeString.Trim(); if (!ParseVolumeSizes(volumeString, VolumeSizes) || VolumeSizes.Size() == 0) { - ::MessageBoxW(*this, LangString(IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0); + ::MessageBoxW(*this, LangString(IDS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0); return; } CModalDialog::OnOK(); diff --git a/CPP/7zip/UI/FileManager/SplitDialog.h b/CPP/7zip/UI/FileManager/SplitDialog.h index 607a3daf..33fb64e7 100755 --- a/CPP/7zip/UI/FileManager/SplitDialog.h +++ b/CPP/7zip/UI/FileManager/SplitDialog.h @@ -1,11 +1,11 @@ // SplitDialog.h -#ifndef __SPLITDIALOG_H -#define __SPLITDIALOG_H +#ifndef __SPLIT_DIALOG_H +#define __SPLIT_DIALOG_H -#include "Common/Types.h" #include "Windows/Control/Dialog.h" #include "Windows/Control/ComboBox.h" + #include "SplitDialogRes.h" class CSplitDialog: public NWindows::NControl::CModalDialog @@ -14,6 +14,7 @@ class CSplitDialog: public NWindows::NControl::CModalDialog NWindows::NControl::CComboBox _volumeCombo; virtual void OnOK(); virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); void OnButtonSetPath(); public: diff --git a/CPP/7zip/UI/FileManager/SplitDialog.rc b/CPP/7zip/UI/FileManager/SplitDialog.rc index 7e78daaf..e977d651 100755 --- a/CPP/7zip/UI/FileManager/SplitDialog.rc +++ b/CPP/7zip/UI/FileManager/SplitDialog.rc @@ -1,32 +1,16 @@ #include "SplitDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 223 -#define ySize2 89 +#define xc 288 +#define yc 96 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) - -#define bYPos (ySize - marg - bYSize) -#define b1XPos (xSize - marg - bXSize) -#define b2XPos (b1XPos - 10 - bXSize) - - - -IDD_DIALOG_SPLIT DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_SPLIT MY_RESIZE_DIALOG CAPTION "Split File" -MY_FONT -BEGIN - LTEXT "&Split to:", IDC_STATIC_SPLIT_PATH, marg, marg, xSize2, 8 - COMBOBOX IDC_COMBO_SPLIT_PATH, marg, 18, xSize2 - bDotsSize - 12, 126, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "...", IDC_BUTTON_SPLIT_PATH, xSize - marg - bDotsSize, 17, bDotsSize, bYSize, WS_GROUP - LTEXT "Split to &volumes, bytes:", IDC_STATIC_SPLIT_VOLUME, marg, 38, xSize2, 8 - COMBOBOX IDC_COMBO_SPLIT_VOLUME, marg, 50, 120, 52, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize - PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize -END - -STRINGTABLE BEGIN - IDS_COMPRESS_INCORRECT_VOLUME_SIZE "Incorrect volume size" + LTEXT "&Split to:", IDC_STATIC_SPLIT_PATH, m, m, xc, 8 + COMBOBOX IDC_COMBO_SPLIT_PATH, m, 20, xc - bxsDots - m, 64, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDC_BUTTON_SPLIT_PATH, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP + LTEXT "Split to &volumes, bytes:", IDC_STATIC_SPLIT_VOLUME, m, 44, xc, 8 + COMBOBOX IDC_COMBO_SPLIT_VOLUME, m, 56, 96, 52, MY_COMBO_WITH_EDIT + OK_CANCEL END diff --git a/CPP/7zip/UI/FileManager/SplitDialogRes.h b/CPP/7zip/UI/FileManager/SplitDialogRes.h index 019b7029..a6f06d1c 100755 --- a/CPP/7zip/UI/FileManager/SplitDialogRes.h +++ b/CPP/7zip/UI/FileManager/SplitDialogRes.h @@ -5,4 +5,3 @@ #define IDC_STATIC_SPLIT_VOLUME 1010 #define IDC_COMBO_SPLIT_VOLUME 1011 -#define IDS_COMPRESS_INCORRECT_VOLUME_SIZE 95 diff --git a/CPP/7zip/UI/FileManager/SplitUtils.cpp b/CPP/7zip/UI/FileManager/SplitUtils.cpp index 3a7635fa..8bae0573 100755 --- a/CPP/7zip/UI/FileManager/SplitUtils.cpp +++ b/CPP/7zip/UI/FileManager/SplitUtils.cpp @@ -59,10 +59,11 @@ bool ParseVolumeSizes(const UString &s, CRecordVector<UInt64> &values) void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo) { - volumeCombo.AddString(TEXT("1457664 - 3.5\" floppy")); + volumeCombo.AddString(TEXT("10M")); volumeCombo.AddString(TEXT("650M - CD")); volumeCombo.AddString(TEXT("700M - CD")); volumeCombo.AddString(TEXT("4480M - DVD")); + volumeCombo.AddString(TEXT("1457664 - 3.5\" floppy")); } UInt64 GetNumberOfVolumes(UInt64 size, CRecordVector<UInt64> &volSizes) diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.cpp b/CPP/7zip/UI/FileManager/SysIconUtils.cpp index 3e5de7aa..e359ed2b 100755 --- a/CPP/7zip/UI/FileManager/SysIconUtils.cpp +++ b/CPP/7zip/UI/FileManager/SysIconUtils.cpp @@ -1,12 +1,13 @@ -// SysIconUtils.h +// SysIconUtils.cpp #include "StdAfx.h" -#include "SysIconUtils.h" #ifndef _UNICODE #include "Common/StringConvert.h" #endif +#include "SysIconUtils.h" + #ifndef _UNICODE extern bool g_IsNT; #endif @@ -18,7 +19,7 @@ int GetIconIndexForCSIDL(int csidl) if (pidl) { SHFILEINFO shellInfo; - SHGetFileInfo(LPCTSTR(pidl), FILE_ATTRIBUTE_NORMAL, + SHGetFileInfo(LPCTSTR(pidl), FILE_ATTRIBUTE_NORMAL, &shellInfo, sizeof(shellInfo), SHGFI_PIDL | SHGFI_SYSICONINDEX); IMalloc *pMalloc; @@ -33,10 +34,10 @@ int GetIconIndexForCSIDL(int csidl) return 0; } -DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex) +DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attrib, int &iconIndex) { SHFILEINFO shellInfo; - DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, + DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX); iconIndex = shellInfo.iIcon; return res; @@ -44,7 +45,7 @@ DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex) #ifndef _UNICODE -typedef int (WINAPI * SHGetFileInfoWP)(LPCWSTR pszPath, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags); +typedef int (WINAPI * SHGetFileInfoWP)(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags); struct CSHGetFileInfoInit { @@ -57,36 +58,36 @@ struct CSHGetFileInfoInit } g_SHGetFileInfoInit; #endif -DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD dwFileAttributes, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags) +static DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags) { #ifdef _UNICODE - return SHGetFileInfoW( + return SHGetFileInfo( #else if (g_SHGetFileInfoInit.shGetFileInfoW == 0) return 0; return g_SHGetFileInfoInit.shGetFileInfoW( #endif - pszPath, dwFileAttributes, psfi, cbFileInfo, uFlags); + pszPath, attrib, psfi, cbFileInfo, uFlags); } #ifndef _UNICODE // static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; } -DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attributes, int &iconIndex) +DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attrib, int &iconIndex) { if(g_IsNT) { SHFILEINFOW shellInfo; - DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, + DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX); iconIndex = shellInfo.iIcon; return res; } else - return GetRealIconIndex(UnicodeStringToMultiByte(path), attributes, iconIndex); + return GetRealIconIndex(UnicodeStringToMultiByte(path), attrib, iconIndex); } #endif -DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attributes, +DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib, int &iconIndex, UString &typeName) { #ifndef _UNICODE @@ -94,9 +95,8 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attributes, { SHFILEINFO shellInfo; shellInfo.szTypeName[0] = 0; - DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, - sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX - | SHGFI_TYPENAME); + DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, + sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME); typeName = GetUnicodeString(shellInfo.szTypeName); iconIndex = shellInfo.iIcon; return res; @@ -106,49 +106,54 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attributes, { SHFILEINFOW shellInfo; shellInfo.szTypeName[0] = 0; - DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo, - sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX - | SHGFI_TYPENAME); + DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, + sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME); typeName = shellInfo.szTypeName; iconIndex = shellInfo.iIcon; return res; } } -int CExtToIconMap::GetIconIndex(UINT32 attributes, const UString &fileNameSpec, UString &typeName) +int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName, UString &typeName) { - UString fileName = fileNameSpec; - if ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) + int dotPos = fileName.ReverseFind(L'.'); + if ((attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 || dotPos < 0) { - fileName = L"__Fldr__"; - if (_dirIconIndex < 0) - GetRealIconIndex(fileName, attributes, _dirIconIndex, _dirTypeName); - typeName = _dirTypeName; - return _dirIconIndex; + CAttribIconPair pair; + pair.Attrib = attrib; + int index = _attribMap.FindInSorted(pair); + if (index >= 0) + { + typeName = _attribMap[index].TypeName; + return _attribMap[index].IconIndex; + } + GetRealIconIndex( + #ifdef UNDER_CE + L"\\" + #endif + L"__File__" + , attrib, pair.IconIndex, pair.TypeName); + _attribMap.AddToSorted(pair); + typeName = pair.TypeName; + return pair.IconIndex; } - int dotPos = fileName.ReverseFind('.'); - if (dotPos < 0) + + CExtIconPair pair; + pair.Ext = fileName.Mid(dotPos + 1); + int index = _extMap.FindInSorted(pair); + if (index >= 0) { - fileName = L"__File__"; - if (_noExtIconIndex < 0) - GetRealIconIndex(fileName, attributes, _noExtIconIndex, _noExtTypeName); - typeName = _noExtTypeName; - return _noExtIconIndex; + typeName = _extMap[index].TypeName; + return _extMap[index].IconIndex; } - CExtIconPair extIconPair; - extIconPair.Ext = fileName.Mid(dotPos + 1); - int anIndex = _map.FindInSorted(extIconPair); - if (anIndex >= 0) - return _map[anIndex].IconIndex; - fileName = fileName.Mid(dotPos); - GetRealIconIndex(fileName, attributes, extIconPair.IconIndex, extIconPair.TypeName); - _map.AddToSorted(extIconPair); - typeName = extIconPair.TypeName; - return extIconPair.IconIndex; + GetRealIconIndex(fileName.Mid(dotPos), attrib, pair.IconIndex, pair.TypeName); + _extMap.AddToSorted(pair); + typeName = pair.TypeName; + return pair.IconIndex; } -int CExtToIconMap::GetIconIndex(UINT32 attributes, const UString &fileName) +int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName) { UString typeName; - return GetIconIndex(attributes, fileName, typeName); + return GetIconIndex(attrib, fileName, typeName); } diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.h b/CPP/7zip/UI/FileManager/SysIconUtils.h index a90d28bc..5ba9c57f 100755 --- a/CPP/7zip/UI/FileManager/SysIconUtils.h +++ b/CPP/7zip/UI/FileManager/SysIconUtils.h @@ -1,7 +1,7 @@ // SysIconUtils.h -#ifndef __SYSICONUTILS_H -#define __SYSICONUTILS_H +#ifndef __SYS_ICON_UTILS_H +#define __SYS_ICON_UTILS_H #include "Common/MyString.h" @@ -10,42 +10,48 @@ struct CExtIconPair UString Ext; int IconIndex; UString TypeName; - }; -inline bool operator==(const CExtIconPair &a1, const CExtIconPair &a2) +struct CAttribIconPair { - return (a1.Ext == a2.Ext); -} + DWORD Attrib; + int IconIndex; + UString TypeName; +}; -inline bool operator<(const CExtIconPair &a1, const CExtIconPair &a2) -{ - return (a1.Ext < a2.Ext); -} +inline bool operator==(const CExtIconPair &a1, const CExtIconPair &a2) { return a1.Ext == a2.Ext; } +inline bool operator< (const CExtIconPair &a1, const CExtIconPair &a2) { return a1.Ext < a2.Ext; } + +inline bool operator==(const CAttribIconPair &a1, const CAttribIconPair &a2) { return a1.Attrib == a2.Attrib; } +inline bool operator< (const CAttribIconPair &a1, const CAttribIconPair &a2) { return a1.Attrib < a2.Attrib; } class CExtToIconMap { - int _dirIconIndex; - UString _dirTypeName; - int _noExtIconIndex; - UString _noExtTypeName; - CObjectVector<CExtIconPair> _map; + CObjectVector<CExtIconPair> _extMap; + CObjectVector<CAttribIconPair> _attribMap; public: - CExtToIconMap(): _dirIconIndex(-1), _noExtIconIndex(-1) {} void Clear() { - _dirIconIndex = -1; - _noExtIconIndex = -1; - _map.Clear(); + _extMap.Clear(); + _attribMap.Clear(); } - int GetIconIndex(UINT32 attributes, const UString &fileName, UString &typeName); - int GetIconIndex(UINT32 attributes, const UString &fileName); + int GetIconIndex(DWORD attrib, const UString &fileName, UString &typeName); + int GetIconIndex(DWORD attrib, const UString &fileName); }; -DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex); +DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attrib, int &iconIndex); #ifndef _UNICODE -DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attributes, int &iconIndex); +DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attrib, int &iconIndex); #endif int GetIconIndexForCSIDL(int csidl); +inline HIMAGELIST GetSysImageList(bool smallIcons) +{ + SHFILEINFO shellInfo; + return (HIMAGELIST)SHGetFileInfo(TEXT(""), + FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY, + &shellInfo, sizeof(shellInfo), + SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON)); +} + #endif diff --git a/CPP/7zip/UI/FileManager/SystemPage.cpp b/CPP/7zip/UI/FileManager/SystemPage.cpp index 1cd7ce15..3681992d 100755 --- a/CPP/7zip/UI/FileManager/SystemPage.cpp +++ b/CPP/7zip/UI/FileManager/SystemPage.cpp @@ -52,11 +52,11 @@ bool CSystemPage::OnInit() _listViewExt.SetExtendedListViewStyle(newFlags, newFlags); _listViewPlugins.SetExtendedListViewStyle(newFlags, newFlags); - _listViewExt.InsertColumn(0, LangString(IDS_PROP_EXTENSION, 0x02000205), 70); + _listViewExt.InsertColumn(0, LangString(IDS_PROP_EXTENSION, 0x02000205), 40); const UString s = LangString(IDS_PLUGIN, 0x03010310); - _listViewExt.InsertColumn(1, s, 70); + _listViewExt.InsertColumn(1, s, 40); - _listViewPlugins.InsertColumn(0, s, 70); + _listViewPlugins.InsertColumn(0, s, 40); _extDatabase.Read(); @@ -77,11 +77,8 @@ bool CSystemPage::OnInit() } // _listViewExt.SortItems(); - if(_listViewExt.GetItemCount() > 0) - { - UINT state = LVIS_SELECTED | LVIS_FOCUSED; - _listViewExt.SetItemState(0, state, state); - } + if (_listViewExt.GetItemCount() > 0) + _listViewExt.SetItemState_FocusedSelected(0); RefreshPluginsList(-1); _initMode = false; @@ -166,7 +163,10 @@ LONG CSystemPage::OnApply() else NRegistryAssociations::DeleteContextMenuHandler(); */ + #ifndef UNDER_CE SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); + WasChanged = true; + #endif return PSNRET_NOERROR; } @@ -370,12 +370,11 @@ void CSystemPage::RefreshPluginsList(int selectIndex) int itemIndex = _listViewPlugins.InsertItem(i, _extDatabase.Plugins[pluginPair.Index].Name); _listViewPlugins.SetCheckState(itemIndex, pluginPair.Enabled); } - if(_listViewPlugins.GetItemCount() > 0) + if (_listViewPlugins.GetItemCount() > 0) { if (selectIndex < 0) selectIndex = 0; - UINT state = LVIS_SELECTED | LVIS_FOCUSED; - _listViewPlugins.SetItemState(selectIndex, state, state); + _listViewPlugins.SetItemState_FocusedSelected(selectIndex); } _initMode = false; } diff --git a/CPP/7zip/UI/FileManager/SystemPage.h b/CPP/7zip/UI/FileManager/SystemPage.h index 1b5891f6..967731fd 100755 --- a/CPP/7zip/UI/FileManager/SystemPage.h +++ b/CPP/7zip/UI/FileManager/SystemPage.h @@ -1,7 +1,7 @@ // SystemPage.h -#ifndef __SYSTEMPAGE_H -#define __SYSTEMPAGE_H +#ifndef __SYSTEM_PAGE_H +#define __SYSTEM_PAGE_H #include "Windows/Control/PropertyPage.h" #include "Windows/Control/ListView.h" @@ -13,7 +13,6 @@ class CSystemPage: public NWindows::NControl::CPropertyPage bool _initMode; CExtDatabase _extDatabase; - // CObjectVector<NZipRootRegistry::CArchiverInfo> m_Archivers; NWindows::NControl::CListView _listViewExt; NWindows::NControl::CListView _listViewPlugins; @@ -26,6 +25,8 @@ class CSystemPage: public NWindows::NControl::CPropertyPage void SelectAll(); public: + bool WasChanged; + CSystemPage(): WasChanged(false) {} virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); virtual bool OnInit(); virtual void OnNotifyHelp(); diff --git a/CPP/7zip/UI/FileManager/SystemPage.rc b/CPP/7zip/UI/FileManager/SystemPage.rc index 9b4e808d..52e60d19 100755 --- a/CPP/7zip/UI/FileManager/SystemPage.rc +++ b/CPP/7zip/UI/FileManager/SystemPage.rc @@ -1,26 +1,42 @@ #include "SystemPageRes.h" #include "../../GuiCommon.rc" -#define xSize2 196 -#define ySize2 200 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) -#define g0Size xSize2 -#define gYSize (ySize2 - 20 - bYSize) +#define xc 200 +#define yc 200 - -IDD_SYSTEM DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE +IDD_SYSTEM MY_PAGE CAPTION "System" -MY_FONT BEGIN - LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, marg, marg, xSize2, 8 - CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32", + LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, m, m, xc, 8 + CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32", LVS_LIST | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP, - marg, 20, g0Size, gYSize - PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, marg, (ySize - marg - bYSize), 90, bYSize + m, m + 12, xc, (yc - m - 12 - 1 - bys) + PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, (ys - m - bys), 90, bys +END + +#ifdef UNDER_CE + +#undef m +#undef xc +#undef yc + +#define m 4 +#define xc (SMALL_PAGE_SIZE_X + 8) +#define yc (128 + 8) +IDD_SYSTEM_2 MY_PAGE +CAPTION "System" +BEGIN + LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, m, m, xc, 8 + CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32", + LVS_LIST | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP, + m, m + 12, xc, (yc - m - 12 - 1 - bys - 8) + PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, (ys - m - bys - 8), 90, bys END +#endif + + STRINGTABLE BEGIN IDS_PLUGIN "Plugin" diff --git a/CPP/7zip/UI/FileManager/SystemPageRes.h b/CPP/7zip/UI/FileManager/SystemPageRes.h index 8dce778b..b60b4533 100755 --- a/CPP/7zip/UI/FileManager/SystemPageRes.h +++ b/CPP/7zip/UI/FileManager/SystemPageRes.h @@ -1,4 +1,5 @@ -#define IDD_SYSTEM 902 +#define IDD_SYSTEM 540 +#define IDD_SYSTEM_2 640 #define IDS_PLUGIN 990 // #define IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU 1010 #define IDC_SYSTEM_STATIC_ASSOCIATE 1020 diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp index 3701d2bb..43dfa4dc 100755 --- a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp +++ b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp @@ -2,73 +2,56 @@ #include "StdAfx.h" -#include "MessagesDialog.h" #include "PasswordDialog.h" #include "UpdateCallback100.h" -CUpdateCallback100Imp::~CUpdateCallback100Imp() -{ - if (ShowMessages && !Messages.IsEmpty()) - { - CMessagesDialog messagesDialog; - messagesDialog.Messages = &Messages; - messagesDialog.Create(_parentWindow); - } -} - -void CUpdateCallback100Imp::AddErrorMessage(LPCWSTR message) -{ - Messages.Add(message); -} - STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles) { - ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles); + ProgressDialog->Sync.SetNumFilesTotal(numFiles); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size) { - ProgressDialog.ProgressSynch.SetProgress(size, 0); + ProgressDialog->Sync.SetProgress(size, 0); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completeValue) { - RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause()); + RINOK(ProgressDialog->Sync.ProcessStopAndPause()); if (completeValue != NULL) - ProgressDialog.ProgressSynch.SetPos(*completeValue); + ProgressDialog->Sync.SetPos(*completeValue); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) { - ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize); + ProgressDialog->Sync.SetRatioInfo(inSize, outSize); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t *name) { - ProgressDialog.ProgressSynch.SetCurrentFileName(name); + ProgressDialog->Sync.SetCurrentFileName(name); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t *name) { - ProgressDialog.ProgressSynch.SetCurrentFileName(name); + ProgressDialog->Sync.SetCurrentFileName(name); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::OperationResult(Int32 /* operationResult */) { - NumFiles++; - ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles); + ProgressDialog->Sync.SetNumFilesCur(++_numFiles); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message) { - AddErrorMessage(message); + ProgressDialog->Sync.AddErrorMessage(message); return S_OK; } @@ -88,7 +71,7 @@ STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const U STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */) { - return ProgressDialog.ProgressSynch.ProcessStopAndPause(); + return ProgressDialog->Sync.ProcessStopAndPause(); } STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password) @@ -97,7 +80,8 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password) if (!_passwordIsDefined) { CPasswordDialog dialog; - if (dialog.Create(_parentWindow) == IDCANCEL) + ProgressDialog->WaitCreating(); + if (dialog.Create(*ProgressDialog) == IDCANCEL) return E_ABORT; _password = dialog.Password; _passwordIsDefined = true; diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.h b/CPP/7zip/UI/FileManager/UpdateCallback100.h index 5ae194a2..aa13320f 100755 --- a/CPP/7zip/UI/FileManager/UpdateCallback100.h +++ b/CPP/7zip/UI/FileManager/UpdateCallback100.h @@ -4,15 +4,12 @@ #define __UPDATE_CALLBACK100_H #include "Common/MyCom.h" -#include "Common/MyString.h" -#include "../Agent/IFolderArchive.h" -#include "ProgressDialog2.h" #include "../../IPassword.h" -#ifdef LANG -#include "LangUtils.h" -#endif +#include "../Agent/IFolderArchive.h" + +#include "ProgressDialog2.h" class CUpdateCallback100Imp: public IFolderArchiveUpdateCallback, @@ -22,7 +19,14 @@ class CUpdateCallback100Imp: public ICompressProgressInfo, public CMyUnknownImp { + bool _passwordIsDefined; + UString _password; + UInt64 _numFiles; public: + CProgressDialog *ProgressDialog; + + CUpdateCallback100Imp(): ProgressDialog(0) {} + MY_UNKNOWN_IMP5( IFolderArchiveUpdateCallback, ICryptoGetTextPassword2, @@ -38,35 +42,13 @@ public: STDMETHOD(CryptoGetTextPassword)(BSTR *password); STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password); -private: - bool _passwordIsDefined; - UString _password; - void AddErrorMessage(LPCWSTR message); - bool ShowMessages; - -public: - CUpdateCallback100Imp(): ShowMessages(true) {} - ~CUpdateCallback100Imp(); - CProgressDialog ProgressDialog; - HWND _parentWindow; - UStringVector Messages; - UInt64 NumFolders; - UInt64 NumFiles; - - void Init(HWND parentWindow, - bool passwordIsDefined, const UString &password) + void Init(bool passwordIsDefined, const UString &password) { _passwordIsDefined = passwordIsDefined; _password = password; - _parentWindow = parentWindow; - NumFolders = NumFiles = 0; - } - void StartProgressDialog(const UString &title) - { - ProgressDialog.Create(title, _parentWindow); + _numFiles = 0; } - }; #endif diff --git a/CPP/7zip/UI/FileManager/ViewSettings.cpp b/CPP/7zip/UI/FileManager/ViewSettings.cpp index 0f98c217..6ec53787 100755 --- a/CPP/7zip/UI/FileManager/ViewSettings.cpp +++ b/CPP/7zip/UI/FileManager/ViewSettings.cpp @@ -12,7 +12,7 @@ using namespace NWindows; using namespace NRegistry; -#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP") TEXT(STRING_PATH_SEPARATOR) TEXT("FM") +#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR) TEXT("FM") static const TCHAR *kCUBasePath = REG_PATH_FM; static const TCHAR *kCulumnsKeyName = REG_PATH_FM TEXT(STRING_PATH_SEPARATOR) TEXT("Columns"); @@ -48,7 +48,7 @@ static const UInt32 kColumnHeaderSize = 12; static const UInt32 kColumnInfoVersion = 1; -static NSynchronization::CCriticalSection g_RegistryOperationsCriticalSection; +static NSynchronization::CCriticalSection g_CS; class CTempOutBufferSpec { @@ -126,7 +126,7 @@ void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo) buffer.WriteUInt32(column.Width); } { - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; key.Create(HKEY_CURRENT_USER, kCulumnsKeyName); key.SetValue(GetSystemString(id), (const Byte *)buffer, dataSize); @@ -140,9 +140,9 @@ void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo) CByteBuffer buffer; UInt32 size; { - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - if(key.Open(HKEY_CURRENT_USER, kCulumnsKeyName, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, kCulumnsKeyName, KEY_READ) != ERROR_SUCCESS) return; if (key.QueryValue(GetSystemString(id), buffer, size) != ERROR_SUCCESS) return; @@ -197,8 +197,8 @@ struct CPanelsInfo void SaveWindowSize(const RECT &rect, bool maximized) { CSysString keyName = kCUBasePath; + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); key.Create(HKEY_CURRENT_USER, keyName); // CWindowPosition position; CTempOutBufferSpec buffer; @@ -214,9 +214,9 @@ void SaveWindowSize(const RECT &rect, bool maximized) bool ReadWindowSize(RECT &rect, bool &maximized) { CSysString keyName = kCUBasePath; + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - if(key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS) return false; CByteBuffer buffer; UInt32 size; @@ -239,8 +239,8 @@ bool ReadWindowSize(RECT &rect, bool &maximized) void SavePanelsInfo(UInt32 numPanels, UInt32 currentPanel, UInt32 splitterPos) { CSysString keyName = kCUBasePath; + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); key.Create(HKEY_CURRENT_USER, keyName); CTempOutBufferSpec buffer; @@ -254,9 +254,9 @@ void SavePanelsInfo(UInt32 numPanels, UInt32 currentPanel, UInt32 splitterPos) bool ReadPanelsInfo(UInt32 &numPanels, UInt32 ¤tPanel, UInt32 &splitterPos) { CSysString keyName = kCUBasePath; + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - if(key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS) return false; CByteBuffer buffer; UInt32 size; @@ -286,7 +286,7 @@ static const UInt32 kDefaultToolbarMask = 8 | 4 | 1; UInt32 ReadToolbarsMask() { CKey key; - if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) return kDefaultToolbarMask; UInt32 mask; if (key.QueryValue(kToolbars, mask) != ERROR_SUCCESS) @@ -305,17 +305,17 @@ static UString GetPanelPathName(UInt32 panelIndex) void SavePanelPath(UInt32 panel, const UString &path) { + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); key.Create(HKEY_CURRENT_USER, kCUBasePath); key.SetValue(GetPanelPathName(panel), path); } bool ReadPanelPath(UInt32 panel, UString &path) { + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) return false; return (key.QueryValue(GetPanelPathName(panel), path) == ERROR_SUCCESS); } @@ -334,7 +334,7 @@ void ReadListMode(CListMode &listMode) { CKey key; listMode.Init(); - if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) + if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) return; UInt32 t; if (key.QueryValue(kListMode, t) != ERROR_SUCCESS) @@ -347,53 +347,21 @@ void ReadListMode(CListMode &listMode) } -void SaveStringList(LPCTSTR valueName, const UStringVector &folders) +static void SaveStringList(LPCTSTR valueName, const UStringVector &folders) { - UInt32 sizeInChars = 0; - int i; - for (i = 0; i < folders.Size(); i++) - sizeInChars += folders[i].Length() + 1; - CBuffer<wchar_t> buffer; - buffer.SetCapacity(sizeInChars); - int pos = 0; - for (i = 0; i < folders.Size(); i++) - { - MyStringCopy((wchar_t *)buffer + pos, (const wchar_t *)folders[i]); - pos += folders[i].Length() + 1; - } + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); key.Create(HKEY_CURRENT_USER, kCUBasePath); - key.SetValue(valueName, buffer, sizeInChars * sizeof(wchar_t)); + key.SetValue_Strings(valueName, folders); } -void ReadStringList(LPCTSTR valueName, UStringVector &folders) +static void ReadStringList(LPCTSTR valueName, UStringVector &folders) { folders.Clear(); + NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection); - if(key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) - return; - CByteBuffer buffer; - UInt32 dataSize; - if (key.QueryValue(valueName, buffer, dataSize) != ERROR_SUCCESS) - return; - if (dataSize % sizeof(wchar_t) != 0) - return; - const wchar_t *data = (const wchar_t *)(const Byte *)buffer; - int sizeInChars = dataSize / sizeof(wchar_t); - UString string; - for (int i = 0; i < sizeInChars; i++) - { - wchar_t c = data[i]; - if (c == L'\0') - { - folders.Add(string); - string.Empty(); - } - else - string += c; - } + if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS) + key.GetValue_Strings(valueName, folders); } void SaveFolderHistory(const UStringVector &folders) @@ -411,14 +379,12 @@ void SaveCopyHistory(const UStringVector &folders) void ReadCopyHistory(UStringVector &folders) { ReadStringList(kCopyHistoryValueName, folders); } -void AddUniqueStringToHeadOfList(UStringVector &list, - const UString &string) +void AddUniqueStringToHeadOfList(UStringVector &list, const UString &s) { - for(int i = 0; i < list.Size();) - if (string.CompareNoCase(list[i]) == 0) + for (int i = 0; i < list.Size();) + if (s.CompareNoCase(list[i]) == 0) list.Delete(i); else i++; - list.Insert(0, string); + list.Insert(0, s); } - diff --git a/CPP/7zip/UI/FileManager/ViewSettings.h b/CPP/7zip/UI/FileManager/ViewSettings.h index 2500ce7b..b0510813 100755 --- a/CPP/7zip/UI/FileManager/ViewSettings.h +++ b/CPP/7zip/UI/FileManager/ViewSettings.h @@ -1,9 +1,10 @@ // ViewSettings.h -#ifndef __VIEWSETTINGS_H -#define __VIEWSETTINGS_H +#ifndef __VIEW_SETTINGS_H +#define __VIEW_SETTINGS_H #include "Common/MyString.h" +#include "Common/Types.h" struct CColumnInfo { @@ -44,15 +45,15 @@ struct CListViewInfo return -1; } - bool IsEqual(const CListViewInfo &aNewInfo) const + bool IsEqual(const CListViewInfo &info) const { - if (Columns.Size() != aNewInfo.Columns.Size() || - // SortIndex != aNewInfo.SortIndex || - SortID != aNewInfo.SortID || - Ascending != aNewInfo.Ascending) + if (Columns.Size() != info.Columns.Size() || + // SortIndex != info.SortIndex || + SortID != info.SortID || + Ascending != info.Ascending) return false; for (int i = 0; i < Columns.Size(); i++) - if (Columns[i] != aNewInfo.Columns[i]) + if (Columns[i] != info.Columns[i]) return false; return true; } @@ -92,7 +93,6 @@ void ReadFastFolders(UStringVector &folders); void SaveCopyHistory(const UStringVector &folders); void ReadCopyHistory(UStringVector &folders); -void AddUniqueStringToHeadOfList(UStringVector &list, - const UString &string); +void AddUniqueStringToHeadOfList(UStringVector &list, const UString &s); #endif diff --git a/CPP/7zip/UI/FileManager/makefile b/CPP/7zip/UI/FileManager/makefile index fea2d39a..d26aa04b 100755 --- a/CPP/7zip/UI/FileManager/makefile +++ b/CPP/7zip/UI/FileManager/makefile @@ -1,28 +1,33 @@ PROG = 7zFM.exe -LIBS = $(LIBS) user32.lib oleaut32.lib advapi32.lib shell32.lib ole32.lib comctl32.lib htmlhelp.lib Mpr.lib Gdi32.lib comdlg32.lib CFLAGS = $(CFLAGS) -I ../../../ \ -DLANG \ - -DWIN_LONG_PATH \ -DNEW_FOLDER_INTERFACE \ -DEXTERNAL_CODECS \ - -DSUPPORT_DEVICE_FILE \ + +!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 FM_OBJS = \ $O\App.obj \ + $O\BrowseDialog.obj \ $O\ClassDefs.obj \ $O\EnumFormatEtc.obj \ $O\ExtractCallback.obj \ $O\FileFolderPluginOpen.obj \ $O\FilePlugins.obj \ $O\FM.obj \ + $O\FoldersPage.obj \ $O\FormatUtils.obj \ - $O\FSDrives.obj \ $O\FSFolder.obj \ $O\FSFolderCopy.obj \ $O\HelpUtils.obj \ $O\LangUtils.obj \ + $O\MenuPage.obj \ $O\MyLoadMenu.obj \ - $O\NetFolder.obj \ $O\OpenCallback.obj \ $O\OptionsDialog.obj \ $O\Panel.obj \ @@ -89,21 +94,33 @@ WIN_OBJS = \ $O\FileFind.obj \ $O\FileIO.obj \ $O\FileName.obj \ - $O\FileSystem.obj \ $O\Memory.obj \ $O\MemoryLock.obj \ $O\Menu.obj \ - $O\Net.obj \ + $O\Process.obj \ $O\PropVariant.obj \ $O\PropVariantConversions.obj \ $O\Registry.obj \ $O\ResourceString.obj \ - $O\Security.obj \ $O\Shell.obj \ $O\Synchronization.obj \ $O\Time.obj \ $O\Window.obj \ +!IFNDEF UNDER_CE + +FM_OBJS = $(FM_OBJS) \ + $O\FSDrives.obj \ + $O\NetFolder.obj \ + +WIN_OBJS = $(WIN_OBJS) \ + $O\FileSystem.obj \ + $O\Net.obj \ + $O\Security.obj \ + +!ENDIF + + WIN_CTRL_OBJS = \ $O\ComboBox.obj \ $O\Dialog.obj \ @@ -118,6 +135,9 @@ WIN_CTRL_OBJS = \ $O\StreamObjects.obj \ $O\StreamUtils.obj \ +AR_COMMON_OBJS = \ + $O\OutStreamWithCRC.obj \ + UI_COMMON_OBJS = \ $O\ArchiveExtractCallback.obj \ $O\ArchiveName.obj \ @@ -137,8 +157,9 @@ UI_COMMON_OBJS = \ $O\WorkDir.obj \ $O\ZipRegistry.obj \ -AR_COMMON_OBJS = \ - $O\OutStreamWithCRC.obj \ +EXPLORER_OBJS = \ + $O\ContextMenu.obj \ + $O\RegistryContextMenu.obj \ AGENT_OBJS = \ $O\Agent.obj \ @@ -164,8 +185,9 @@ OBJS = \ $(WIN_OBJS) \ $(WIN_CTRL_OBJS) \ $(7ZIP_COMMON_OBJS) \ - $(UI_COMMON_OBJS) \ $(AR_COMMON_OBJS) \ + $(UI_COMMON_OBJS) \ + $(EXPLORER_OBJS) \ $(AGENT_OBJS) \ $O\CopyCoder.obj \ $(CRC_OBJS) \ @@ -184,12 +206,14 @@ $(WIN_CTRL_OBJS): ../../../Windows/Control/$(*B).cpp $(COMPL) $(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp $(COMPL) -$(UI_COMMON_OBJS): ../Common/$(*B).cpp - $(COMPL) $(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp $(COMPL) +$(UI_COMMON_OBJS): ../Common/$(*B).cpp + $(COMPL) $(AGENT_OBJS): ../Agent/$(*B).cpp $(COMPL) +$(EXPLORER_OBJS): ../Explorer/$(*B).cpp + $(COMPL) $O\CopyCoder.obj: ../../Compress/$(*B).cpp $(COMPL) diff --git a/CPP/7zip/UI/FileManager/resource.h b/CPP/7zip/UI/FileManager/resource.h index 72121c89..13c8e0e7 100755 --- a/CPP/7zip/UI/FileManager/resource.h +++ b/CPP/7zip/UI/FileManager/resource.h @@ -1,5 +1,5 @@ -#define IDI_FAM 101 -#define IDI_FM 101 +#include "resourceGui.h" + #define IDR_MENUBAR1 103 #define IDM_MENU 103 #define IDR_ACCELERATOR1 209 @@ -109,9 +109,6 @@ #define IDS_SELECT_MASK 2252 #define IDS_FOLDERS_HISTORY 2260 #define IDS_N_SELECTED_ITEMS 2270 -#define IDS_FILES_COLON 2274 -#define IDS_FOLDERS_COLON 2275 -#define IDS_SIZE_COLON 2276 #define IDS_TOO_MANY_ITEMS 2279 #define IDS_WANT_UPDATE_MODIFIED_FILE 2280 @@ -160,9 +157,6 @@ #define IDS_SCANNING 4050 #define IDS_PROPERTIES 4060 -#define IDS_PROGRESS_TESTING 4100 -#define IDS_MESSAGE_NO_ERRORS 4200 - #define IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER 4301 #define IDS_SELECT_ONE_FILE 4302 #define IDS_SELECT_FILES 4303 diff --git a/CPP/7zip/UI/FileManager/resource.rc b/CPP/7zip/UI/FileManager/resource.rc index cdfed0b6..833cb374 100755 --- a/CPP/7zip/UI/FileManager/resource.rc +++ b/CPP/7zip/UI/FileManager/resource.rc @@ -32,7 +32,7 @@ BEGIN MENUITEM "Com&bine files...", IDM_FILE_COMBINE MENUITEM SEPARATOR MENUITEM "P&roperties\tAlt+Enter", IDM_FILE_PROPERTIES - MENUITEM "Comme&nt\tCtrl+Z", IDM_FILE_COMMENT + MENUITEM "Comme&nt...\tCtrl+Z", IDM_FILE_COMMENT MENUITEM "Calculate checksum", IDM_FILE_CRC MENUITEM "Di&ff", IDM_FILE_DIFF MENUITEM SEPARATOR @@ -78,11 +78,9 @@ BEGIN MENUITEM "Large Buttons", IDM_VIEW_TOOLBARS_LARGE_BUTTONS MENUITEM "Show Buttons Text", IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT END - MENUITEM SEPARATOR MENUITEM "Open Root Folder\t\\", IDM_OPEN_ROOT_FOLDER MENUITEM "Up One Level\tBackspace", IDM_OPEN_PARENT_FOLDER MENUITEM "Folders History...\tAlt+F12", IDM_FOLDERS_HISTORY - MENUITEM SEPARATOR MENUITEM "&Refresh\tCtrl+R", IDM_VIEW_REFRESH END POPUP "F&avorites" @@ -97,34 +95,38 @@ BEGIN BEGIN MENUITEM "&Options...", IDM_OPTIONS MENUITEM "&Benchmark", IDM_BENCHMARK + #ifndef UNDER_CE END POPUP "&Help" BEGIN MENUITEM "&Contents...\tF1", IDM_HELP_CONTENTS + #endif MENUITEM SEPARATOR - MENUITEM "&About 7-Zip...", IDM_ABOUT + MENUITEM "&About 7-Zip...", IDM_ABOUT END END -IDI_FM ICON "FM.ico" +IDI_ICON ICON "../../UI/FileManager/FM.ico" -1 24 MOVEABLE PURE "7zFM.exe.manifest" +#ifndef UNDER_CE +1 24 MOVEABLE PURE "../../UI/FileManager/7zFM.exe.manifest" +#endif -IDB_ADD BITMAP "Add.bmp" -IDB_EXTRACT BITMAP "Extract.bmp" -IDB_TEST BITMAP "Test.bmp" -IDB_COPY BITMAP "Copy.bmp" -IDB_MOVE BITMAP "Move.bmp" -IDB_DELETE BITMAP "Delete.bmp" -IDB_INFO BITMAP "Info.bmp" -IDB_ADD2 BITMAP "Add2.bmp" -IDB_EXTRACT2 BITMAP "Extract2.bmp" -IDB_TEST2 BITMAP "Test2.bmp" -IDB_COPY2 BITMAP "Copy2.bmp" -IDB_MOVE2 BITMAP "Move2.bmp" -IDB_DELETE2 BITMAP "Delete2.bmp" -IDB_INFO2 BITMAP "Info2.bmp" +IDB_ADD BITMAP "../../UI/FileManager/Add.bmp" +IDB_EXTRACT BITMAP "../../UI/FileManager/Extract.bmp" +IDB_TEST BITMAP "../../UI/FileManager/Test.bmp" +IDB_COPY BITMAP "../../UI/FileManager/Copy.bmp" +IDB_MOVE BITMAP "../../UI/FileManager/Move.bmp" +IDB_DELETE BITMAP "../../UI/FileManager/Delete.bmp" +IDB_INFO BITMAP "../../UI/FileManager/Info.bmp" +IDB_ADD2 BITMAP "../../UI/FileManager/Add2.bmp" +IDB_EXTRACT2 BITMAP "../../UI/FileManager/Extract2.bmp" +IDB_TEST2 BITMAP "../../UI/FileManager/Test2.bmp" +IDB_COPY2 BITMAP "../../UI/FileManager/Copy2.bmp" +IDB_MOVE2 BITMAP "../../UI/FileManager/Move2.bmp" +IDB_DELETE2 BITMAP "../../UI/FileManager/Delete2.bmp" +IDB_INFO2 BITMAP "../../UI/FileManager/Info2.bmp" STRINGTABLE @@ -187,9 +189,6 @@ BEGIN IDS_SELECT_MASK "Mask:" IDS_FOLDERS_HISTORY "Folders History" IDS_N_SELECTED_ITEMS "{0} object(s) selected" - IDS_FILES_COLON "Files:" - IDS_FOLDERS_COLON "Folders:" - IDS_SIZE_COLON "Size:" IDS_PROP_TOTAL_SIZE "Total Size" IDS_PROP_FREE_SPACE "Free Space" @@ -219,8 +218,6 @@ BEGIN IDS_NETWORK "Network" IDS_DOCUMENTS "Documents" - IDS_PROGRESS_TESTING "Testing" - IDS_MESSAGE_NO_ERRORS "There are no errors" IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER "The operation cannot be called from a folder that has a long path." IDS_SELECT_ONE_FILE "You must select one file" IDS_SELECT_FILES "You must select one or more files" @@ -228,20 +225,24 @@ BEGIN END +#include "AboutDialog.rc" +#include "BrowseDialog.rc" #include "ComboDialog.rc" #include "CopyDialog.rc" +#include "EditPage.rc" +#include "FoldersPage.rc" +#include "LangPage.rc" #include "ListViewDialog.rc" -#include "PropertyName.rc" +#include "MenuPage.rc" #include "MessagesDialog.rc" #include "OverwriteDialog.rc" #include "PasswordDialog.rc" -#include "SplitDialog.rc" -#include "ProgressDialog2.rc" -#include "AboutDialog.rc" -#include "LangPage.rc" #include "PluginsPage.rc" -#include "SystemPage.rc" -#include "EditPage.rc" +#include "ProgressDialog2.rc" +#include "PropertyName.rc" #include "SettingsPage.rc" -#include "../GUI/ExtractDialog.rc" +#include "SplitDialog.rc" +#include "SystemPage.rc" #include "../GUI/Extract.rc" +#include "../Explorer/resource2.rc" +#include "resourceGui.rc" diff --git a/CPP/7zip/UI/FileManager/resourceGui.h b/CPP/7zip/UI/FileManager/resourceGui.h new file mode 100755 index 00000000..14cedda5 --- /dev/null +++ b/CPP/7zip/UI/FileManager/resourceGui.h @@ -0,0 +1,10 @@ +#define IDI_ICON 1 + +#define IDS_INCORRECT_VOLUME_SIZE 95 + +#define IDS_FILES_COLON 2274 +#define IDS_FOLDERS_COLON 2275 +#define IDS_SIZE_COLON 2276 + +#define IDS_PROGRESS_TESTING 4100 +#define IDS_MESSAGE_NO_ERRORS 4200 diff --git a/CPP/7zip/UI/FileManager/resourceGui.rc b/CPP/7zip/UI/FileManager/resourceGui.rc new file mode 100755 index 00000000..2e706ea2 --- /dev/null +++ b/CPP/7zip/UI/FileManager/resourceGui.rc @@ -0,0 +1,13 @@ +#include "resourceGui.h" + +STRINGTABLE +BEGIN + IDS_INCORRECT_VOLUME_SIZE "Incorrect volume size" + + IDS_FILES_COLON "Files:" + IDS_FOLDERS_COLON "Folders:" + IDS_SIZE_COLON "Size:" + + IDS_PROGRESS_TESTING "Testing" + IDS_MESSAGE_NO_ERRORS "There are no errors" +END diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp index c7a1cc5b..f669c0e1 100755 --- a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp +++ b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp @@ -3,19 +3,18 @@ #include "StdAfx.h" #include "Common/IntToString.h" -#include "Common/StringToInt.h" #include "Common/MyException.h" -#include "Windows/Thread.h" + #include "Windows/Error.h" #include "Windows/System.h" +#include "Windows/Thread.h" + #include "../FileManager/HelpUtils.h" -// #include "BenchmarkDialogRes.h" + #include "BenchmarkDialog.h" using namespace NWindows; -// const int kNumBenchDictionaryBitsStart = 21; - static LPCWSTR kHelpTopic = L"fm/benchmark.htm"; static const UINT_PTR kTimerID = 4; @@ -27,6 +26,8 @@ static const UINT kTimerElapse = 1000; using namespace NWindows; +UString HResultToMessage(HRESULT errorCode); + #ifdef LANG static CIDLangPair kIDLangPairs[] = { @@ -57,17 +58,16 @@ static CIDLangPair kIDLangPairs[] = }; #endif -static void MyMessageBoxError(HWND hwnd, LPCWSTR message) -{ - MessageBoxW(hwnd, message, L"7-Zip", MB_ICONERROR); -} - const LPCTSTR kProcessingString = TEXT("..."); const LPCTSTR kMB = TEXT(" MB"); const LPCTSTR kMIPS = TEXT(" MIPS"); const LPCTSTR kKBs = TEXT(" KB/s"); +#ifdef UNDER_CE +static const int kMinDicLogSize = 20; +#else static const int kMinDicLogSize = 21; +#endif static const UInt32 kMinDicSize = (1 << kMinDicLogSize); static const UInt32 kMaxDicSize = #ifdef _WIN64 @@ -83,39 +83,59 @@ bool CBenchmarkDialog::OnInit() LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); #endif - _syncInfo.Init(); + Sync.Init(); - m_Dictionary.Attach(GetItem(IDC_BENCHMARK_COMBO_DICTIONARY)); - int cur = 0; - // _syncInfo.DictionarySize = (1 << kNumBenchDictionaryBitsStart); UInt32 numCPUs = NSystem::GetNumberOfProcessors(); if (numCPUs < 1) numCPUs = 1; numCPUs = MyMin(numCPUs, (UInt32)(1 << 8)); - cur = 0; - bool setDefaultThreads = (_syncInfo.NumThreads == (UInt32)(-1)); - if (setDefaultThreads) + + if (Sync.NumThreads == (UInt32)-1) { - _syncInfo.NumThreads = numCPUs; - if (_syncInfo.NumThreads > 1) - _syncInfo.NumThreads &= ~1; + Sync.NumThreads = numCPUs; + if (Sync.NumThreads > 1) + Sync.NumThreads &= ~1; + } + m_NumThreads.Attach(GetItem(IDC_BENCHMARK_COMBO_NUM_THREADS)); + int cur = 0; + for (UInt32 num = 1; num <= numCPUs * 2;) + { + TCHAR s[40]; + ConvertUInt64ToString(num, s); + int index = (int)m_NumThreads.AddString(s); + m_NumThreads.SetItemData(index, num); + if (num <= Sync.NumThreads) + cur = index; + if (num > 1) + num++; + num++; } + m_NumThreads.SetCurSel(cur); + Sync.NumThreads = GetNumberOfThreads(); + m_Dictionary.Attach(GetItem(IDC_BENCHMARK_COMBO_DICTIONARY)); + cur = 0; UInt64 ramSize = NSystem::GetRamSize(); - bool setDefaultDictionary = (_syncInfo.DictionarySize == (UInt32)(-1)); - if (setDefaultDictionary) + + #ifdef UNDER_CE + const UInt32 kNormalizedCeSize = (16 << 20); + if (ramSize > kNormalizedCeSize && ramSize < (33 << 20)) + ramSize = kNormalizedCeSize; + #endif + + if (Sync.DictionarySize == (UInt32)-1) { int dicSizeLog; - for (dicSizeLog = 25; dicSizeLog >= kBenchMinDicLogSize; dicSizeLog--) - if (GetBenchMemoryUsage(_syncInfo.NumThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize) + for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--) + if (GetBenchMemoryUsage(Sync.NumThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize) break; - _syncInfo.DictionarySize = (1 << dicSizeLog); + Sync.DictionarySize = (1 << dicSizeLog); } - if (_syncInfo.DictionarySize < kMinDicSize) - _syncInfo.DictionarySize = kMinDicSize; - if (_syncInfo.DictionarySize > kMaxDicSize) - _syncInfo.DictionarySize = kMaxDicSize; + if (Sync.DictionarySize < kMinDicSize) + Sync.DictionarySize = kMinDicSize; + if (Sync.DictionarySize > kMaxDicSize) + Sync.DictionarySize = kMaxDicSize; for (int i = kMinDicLogSize; i <= 30; i++) for (int j = 0; j < 2; j++) @@ -128,35 +148,17 @@ bool CBenchmarkDialog::OnInit() lstrcat(s, kMB); int index = (int)m_Dictionary.AddString(s); m_Dictionary.SetItemData(index, dictionary); - if (dictionary <= _syncInfo.DictionarySize) + if (dictionary <= Sync.DictionarySize) cur = index; } m_Dictionary.SetCurSel(cur); - m_NumThreads.Attach(GetItem(IDC_BENCHMARK_COMBO_NUM_THREADS)); - for (UInt32 num = 1; ;) - { - if (num > numCPUs * 2) - break; - TCHAR s[40]; - ConvertUInt64ToString(num, s); - int index = (int)m_NumThreads.AddString(s); - m_NumThreads.SetItemData(index, num); - if (num <= numCPUs && setDefaultThreads) - { - _syncInfo.NumThreads = num; - cur = index; - } - if (num > 1) - num++; - num++; - } - m_NumThreads.SetCurSel(cur); - OnChangeSettings(); - _syncInfo._startEvent.Set(); + Sync._startEvent.Set(); _timer = SetTimer(kTimerID, kTimerElapse); + + NormalizePosition(); return CModalDialog::OnInit(); } @@ -213,11 +215,11 @@ void CBenchmarkDialog::OnChangeSettings() SetItemText(g_IDs[i], kProcessingString); _startTime = GetTickCount(); PrintTime(); - NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS); - _syncInfo.Init(); - _syncInfo.DictionarySize = dictionary; - _syncInfo.Changed = true; - _syncInfo.NumThreads = GetNumberOfThreads(); + NWindows::NSynchronization::CCriticalSectionLock lock(Sync.CS); + Sync.Init(); + Sync.DictionarySize = dictionary; + Sync.Changed = true; + Sync.NumThreads = GetNumberOfThreads(); } void CBenchmarkDialog::OnRestartButton() @@ -228,7 +230,7 @@ void CBenchmarkDialog::OnRestartButton() void CBenchmarkDialog::OnStopButton() { EnableItem(IDC_BUTTON_STOP, false); - _syncInfo.Pause(); + Sync.Pause(); } void CBenchmarkDialog::OnHelp() @@ -238,7 +240,7 @@ void CBenchmarkDialog::OnHelp() void CBenchmarkDialog::OnCancel() { - _syncInfo.Stop(); + Sync.Stop(); KillTimer(_timer); CModalDialog::OnCancel(); } @@ -256,7 +258,7 @@ void CBenchmarkDialog::PrintTime() UInt32 curTime = ::GetTickCount(); UInt32 elapsedTime = (curTime - _startTime); UInt32 elapsedSec = elapsedTime / 1000; - if (elapsedSec != 0 && _syncInfo.WasPaused()) + if (elapsedSec != 0 && Sync.WasPaused()) return; TCHAR s[40]; GetTimeString(elapsedSec, s); @@ -310,26 +312,26 @@ void CBenchmarkDialog::PrintResults( bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { PrintTime(); - NWindows::NSynchronization::CCriticalSectionLock lock(_syncInfo.CS); + NWindows::NSynchronization::CCriticalSectionLock lock(Sync.CS); TCHAR s[40]; - ConvertUInt64ToString((_syncInfo.ProcessedSize >> 20), s); + ConvertUInt64ToString((Sync.ProcessedSize >> 20), s); lstrcat(s, kMB); SetItemText(IDC_BENCHMARK_SIZE_VALUE, s); - ConvertUInt64ToString(_syncInfo.NumPasses, s); + ConvertUInt64ToString(Sync.NumPasses, s); SetItemText(IDC_BENCHMARK_PASSES_VALUE, s); /* - ConvertUInt64ToString(_syncInfo.NumErrors, s); + ConvertUInt64ToString(Sync.NumErrors, s); SetItemText(IDC_BENCHMARK_ERRORS_VALUE, s); */ { - UInt32 dicSizeTemp = (UInt32)MyMax(_syncInfo.ProcessedSize, UInt64(1) << 20); - dicSizeTemp = MyMin(dicSizeTemp, _syncInfo.DictionarySize), + UInt32 dicSizeTemp = (UInt32)MyMax(Sync.ProcessedSize, UInt64(1) << 20); + dicSizeTemp = MyMin(dicSizeTemp, Sync.DictionarySize), PrintResults(dicSizeTemp, - _syncInfo.CompressingInfoTemp, + Sync.CompressingInfoTemp, IDC_BENCHMARK_COMPRESSING_USAGE, IDC_BENCHMARK_COMPRESSING_SPEED, IDC_BENCHMARK_COMPRESSING_RPU, @@ -338,8 +340,8 @@ bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { PrintResults( - _syncInfo.DictionarySize, - _syncInfo.CompressingInfo, + Sync.DictionarySize, + Sync.CompressingInfo, IDC_BENCHMARK_COMPRESSING_USAGE2, IDC_BENCHMARK_COMPRESSING_SPEED2, IDC_BENCHMARK_COMPRESSING_RPU2, @@ -348,8 +350,8 @@ bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { PrintResults( - _syncInfo.DictionarySize, - _syncInfo.DecompressingInfoTemp, + Sync.DictionarySize, + Sync.DecompressingInfoTemp, IDC_BENCHMARK_DECOMPRESSING_USAGE, IDC_BENCHMARK_DECOMPRESSING_SPEED, IDC_BENCHMARK_DECOMPRESSING_RPU, @@ -358,26 +360,26 @@ bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) } { PrintResults( - _syncInfo.DictionarySize, - _syncInfo.DecompressingInfo, + Sync.DictionarySize, + Sync.DecompressingInfo, IDC_BENCHMARK_DECOMPRESSING_USAGE2, IDC_BENCHMARK_DECOMPRESSING_SPEED2, IDC_BENCHMARK_DECOMPRESSING_RPU2, IDC_BENCHMARK_DECOMPRESSING_RATING2, true); - if (_syncInfo.DecompressingInfo.GlobalTime > 0 && - _syncInfo.CompressingInfo.GlobalTime > 0) + if (Sync.DecompressingInfo.GlobalTime > 0 && + Sync.CompressingInfo.GlobalTime > 0) { - UInt64 comprRating = GetCompressRating(_syncInfo.DictionarySize, - _syncInfo.CompressingInfo.GlobalTime, _syncInfo.CompressingInfo.GlobalFreq, _syncInfo.CompressingInfo.UnpackSize); - UInt64 decomprRating = GetDecompressRating(_syncInfo.DecompressingInfo.GlobalTime, - _syncInfo.DecompressingInfo.GlobalFreq, _syncInfo.DecompressingInfo.UnpackSize, - _syncInfo.DecompressingInfo.PackSize, 1); + UInt64 comprRating = GetCompressRating(Sync.DictionarySize, + Sync.CompressingInfo.GlobalTime, Sync.CompressingInfo.GlobalFreq, Sync.CompressingInfo.UnpackSize); + UInt64 decomprRating = GetDecompressRating(Sync.DecompressingInfo.GlobalTime, + Sync.DecompressingInfo.GlobalFreq, Sync.DecompressingInfo.UnpackSize, + Sync.DecompressingInfo.PackSize, 1); PrintRating((comprRating + decomprRating) / 2, IDC_BENCHMARK_TOTAL_RATING_VALUE); PrintRating(( - GetRatingPerUsage(_syncInfo.CompressingInfo, comprRating) + - GetRatingPerUsage(_syncInfo.DecompressingInfo, decomprRating)) / 2, IDC_BENCHMARK_TOTAL_RPU_VALUE); - PrintUsage((GetUsage(_syncInfo.CompressingInfo) + GetUsage(_syncInfo.DecompressingInfo)) / 2, IDC_BENCHMARK_TOTAL_USAGE_VALUE); + GetRatingPerUsage(Sync.CompressingInfo, comprRating) + + GetRatingPerUsage(Sync.DecompressingInfo, decomprRating)) / 2, IDC_BENCHMARK_TOTAL_RPU_VALUE); + PrintUsage((GetUsage(Sync.CompressingInfo) + GetUsage(Sync.DecompressingInfo)) / 2, IDC_BENCHMARK_TOTAL_USAGE_VALUE); } } return true; @@ -411,7 +413,7 @@ bool CBenchmarkDialog::OnButtonClicked(int buttonID, HWND buttonHWND) struct CThreadBenchmark { - CProgressSyncInfo *SyncInfo; + CBenchmarkDialog *BenchmarkDialog; UInt64 _startTime; #ifdef EXTERNAL_LZMA CCodecs *codecs; @@ -431,33 +433,33 @@ struct CThreadBenchmark struct CBenchCallback: public IBenchCallback { UInt32 dictionarySize; - CProgressSyncInfo *SyncInfo; + CProgressSyncInfo *Sync; HRESULT SetEncodeResult(const CBenchInfo &info, bool final); HRESULT SetDecodeResult(const CBenchInfo &info, bool final); }; HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final) { - NSynchronization::CCriticalSectionLock lock(SyncInfo->CS); - if (SyncInfo->Changed || SyncInfo->Paused || SyncInfo->Stopped) + NSynchronization::CCriticalSectionLock lock(Sync->CS); + if (Sync->Changed || Sync->Paused || Sync->Stopped) return E_ABORT; - SyncInfo->ProcessedSize = info.UnpackSize; - if (final && SyncInfo->CompressingInfo.GlobalTime == 0) + Sync->ProcessedSize = info.UnpackSize; + if (final && Sync->CompressingInfo.GlobalTime == 0) { - (CBenchInfo&)SyncInfo->CompressingInfo = info; - if (SyncInfo->CompressingInfo.GlobalTime == 0) - SyncInfo->CompressingInfo.GlobalTime = 1; + (CBenchInfo&)Sync->CompressingInfo = info; + if (Sync->CompressingInfo.GlobalTime == 0) + Sync->CompressingInfo.GlobalTime = 1; } else - (CBenchInfo&)SyncInfo->CompressingInfoTemp = info; + (CBenchInfo&)Sync->CompressingInfoTemp = info; return S_OK; } HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final) { - NSynchronization::CCriticalSectionLock lock(SyncInfo->CS); - if (SyncInfo->Changed || SyncInfo->Paused || SyncInfo->Stopped) + NSynchronization::CCriticalSectionLock lock(Sync->CS); + if (Sync->Changed || Sync->Paused || Sync->Stopped) return E_ABORT; CBenchInfo info2 = info; if (info2.NumIterations == 0) @@ -467,27 +469,28 @@ HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final) info2.PackSize *= info2.NumIterations; info2.NumIterations = 1; - if (final && SyncInfo->DecompressingInfo.GlobalTime == 0) + if (final && Sync->DecompressingInfo.GlobalTime == 0) { - (CBenchInfo&)SyncInfo->DecompressingInfo = info2; - if (SyncInfo->DecompressingInfo.GlobalTime == 0) - SyncInfo->DecompressingInfo.GlobalTime = 1; + (CBenchInfo&)Sync->DecompressingInfo = info2; + if (Sync->DecompressingInfo.GlobalTime == 0) + Sync->DecompressingInfo.GlobalTime = 1; } else - (CBenchInfo&)SyncInfo->DecompressingInfoTemp = info2; + (CBenchInfo&)Sync->DecompressingInfoTemp = info2; return S_OK; } HRESULT CThreadBenchmark::Process() { + CProgressSyncInfo &sync = BenchmarkDialog->Sync; + sync.WaitCreating(); try { - SyncInfo->WaitCreating(); for (;;) { - if (SyncInfo->WasStopped()) + if (sync.WasStopped()) return 0; - if (SyncInfo->WasPaused()) + if (sync.WasPaused()) { Sleep(200); continue; @@ -495,18 +498,18 @@ HRESULT CThreadBenchmark::Process() UInt32 dictionarySize; UInt32 numThreads; { - NSynchronization::CCriticalSectionLock lock(SyncInfo->CS); - if (SyncInfo->Stopped || SyncInfo->Paused) + NSynchronization::CCriticalSectionLock lock(sync.CS); + if (sync.Stopped || sync.Paused) continue; - if (SyncInfo->Changed) - SyncInfo->Init(); - dictionarySize = SyncInfo->DictionarySize; - numThreads = SyncInfo->NumThreads; + if (sync.Changed) + sync.Init(); + dictionarySize = sync.DictionarySize; + numThreads = sync.NumThreads; } CBenchCallback callback; callback.dictionarySize = dictionarySize; - callback.SyncInfo = SyncInfo; + callback.Sync = &sync; HRESULT result; try { @@ -525,44 +528,46 @@ HRESULT CThreadBenchmark::Process() { if (result != E_ABORT) { - // SyncInfo->NumErrors++; + // sync.NumErrors++; { - NSynchronization::CCriticalSectionLock lock(SyncInfo->CS); - SyncInfo->Pause(); + NSynchronization::CCriticalSectionLock lock(sync.CS); + sync.Pause(); } - CSysString message; + UString message; if (result == S_FALSE) - message = TEXT("Decoding error"); + message = L"Decoding error"; + else if (result == CLASS_E_CLASSNOTAVAILABLE) + message = L"Can't find 7z.dll"; else - message = NError::MyFormatMessage(result); - MessageBox(0, message, TEXT("7-Zip"), MB_ICONERROR); + message = HResultToMessage(result); + BenchmarkDialog->MessageBoxError(message); } } else { - NSynchronization::CCriticalSectionLock lock(SyncInfo->CS); - SyncInfo->NumPasses++; + NSynchronization::CCriticalSectionLock lock(sync.CS); + sync.NumPasses++; } } // return S_OK; } catch(CSystemException &e) { - MessageBox(0, NError::MyFormatMessage(e.ErrorCode), TEXT("7-Zip"), MB_ICONERROR); + BenchmarkDialog->MessageBoxError(HResultToMessage(e.ErrorCode)); return E_FAIL; } catch(...) { - MyMessageBoxError(0, L"Some error"); + BenchmarkDialog->MessageBoxError(HResultToMessage(E_FAIL)); return E_FAIL; } } HRESULT Benchmark( - #ifdef EXTERNAL_LZMA - CCodecs *codecs, - #endif - UInt32 numThreads, UInt32 dictionarySize) + #ifdef EXTERNAL_LZMA + CCodecs *codecs, + #endif + UInt32 numThreads, UInt32 dictionarySize, HWND hwndParent) { CThreadBenchmark benchmarker; #ifdef EXTERNAL_LZMA @@ -570,12 +575,12 @@ HRESULT Benchmark( #endif CBenchmarkDialog benchmarkDialog; - benchmarkDialog._syncInfo.DictionarySize = dictionarySize; - benchmarkDialog._syncInfo.NumThreads = numThreads; + benchmarkDialog.Sync.DictionarySize = dictionarySize; + benchmarkDialog.Sync.NumThreads = numThreads; - benchmarker.SyncInfo = &benchmarkDialog._syncInfo; + benchmarker.BenchmarkDialog = &benchmarkDialog; NWindows::CThread thread; RINOK(thread.Create(CThreadBenchmark::MyThreadFunction, &benchmarker)); - benchmarkDialog.Create(0); + benchmarkDialog.Create(hwndParent); return thread.Wait(); } diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.h b/CPP/7zip/UI/GUI/BenchmarkDialog.h index a57cdb39..3152ee6c 100755 --- a/CPP/7zip/UI/GUI/BenchmarkDialog.h +++ b/CPP/7zip/UI/GUI/BenchmarkDialog.h @@ -1,11 +1,8 @@ // BenchmarkDialog.h -#ifndef __BENCHMARKDIALOG_H -#define __BENCHMARKDIALOG_H +#ifndef __BENCHMARK_DIALOG_H +#define __BENCHMARK_DIALOG_H -#include "BenchmarkDialogRes.h" - -#include "Windows/Control/Dialog.h" #include "Windows/Control/ComboBox.h" #include "Windows/Synchronization.h" #include "../../Compress/LZMA_Alone/LzmaBench.h" @@ -14,6 +11,10 @@ #include "../Common/LoadCodecs.h" #endif +#include "../FileManager/DialogSize.h" + +#include "BenchmarkDialogRes.h" + struct CBenchInfo2 : public CBenchInfo { void Init() { GlobalTime = UserTime = 0; } @@ -116,16 +117,24 @@ class CBenchmarkDialog: UInt32 OnChangeDictionary(); void OnChangeSettings(); public: - CProgressSyncInfo _syncInfo; + CProgressSyncInfo Sync; CBenchmarkDialog(): _timer(0) {} - INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); } + INT_PTR Create(HWND wndParent = 0) + { + BIG_DIALOG_SIZE(332, 228); + return CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_BENCHMARK), wndParent); + } + void MessageBoxError(LPCWSTR message) + { + MessageBoxW(*this, message, L"7-Zip", MB_ICONERROR); + } }; HRESULT Benchmark( - #ifdef EXTERNAL_LZMA - CCodecs *codecs, - #endif - UInt32 dictionarySize, UInt32 numThreads); + #ifdef EXTERNAL_LZMA + CCodecs *codecs, + #endif + UInt32 dictionarySize, UInt32 numThreads, HWND hwndParent = NULL); #endif diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.rc b/CPP/7zip/UI/GUI/BenchmarkDialog.rc index 58f2ab62..b77bac5f 100755 --- a/CPP/7zip/UI/GUI/BenchmarkDialog.rc +++ b/CPP/7zip/UI/GUI/BenchmarkDialog.rc @@ -1,116 +1,227 @@ #include "BenchmarkDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 330 -#define ySize2 228 +#define xc 332 +#define yc 228 + +#undef g0xs +#undef g1x +#undef g1xs +#undef g2xs +#undef g3x +#undef g3xs +#undef g4x + +#define gs 160 +#define gSpace 24 + +#define g0xs 90 +#define g1xs 44 +#define g1x (m + g0xs) +#define gc2x (g1x + g1xs + m) +#define gc2xs 80 + +#define g4x (m + m) + +#define sRating 60 +#define sSpeed 60 +#define sUsage 60 +#define sRpu 60 + +#define xRating (xs - m - m - sRating) +#define xRpu (xRating - sRpu) +#define xUsage (xRpu - sUsage) +#define xSpeed (xUsage - sSpeed) -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define sLabel (xUsage - g4x) +#define sTotalRating (sUsage + sRpu + sRating + m + m) +#define xTotalRating (xs - m - sTotalRating) -#undef g0XSize -#undef g1XPos -#undef g1XSize -#undef g2XSize -#undef g3XPos -#undef g3XSize +#define g2xs 58 +#define g3xs 36 +#define g3x (m + g2xs) -#define bXPos1 (xSize - marg - bXSize) -#define bXPos2 (bXPos1 - 10 - bXSize) -#define bYPos (ySize - marg - bYSize) +IDD_DIALOG_BENCHMARK DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX +CAPTION "Benchmark" +MY_FONT +BEGIN + PUSHBUTTON "&Restart", IDC_BUTTON_RESTART, bx1, m, bxs, bys + PUSHBUTTON "&Stop", IDC_BUTTON_STOP, bx1, m + bys + 6, bxs, bys + + PUSHBUTTON "&Help", IDHELP, bx2, by, bxs, bys + PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys + + LTEXT "&Dictionary size:", IDC_BENCHMARK_DICTIONARY, m, m + 1, g0xs, 8 + COMBOBOX IDC_BENCHMARK_COMBO_DICTIONARY, g1x, m, g1xs, 140, MY_COMBO + LTEXT "Memory usage:", IDC_BENCHMARK_MEMORY, gc2x, m + 1, gc2xs, 8 + LTEXT "0 MB", IDC_BENCHMARK_MEMORY_VALUE, gc2x + gc2xs, m + 1, 40, 8 + + LTEXT "&Number of CPU threads:", IDC_BENCHMARK_NUM_THREADS, m, 28, g0xs, 8 + COMBOBOX IDC_BENCHMARK_COMBO_NUM_THREADS, g1x, 27, g1xs, 140, MY_COMBO + LTEXT "1", IDC_BENCHMARK_HARDWARE_THREADS, gc2x, 28, 40, 8 + + RTEXT "CPU Usage", IDC_BENCHMARK_USAGE_LABEL, xUsage, 54, sUsage, 8 + RTEXT "Speed", IDC_BENCHMARK_SPEED_LABEL, xSpeed, 54, sSpeed, 8 + RTEXT "Rating / Usage", IDC_BENCHMARK_RPU_LABEL, xRpu, 54, sRpu, 8 + RTEXT "Rating", IDC_BENCHMARK_RATING_LABEL, xRating, 54, sRating, 8 + + GROUPBOX "Compressing", IDC_BENCHMARK_COMPRESSING, m, 64, xc, 40 + + LTEXT "Current", IDC_BENCHMARK_CURRENT, g4x, 76, sLabel, 8 + RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE, xUsage, 76, sUsage, 8 + RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED, xSpeed, 76, sSpeed, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU, xRpu, 76, sRpu, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING, xRating, 76, sRating, 8 + + LTEXT "Resulting", IDC_BENCHMARK_RESULTING, g4x, 89, sLabel, 8 + RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE2, xUsage, 89, sUsage, 8 + RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED2, xSpeed, 89, sSpeed, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU2, xRpu, 89, sRpu, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING2, xRating, 89, sRating, 8 + + GROUPBOX "Decompressing", IDC_BENCHMARK_DECOMPRESSING, m, 111, xc, 40 + + LTEXT "Current", IDC_BENCHMARK_CURRENT2, g4x, 123, sLabel, 8 + RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE, xUsage, 123, sUsage, 8 + RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED, xSpeed, 123, sSpeed, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU, xRpu, 123, sRpu, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING, xRating, 123, sRating, 8 + + LTEXT "Resulting", IDC_BENCHMARK_RESULTING2, g4x, 136, sLabel, 8 + RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE2, xUsage, 136, sUsage, 8 + RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED2, xSpeed, 136, sSpeed, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU2, xRpu, 136, sRpu, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING2, xRating, 136, sRating, 8 + + GROUPBOX "Total Rating", IDC_BENCHMARK_TOTAL_RATING, xTotalRating, 163, sTotalRating, 38 + RTEXT "0", IDC_BENCHMARK_TOTAL_USAGE_VALUE, xUsage, 181, sUsage, 8 + RTEXT "0", IDC_BENCHMARK_TOTAL_RPU_VALUE, xRpu, 181, sRpu, 8 + RTEXT "0", IDC_BENCHMARK_TOTAL_RATING_VALUE, xRating, 181, sRating, 8 + + LTEXT "Elapsed time:", IDC_BENCHMARK_ELAPSED, m, 163, g2xs, 8 + LTEXT "Size:", IDC_BENCHMARK_SIZE, m, 176, g2xs, 8 + LTEXT "Passes:", IDC_BENCHMARK_PASSES, m, 189, g2xs, 8 + RTEXT "00:00:00", IDC_BENCHMARK_ELAPSED_VALUE, g3x, 163, g3xs, 8 + RTEXT "0", IDC_BENCHMARK_SIZE_VALUE, g3x, 176, g3xs, 8 + RTEXT "0", IDC_BENCHMARK_PASSES_VALUE, g3x, 189, g3xs, 8 +END -#define gSize 160 +#ifdef UNDER_CE + +#undef m +#define m 4 + +#undef xc +#undef yc + +#define xc 154 +#define yc 160 + +#undef g0xs +#undef g1x +#undef g1xs +#undef g2xs +#undef g3x +#undef g3xs + +#undef bxs +#undef bys + +#define bxs 60 +#define bys 14 + +#undef gs +#undef gSpace + +#define gs 160 #define gSpace 24 -#define g0XSize 90 -#define g1XSize 44 -#define g1XPos (marg + g0XSize) -#define gc2XPos (g1XPos + g1XSize + 10) -#define gc2XSize 80 +#define g0xs (xc - bxs) +#define g1xs 44 + +#undef g4x +#define g4x (m) -#define g10XPos (marg + marg) +#undef xRpu +#undef xUsage +#undef xRating +#undef xTotalRating -#define gRatingSize 60 -#define gSpeedSize 60 -#define gUsageSize 60 -#define gRpuSize 60 +#undef sRpu +#undef sRating +#undef sUsage +#undef sLabel +#undef sTotalRating -#define gRatingPos (xSize - marg - marg - gRatingSize) -#define gRpuPos (gRatingPos - gRpuSize) -#define gUsagePos (gRpuPos - gUsageSize) -#define gSpeedPos (gUsagePos - gSpeedSize) +#define sRating 40 +#define sUsage 24 +#define sRpu 40 -#define gLabelSize (gUsagePos - g10XPos) -#define gTotalRatingSize (gUsageSize + gRpuSize + gRatingSize + marg + marg) -#define gTotalRatingPos (xSize - marg - gTotalRatingSize) +#define xRating (xs - m - sRating) +#define xRpu (xRating - sRpu) +#define xUsage (xRpu - sUsage) -#define g2XSize 58 -#define g3XSize 36 -#define g3XPos (marg + g2XSize) +#define sLabel (xUsage - g4x) +#define sTotalRating (sRpu + sRating) +#define xTotalRating (xs - m - sTotalRating) +#define g3xs 32 +#define g3x (xRpu - g3xs) +#define g2xs (g3x - m) -IDD_DIALOG_BENCHMARK DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX + +IDD_DIALOG_BENCHMARK_2 DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX CAPTION "Benchmark" MY_FONT BEGIN - PUSHBUTTON "&Restart", IDC_BUTTON_RESTART, bXPos1, marg, bXSize, bYSize - PUSHBUTTON "&Stop", IDC_BUTTON_STOP, bXPos1, 27, bXSize, bYSize - - PUSHBUTTON "&Help", IDHELP, bXPos2, bYPos, bXSize,bYSize - PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize + PUSHBUTTON "&Restart", IDC_BUTTON_RESTART, bx1, m, bxs, bys + PUSHBUTTON "&Stop", IDC_BUTTON_STOP, bx1, m + bys + m, bxs, bys + PUSHBUTTON "Cancel", IDCANCEL, bx1, m + bys + m + bys + m, bxs, bys - LTEXT "&Dictionary size:", IDC_BENCHMARK_DICTIONARY, marg, marg + 1, g0XSize, 8 - COMBOBOX IDC_BENCHMARK_COMBO_DICTIONARY, g1XPos, marg, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "&Dictionary size:", IDC_BENCHMARK_DICTIONARY, m, m, g0xs, 8 + COMBOBOX IDC_BENCHMARK_COMBO_DICTIONARY, m, m + 11, g1xs, 140, MY_COMBO - LTEXT "&Number of CPU threads:", IDC_BENCHMARK_NUM_THREADS, marg, 24, g0XSize, 8 - COMBOBOX IDC_BENCHMARK_COMBO_NUM_THREADS, g1XPos, 23, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "&Number of CPU threads:", IDC_BENCHMARK_NUM_THREADS, m, 31, g0xs, 8 + COMBOBOX IDC_BENCHMARK_COMBO_NUM_THREADS, m, 42, g1xs, 140, MY_COMBO - LTEXT "Memory usage:", IDC_BENCHMARK_MEMORY, gc2XPos, marg + 1, gc2XSize, 8 - LTEXT "0 MB", IDC_BENCHMARK_MEMORY_VALUE, gc2XPos + gc2XSize, marg + 1, 40, 8 - LTEXT "1", IDC_BENCHMARK_HARDWARE_THREADS, gc2XPos, 24, 40, 8 + LTEXT "0 MB", IDC_BENCHMARK_MEMORY_VALUE, m + g1xs + 8, m + 13, xc - bxs - g1xs - 8, 8 + LTEXT "1", IDC_BENCHMARK_HARDWARE_THREADS, m + g1xs + 8, 44, xc - bxs - g1xs - 8, 8 + + LTEXT "Current", IDC_BENCHMARK_CURRENT, g4x, 70, sLabel, 8 + RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE, xUsage, 70, sUsage, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU, xRpu, 70, sRpu, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING, xRating, 70, sRating, 8 - RTEXT "CPU Usage", IDC_BENCHMARK_USAGE_LABEL, gUsagePos, 53, gUsageSize, 8 - RTEXT "Speed", IDC_BENCHMARK_SPEED_LABEL, gSpeedPos, 53, gSpeedSize, 8 - RTEXT "Rating / Usage", IDC_BENCHMARK_RPU_LABEL, gRpuPos, 53, gRpuSize, 8 - RTEXT "Rating", IDC_BENCHMARK_RATING_LABEL, gRatingPos, 53, gRatingSize, 8 + LTEXT "Resulting", IDC_BENCHMARK_RESULTING, g4x, 80, sLabel, 8 + RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE2, xUsage, 80, sUsage, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU2, xRpu, 80, sRpu, 8 + RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING2, xRating, 80, sRating, 8 + + LTEXT "Compressing", IDC_BENCHMARK_COMPRESSING, m, 60, xc - bxs, 8 - GROUPBOX "Compressing", IDC_BENCHMARK_COMPRESSING, marg, 64, xSize2, 40 - - LTEXT "Current", IDC_BENCHMARK_CURRENT, g10XPos, 76, gLabelSize, 8 - RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE, gUsagePos, 76, gUsageSize, 8 - RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED, gSpeedPos, 76, gSpeedSize, 8 - RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU, gRpuPos, 76, gRpuSize, 8 - RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING, gRatingPos, 76, gRatingSize, 8 + LTEXT "Current", IDC_BENCHMARK_CURRENT2, g4x, 104, sLabel, 8 + RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE, xUsage, 104, sUsage, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU, xRpu, 104, sRpu, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING, xRating, 104, sRating, 8 - LTEXT "Resulting", IDC_BENCHMARK_RESULTING, g10XPos, 89, gLabelSize, 8 - RTEXT "100%", IDC_BENCHMARK_COMPRESSING_USAGE2, gUsagePos, 89, gUsageSize, 8 - RTEXT "100 KB/s", IDC_BENCHMARK_COMPRESSING_SPEED2, gSpeedPos, 89, gSpeedSize, 8 - RTEXT "0", IDC_BENCHMARK_COMPRESSING_RPU2, gRpuPos, 89, gRpuSize, 8 - RTEXT "0", IDC_BENCHMARK_COMPRESSING_RATING2, gRatingPos, 89, gRatingSize, 8 + LTEXT "Resulting", IDC_BENCHMARK_RESULTING2, g4x, 114, sLabel, 8 + RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE2, xUsage, 114, sUsage, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU2, xRpu, 114, sRpu, 8 + RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING2, xRating, 114, sRating, 8 - GROUPBOX "Decompressing", IDC_BENCHMARK_DECOMPRESSING, marg, 111, xSize2, 40 + LTEXT "Decompressing", IDC_BENCHMARK_DECOMPRESSING, m, 94, xc, 8 - LTEXT "Current", IDC_BENCHMARK_CURRENT2, g10XPos, 123, gLabelSize, 8 - RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE, gUsagePos, 123, gUsageSize, 8 - RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED, gSpeedPos, 123, gSpeedSize, 8 - RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU, gRpuPos, 123, gRpuSize, 8 - RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING, gRatingPos, 123, gRatingSize, 8 + RTEXT "0", IDC_BENCHMARK_TOTAL_RPU_VALUE, xRpu, 140, sRpu, 8 + RTEXT "0", IDC_BENCHMARK_TOTAL_RATING_VALUE, xRating, 140, sRating, 8 - LTEXT "Resulting", IDC_BENCHMARK_RESULTING2, g10XPos, 136, gLabelSize, 8 - RTEXT "100%", IDC_BENCHMARK_DECOMPRESSING_USAGE2, gUsagePos, 136, gUsageSize, 8 - RTEXT "100 KB/s", IDC_BENCHMARK_DECOMPRESSING_SPEED2, gSpeedPos, 136, gSpeedSize, 8 - RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RPU2, gRpuPos, 136, gRpuSize, 8 - RTEXT "0", IDC_BENCHMARK_DECOMPRESSING_RATING2, gRatingPos, 136, gRatingSize, 8 - - GROUPBOX "Total Rating", IDC_BENCHMARK_TOTAL_RATING, gTotalRatingPos, 163, gTotalRatingSize, 38 - RTEXT "0", IDC_BENCHMARK_TOTAL_USAGE_VALUE, gUsagePos, 181, gUsageSize, 8 - RTEXT "0", IDC_BENCHMARK_TOTAL_RPU_VALUE, gRpuPos, 181, gRpuSize, 8 - RTEXT "0", IDC_BENCHMARK_TOTAL_RATING_VALUE, gRatingPos, 181, gRatingSize, 8 - - LTEXT "Elapsed time:", IDC_BENCHMARK_ELAPSED, marg, 163, g2XSize, 8 - LTEXT "Size:", IDC_BENCHMARK_SIZE, marg, 176, g2XSize, 8 - LTEXT "Passes:", IDC_BENCHMARK_PASSES, marg, 189, g2XSize, 8 - RTEXT "00:00:00", IDC_BENCHMARK_ELAPSED_VALUE, g3XPos, 163, g3XSize, 8 - RTEXT "0", IDC_BENCHMARK_SIZE_VALUE, g3XPos, 176, g3XSize, 8 - RTEXT "0", IDC_BENCHMARK_PASSES_VALUE, g3XPos, 189, g3XSize, 8 + LTEXT "Elapsed time:", IDC_BENCHMARK_ELAPSED, m, 130, g2xs, 8 + LTEXT "Size:", IDC_BENCHMARK_SIZE, m, 140, g2xs, 8 + LTEXT "Passes:", IDC_BENCHMARK_PASSES, m, 150, g2xs, 8 + + RTEXT "00:00:00", IDC_BENCHMARK_ELAPSED_VALUE, g3x, 130, g3xs, 8 + RTEXT "0", IDC_BENCHMARK_SIZE_VALUE, g3x, 140, g3xs, 8 + RTEXT "0", IDC_BENCHMARK_PASSES_VALUE, g3x, 150, g3xs, 8 END + +#endif diff --git a/CPP/7zip/UI/GUI/BenchmarkDialogRes.h b/CPP/7zip/UI/GUI/BenchmarkDialogRes.h index 6ef52188..2488bd1c 100755 --- a/CPP/7zip/UI/GUI/BenchmarkDialogRes.h +++ b/CPP/7zip/UI/GUI/BenchmarkDialogRes.h @@ -1,4 +1,5 @@ -#define IDD_DIALOG_BENCHMARK 800 +#define IDD_DIALOG_BENCHMARK 550 +#define IDD_DIALOG_BENCHMARK_2 650 #define IDC_BUTTON_STOP 1001 #define IDC_BUTTON_RESTART 1002 #define IDC_BENCHMARK_DICTIONARY 1010 diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp index 04a40a43..bafaf371 100755 --- a/CPP/7zip/UI/GUI/CompressDialog.cpp +++ b/CPP/7zip/UI/GUI/CompressDialog.cpp @@ -2,16 +2,14 @@ #include "StdAfx.h" -#include "Common/Defs.h" #include "Common/IntToString.h" #include "Common/StringConvert.h" -#include "Windows/CommonDialog.h" #include "Windows/FileDir.h" #include "Windows/FileName.h" -#include "Windows/ResourceString.h" #include "Windows/System.h" +#include "../FileManager/BrowseDialog.h" #include "../FileManager/FormatUtils.h" #include "../FileManager/HelpUtils.h" #include "../FileManager/SplitUtils.h" @@ -22,8 +20,6 @@ #include "CompressDialog.h" -#include "resource.h" - #ifndef _UNICODE extern bool g_IsNT; #endif @@ -249,7 +245,7 @@ static UInt64 GetMaxRamSizeForProgram() physSize = 0; else physSize -= kMinSysSize; - const UInt64 kMinUseSize = (1 << 25); + const UInt64 kMinUseSize = (1 << 24); if (physSize < kMinUseSize) physSize = kMinUseSize; return physSize; @@ -282,23 +278,24 @@ bool CCompressDialog::OnInit() AddVolumeItems(m_Volume); - ReadCompressionInfo(m_RegistryInfo); + m_RegistryInfo.Load(); CheckButton(IDC_COMPRESS_CHECK_SHOW_PASSWORD, m_RegistryInfo.ShowPassword); CheckButton(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, m_RegistryInfo.EncryptHeaders); UpdatePasswordControl(); - Info.ArchiverInfoIndex = 0; + Info.FormatIndex = -1; int i; - for (i = 0; i < m_ArchiverInfoList.Size(); i++) + for (i = 0; i < ArcIndices.Size(); i++) { - const CArcInfoEx &ai = m_ArchiverInfoList[i]; + int arcIndex = ArcIndices[i]; + const CArcInfoEx &ai = (*ArcFormats)[arcIndex]; int index = (int)m_Format.AddString(ai.Name); - m_Format.SetItemData(index, i); - if (ai.Name.CompareNoCase(m_RegistryInfo.ArchiveType) == 0 || i == 0) + m_Format.SetItemData(index, arcIndex); + if (ai.Name.CompareNoCase(m_RegistryInfo.ArcType) == 0 || i == 0) { m_Format.SetCurSel(index); - Info.ArchiverInfoIndex = i; + Info.FormatIndex = arcIndex; } } @@ -306,8 +303,8 @@ bool CCompressDialog::OnInit() SetLevel(); SetParams(); - for (i = 0; i < m_RegistryInfo.HistoryArchives.Size() && i < kHistorySize; i++) - m_ArchivePath.AddString(m_RegistryInfo.HistoryArchives[i]); + for (i = 0; i < m_RegistryInfo.ArcPaths.Size() && i < kHistorySize; i++) + m_ArchivePath.AddString(m_RegistryInfo.ArcPaths[i]); m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_ADD, 0x02000DA1)); m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_UPDATE, 0x02000DA2)); @@ -332,6 +329,9 @@ bool CCompressDialog::OnInit() SetEncryptionMethod(); SetMemoryUsage(); + + NormalizePosition(); + return CModalDialog::OnInit(); } @@ -339,7 +339,9 @@ namespace NCompressDialog { bool CInfo::GetFullPathName(UString &result) const { + #ifndef UNDER_CE NDirectory::MySetCurrentDirectory(CurrentDirPrefix); + #endif return MyGetFullPathName(ArchiveName, result); } } @@ -491,7 +493,7 @@ void CCompressDialog::OnButtonSetArchive() UString s = LangString(IDS_OPEN_TYPE_ALL_FILES, 0x02000DB1); s += L" (*.*)"; UString resPath; - if (!MyGetOpenFileName(HWND(*this), title, fullFileName, s, resPath)) + if (!MyBrowseForFile(HWND(*this), title, fullFileName, s, resPath)) return; m_ArchivePath.SetText(resPath); } @@ -546,8 +548,8 @@ void CCompressDialog::OnOK() UString s; m_ArchivePath.GetText(s); s.Trim(); - m_RegistryInfo.HistoryArchives.Clear(); - AddUniqueString(m_RegistryInfo.HistoryArchives, s); + m_RegistryInfo.ArcPaths.Clear(); + AddUniqueString(m_RegistryInfo.ArcPaths, s); Info.ArchiveName = s; Info.UpdateMode = NCompressDialog::NUpdateMode::EEnum(m_UpdateMode.GetCurSel()); @@ -564,7 +566,7 @@ void CCompressDialog::OnOK() Info.Method = GetMethodSpec(); Info.EncryptionMethod = GetEncryptionMethodSpec(); - Info.ArchiverInfoIndex = GetFormatIndex(); + Info.FormatIndex = GetFormatIndex(); Info.SFXMode = IsSFX(); Info.OpenShareForWrite = IsButtonCheckedBool(IDC_COMPRESS_SHARED); @@ -590,7 +592,7 @@ void CCompressDialog::OnOK() wchar_t s[32]; ConvertUInt64ToString(volumeSize, s); if (::MessageBoxW(*this, MyFormatNew(IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE, 0x02000D42, s), - L"7-Zip", MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES) + L"7-Zip", MB_YESNOCANCEL | MB_ICONQUESTION) != IDYES) return; } } @@ -601,15 +603,15 @@ void CCompressDialog::OnOK() UString sTemp; m_ArchivePath.GetLBText(i, sTemp); sTemp.Trim(); - AddUniqueString(m_RegistryInfo.HistoryArchives, sTemp); + AddUniqueString(m_RegistryInfo.ArcPaths, sTemp); } - if (m_RegistryInfo.HistoryArchives.Size() > kHistorySize) - m_RegistryInfo.HistoryArchives.DeleteBack(); + if (m_RegistryInfo.ArcPaths.Size() > kHistorySize) + m_RegistryInfo.ArcPaths.DeleteBack(); - m_RegistryInfo.ArchiveType = m_ArchiverInfoList[Info.ArchiverInfoIndex].Name; + m_RegistryInfo.ArcType = (*ArcFormats)[Info.FormatIndex].Name; m_RegistryInfo.ShowPassword = IsShowPasswordChecked(); - SaveCompressionInfo(m_RegistryInfo); + m_RegistryInfo.Save(); CModalDialog::OnOK(); } @@ -643,9 +645,9 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam) } case IDC_COMPRESS_COMBO_LEVEL: { - const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; int index = FindRegistryFormatAlways(ai.Name); - NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; fo.ResetForLevelChange(); SetMethod(); SetSolidBlockSize(); @@ -693,7 +695,7 @@ void CCompressDialog::SetArchiveName2(bool prevWasSFX) { UString fileName; m_ArchivePath.GetText(fileName); - const CArcInfoEx &prevArchiverInfo = m_ArchiverInfoList[m_PrevFormat]; + const CArcInfoEx &prevArchiverInfo = (*ArcFormats)[m_PrevFormat]; if (prevArchiverInfo.KeepName || Info.KeepName) { UString prevExtension = prevArchiverInfo.GetMainExt(); @@ -716,9 +718,9 @@ void CCompressDialog::SetArchiveName2(bool prevWasSFX) void CCompressDialog::SetArchiveName(const UString &name) { UString fileName = name; - Info.ArchiverInfoIndex = GetFormatIndex(); - const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex]; - m_PrevFormat = Info.ArchiverInfoIndex; + Info.FormatIndex = GetFormatIndex(); + const CArcInfoEx &ai = (*ArcFormats)[Info.FormatIndex]; + m_PrevFormat = Info.FormatIndex; if (ai.KeepName) { fileName = OriginalFileName; @@ -746,10 +748,10 @@ void CCompressDialog::SetArchiveName(const UString &name) int CCompressDialog::FindRegistryFormat(const UString &name) { - for (int i = 0; i < m_RegistryInfo.FormatOptionsVector.Size(); i++) + for (int i = 0; i < m_RegistryInfo.Formats.Size(); i++) { - const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[i]; - if (GetUnicodeString(fo.FormatID) == name) + const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[i]; + if (name.CompareNoCase(GetUnicodeString(fo.FormatID)) == 0) return i; } return -1; @@ -762,7 +764,7 @@ int CCompressDialog::FindRegistryFormatAlways(const UString &name) { NCompression::CFormatOptions fo; fo.FormatID = GetSystemString(name); - index = m_RegistryInfo.FormatOptionsVector.Add(fo); + index = m_RegistryInfo.Formats.Add(fo); } return index; } @@ -770,7 +772,7 @@ int CCompressDialog::FindRegistryFormatAlways(const UString &name) int CCompressDialog::GetStaticFormatIndex() { int formatIndex = GetFormatIndex(); - const CArcInfoEx &ai = m_ArchiverInfoList[formatIndex]; + const CArcInfoEx &ai = (*ArcFormats)[formatIndex]; for (int i = 0; i < MY_SIZE_OF_ARRAY(g_Formats); i++) if (ai.Name.CompareNoCase(g_Formats[i].Name) == 0) return i; @@ -793,12 +795,12 @@ void CCompressDialog::SetLevel() { m_Level.ResetContent(); const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()]; - const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; int index = FindRegistryFormat(ai.Name); UInt32 level = kNormal; if (index >= 0) { - const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; if (fo.Level <= kUltra) level = fo.Level; else @@ -829,12 +831,12 @@ void CCompressDialog::SetMethod(int keepMethodId) return; } const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()]; - const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; int index = FindRegistryFormat(ai.Name); UString defaultMethod; if (index >= 0) { - const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; defaultMethod = fo.Method; } bool isSfx = IsSFX(); @@ -865,14 +867,14 @@ void CCompressDialog::SetMethod(int keepMethodId) bool CCompressDialog::IsZipFormat() { - const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; return (ai.Name.CompareNoCase(L"zip") == 0); } void CCompressDialog::SetEncryptionMethod() { _encryptionMethod.ResetContent(); - const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; if (ai.Name.CompareNoCase(L"7z") == 0) { _encryptionMethod.AddString(TEXT("AES-256")); @@ -884,7 +886,7 @@ void CCompressDialog::SetEncryptionMethod() UString encryptionMethod; if (index >= 0) { - const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; encryptionMethod = fo.EncryptionMethod; } _encryptionMethod.AddString(TEXT("ZipCrypto")); @@ -960,12 +962,12 @@ int CCompressDialog::AddDictionarySize(UInt32 size) void CCompressDialog::SetDictionary() { m_Dictionary.ResetContent(); - const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; int index = FindRegistryFormat(ai.Name); UInt32 defaultDictionary = UInt32(-1); if (index >= 0) { - const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; if (fo.Method.CompareNoCase(GetMethodSpec()) == 0) defaultDictionary = fo.Dictionary; } @@ -1105,12 +1107,12 @@ int CCompressDialog::AddOrder(UInt32 size) void CCompressDialog::SetOrder() { m_Order.ResetContent(); - const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; int index = FindRegistryFormat(ai.Name); UInt32 defaultOrder = UInt32(-1); if (index >= 0) { - const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; if (fo.Method.CompareNoCase(GetMethodSpec()) == 0) defaultOrder = fo.Order; } @@ -1224,11 +1226,11 @@ void CCompressDialog::SetSolidBlockSize() UInt32 defaultBlockSize = (UInt32)-1; - const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; int index = FindRegistryFormat(ai.Name); if (index >= 0) { - const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; if (fo.Method.CompareNoCase(GetMethodSpec()) == 0) defaultBlockSize = fo.BlockLogSize; } @@ -1268,12 +1270,12 @@ void CCompressDialog::SetNumThreads() UInt32 numHardwareThreads = NSystem::GetNumberOfProcessors(); UInt32 defaultValue = numHardwareThreads; - const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; int index = FindRegistryFormat(ai.Name); if (index >= 0) { - const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; - if (fo.Method.CompareNoCase(GetMethodSpec()) == 0) + const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; + if (fo.Method.CompareNoCase(GetMethodSpec()) == 0 && fo.NumThreads != (UInt32)-1) defaultValue = fo.NumThreads; } @@ -1422,23 +1424,23 @@ void CCompressDialog::SetMemoryUsage() void CCompressDialog::SetParams() { - const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()]; + const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()]; m_Params.SetText(TEXT("")); int index = FindRegistryFormat(ai.Name); if (index >= 0) { - const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; m_Params.SetText(fo.Options); } } void CCompressDialog::SaveOptionsInMem() { - const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex]; + const CArcInfoEx &ai = (*ArcFormats)[Info.FormatIndex]; int index = FindRegistryFormatAlways(ai.Name); m_Params.GetText(Info.Options); Info.Options.Trim(); - NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index]; + NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index]; fo.Options = Info.Options; fo.Level = GetLevelSpec(); fo.Dictionary = GetDictionarySpec(); diff --git a/CPP/7zip/UI/GUI/CompressDialog.h b/CPP/7zip/UI/GUI/CompressDialog.h index 75eeeee8..19c75875 100755 --- a/CPP/7zip/UI/GUI/CompressDialog.h +++ b/CPP/7zip/UI/GUI/CompressDialog.h @@ -4,12 +4,13 @@ #define __COMPRESS_DIALOG_H #include "Windows/Control/ComboBox.h" -#include "Windows/Control/Dialog.h" #include "Windows/Control/Edit.h" #include "../Common/LoadCodecs.h" #include "../Common/ZipRegistry.h" +#include "../FileManager/DialogSize.h" + #include "CompressDialogRes.h" namespace NCompressDialog @@ -53,7 +54,7 @@ namespace NCompressDialog bool GetFullPathName(UString &result) const; - int ArchiverInfoIndex; + int FormatIndex; UString Password; bool EncryptHeadersIsAllowed; @@ -155,13 +156,17 @@ class CCompressDialog: public NWindows::NControl::CModalDialog int GetFormatIndex(); public: - CObjectVector<CArcInfoEx> m_ArchiverInfoList; + CObjectVector<CArcInfoEx> *ArcFormats; + CRecordVector<int> ArcIndices; NCompressDialog::CInfo Info; UString OriginalFileName; // for bzip2, gzip2 INT_PTR Create(HWND wndParent = 0) - { return CModalDialog::Create(IDD_DIALOG_COMPRESS, wndParent); } + { + BIG_DIALOG_SIZE(400, 304); + return CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_COMPRESS), wndParent); + } protected: diff --git a/CPP/7zip/UI/GUI/CompressDialog.rc b/CPP/7zip/UI/GUI/CompressDialog.rc index 8e79f1bf..5f622c76 100755 --- a/CPP/7zip/UI/GUI/CompressDialog.rc +++ b/CPP/7zip/UI/GUI/CompressDialog.rc @@ -1,124 +1,187 @@ #include "CompressDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 400 -#define ySize2 305 - -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#define xc 400 +#define yc 304 #undef gSize #undef gSpace -#undef g0XSize -#undef g1XPos -#undef g1XSize -#undef g2XSize -#undef g3XPos -#undef g3XSize -#undef g4XPos -#undef g4XPos2 -#undef g4XSize -#undef g4XSize2 -#undef bXPos1 -#undef bXPos2 -#undef bXPos3 -#undef bYPos - -#define gSize 190 +#undef g0xs +#undef g1x +#undef g1xs +#undef g2xs +#undef g3x +#undef g3xs +#undef g4x +#undef g4x2 +#undef g4xs +#undef g4xs2 + +#define gSize 192 #define gSpace 24 -#define g1XSize 90 -#define g0XSize (gSize - g1XSize) -#define g1XPos (marg + g0XSize) - -#define g3XSize 40 -#define g2XSize (gSize - g3XSize) -#define g3XPos (marg + g2XSize) +#define g1xs 88 +#define g0xs (gSize - g1xs) +#define g1x (m + g0xs) -#define g4XPos (marg + gSize + gSpace) -#define g4XPos2 (g4XPos + 7) -#define g4XSize (xSize2 - gSize - gSpace) -#define g4XSize2 (g4XSize - 14) +#define g3xs 40 +#define g2xs (gSize - g3xs) +#define g3x (m + g2xs) -#define OptYPos 73 -#define PswYPos 128 +#define g4x (m + gSize + gSpace) +#define g4x2 (g4x + m) +#define g4xs (xc - gSize - gSpace) +#define g4xs2 (g4xs - m - m) -#define bXPos1 (xSize - marg - bXSize) -#define bXPos2 (bXPos1 - 10 - bXSize) -#define bXPos3 (bXPos2 - 10 - bXSize) +#define yOpt 72 +#define yPsw 128 -#define bYPos (ySize - marg - bYSize) - -IDD_DIALOG_COMPRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +IDD_DIALOG_COMPRESS MY_DIALOG CAPTION "Add to Archive" -MY_FONT BEGIN - LTEXT "&Archive:", IDC_STATIC_COMPRESS_ARCHIVE, marg, marg, xSize2, 8 - COMBOBOX IDC_COMPRESS_COMBO_ARCHIVE, marg, 18, xSize2 - bDotsSize - 12, 126, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "...", IDC_COMPRESS_BUTTON_SET_ARCHIVE, xSize - marg - bDotsSize, 17, bDotsSize, bYSize, WS_GROUP + LTEXT "&Archive:", IDC_STATIC_COMPRESS_ARCHIVE, m, m, xc, 8 + COMBOBOX IDC_COMPRESS_COMBO_ARCHIVE, m, 18, xc - bxsDots - 12, 126, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDC_COMPRESS_BUTTON_SET_ARCHIVE, xs - m - bxsDots, 17, bxsDots, bys, WS_GROUP - LTEXT "Archive &format:", IDC_STATIC_COMPRESS_FORMAT, marg, 41, g0XSize, 8 - COMBOBOX IDC_COMPRESS_COMBO_FORMAT, g1XPos, 39, g1XSize , 80,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + LTEXT "Archive &format:", IDC_STATIC_COMPRESS_FORMAT, m, 41, g0xs, 8 + COMBOBOX IDC_COMPRESS_COMBO_FORMAT, g1x, 39, g1xs , 80, MY_COMBO | CBS_SORT - LTEXT "Compression &level:",IDC_STATIC_COMPRESS_LEVEL, marg, 62, g0XSize, 8 - COMBOBOX IDC_COMPRESS_COMBO_LEVEL, g1XPos, 60, g1XSize, 80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Compression &level:",IDC_STATIC_COMPRESS_LEVEL, m, 62, g0xs, 8 + COMBOBOX IDC_COMPRESS_COMBO_LEVEL, g1x, 60, g1xs, 80, MY_COMBO - LTEXT "Compression &method:",IDC_STATIC_COMPRESS_METHOD, marg, 83, g0XSize, 8 - COMBOBOX IDC_COMPRESS_COMBO_METHOD, g1XPos, 81, g1XSize, 80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Compression &method:",IDC_STATIC_COMPRESS_METHOD, m, 83, g0xs, 8 + COMBOBOX IDC_COMPRESS_COMBO_METHOD, g1x, 81, g1xs, 80, MY_COMBO - LTEXT "&Dictionary size:",IDC_STATIC_COMPRESS_DICTIONARY, marg, 104, g0XSize, 8 - COMBOBOX IDC_COMPRESS_COMBO_DICTIONARY, g1XPos, 102, g1XSize, 167, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "&Dictionary size:",IDC_STATIC_COMPRESS_DICTIONARY, m, 104, g0xs, 8 + COMBOBOX IDC_COMPRESS_COMBO_DICTIONARY, g1x, 102, g1xs, 167, MY_COMBO - LTEXT "&Word size:",IDC_STATIC_COMPRESS_ORDER, marg, 125, g0XSize, 8 - COMBOBOX IDC_COMPRESS_COMBO_ORDER, g1XPos, 123, g1XSize, 141, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "&Word size:",IDC_STATIC_COMPRESS_ORDER, m, 125, g0xs, 8 + COMBOBOX IDC_COMPRESS_COMBO_ORDER, g1x, 123, g1xs, 141, MY_COMBO - LTEXT "&Solid Block size:",IDC_STATIC_COMPRESS_SOLID, marg, 146, g0XSize, 8 - COMBOBOX IDC_COMPRESS_COMBO_SOLID, g1XPos, 144, g1XSize, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "&Solid Block size:",IDC_STATIC_COMPRESS_SOLID, m, 146, g0xs, 8 + COMBOBOX IDC_COMPRESS_COMBO_SOLID, g1x, 144, g1xs, 140, MY_COMBO - LTEXT "&Number of CPU threads:",IDC_STATIC_COMPRESS_THREADS, marg, 167, g0XSize, 8 - COMBOBOX IDC_COMPRESS_COMBO_THREADS, g1XPos, 165, g1XSize - 35, 140, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "1", IDC_COMPRESS_HARDWARE_THREADS, g1XPos + g1XSize - 35 + 10, 167, 25, 8 + LTEXT "&Number of CPU threads:",IDC_STATIC_COMPRESS_THREADS, m, 167, g0xs, 8 + COMBOBOX IDC_COMPRESS_COMBO_THREADS, g1x, 165, g1xs - 35, 140, MY_COMBO + RTEXT "1", IDC_COMPRESS_HARDWARE_THREADS, g1x + g1xs - 35 + 10, 167, 25, 8 - LTEXT "Memory usage for Compressing:", IDC_STATIC_COMPRESS_MEMORY, marg, 190, g2XSize, 8 - RTEXT "0", IDC_STATIC_COMPRESS_MEMORY_VALUE, g3XPos, 190, g3XSize, 8 + LTEXT "Memory usage for Compressing:", IDC_STATIC_COMPRESS_MEMORY, m, 190, g2xs, 8 + RTEXT "0", IDC_STATIC_COMPRESS_MEMORY_VALUE, g3x, 190, g3xs, 8 - LTEXT "Memory usage for Decompressing:", IDC_STATIC_COMPRESS_MEMORY_DE, marg, 206, g2XSize, 8 - RTEXT "0",IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, g3XPos, 206, g3XSize, 8 + LTEXT "Memory usage for Decompressing:", IDC_STATIC_COMPRESS_MEMORY_DE, m, 206, g2xs, 8 + RTEXT "0",IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, g3x, 206, g3xs, 8 - LTEXT "Split to &volumes, bytes:", IDC_STATIC_COMPRESS_VOLUME, marg, 225, gSize, 8 - COMBOBOX IDC_COMPRESS_COMBO_VOLUME, marg, 237, gSize, 73, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP + LTEXT "Split to &volumes, bytes:", IDC_STATIC_COMPRESS_VOLUME, m, 225, gSize, 8 + COMBOBOX IDC_COMPRESS_COMBO_VOLUME, m, 237, gSize, 73, MY_COMBO_WITH_EDIT - LTEXT "&Parameters:",IDC_STATIC_COMPRESS_PARAMETERS, marg, 260, xSize2, 8 - EDITTEXT IDC_COMPRESS_EDIT_PARAMETERS, marg, 272, xSize2, 14, ES_AUTOHSCROLL + LTEXT "&Parameters:",IDC_STATIC_COMPRESS_PARAMETERS, m, 260, xc, 8 + EDITTEXT IDC_COMPRESS_EDIT_PARAMETERS, m, 272, xc, 14, ES_AUTOHSCROLL - LTEXT "&Update mode:",IDC_STATIC_COMPRESS_UPDATE_MODE, g4XPos, 39, g4XSize, 8 - COMBOBOX IDC_COMPRESS_COMBO_UPDATE_MODE, g4XPos, 51, g4XSize, 80, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "&Update mode:",IDC_STATIC_COMPRESS_UPDATE_MODE, g4x, 39, g4xs, 8 + COMBOBOX IDC_COMPRESS_COMBO_UPDATE_MODE, g4x, 51, g4xs, 80, MY_COMBO - GROUPBOX "Options",IDC_STATIC_COMPRESS_OPTIONS, g4XPos, OptYPos, g4XSize, 48 - CONTROL "Create SF&X archive",IDC_COMPRESS_SFX, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - g4XPos2, OptYPos + 14, g4XSize2, 10 - CONTROL "Compress shared files",IDC_COMPRESS_SHARED, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - g4XPos2, OptYPos + 30, g4XSize2, 10 + GROUPBOX "Options",IDC_STATIC_COMPRESS_OPTIONS, g4x, yOpt, g4xs, 48 + CONTROL "Create SF&X archive",IDC_COMPRESS_SFX, MY_CHECKBOX, + g4x2, yOpt + 14, g4xs2, 10 + CONTROL "Compress shared files",IDC_COMPRESS_SHARED, MY_CHECKBOX, + g4x2, yOpt + 30, g4xs2, 10 - GROUPBOX "Encryption",IDC_COMPRESS_ENCRYPTION, g4XPos, PswYPos, g4XSize, 127 + GROUPBOX "Encryption",IDC_COMPRESS_ENCRYPTION, g4x, yPsw, g4xs, 127 + + LTEXT "Enter password:",IDC_STATIC_COMPRESS_PASSWORD1, g4x2, yPsw + 14, g4xs2, 8 + EDITTEXT IDC_COMPRESS_EDIT_PASSWORD1, g4x2, yPsw + 26, g4xs2, 14, ES_PASSWORD | ES_AUTOHSCROLL + LTEXT "Reenter password:",IDC_STATIC_COMPRESS_PASSWORD2, g4x2, yPsw + 46, g4xs2, 8 + EDITTEXT IDC_COMPRESS_EDIT_PASSWORD2, g4x2, yPsw + 58, g4xs2, 14, ES_PASSWORD | ES_AUTOHSCROLL + + CONTROL "Show Password",IDC_COMPRESS_CHECK_SHOW_PASSWORD,MY_CHECKBOX, + g4x2, yPsw + 79, g4xs2, 10 + + LTEXT "&Encryption method:",IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, g4x2, yPsw + 95, 100, 8 + COMBOBOX IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, g4x2 + 100, yPsw + 93, g4xs2 - 100, 198, MY_COMBO + + CONTROL "Encrypt file &names", IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, MY_CHECKBOX, + g4x2, yPsw + 111, g4xs2, 10 + + DEFPUSHBUTTON "OK", IDOK, bx3, by, bxs, bys, WS_GROUP + PUSHBUTTON "Cancel", IDCANCEL, bx2, by, bxs, bys + PUSHBUTTON "Help", IDHELP, bx1, by, bxs, bys +END + + +#ifdef UNDER_CE + +#undef m +#undef xc +#undef yc - LTEXT "Enter password:",IDC_STATIC_COMPRESS_PASSWORD1, g4XPos2, PswYPos + 14, g4XSize2, 8 - EDITTEXT IDC_COMPRESS_EDIT_PASSWORD1, g4XPos2, PswYPos + 26, g4XSize2, 14, ES_PASSWORD | ES_AUTOHSCROLL - LTEXT "Reenter password:",IDC_STATIC_COMPRESS_PASSWORD2, g4XPos2, PswYPos + 46, g4XSize2, 8 - EDITTEXT IDC_COMPRESS_EDIT_PASSWORD2, g4XPos2, PswYPos + 58, g4XSize2, 14, ES_PASSWORD | ES_AUTOHSCROLL +#define m 4 +#define xc 152 +#define yc 160 - CONTROL "Show Password",IDC_COMPRESS_CHECK_SHOW_PASSWORD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP, - g4XPos2, PswYPos + 79, g4XSize2, 10 - LTEXT "&Encryption method:",IDC_STATIC_COMPRESS_ENCRYPTION_METHOD, g4XPos2, PswYPos + 95, 100, 8 - COMBOBOX IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, g4XPos2 + 100, PswYPos + 93, g4XSize2 - 100, 198, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP +IDD_DIALOG_COMPRESS_2 MY_DIALOG +CAPTION "Add to Archive" +MY_FONT +BEGIN + // LTEXT "&Archive:", IDC_STATIC_COMPRESS_ARCHIVE, m, m + 1, 32, 8 + COMBOBOX IDC_COMPRESS_COMBO_ARCHIVE, m, m, xc - bxsDots - m, 126, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDC_COMPRESS_BUTTON_SET_ARCHIVE, xs - m - bxsDots, m, bxsDots, 12, WS_GROUP + + COMBOBOX IDC_COMPRESS_COMBO_FORMAT, m , 22, 32, 80, MY_COMBO | CBS_SORT + COMBOBOX IDC_COMPRESS_COMBO_LEVEL, m + 36, 22, 68, 80, MY_COMBO + COMBOBOX IDC_COMPRESS_COMBO_METHOD, m + 108, 22, 44, 80, MY_COMBO + + COMBOBOX IDC_COMPRESS_COMBO_DICTIONARY, m, 40, 40, 80, MY_COMBO + COMBOBOX IDC_COMPRESS_COMBO_ORDER, m + 44, 40, 32, 80, MY_COMBO + COMBOBOX IDC_COMPRESS_COMBO_SOLID, m + 80, 40, 40, 80, MY_COMBO + COMBOBOX IDC_COMPRESS_COMBO_THREADS, m + 124, 40, 28, 80, MY_COMBO + + LTEXT "Split to &volumes, bytes:", IDC_STATIC_COMPRESS_VOLUME, m, 60, 32, 8 + COMBOBOX IDC_COMPRESS_COMBO_VOLUME, m + 32, 58, 44, 73, MY_COMBO_WITH_EDIT + LTEXT "&Parameters:",IDC_STATIC_COMPRESS_PARAMETERS, m + 80, 60, 48, 8 + EDITTEXT IDC_COMPRESS_EDIT_PARAMETERS, m + 128, 58, 24, 13, ES_AUTOHSCROLL + + COMBOBOX IDC_COMPRESS_COMBO_UPDATE_MODE, m, 76, 88, 80, MY_COMBO + CONTROL "SF&X", IDC_COMPRESS_SFX, MY_CHECKBOX, m + 92, 77, 60, 10 - CONTROL "Encrypt file &names", IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, - g4XPos2, PswYPos + 111, g4XSize2, 10 + CONTROL "Compress shared files", IDC_COMPRESS_SHARED, MY_CHECKBOX, m, 94, xc, 10 - DEFPUSHBUTTON "OK", IDOK, bXPos3, bYPos, bXSize, bYSize, WS_GROUP - PUSHBUTTON "Cancel", IDCANCEL, bXPos2, bYPos, bXSize, bYSize - PUSHBUTTON "Help", IDHELP, bXPos1, bYPos, bXSize, bYSize + LTEXT "Enter password:", IDC_STATIC_COMPRESS_PASSWORD1, m, 112, 60, 8 + EDITTEXT IDC_COMPRESS_EDIT_PASSWORD1, m + 60, 110, 44, 13, ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "Show Password", IDC_COMPRESS_CHECK_SHOW_PASSWORD, MY_CHECKBOX, m + 108, 112, 44, 10 + + COMBOBOX IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, m, 128, 48, 198, MY_COMBO + CONTROL "Encrypt file &names", IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, MY_CHECKBOX, m + 52, 130, 100, 10 + + OK_CANCEL +END + +#endif + +STRINGTABLE +BEGIN + IDS_METHOD_STORE "Store" + IDS_METHOD_NORMAL "Normal" + IDS_METHOD_MAXIMUM "Maximum" + IDS_METHOD_FAST "Fast" + IDS_METHOD_FASTEST "Fastest" + IDS_METHOD_ULTRA "Ultra" + + IDS_COMPRESS_NON_SOLID "Non-solid" + IDS_COMPRESS_SOLID "Solid" + + IDS_COMPRESS_UPDATE_MODE_ADD "Add and replace files" + IDS_COMPRESS_UPDATE_MODE_UPDATE "Update and add files" + IDS_COMPRESS_UPDATE_MODE_FRESH "Freshen existing files" + IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE "Synchronize files" + IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE "Browse" + IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE "Specified volume size: {0} bytes.\nAre you sure you want to split archive into such volumes?" + + IDS_OPEN_TYPE_ALL_FILES "All Files" + + IDS_PASSWORD_USE_ASCII "Use only English letters, numbers and special characters (!, #, $, ...) for password." + IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH "Passwords do not match" + IDS_PASSWORD_IS_TOO_LONG "Password is too long" END diff --git a/CPP/7zip/UI/GUI/CompressDialogRes.h b/CPP/7zip/UI/GUI/CompressDialogRes.h index beedde4e..2dcdc80e 100755 --- a/CPP/7zip/UI/GUI/CompressDialogRes.h +++ b/CPP/7zip/UI/GUI/CompressDialogRes.h @@ -1,4 +1,5 @@ -#define IDD_DIALOG_COMPRESS 152 +#define IDD_DIALOG_COMPRESS 551 +#define IDD_DIALOG_COMPRESS_2 651 #define IDC_STATIC_COMPRESS_MEMORY 1022 #define IDC_STATIC_COMPRESS_MEMORY_DE 1023 #define IDC_STATIC_COMPRESS_MEMORY_VALUE 1027 @@ -50,3 +51,31 @@ #define IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES 1122 #define IDC_COMPRESS_SHARED 1130 + + +#define IDS_OPEN_TYPE_ALL_FILES 80 + +#define IDS_METHOD_STORE 81 +#define IDS_METHOD_NORMAL 82 +#define IDS_METHOD_MAXIMUM 83 +#define IDS_METHOD_FAST 84 +#define IDS_METHOD_FASTEST 85 +#define IDS_METHOD_ULTRA 86 + +#define IDS_COMPRESS_NON_SOLID 88 +#define IDS_COMPRESS_SOLID 89 + +#define IDS_COMPRESS_UPDATE_MODE_ADD 90 +#define IDS_COMPRESS_UPDATE_MODE_UPDATE 91 +#define IDS_COMPRESS_UPDATE_MODE_FRESH 92 +#define IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE 93 + +#define IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE 94 + +#define IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE 96 + +#define IDS_PASSWORD_USE_ASCII 110 +#define IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH 111 +#define IDS_PASSWORD_IS_TOO_LONG 112 + +#define IDS_COMPRESS_INCORRECT_VOLUME_SIZE 95 diff --git a/CPP/7zip/UI/GUI/Extract.rc b/CPP/7zip/UI/GUI/Extract.rc index 0c655ce4..ad8f9910 100755 --- a/CPP/7zip/UI/GUI/Extract.rc +++ b/CPP/7zip/UI/GUI/Extract.rc @@ -20,4 +20,14 @@ BEGIN IDS_MEM_ERROR "The system cannot allocate the required amount of memory" IDS_UNKNOWN_ERROR "Unknown Error" IDS_UNSUPPORTED_ARCHIVE_TYPE "Unsupported archive type" + + IDC_EXTRACT_RADIO_FULL_PATHNAMES "Full pathnames" + IDC_EXTRACT_RADIO_CURRENT_PATHNAMES "Current pathnames" + IDC_EXTRACT_RADIO_NO_PATHNAMES "No pathnames" + + IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE "Ask before overwrite" + IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT "Overwrite without prompt" + IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES "Skip existing files" + IDC_EXTRACT_RADIO_AUTO_RENAME "Auto rename" + IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING "Auto rename existing files" END diff --git a/CPP/7zip/UI/GUI/ExtractDialog.cpp b/CPP/7zip/UI/GUI/ExtractDialog.cpp index 6b388700..94556639 100755 --- a/CPP/7zip/UI/GUI/ExtractDialog.cpp +++ b/CPP/7zip/UI/GUI/ExtractDialog.cpp @@ -7,7 +7,7 @@ #include "ExtractDialog.h" #include "Common/StringConvert.h" -#include "Windows/Shell.h" + #include "Windows/FileName.h" #include "Windows/FileDir.h" #include "Windows/ResourceString.h" @@ -18,35 +18,47 @@ #include "../Common/ZipRegistry.h" +#include "../FileManager/BrowseDialog.h" #include "../FileManager/LangUtils.h" +#include "../FileManager/resourceGui.h" #include "ExtractRes.h" #include "ExtractDialogRes.h" -// #include "Help/Context/Extract.h" - using namespace NWindows; using namespace NFile; using namespace NName; -static const int kPathModeButtons[] = +extern HINSTANCE g_hInstance; + +static CIDLangPair kPathMode_Pairs[] = +{ + { IDC_EXTRACT_RADIO_FULL_PATHNAMES, 0x02000811 }, + // { IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, 0x02000812 }, + { IDC_EXTRACT_RADIO_NO_PATHNAMES, 0x02000813 } +}; + +static CIDLangPair kOverwriteMode_Pairs[] = { - IDC_EXTRACT_RADIO_FULL_PATHNAMES, - IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, - IDC_EXTRACT_RADIO_NO_PATHNAMES + { IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, 0x02000821 }, + { IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, 0x02000822 }, + { IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, 0x02000823 }, + { IDC_EXTRACT_RADIO_AUTO_RENAME, 0x02000824 }, + { IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, 0x02000825 } }; #ifndef _SFX -static const NExtract::NPathMode::EEnum kPathModeButtonsVals[] = +static const + // NExtract::NPathMode::EEnum + int + kPathModeButtonsVals[] = { NExtract::NPathMode::kFullPathnames, - NExtract::NPathMode::kCurrentPathnames, + // NExtract::NPathMode::kCurrentPathnames, NExtract::NPathMode::kNoPathnames }; -static const int kNumPathnamesButtons = sizeof(kPathModeButtons) / sizeof(kPathModeButtons[0]); - static const int kOverwriteButtons[] = { IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, @@ -56,7 +68,10 @@ static const int kOverwriteButtons[] = IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, }; -static const NExtract::NOverwriteMode::EEnum kOverwriteButtonsVals[] = +static const + int + // NExtract::NOverwriteMode::EEnum + kOverwriteButtonsVals[] = { NExtract::NOverwriteMode::kAskBefore, NExtract::NOverwriteMode::kWithoutPrompt, @@ -76,65 +91,11 @@ static const int kFilesButtons[] = static const int kNumFilesButtons = sizeof(kFilesButtons) / sizeof(kFilesButtons[0]); */ -void CExtractDialog::GetPathMode() -{ - for (int i = 0; i < kNumPathnamesButtons; i++) - if(IsButtonCheckedBool(kPathModeButtons[i])) - { - PathMode = kPathModeButtonsVals[i]; - return; - } - throw 1; -} - -void CExtractDialog::SetPathMode() -{ - for (int j = 0; j < 2; j++) - { - for (int i = 0; i < kNumPathnamesButtons; i++) - if(PathMode == kPathModeButtonsVals[i]) - { - CheckRadioButton(kPathModeButtons[0], kPathModeButtons[kNumPathnamesButtons - 1], - kPathModeButtons[i]); - return; - } - PathMode = kPathModeButtonsVals[0]; - } - throw 1; -} - -void CExtractDialog::GetOverwriteMode() -{ - for (int i = 0; i < kNumOverwriteButtons; i++) - if(IsButtonCheckedBool(kOverwriteButtons[i])) - { - OverwriteMode = kOverwriteButtonsVals[i]; - return; - } - throw 0; -} - -void CExtractDialog::SetOverwriteMode() -{ - for (int j = 0; j < 2; j++) - { - for (int i = 0; i < kNumOverwriteButtons; i++) - if(OverwriteMode == kOverwriteButtonsVals[i]) - { - CheckRadioButton(kOverwriteButtons[0], kOverwriteButtons[kNumOverwriteButtons - 1], - kOverwriteButtons[i]); - return; - } - OverwriteMode = kOverwriteButtonsVals[0]; - } - throw 1; -} - /* int CExtractDialog::GetFilesMode() const { for (int i = 0; i < kNumFilesButtons; i++) - if(IsButtonCheckedBool(kFilesButtons[i])) + if (IsButtonCheckedBool(kFilesButtons[i])) return i; throw 0; } @@ -147,18 +108,10 @@ static CIDLangPair kIDLangPairs[] = { { IDC_STATIC_EXTRACT_EXTRACT_TO, 0x02000801 }, { IDC_EXTRACT_PATH_MODE, 0x02000810 }, - { IDC_EXTRACT_RADIO_FULL_PATHNAMES, 0x02000811 }, - { IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, 0x02000812 }, - { IDC_EXTRACT_RADIO_NO_PATHNAMES, 0x02000813 }, - { IDC_EXTRACT_OVERWRITE_MODE, 0x02000820 }, - { IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, 0x02000821 }, - { IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, 0x02000822 }, - { IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, 0x02000823 }, - { IDC_EXTRACT_RADIO_AUTO_RENAME, 0x02000824 }, - { IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, 0x02000825 }, - { IDC_EXTRACT_FILES, 0x02000830 }, - { IDC_EXTRACT_RADIO_SELECTED_FILES, 0x02000831 }, - { IDC_EXTRACT_RADIO_ALL_FILES, 0x02000832 }, + { IDC_EXTRACT_OVERWRITE_MODE, 0x02000820 }, + // { IDC_EXTRACT_FILES, 0x02000830 }, + // { IDC_EXTRACT_RADIO_SELECTED_FILES, 0x02000831 }, + // { IDC_EXTRACT_RADIO_ALL_FILES, 0x02000832 }, { IDC_EXTRACT_PASSWORD, 0x02000802 }, { IDC_EXTRACT_CHECK_SHOW_PASSWORD, 0x02000B02 }, { IDOK, 0x02000702 }, @@ -174,6 +127,23 @@ static CIDLangPair kIDLangPairs[] = static const int kHistorySize = 8; #endif +#ifndef _SFX +static void AddComboItems(NWindows::NControl::CComboBox &combo, const CIDLangPair *items, int numItems, const int *values, int curVal) +{ + int curSel = 0; + for (int i = 0; i < numItems; i++) + { + UString s = LangString(items[i].ControlID, items[i].LangID); + s.Replace(L"&", L""); + int index = (int)combo.AddString(s); + combo.SetItemData(index, i); + if (values[i] == curVal) + curSel = i; + } + combo.SetCurSel(curSel); +} +#endif + bool CExtractDialog::OnInit() { #ifdef LANG @@ -186,18 +156,18 @@ bool CExtractDialog::OnInit() _passwordControl.SetPasswordChar(TEXT('*')); #endif - NExtract::CInfo extractionInfo; + NExtract::CInfo info; #ifdef NO_REGISTRY PathMode = NExtract::NPathMode::kFullPathnames; OverwriteMode = NExtract::NOverwriteMode::kAskBefore; - // extractionInfo.Paths = NExtract::NPathMode::kFullPathnames; + // info.Paths = NExtract::NPathMode::kFullPathnames; #else - ReadExtractionInfo(extractionInfo); - CheckButton(IDC_EXTRACT_CHECK_SHOW_PASSWORD, extractionInfo.ShowPassword); + info.Load(); + CheckButton(IDC_EXTRACT_CHECK_SHOW_PASSWORD, info.ShowPassword); UpdatePasswordControl(); - PathMode = extractionInfo.PathMode; - OverwriteMode = extractionInfo.OverwriteMode; + PathMode = info.PathMode; + OverwriteMode = info.OverwriteMode; #endif _path.Attach(GetItem(IDC_EXTRACT_COMBO_PATH)); @@ -205,22 +175,26 @@ bool CExtractDialog::OnInit() _path.SetText(DirectoryPath); #ifndef NO_REGISTRY - for(int i = 0; i < extractionInfo.Paths.Size() && i < kHistorySize; i++) - _path.AddString(extractionInfo.Paths[i]); + for (int i = 0; i < info.Paths.Size() && i < kHistorySize; i++) + _path.AddString(info.Paths[i]); #endif /* - if(extractionInfo.Paths.Size() > 0) + if (info.Paths.Size() > 0) _path.SetCurSel(0); else _path.SetCurSel(-1); */ - - #ifndef _SFX - SetPathMode(); - SetOverwriteMode(); + + _pathMode.Attach(GetItem(IDC_EXTRACT_COMBO_PATH_MODE)); + AddComboItems(_pathMode, kPathMode_Pairs, sizeof(kPathMode_Pairs) / sizeof(kPathMode_Pairs[0]), + kPathModeButtonsVals, PathMode); + + _overwriteMode.Attach(GetItem(IDC_EXTRACT_COMBO_OVERWRITE_MODE)); + AddComboItems(_overwriteMode, kOverwriteMode_Pairs, sizeof(kOverwriteMode_Pairs) / sizeof(kOverwriteMode_Pairs[0]), + kOverwriteButtonsVals, OverwriteMode); /* CheckRadioButton(kFilesButtons[0], kFilesButtons[kNumFilesButtons - 1], @@ -233,11 +207,15 @@ bool CExtractDialog::OnInit() #endif + HICON icon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON)); + SetIcon(ICON_BIG, icon); // CWindow filesWindow = GetItem(IDC_EXTRACT_RADIO_FILES); // filesWindow.Enable(_enableFilesButton); // UpdateWildCardState(); + NormalizePosition(); + return CModalDialog::OnInit(); } @@ -284,7 +262,7 @@ void CExtractDialog::OnButtonSetPath() _path.GetText(currentPath); UString title = LangStringSpec(IDS_EXTRACT_SET_FOLDER, 0x02000881); UString resultPath; - if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath)) + if (!MyBrowseForFolder(HWND(*this), title, currentPath, resultPath)) return; #ifndef NO_REGISTRY _path.SetCurSel(-1); @@ -294,7 +272,7 @@ void CExtractDialog::OnButtonSetPath() void AddUniqueString(UStringVector &list, const UString &s) { - for(int i = 0; i < list.Size(); i++) + for (int i = 0; i < list.Size(); i++) if (s.CompareNoCase(list[i]) == 0) return; list.Add(s); @@ -303,18 +281,21 @@ void AddUniqueString(UStringVector &list, const UString &s) void CExtractDialog::OnOK() { #ifndef _SFX - GetPathMode(); - GetOverwriteMode(); + NExtract::NPathMode::EEnum pathMode2 = (NExtract::NPathMode::EEnum)kPathModeButtonsVals[_pathMode.GetItemData(_pathMode.GetCurSel())]; + if (PathMode != NExtract::NPathMode::kCurrentPathnames || + pathMode2 != NExtract::NPathMode::kFullPathnames) + PathMode = pathMode2; + OverwriteMode = (NExtract::NOverwriteMode::EEnum)kOverwriteButtonsVals[_overwriteMode.GetItemData(_overwriteMode.GetCurSel())]; + // _filesMode = (NExtractionDialog::NFilesMode::EEnum)GetFilesMode(); _passwordControl.GetText(Password); #endif - NExtract::CInfo extractionInfo; - extractionInfo.PathMode = PathMode; - extractionInfo.OverwriteMode = OverwriteMode; - extractionInfo.ShowPassword = (IsButtonChecked( - IDC_EXTRACT_CHECK_SHOW_PASSWORD) == BST_CHECKED); + NExtract::CInfo info; + info.PathMode = PathMode; + info.OverwriteMode = OverwriteMode; + info.ShowPassword = (IsButtonCheckedBool(IDC_EXTRACT_CHECK_SHOW_PASSWORD)); UString s; @@ -325,10 +306,10 @@ void CExtractDialog::OnOK() #else int currentItem = _path.GetCurSel(); - if(currentItem == CB_ERR) + if (currentItem == CB_ERR) { _path.GetText(s); - if(_path.GetCount() >= kHistorySize) + if (_path.GetCount() >= kHistorySize) currentItem = _path.GetCount() - 1; } else @@ -338,19 +319,19 @@ void CExtractDialog::OnOK() s.Trim(); #ifndef _SFX - AddUniqueString(extractionInfo.Paths, s); + AddUniqueString(info.Paths, s); #endif DirectoryPath = s; #ifndef NO_REGISTRY - for(int i = 0; i < _path.GetCount(); i++) - if(i != currentItem) + for (int i = 0; i < _path.GetCount(); i++) + if (i != currentItem) { UString sTemp; _path.GetLBText(i, sTemp); sTemp.Trim(); - AddUniqueString(extractionInfo.Paths, sTemp); + AddUniqueString(info.Paths, sTemp); } - SaveExtractionInfo(extractionInfo); + info.Save(); #endif CModalDialog::OnOK(); } diff --git a/CPP/7zip/UI/GUI/ExtractDialog.h b/CPP/7zip/UI/GUI/ExtractDialog.h index 6ac82f74..b0636c72 100755 --- a/CPP/7zip/UI/GUI/ExtractDialog.h +++ b/CPP/7zip/UI/GUI/ExtractDialog.h @@ -1,11 +1,10 @@ // ExtractDialog.h -#ifndef __EXTRACTDIALOG_H -#define __EXTRACTDIALOG_H +#ifndef __EXTRACT_DIALOG_H +#define __EXTRACT_DIALOG_H #include "ExtractDialogRes.h" -#include "Windows/Control/Dialog.h" #include "Windows/Control/Edit.h" #include "Windows/Control/ComboBox.h" @@ -14,6 +13,8 @@ #endif #include "../Common/ExtractMode.h" +#include "../FileManager/DialogSize.h" + namespace NExtractionDialog { /* @@ -39,13 +40,11 @@ class CExtractDialog: public NWindows::NControl::CModalDialog #ifndef _SFX NWindows::NControl::CEdit _passwordControl; + NWindows::NControl::CComboBox _pathMode; + NWindows::NControl::CComboBox _overwriteMode; #endif #ifndef _SFX - void GetPathMode(); - void SetPathMode(); - void GetOverwriteMode(); - void SetOverwriteMode(); // int GetFilesMode() const; void UpdatePasswordControl(); #endif @@ -71,7 +70,14 @@ public: NExtract::NOverwriteMode::EEnum OverwriteMode; INT_PTR Create(HWND aWndParent = 0) - { return CModalDialog::Create(IDD_DIALOG_EXTRACT, aWndParent); } + { + #ifdef _SFX + BIG_DIALOG_SIZE(240, 64); + #else + BIG_DIALOG_SIZE(300, 160); + #endif + return CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_EXTRACT), aWndParent); + } }; #endif diff --git a/CPP/7zip/UI/GUI/ExtractDialog.rc b/CPP/7zip/UI/GUI/ExtractDialog.rc index f1d50317..db8a5b24 100755 --- a/CPP/7zip/UI/GUI/ExtractDialog.rc +++ b/CPP/7zip/UI/GUI/ExtractDialog.rc @@ -1,80 +1,83 @@ #include "ExtractDialogRes.h" #include "../../GuiCommon.rc" -#define xSize2 285 -#define ySize2 204 +#define xc 280 +#define yc 128 -#define xSize (xSize2 + marg + marg) -#define ySize (ySize2 + marg + marg) +#undef g1xs +#undef g2x +#undef g2x2 +#undef g2xs +#undef g2xs2 -#undef g1XSize -#undef g1XSize2 -#undef g1XPos2 -#undef g2XPos -#undef g2XPos2 -#undef g2XSize -#undef g2XSize2 +#define g1xs 128 -#define bYPos (ySize - marg - bYSize) +#define gSpace 24 +#define g2x (m + g1xs + gSpace) +#define g2x2 (g2x + m) +#define g2xs (xc - g1xs - gSpace) +#define g2xs2 (g2xs - m - m) -#define g1XSize 127 -#define g1XSize2 (g1XSize - 13) -#define g1XPos2 (marg + 7) +IDD_DIALOG_EXTRACT MY_DIALOG +CAPTION "Extract" +BEGIN + LTEXT "E&xtract to:", IDC_STATIC_EXTRACT_EXTRACT_TO, m, m, xc, 8 + COMBOBOX IDC_EXTRACT_COMBO_PATH, m, m + 12, xc - bxsDots - 12, 100, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDC_EXTRACT_BUTTON_SET_PATH, xs - m - bxsDots, m + 12 - 2, bxsDots, bys, WS_GROUP + + LTEXT "Path mode:", IDC_EXTRACT_PATH_MODE, m, m + 36, g1xs, 8 + COMBOBOX IDC_EXTRACT_COMBO_PATH_MODE, m, m + 48, g1xs, 140, MY_COMBO + + LTEXT "Overwrite mode:", IDC_EXTRACT_OVERWRITE_MODE, m, m + 68, g1xs, 8 + COMBOBOX IDC_EXTRACT_COMBO_OVERWRITE_MODE, m, m + 80, g1xs, 140, MY_COMBO + + #ifdef UNDER_CE + LTEXT "Password", IDC_EXTRACT_PASSWORD, g2x, m + 36, g2xs, 8 + #else + GROUPBOX "Password", IDC_EXTRACT_PASSWORD, g2x, m + 36, g2xs, 56 + #endif + EDITTEXT IDC_EXTRACT_EDIT_PASSWORD, g2x2, m + 50, g2xs2, 14, ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "Show Password", IDC_EXTRACT_CHECK_SHOW_PASSWORD, MY_CHECKBOX, g2x2, m + 72, g2xs2, 10 + + DEFPUSHBUTTON "OK", IDOK, bx3, by, bxs, bys, WS_GROUP + PUSHBUTTON "Cancel", IDCANCEL, bx2, by, bxs, bys + PUSHBUTTON "Help", IDHELP, bx1, by, bxs, bys +END + + +#ifdef UNDER_CE -#define gSpace 14 -#define g2XPos (marg + g1XSize + gSpace) -#define g2XPos2 (g2XPos + 7) -#define g2XSize (xSize2 - g1XSize - gSpace) -#define g2XSize2 (g2XSize - 14) +#undef m +#define m 4 -#define bXPos1 (xSize - marg - bXSize) -#define bXPos2 (bXPos1 - 10 - bXSize) -#define bXPos3 (bXPos2 - 10 - bXSize) +#undef xc +#undef yc -IDD_DIALOG_EXTRACT DIALOG DISCARDABLE 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE +#define xc 152 +#define yc 128 + +#undef g1xs + +#define g1xs 64 + +IDD_DIALOG_EXTRACT_2 MY_DIALOG CAPTION "Extract" -MY_FONT BEGIN - LTEXT "E&xtract to:", IDC_STATIC_EXTRACT_EXTRACT_TO, marg, marg, xSize2, 8 - - COMBOBOX IDC_EXTRACT_COMBO_PATH, marg, 21, xSize2 - bDotsSize - 13, 126, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - - PUSHBUTTON "...", IDC_EXTRACT_BUTTON_SET_PATH, xSize - marg - bDotsSize, 20, bDotsSize, bYSize, WS_GROUP - - GROUPBOX "Path mode",IDC_EXTRACT_PATH_MODE, marg, 44, g1XSize, 57 - CONTROL "Full pathnames", IDC_EXTRACT_RADIO_FULL_PATHNAMES,"Button", BS_AUTORADIOBUTTON | WS_GROUP, - g1XPos2, 57, g1XSize2, 10 - CONTROL "Current pathnames",IDC_EXTRACT_RADIO_CURRENT_PATHNAMES, "Button", BS_AUTORADIOBUTTON, - g1XPos2, 71, g1XSize2, 10 - CONTROL "No pathnames", IDC_EXTRACT_RADIO_NO_PATHNAMES, "Button", BS_AUTORADIOBUTTON, - g1XPos2, 85, g1XSize2, 10 - - GROUPBOX "Overwrite mode",IDC_EXTRACT_OVERWRITE_MODE, g2XPos, 44, g2XSize, 88, WS_GROUP - CONTROL "Ask before overwrite", IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE, "Button", BS_AUTORADIOBUTTON | WS_GROUP, - g2XPos2, 57, g2XSize2, 10 - CONTROL "Overwrite without prompt", IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT, "Button", BS_AUTORADIOBUTTON, - g2XPos2, 71, g2XSize2, 10 - CONTROL "Skip existing files", IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES, "Button", BS_AUTORADIOBUTTON, - g2XPos2, 85, g2XSize2, 10 - CONTROL "Auto rename", IDC_EXTRACT_RADIO_AUTO_RENAME, "Button", BS_AUTORADIOBUTTON, - g2XPos2, 99, g2XSize2, 10 - CONTROL "Auto rename existing files", IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING, "Button", BS_AUTORADIOBUTTON, - g2XPos2,113, g2XSize2, 10 - - GROUPBOX "Files",IDC_EXTRACT_FILES, marg, 140, 127, 48, NOT WS_VISIBLE | WS_DISABLED | WS_GROUP - CONTROL "&Selected files",IDC_EXTRACT_RADIO_SELECTED_FILES, "Button", BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED | WS_GROUP, - g1XPos2, 153, g1XSize2, 10 - CONTROL "&All files",IDC_EXTRACT_RADIO_ALL_FILES, "Button", BS_AUTORADIOBUTTON | NOT WS_VISIBLE | WS_DISABLED, - g1XPos2, 166, g1XSize2, 10 - - GROUPBOX "Password",IDC_EXTRACT_PASSWORD, g2XPos, 142, g2XSize, 46 - EDITTEXT IDC_EXTRACT_EDIT_PASSWORD,154,153,130,14, ES_PASSWORD | ES_AUTOHSCROLL - CONTROL "Show Password",IDC_EXTRACT_CHECK_SHOW_PASSWORD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP, - g2XPos2, 172, g2XSize2, 10 + LTEXT "E&xtract to:", IDC_STATIC_EXTRACT_EXTRACT_TO, m, m, xc - bxsDots - 8, 8 + COMBOBOX IDC_EXTRACT_COMBO_PATH, m, m + 12, xc - bxsDots - 8, 100, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDC_EXTRACT_BUTTON_SET_PATH, xs - m - bxsDots, m + 12 - 3, bxsDots, bys, WS_GROUP + + LTEXT "Path mode:", IDC_EXTRACT_PATH_MODE, m, m + 36, g1xs, 8 + COMBOBOX IDC_EXTRACT_COMBO_PATH_MODE, m + g1xs, m + 36, xc - g1xs, 100, MY_COMBO + + LTEXT "Overwrite mode:", IDC_EXTRACT_OVERWRITE_MODE, m, m + 56, g1xs, 8 + COMBOBOX IDC_EXTRACT_COMBO_OVERWRITE_MODE, m + g1xs, m + 56, xc - g1xs, 100, MY_COMBO + + LTEXT "Password", IDC_EXTRACT_PASSWORD, m, m + 76, g1xs, 8 + EDITTEXT IDC_EXTRACT_EDIT_PASSWORD, m + g1xs, m + 76, xc - g1xs, 14, ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "Show Password", IDC_EXTRACT_CHECK_SHOW_PASSWORD, MY_CHECKBOX, m, m + 92, xc, 10 - DEFPUSHBUTTON "OK", IDOK, bXPos3, bYPos, bXSize, bYSize, WS_GROUP - PUSHBUTTON "Cancel", IDCANCEL, bXPos2, bYPos, bXSize, bYSize - PUSHBUTTON "Help", IDHELP, bXPos1, bYPos, bXSize, bYSize + OK_CANCEL END - +#endif diff --git a/CPP/7zip/UI/GUI/ExtractDialogRes.h b/CPP/7zip/UI/GUI/ExtractDialogRes.h index bc45ed23..38652b29 100755 --- a/CPP/7zip/UI/GUI/ExtractDialogRes.h +++ b/CPP/7zip/UI/GUI/ExtractDialogRes.h @@ -1,24 +1,15 @@ -#define IDD_DIALOG_EXTRACT 137 +#define IDD_DIALOG_EXTRACT 552 +#define IDD_DIALOG_EXTRACT_2 652 #define IDC_STATIC_EXTRACT_EXTRACT_TO 1020 #define IDC_EXTRACT_COMBO_PATH 1021 #define IDC_EXTRACT_BUTTON_SET_PATH 1022 +#define IDC_EXTRACT_COMBO_PATH_MODE 1030 +#define IDC_EXTRACT_COMBO_OVERWRITE_MODE 1031 #define IDC_EXTRACT_PATH_MODE 1040 -#define IDC_EXTRACT_RADIO_FULL_PATHNAMES 1041 -#define IDC_EXTRACT_RADIO_CURRENT_PATHNAMES 1042 -#define IDC_EXTRACT_RADIO_NO_PATHNAMES 1043 - #define IDC_EXTRACT_OVERWRITE_MODE 1050 -#define IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE 1051 -#define IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT 1052 -#define IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES 1053 -#define IDC_EXTRACT_RADIO_SELECTED_FILES 1054 -#define IDC_EXTRACT_RADIO_ALL_FILES 1055 -#define IDC_EXTRACT_RADIO_AUTO_RENAME 1056 -#define IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING 1057 - #define IDC_EXTRACT_FILES 1060 diff --git a/CPP/7zip/UI/GUI/ExtractGUI.cpp b/CPP/7zip/UI/GUI/ExtractGUI.cpp index 95864d2c..54ffd51c 100755 --- a/CPP/7zip/UI/GUI/ExtractGUI.cpp +++ b/CPP/7zip/UI/GUI/ExtractGUI.cpp @@ -13,14 +13,16 @@ #include "../FileManager/ExtractCallback.h" #include "../FileManager/FormatUtils.h" #include "../FileManager/LangUtils.h" +#include "../FileManager/resourceGui.h" #include "../Common/ArchiveExtractCallback.h" #include "../Common/PropIDUtils.h" #include "../Explorer/MyMessages.h" -#include "resource.h" +#include "resource2.h" #include "ExtractRes.h" + #include "ExtractDialog.h" #include "ExtractGUI.h" @@ -28,87 +30,84 @@ using namespace NWindows; static const wchar_t *kIncorrectOutDir = L"Incorrect output directory path"; -struct CThreadExtracting -{ - CCodecs *codecs; - CExtractCallbackImp *ExtractCallbackSpec; - CIntVector FormatIndices; - - UStringVector *ArchivePaths; - UStringVector *ArchivePathsFull; - const NWildcard::CCensorNode *WildcardCensor; - const CExtractOptions *Options; - CMyComPtr<IExtractCallbackUI> ExtractCallback; - CDecompressStat Stat; - UString ErrorMessage; - HRESULT Result; - - DWORD Process() - { - ExtractCallbackSpec->ProgressDialog.WaitCreating(); - try - { - Result = DecompressArchives( - codecs, FormatIndices, - *ArchivePaths, *ArchivePathsFull, - *WildcardCensor, *Options, ExtractCallbackSpec, ExtractCallback, ErrorMessage, Stat); - } - catch(const UString &s) - { - ErrorMessage = s; - Result = E_FAIL; - } - catch(const wchar_t *s) - { - ErrorMessage = s; - Result = E_FAIL; - } - catch(const char *s) - { - ErrorMessage = GetUnicodeString(s); - Result = E_FAIL; - } - catch(...) - { - Result = E_FAIL; - } - ExtractCallbackSpec->ProgressDialog.MyClose(); - return 0; - } - static THREAD_FUNC_DECL MyThreadFunction(void *param) - { - return ((CThreadExtracting *)param)->Process(); - } -}; - #ifndef _SFX static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) { wchar_t sz[32]; s += LangString(resourceID, langID); - s += L" "; + s += L' '; ConvertUInt64ToString(value, sz); s += sz; - s += L"\n"; + s += L'\n'; } static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) { wchar_t sz[32]; s += LangString(resourceID, langID); - s += L" "; + s += L' '; ConvertUInt64ToString(value, sz); s += sz; ConvertUInt64ToString(value >> 20, sz); s += L" ("; s += sz; s += L" MB)"; - s += L"\n"; + s += L'\n'; } #endif +class CThreadExtracting: public CProgressThreadVirt +{ + HRESULT ProcessVirt(); +public: + CCodecs *codecs; + CExtractCallbackImp *ExtractCallbackSpec; + CIntVector FormatIndices; + + UStringVector *ArchivePaths; + UStringVector *ArchivePathsFull; + const NWildcard::CCensorNode *WildcardCensor; + const CExtractOptions *Options; + CMyComPtr<IExtractCallbackUI> ExtractCallback; + UString Title; +}; + +HRESULT CThreadExtracting::ProcessVirt() +{ + CDecompressStat Stat; + HRESULT res = DecompressArchives(codecs, FormatIndices, *ArchivePaths, *ArchivePathsFull, + *WildcardCensor, *Options, ExtractCallbackSpec, ExtractCallback, ErrorMessage, Stat); + #ifndef _SFX + if (Options->TestMode && ExtractCallbackSpec->IsOK()) + { + UString s; + AddValuePair(IDS_ARCHIVES_COLON, 0x02000324, Stat.NumArchives, s); + AddValuePair(IDS_FOLDERS_COLON, 0x02000321, Stat.NumFolders, s); + AddValuePair(IDS_FILES_COLON, 0x02000320, Stat.NumFiles, s); + AddSizePair(IDS_SIZE_COLON, 0x02000322, Stat.UnpackSize, s); + AddSizePair(IDS_COMPRESSED_COLON, 0x02000323, Stat.PackSize, s); + + if (Options->CalcCrc) + { + wchar_t temp[16]; + ConvertUInt32ToHex(Stat.CrcSum, temp); + s += L"CRC: "; + s += temp; + s += L'\n'; + } + + s += L'\n'; + s += LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608); + + OkMessageTitle = Title; + OkMessage = s; + } + #endif + return res; +}; + HRESULT ExtractGUI( CCodecs *codecs, const CIntVector &formatIndices, @@ -117,8 +116,12 @@ HRESULT ExtractGUI( const NWildcard::CCensorNode &wildcardCensor, CExtractOptions &options, bool showDialog, - CExtractCallbackImp *extractCallback) + bool &messageWasDisplayed, + CExtractCallbackImp *extractCallback, + HWND hwndParent) { + messageWasDisplayed = false; + CThreadExtracting extracter; extracter.codecs = codecs; extracter.FormatIndices = formatIndices; @@ -126,14 +129,17 @@ HRESULT ExtractGUI( if (!options.TestMode) { UString outputDir = options.OutputDir; + #ifndef UNDER_CE if (outputDir.IsEmpty()) NFile::NDirectory::MyGetCurrentDirectory(outputDir); + #endif if (showDialog) { CExtractDialog dialog; if (!NFile::NDirectory::MyGetFullPathName(outputDir, dialog.DirectoryPath)) { ShowErrorMessage(kIncorrectOutDir); + messageWasDisplayed = true; return E_FAIL; } NFile::NName::NormalizeDirPathPrefix(dialog.DirectoryPath); @@ -141,7 +147,7 @@ HRESULT ExtractGUI( // dialog.OverwriteMode = options.OverwriteMode; // dialog.PathMode = options.PathMode; - if(dialog.Create(0) != IDOK) + if (dialog.Create(hwndParent) != IDOK) return E_ABORT; outputDir = dialog.DirectoryPath; options.OverwriteMode = dialog.OverwriteMode; @@ -154,6 +160,7 @@ HRESULT ExtractGUI( if (!NFile::NDirectory::MyGetFullPathName(outputDir, options.OutputDir)) { ShowErrorMessage(kIncorrectOutDir); + messageWasDisplayed = true; return E_FAIL; } NFile::NName::NormalizeDirPathPrefix(options.OutputDir); @@ -167,7 +174,7 @@ HRESULT ExtractGUI( 0x02000603, #endif options.OutputDir); - MyMessageBox(s2 + UString(L"\n") + s); + MyMessageBox(s2 + UString(L'\n') + s); return E_FAIL; } */ @@ -176,47 +183,23 @@ HRESULT ExtractGUI( UString title = LangStringSpec(options.TestMode ? IDS_PROGRESS_TESTING : IDS_PROGRESS_EXTRACTING, options.TestMode ? 0x02000F90: 0x02000890); + extracter.Title = title; extracter.ExtractCallbackSpec = extractCallback; + extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog; extracter.ExtractCallback = extractCallback; extracter.ExtractCallbackSpec->Init(); + extracter.ProgressDialog.CompressingMode = false; + extracter.ArchivePaths = &archivePaths; extracter.ArchivePathsFull = &archivePathsFull; extracter.WildcardCensor = &wildcardCensor; extracter.Options = &options; - NWindows::CThread thread; - RINOK(thread.Create(CThreadExtracting::MyThreadFunction, &extracter)); - extracter.ExtractCallbackSpec->StartProgressDialog(title); - if (extracter.Result == S_OK && options.TestMode && - extracter.ExtractCallbackSpec->Messages.IsEmpty() && - extracter.ExtractCallbackSpec->NumArchiveErrors == 0) - { - #ifndef _SFX - UString s; - AddValuePair(IDS_ARCHIVES_COLON, 0x02000324, extracter.Stat.NumArchives, s); - AddValuePair(IDS_FOLDERS_COLON, 0x02000321, extracter.Stat.NumFolders, s); - AddValuePair(IDS_FILES_COLON, 0x02000320, extracter.Stat.NumFiles, s); - AddSizePair(IDS_SIZE_COLON, 0x02000322, extracter.Stat.UnpackSize, s); - AddSizePair(IDS_COMPRESSED_COLON, 0x02000323, extracter.Stat.PackSize, s); - - if (options.CalcCrc) - { - wchar_t temp[16]; - ConvertUInt32ToHex(extracter.Stat.CrcSum, temp); - s += L"CRC: "; - s += temp; - s += L"\n"; - } + extracter.ProgressDialog.IconID = IDI_ICON; - s += L"\n"; - s += LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608); - - MessageBoxW(0, s, LangString(IDS_PROGRESS_TESTING, 0x02000F90), 0); - #endif - } - if (extracter.Result != S_OK) - if (!extracter.ErrorMessage.IsEmpty()) - throw extracter.ErrorMessage; + RINOK(extracter.Create(title, hwndParent)); + messageWasDisplayed = extracter.ThreadFinishedOK & + extracter.ProgressDialog.MessagesDisplayed; return extracter.Result; } diff --git a/CPP/7zip/UI/GUI/ExtractGUI.h b/CPP/7zip/UI/GUI/ExtractGUI.h index ffefabfe..b0a692f0 100755 --- a/CPP/7zip/UI/GUI/ExtractGUI.h +++ b/CPP/7zip/UI/GUI/ExtractGUI.h @@ -7,6 +7,18 @@ #include "../FileManager/ExtractCallback.h" +/* + RESULT can be S_OK, even if there are errors!!! + if RESULT == S_OK, check extractCallback->IsOK() after ExtractGUI(). + + RESULT = E_ABORT - user break. + RESULT != E_ABORT: + { + messageWasDisplayed = true - message was displayed already. + messageWasDisplayed = false - there was some internal error, so you must show error message. + } +*/ + HRESULT ExtractGUI( CCodecs *codecs, const CIntVector &formatIndices, @@ -15,6 +27,8 @@ HRESULT ExtractGUI( const NWildcard::CCensorNode &wildcardCensor, CExtractOptions &options, bool showDialog, - CExtractCallbackImp *extractCallback); + bool &messageWasDisplayed, + CExtractCallbackImp *extractCallback, + HWND hwndParent = NULL); #endif diff --git a/CPP/7zip/UI/GUI/ExtractRes.h b/CPP/7zip/UI/GUI/ExtractRes.h index 084181ea..6219edda 100755 --- a/CPP/7zip/UI/GUI/ExtractRes.h +++ b/CPP/7zip/UI/GUI/ExtractRes.h @@ -17,3 +17,13 @@ #define IDS_MEM_ERROR 105 #define IDS_UNKNOWN_ERROR 106 #define IDS_UNSUPPORTED_ARCHIVE_TYPE 107 + +#define IDC_EXTRACT_RADIO_FULL_PATHNAMES 1041 +#define IDC_EXTRACT_RADIO_CURRENT_PATHNAMES 1042 +#define IDC_EXTRACT_RADIO_NO_PATHNAMES 1043 + +#define IDC_EXTRACT_RADIO_ASK_BEFORE_OVERWRITE 1051 +#define IDC_EXTRACT_RADIO_OVERWRITE_WITHOUT_PROMPT 1052 +#define IDC_EXTRACT_RADIO_SKIP_EXISTING_FILES 1053 +#define IDC_EXTRACT_RADIO_AUTO_RENAME 1056 +#define IDC_EXTRACT_RADIO_AUTO_RENAME_EXISTING 1057 diff --git a/CPP/7zip/UI/GUI/GUI.cpp b/CPP/7zip/UI/GUI/GUI.cpp index 3a1a633e..a59e7557 100755 --- a/CPP/7zip/UI/GUI/GUI.cpp +++ b/CPP/7zip/UI/GUI/GUI.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#include <initguid.h> +#include "Common/MyInitGuid.h" #include "../../../../C/Alloc.h" @@ -11,6 +11,7 @@ #include "Common/StringConvert.h" #include "Windows/Error.h" +#include "Windows/NtCheck.h" #ifdef _WIN32 #include "Windows/MemoryLock.h" #endif @@ -30,7 +31,10 @@ using namespace NWindows; HINSTANCE g_hInstance; #ifndef _UNICODE -bool g_IsNT = false; +#endif + +#ifdef UNDER_CE +bool g_LVN_ITEMACTIVATE_Support = true; #endif static void ErrorMessage(LPCWSTR message) @@ -55,7 +59,7 @@ static int ShowSysErrorMessage(DWORD errorCode) { if (errorCode == E_OUTOFMEMORY) return ShowMemErrorMessage(); - ErrorMessage(NError::MyFormatMessageW(errorCode)); + ErrorMessage(HResultToMessage(errorCode)); return NExitCode::kFatalError; } @@ -63,12 +67,16 @@ static int Main2() { UStringVector commandStrings; NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings); - if (commandStrings.Size() <= 1) + + #ifndef UNDER_CE + if (commandStrings.Size() > 0) + commandStrings.Delete(0); + #endif + if (commandStrings.Size() == 0) { MessageBoxW(0, L"Specify command", L"7-Zip", 0); return 0; } - commandStrings.Delete(0); CArchiveCommandLineOptions options; CArchiveCommandLineParser parser; @@ -76,7 +84,7 @@ static int Main2() parser.Parse1(commandStrings, options); parser.Parse2(options); - #ifdef _WIN32 + #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES) if (options.LargePages) NSecurity::EnableLockMemoryPrivilege(); #endif @@ -114,7 +122,6 @@ static int Main2() { CExtractCallbackImp *ecs = new CExtractCallbackImp; CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs; - ecs->ProgressDialog.CompressingMode = false; #ifndef _NO_CRYPTO ecs->PasswordIsDefined = options.PasswordEnabled; @@ -135,14 +142,19 @@ static int Main2() eo.Properties = options.ExtractProperties; #endif + bool messageWasDisplayed = false; HRESULT result = ExtractGUI(codecs, formatIndices, options.ArchivePathsSorted, options.ArchivePathsFullSorted, options.WildcardCensor.Pairs.Front().Head, - eo, options.ShowDialog, ecs); + eo, options.ShowDialog, messageWasDisplayed, ecs); if (result != S_OK) + { + if (result != E_ABORT && messageWasDisplayed) + return NExitCode::kFatalError; throw CSystemException(result); - if (ecs->Messages.Size() > 0 || ecs->NumArchiveErrors != 0) + } + if (!ecs->IsOK()) return NExitCode::kFatalError; } else if (options.Command.IsFromUpdateGroup()) @@ -163,31 +175,30 @@ static int Main2() // callback.StdOutMode = options.UpdateOptions.StdOutMode; callback.Init(); - CUpdateErrorInfo errorInfo; - if (!options.UpdateOptions.Init(codecs, formatIndices, options.ArchiveName)) { ErrorLangMessage(IDS_UPDATE_NOT_SUPPORTED, 0x02000601); return NExitCode::kFatalError; } + bool messageWasDisplayed = false; HRESULT result = UpdateGUI( codecs, options.WildcardCensor, options.UpdateOptions, options.ShowDialog, - errorInfo, &callback); + messageWasDisplayed, &callback); if (result != S_OK) { - if (!errorInfo.Message.IsEmpty()) - { - ErrorMessage(errorInfo.Message); - if (result == E_FAIL) - return NExitCode::kFatalError; - } + if (result != E_ABORT && messageWasDisplayed) + return NExitCode::kFatalError; throw CSystemException(result); } if (callback.FailedFiles.Size() > 0) + { + if (!messageWasDisplayed) + throw CSystemException(E_FAIL); return NExitCode::kWarning; + } } else { @@ -196,29 +207,19 @@ static int Main2() return 0; } -static bool inline IsItWindowsNT() -{ - OSVERSIONINFO versionInfo; - versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) - return false; - return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); -} +#define NT_CHECK_FAIL_ACTION ErrorMessage(L"Unsupported Windows version"); return NExitCode::kFatalError; -int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */) -{ - g_hInstance = hInstance; - #ifdef _UNICODE - if (!IsItWindowsNT()) - { - ErrorMessage(L"This program requires Windows NT/2000/2003/2008/XP/Vista"); - return NExitCode::kFatalError; - } +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, + #ifdef UNDER_CE + LPWSTR #else - g_IsNT = IsItWindowsNT(); + LPSTR #endif - + /* lpCmdLine */, int /* nCmdShow */) +{ + g_hInstance = hInstance; #ifdef _WIN32 + NT_CHECK SetLargePageSize(); #endif diff --git a/CPP/7zip/UI/GUI/GUI.dsp b/CPP/7zip/UI/GUI/GUI.dsp index 42c83c60..16a24d40 100755 --- a/CPP/7zip/UI/GUI/GUI.dsp +++ b/CPP/7zip/UI/GUI/GUI.dsp @@ -405,14 +405,6 @@ SOURCE=.\ExtractDialog.h # End Source File # Begin Source File -SOURCE=..\FileManager\MessagesDialog.cpp -# End Source File -# Begin Source File - -SOURCE=..\FileManager\MessagesDialog.h -# End Source File -# Begin Source File - SOURCE=..\FileManager\OverwriteDialog.cpp # End Source File # Begin Source File @@ -800,9 +792,17 @@ SOURCE=..\..\..\Windows\Control\ListView.h SOURCE=..\..\..\Windows\Control\ProgressBar.h # End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Control\Static.h +# End Source File # End Group # Begin Source File +SOURCE=..\..\..\Windows\COM.h +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\CommonDialog.cpp # End Source File # Begin Source File @@ -851,6 +851,10 @@ SOURCE=..\..\..\Windows\FileIO.h # End Source File # Begin Source File +SOURCE=..\..\..\Windows\FileMapping.h +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\FileName.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp b/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp index 07c74e9b..862c96a1 100755 --- a/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp +++ b/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp @@ -2,41 +2,29 @@ #include "StdAfx.h" -#include "Common/Defs.h" #include "Common/IntToString.h" #include "Common/StringConvert.h" #include "Windows/Error.h" #include "Windows/PropVariant.h" -#include "../FileManager/MessagesDialog.h" #include "../FileManager/PasswordDialog.h" #include "UpdateCallbackGUI.h" using namespace NWindows; -CUpdateCallbackGUI::~CUpdateCallbackGUI() -{ - if (!Messages.IsEmpty()) - { - CMessagesDialog messagesDialog; - messagesDialog.Messages = &Messages; - messagesDialog.Create(ParentWindow); - } -} +CUpdateCallbackGUI::~CUpdateCallbackGUI() {} void CUpdateCallbackGUI::Init() { FailedFiles.Clear(); - Messages.Clear(); - NumArchiveErrors = 0; NumFiles = 0; } void CUpdateCallbackGUI::AddErrorMessage(LPCWSTR message) { - Messages.Add(message); + ProgressDialog->Sync.AddErrorMessage(message); } void CUpdateCallbackGUI::AddErrorMessage(const wchar_t *name, DWORD systemError) @@ -52,8 +40,7 @@ HRESULT CUpdateCallbackGUI::OpenResult(const wchar_t *name, HRESULT result) { if (result != S_OK) { - AddErrorMessage (UString(L"Error: ") + name + - UString(L" is not supported archive")); + AddErrorMessage (UString(L"Error: ") + name + UString(L" is not supported archive")); } return S_OK; } @@ -77,7 +64,7 @@ HRESULT CUpdateCallbackGUI::FinishScanning() HRESULT CUpdateCallbackGUI::StartArchive(const wchar_t *name, bool /* updating */) { - ProgressDialog.ProgressSynch.SetTitleFileName(name); + ProgressDialog->Sync.SetTitleFileName(name); return S_OK; } @@ -88,14 +75,14 @@ HRESULT CUpdateCallbackGUI::FinishArchive() HRESULT CUpdateCallbackGUI::CheckBreak() { - return ProgressDialog.ProgressSynch.ProcessStopAndPause(); + return ProgressDialog->Sync.ProcessStopAndPause(); } HRESULT CUpdateCallbackGUI::ScanProgress(UInt64 /* numFolders */, UInt64 numFiles, const wchar_t *path) { - ProgressDialog.ProgressSynch.SetCurrentFileName(path); - ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles); - return ProgressDialog.ProgressSynch.ProcessStopAndPause(); + ProgressDialog->Sync.SetCurrentFileName(path); + ProgressDialog->Sync.SetNumFilesTotal(numFiles); + return ProgressDialog->Sync.ProcessStopAndPause(); } HRESULT CUpdateCallbackGUI::Finilize() @@ -105,13 +92,13 @@ HRESULT CUpdateCallbackGUI::Finilize() HRESULT CUpdateCallbackGUI::SetNumFiles(UInt64 numFiles) { - ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles); + ProgressDialog->Sync.SetNumFilesTotal(numFiles); return S_OK; } HRESULT CUpdateCallbackGUI::SetTotal(UInt64 total) { - ProgressDialog.ProgressSynch.SetProgress(total, 0); + ProgressDialog->Sync.SetProgress(total, 0); return S_OK; } @@ -119,20 +106,20 @@ HRESULT CUpdateCallbackGUI::SetCompleted(const UInt64 *completeValue) { RINOK(CheckBreak()); if (completeValue != NULL) - ProgressDialog.ProgressSynch.SetPos(*completeValue); + ProgressDialog->Sync.SetPos(*completeValue); return S_OK; } HRESULT CUpdateCallbackGUI::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) { RINOK(CheckBreak()); - ProgressDialog.ProgressSynch.SetRatioInfo(inSize, outSize); + ProgressDialog->Sync.SetRatioInfo(inSize, outSize); return S_OK; } HRESULT CUpdateCallbackGUI::GetStream(const wchar_t *name, bool /* isAnti */) { - ProgressDialog.ProgressSynch.SetCurrentFileName(name); + ProgressDialog->Sync.SetCurrentFileName(name); return S_OK; } @@ -150,7 +137,7 @@ HRESULT CUpdateCallbackGUI::OpenFileError(const wchar_t *name, DWORD systemError HRESULT CUpdateCallbackGUI::SetOperationResult(Int32 /* operationResult */) { NumFiles++; - ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles); + ProgressDialog->Sync.SetNumFilesCur(NumFiles); return S_OK; } @@ -159,38 +146,31 @@ HRESULT CUpdateCallbackGUI::CryptoGetTextPassword2(Int32 *passwordIsDefined, BST *password = NULL; if (!PasswordIsDefined) { - if (AskPassword) + if (passwordIsDefined == 0 || AskPassword) { CPasswordDialog dialog; - if (dialog.Create(ProgressDialog) == IDCANCEL) + ProgressDialog->WaitCreating(); + if (dialog.Create(*ProgressDialog) == IDCANCEL) return E_ABORT; Password = dialog.Password; PasswordIsDefined = true; } } - *passwordIsDefined = BoolToInt(PasswordIsDefined); + if (passwordIsDefined != 0) + *passwordIsDefined = BoolToInt(PasswordIsDefined); return StringToBstr(Password, password); } HRESULT CUpdateCallbackGUI::CryptoGetTextPassword(BSTR *password) { - *password = NULL; - if (!PasswordIsDefined) - { - CPasswordDialog dialog; - if (dialog.Create(ProgressDialog) == IDCANCEL) - return E_ABORT; - Password = dialog.Password; - PasswordIsDefined = true; - } - return StringToBstr(Password, password); + return CryptoGetTextPassword2(NULL, password); } /* It doesn't work, since main stream waits Dialog HRESULT CUpdateCallbackGUI::CloseProgress() { - ProgressDialog.MyClose(); + ProgressDialog->MyClose(); return S_OK; }; */ @@ -198,18 +178,18 @@ HRESULT CUpdateCallbackGUI::CloseProgress() HRESULT CUpdateCallbackGUI::Open_CheckBreak() { - return ProgressDialog.ProgressSynch.ProcessStopAndPause(); + return ProgressDialog->Sync.ProcessStopAndPause(); } HRESULT CUpdateCallbackGUI::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) { - // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles); + // if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesTotal(*numFiles); return S_OK; } HRESULT CUpdateCallbackGUI::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) { - return ProgressDialog.ProgressSynch.ProcessStopAndPause(); + return ProgressDialog->Sync.ProcessStopAndPause(); } #ifndef _NO_CRYPTO @@ -217,15 +197,7 @@ HRESULT CUpdateCallbackGUI::Open_SetCompleted(const UInt64 * /* numFiles */, con HRESULT CUpdateCallbackGUI::Open_CryptoGetTextPassword(BSTR *password) { PasswordWasAsked = true; - if (!PasswordIsDefined) - { - CPasswordDialog dialog; - if (dialog.Create(ProgressDialog) == IDCANCEL) - return E_ABORT; - Password = dialog.Password; - PasswordIsDefined = true; - } - return StringToBstr(Password, password); + return CryptoGetTextPassword2(NULL, password); } HRESULT CUpdateCallbackGUI::Open_GetPasswordIfAny(UString &password) @@ -248,7 +220,7 @@ void CUpdateCallbackGUI::Open_ClearPasswordWasAskedFlag() /* HRESULT CUpdateCallbackGUI::ShowDeleteFile(const wchar_t *name) { - ProgressDialog.ProgressSynch.SetCurrentFileName(name); + ProgressDialog->Sync.SetCurrentFileName(name); return S_OK; } */ diff --git a/CPP/7zip/UI/GUI/UpdateCallbackGUI.h b/CPP/7zip/UI/GUI/UpdateCallbackGUI.h index 1f8b70e0..b5ca154a 100755 --- a/CPP/7zip/UI/GUI/UpdateCallbackGUI.h +++ b/CPP/7zip/UI/GUI/UpdateCallbackGUI.h @@ -12,7 +12,6 @@ class CUpdateCallbackGUI: public IUpdateCallbackUI2 { public: - // bool StdOutMode; bool PasswordIsDefined; UString Password; bool AskPassword; @@ -22,9 +21,7 @@ public: CUpdateCallbackGUI(): PasswordIsDefined(false), PasswordWasAsked(false), - AskPassword(false), - // StdOutMode(false) - ParentWindow(0) + AskPassword(false) {} ~CUpdateCallbackGUI(); @@ -33,19 +30,10 @@ public: INTERFACE_IUpdateCallbackUI2(;) INTERFACE_IOpenCallbackUI(;) - // HRESULT CloseProgress(); - UStringVector FailedFiles; - CProgressDialog ProgressDialog; - HWND ParentWindow; - void StartProgressDialog(const UString &title) - { - ProgressDialog.Create(title, ParentWindow); - } + CProgressDialog *ProgressDialog; - UStringVector Messages; - int NumArchiveErrors; void AddErrorMessage(LPCWSTR message); void AddErrorMessage(const wchar_t *name, DWORD systemError); }; diff --git a/CPP/7zip/UI/GUI/UpdateGUI.cpp b/CPP/7zip/UI/GUI/UpdateGUI.cpp index 2d4dbbc2..ed6cae54 100755 --- a/CPP/7zip/UI/GUI/UpdateGUI.cpp +++ b/CPP/7zip/UI/GUI/UpdateGUI.cpp @@ -16,12 +16,15 @@ #include "../Explorer/MyMessages.h" +#include "../FileManager/LangUtils.h" +#include "../FileManager/ProgramLocation.h" #include "../FileManager/StringUtils.h" +#include "../FileManager/resourceGui.h" #include "CompressDialog.h" #include "UpdateGUI.h" -#include "resource.h" +#include "resource2.h" using namespace NWindows; using namespace NFile; @@ -29,51 +32,31 @@ using namespace NFile; static const wchar_t *kDefaultSfxModule = L"7z.sfx"; static const wchar_t *kSFXExtension = L"exe"; -struct CThreadUpdating +extern void AddMessageToString(UString &dest, const UString &src); + +UString HResultToMessage(HRESULT errorCode); + +class CThreadUpdating: public CProgressThreadVirt { + HRESULT ProcessVirt(); +public: CCodecs *codecs; - CUpdateCallbackGUI *UpdateCallbackGUI; const NWildcard::CCensor *WildcardCensor; CUpdateOptions *Options; - - CUpdateErrorInfo *ErrorInfo; - HRESULT Result; - - DWORD Process() - { - UpdateCallbackGUI->ProgressDialog.WaitCreating(); - try - { - Result = UpdateArchive(codecs, *WildcardCensor, *Options, - *ErrorInfo, UpdateCallbackGUI, UpdateCallbackGUI); - } - catch(const UString &s) - { - ErrorInfo->Message = s; - Result = E_FAIL; - } - catch(const wchar_t *s) - { - ErrorInfo->Message = s; - Result = E_FAIL; - } - catch(const char *s) - { - ErrorInfo->Message = GetUnicodeString(s); - Result = E_FAIL; - } - catch(...) - { - Result = E_FAIL; - } - UpdateCallbackGUI->ProgressDialog.MyClose(); - return 0; - } - static THREAD_FUNC_DECL MyThreadFunction(void *param) - { - return ((CThreadUpdating *)param)->Process(); - } +}; + +HRESULT CThreadUpdating::ProcessVirt() +{ + CUpdateErrorInfo ei; + HRESULT res = UpdateArchive(codecs, *WildcardCensor, *Options, + ei, UpdateCallbackGUI, UpdateCallbackGUI); + ErrorMessage = ei.Message; + ErrorPath1 = ei.FileName; + ErrorPath2 = ei.FileName2; + if (ei.SystemError != S_OK && ei.SystemError != E_FAIL && ei.SystemError != E_ABORT) + return ei.SystemError; + return res; }; static void AddProp(CObjectVector<CProperty> &properties, const UString &name, const UString &value) @@ -210,19 +193,22 @@ static void SetOutProperties( static HRESULT ShowDialog( CCodecs *codecs, const NWildcard::CCensor &censor, - CUpdateOptions &options, CUpdateCallbackGUI *callback) + CUpdateOptions &options, CUpdateCallbackGUI *callback, HWND hwndParent) { if (options.Commands.Size() != 1) throw "It must be one command"; UString currentDirPrefix; + #ifndef UNDER_CE { if (!NDirectory::MyGetCurrentDirectory(currentDirPrefix)) return E_FAIL; NName::NormalizeDirPathPrefix(currentDirPrefix); } + #endif bool oneFile = false; NFind::CFileInfoW fileInfo; + UString name; if (censor.Pairs.Size() > 0) { const NWildcard::CPair &pair = censor.Pairs[0]; @@ -231,7 +217,7 @@ static HRESULT ShowDialog( const NWildcard::CItem &item = pair.Head.IncludeItems[0]; if (item.ForFile) { - UString name = pair.Prefix; + name = pair.Prefix; for (int i = 0; i < item.PathParts.Size(); i++) { if (i > 0) @@ -249,13 +235,17 @@ static HRESULT ShowDialog( CCompressDialog dialog; NCompressDialog::CInfo &di = dialog.Info; - for(int i = 0; i < codecs->Formats.Size(); i++) + dialog.ArcFormats = &codecs->Formats; + for (int i = 0; i < codecs->Formats.Size(); i++) { const CArcInfoEx &ai = codecs->Formats[i]; + if (ai.Name.CompareNoCase(L"swfc") == 0) + if (!oneFile || name.Right(4).CompareNoCase(L".swf") != 0) + continue; if (ai.UpdateEnabled && (oneFile || !ai.KeepName)) - dialog.m_ArchiverInfoList.Add(ai); + dialog.ArcIndices.Add(i); } - if(dialog.m_ArchiverInfoList.Size() == 0) + if (dialog.ArcIndices.Size() == 0) { ShowErrorMessage(L"No Update Engines"); return E_FAIL; @@ -263,7 +253,7 @@ static HRESULT ShowDialog( // di.ArchiveName = options.ArchivePath.GetFinalPath(); di.ArchiveName = options.ArchivePath.GetPathWithoutExt(); - dialog.OriginalFileName = fileInfo.Name; + dialog.OriginalFileName = options.ArchivePath.Prefix + fileInfo.Name; di.CurrentDirPrefix = currentDirPrefix; di.SFXMode = options.SfxMode; @@ -274,7 +264,7 @@ static HRESULT ShowDialog( di.KeepName = !oneFile; - if(dialog.Create(0) != IDOK) + if (dialog.Create(hwndParent) != IDOK) return E_ABORT; options.VolumesSizes = di.VolumeSizes; @@ -305,7 +295,7 @@ static HRESULT ShowDialog( default: throw 1091756; } - const CArcInfoEx &archiverInfo = dialog.m_ArchiverInfoList[di.ArchiverInfoIndex]; + const CArcInfoEx &archiverInfo = codecs->Formats[di.FormatIndex]; callback->PasswordIsDefined = (!di.Password.IsEmpty()); if (callback->PasswordIsDefined) callback->Password = di.Password; @@ -334,17 +324,17 @@ static HRESULT ShowDialog( if (di.SFXMode) options.SfxMode = true; - options.MethodMode.FormatIndex = archiverInfo.FormatIndex; + options.MethodMode.FormatIndex = di.FormatIndex; options.ArchivePath.VolExtension = archiverInfo.GetMainExt(); - if(di.SFXMode) + if (di.SFXMode) options.ArchivePath.BaseExtension = kSFXExtension; else options.ArchivePath.BaseExtension = options.ArchivePath.VolExtension; options.ArchivePath.ParseFromPath(di.ArchiveName); NWorkDir::CInfo workDirInfo; - ReadWorkDirInfo(workDirInfo); + workDirInfo.Load(); options.WorkingDir.Empty(); if (workDirInfo.Mode != NWorkDir::NMode::kCurrent) { @@ -361,29 +351,49 @@ HRESULT UpdateGUI( const NWildcard::CCensor &censor, CUpdateOptions &options, bool showDialog, - CUpdateErrorInfo &errorInfo, - CUpdateCallbackGUI *callback) + bool &messageWasDisplayed, + CUpdateCallbackGUI *callback, + HWND hwndParent) { + messageWasDisplayed = false; if (showDialog) { - RINOK(ShowDialog(codecs, censor, options, callback)); + RINOK(ShowDialog(codecs, censor, options, callback, hwndParent)); } if (options.SfxMode && options.SfxModule.IsEmpty()) - options.SfxModule = kDefaultSfxModule; + { + UString folder; + if (!GetProgramFolderPath(folder)) + folder.Empty(); + options.SfxModule = folder + kDefaultSfxModule; + } CThreadUpdating tu; tu.codecs = codecs; tu.UpdateCallbackGUI = callback; + tu.UpdateCallbackGUI->ProgressDialog = &tu.ProgressDialog; tu.UpdateCallbackGUI->Init(); + UString title = LangString(IDS_PROGRESS_COMPRESSING, 0x02000DC0); + + /* + if (hwndParent != 0) + { + tu.ProgressDialog.MainWindow = hwndParent; + // tu.ProgressDialog.MainTitle = fileName; + tu.ProgressDialog.MainAddTitle = title + L" "; + } + */ + tu.WildcardCensor = &censor; tu.Options = &options; - tu.ErrorInfo = &errorInfo; + tu.ProgressDialog.IconID = IDI_ICON; + + RINOK(tu.Create(title, hwndParent)); - NWindows::CThread thread; - RINOK(thread.Create(CThreadUpdating::MyThreadFunction, &tu)) - tu.UpdateCallbackGUI->StartProgressDialog(LangString(IDS_PROGRESS_COMPRESSING, 0x02000DC0)); + messageWasDisplayed = tu.ThreadFinishedOK & + tu.ProgressDialog.MessagesDisplayed; return tu.Result; } diff --git a/CPP/7zip/UI/GUI/UpdateGUI.h b/CPP/7zip/UI/GUI/UpdateGUI.h index 112eff0f..c06ec1e7 100755 --- a/CPP/7zip/UI/GUI/UpdateGUI.h +++ b/CPP/7zip/UI/GUI/UpdateGUI.h @@ -4,16 +4,28 @@ #define __UPDATE_GUI_H #include "../Common/Update.h" + #include "UpdateCallbackGUI.h" -#include "../FileManager/UpdateCallback100.h" +/* + callback->FailedFiles contains names of files for that there were problems. + RESULT can be S_OK, even if there are such warnings!!! + + RESULT = E_ABORT - user break. + RESULT != E_ABORT: + { + messageWasDisplayed = true - message was displayed already. + messageWasDisplayed = false - there was some internal error, so you must show error message. + } +*/ HRESULT UpdateGUI( CCodecs *codecs, const NWildcard::CCensor &censor, CUpdateOptions &options, bool showDialog, - CUpdateErrorInfo &errorInfo, - CUpdateCallbackGUI *callback); + bool &messageWasDisplayed, + CUpdateCallbackGUI *callback, + HWND hwndParent = NULL); #endif diff --git a/CPP/7zip/UI/GUI/makefile b/CPP/7zip/UI/GUI/makefile index 233e2ee2..a3763cbf 100755 --- a/CPP/7zip/UI/GUI/makefile +++ b/CPP/7zip/UI/GUI/makefile @@ -1,14 +1,17 @@ PROG = 7zG.exe -LIBS = $(LIBS) user32.lib advapi32.lib oleaut32.lib shell32.lib comctl32.lib htmlhelp.lib ole32.lib comdlg32.lib CFLAGS = $(CFLAGS) -I ../../../ \ -DLANG \ -DCOMPRESS_MT \ - -DWIN_LONG_PATH \ -DEXTERNAL_LZMA \ -DEXTERNAL_CODECS \ -DBENCH_MT \ - -D_7ZIP_LARGE_PAGES \ - -DSUPPORT_DEVICE_FILE \ + +!IFDEF UNDER_CE +LIBS = $(LIBS) ceshell.lib Commctrl.lib +!ELSE +LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib +CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -DSUPPORT_DEVICE_FILE -D_7ZIP_LARGE_PAGES +!ENDIF GUI_OBJS = \ $O\BenchmarkDialog.obj \ @@ -102,11 +105,16 @@ FM_OBJS = \ $O\RegistryUtils.obj \ $O\SplitUtils.obj \ $O\StringUtils.obj \ - $O\MessagesDialog.obj \ $O\OverwriteDialog.obj \ $O\PasswordDialog.obj \ $O\ProgressDialog2.obj \ +!IFDEF UNDER_CE +FM_OBJS = $(FM_OBJS) \ + $O\BrowseDialog.obj \ + $O\SysIconUtils.obj \ +!ENDIF + C_OBJS = \ $O\Alloc.obj \ $O\Threads.obj \ diff --git a/CPP/7zip/UI/GUI/resource.h b/CPP/7zip/UI/GUI/resource.h deleted file mode 100755 index e154e035..00000000 --- a/CPP/7zip/UI/GUI/resource.h +++ /dev/null @@ -1,49 +0,0 @@ -#define IDS_CONTEXT_EXTRACT 142 -#define IDS_CONTEXT_EXTRACT_HELP 143 -#define IDS_CONTEXT_COMPRESS 144 -#define IDS_CONTEXT_COMPRESS_HELP 145 -#define IDS_CONTEXT_OPEN 146 -#define IDS_CONTEXT_OPEN_HELP 147 -#define IDS_CONTEXT_TEST 148 -#define IDS_CONTEXT_TEST_HELP 149 -#define IDS_CONTEXT_CAPTION_HELP 150 -#define IDS_CONTEXT_POPUP_CAPTION 151 -#define IDS_OPEN_TYPE_ALL_FILES 80 - -#define IDS_METHOD_STORE 81 -#define IDS_METHOD_NORMAL 82 -#define IDS_METHOD_MAXIMUM 83 -#define IDS_METHOD_FAST 84 -#define IDS_METHOD_FASTEST 85 -#define IDS_METHOD_ULTRA 86 - -#define IDS_COMPRESS_NON_SOLID 88 -#define IDS_COMPRESS_SOLID 89 - -#define IDS_COMPRESS_UPDATE_MODE_ADD 90 -#define IDS_COMPRESS_UPDATE_MODE_UPDATE 91 -#define IDS_COMPRESS_UPDATE_MODE_FRESH 92 -#define IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE 93 - -#define IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE 94 -#define IDS_COMPRESS_INCORRECT_VOLUME_SIZE 95 - -#define IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE 96 -#define IDS_CANT_UPDATE_ARCHIVE 97 - -#define IDS_PROGRESS_COMPRESSING 98 -#define IDS_PROGRESS_TESTING 99 -#define IDS_ERROR 100 -#define IDS_MESSAGE_NO_ERRORS 101 -#define IDS_CONFIG_DIALOG_CAPTION 102 - -#define IDS_PASSWORD_USE_ASCII 110 -#define IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH 111 -#define IDS_PASSWORD_IS_TOO_LONG 112 - -#define IDS_FILES_COLON 2274 -#define IDS_FOLDERS_COLON 2275 -#define IDS_SIZE_COLON 2276 -#define IDS_COMPRESSED_COLON 2277 -#define IDS_ARCHIVES_COLON 2278 - diff --git a/CPP/7zip/UI/GUI/resource.rc b/CPP/7zip/UI/GUI/resource.rc index 7782e178..bfc2029b 100755 --- a/CPP/7zip/UI/GUI/resource.rc +++ b/CPP/7zip/UI/GUI/resource.rc @@ -1,68 +1,21 @@ #include "../../MyVersionInfo.rc" #include <winnt.h> -#include "resource.h" + +#include "resource2.rc" +#include "../FileManager/resourceGui.rc" MY_VERSION_INFO_APP("7-Zip GUI", "7zg") -IDI_ICON1 ICON "FM.ico" +IDI_ICON ICON "FM.ico" +#ifndef UNDER_CE 1 24 MOVEABLE PURE "7zG.exe.manifest" +#endif -STRINGTABLE -BEGIN - IDS_CONTEXT_EXTRACT "Extract files..." - IDS_CONTEXT_EXTRACT_HELP "Extracts files from the selected archive." - IDS_CONTEXT_COMPRESS "Add to archive..." - IDS_CONTEXT_COMPRESS_HELP "Adds the selected items to archive." - IDS_CONTEXT_OPEN "Open" - IDS_CONTEXT_OPEN_HELP "Opens the selected archive." - IDS_CONTEXT_TEST "Test archive" - IDS_CONTEXT_TEST_HELP "Tests integrity of the selected archive." - IDS_CONTEXT_CAPTION_HELP "7-Zip commands" - IDS_CONTEXT_POPUP_CAPTION "7-Zip" - IDS_OPEN_TYPE_ALL_FILES "All Files" - IDS_METHOD_STORE "Store" - IDS_METHOD_NORMAL "Normal" - IDS_METHOD_MAXIMUM "Maximum" - IDS_METHOD_FAST "Fast" - IDS_METHOD_FASTEST "Fastest" - IDS_METHOD_ULTRA "Ultra" - IDS_COMPRESS_NON_SOLID "Non-solid" - IDS_COMPRESS_SOLID "Solid" - - IDS_COMPRESS_UPDATE_MODE_ADD "Add and replace files" - IDS_COMPRESS_UPDATE_MODE_UPDATE "Update and add files" - IDS_COMPRESS_UPDATE_MODE_FRESH "Freshen existing files" - IDS_COMPRESS_UPDATE_MODE_SYNCHRONIZE "Synchronize files" - IDS_COMPRESS_SET_ARCHIVE_DIALOG_TITLE "Browse" - IDS_COMPRESS_INCORRECT_VOLUME_SIZE "Incorrect volume size" - IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE "Specified volume size: {0} bytes.\nAre you sure you want to split archive into such volumes?" - - IDS_PASSWORD_USE_ASCII "Use only English letters, numbers and special characters (!, #, $, ...) for password." - IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH "Passwords do not match" - IDS_PASSWORD_IS_TOO_LONG "Password is too long" - - IDS_CANT_UPDATE_ARCHIVE "Can not update archive '{0}'" - IDS_PROGRESS_COMPRESSING "Compressing" - IDS_PROGRESS_TESTING "Testing" - IDS_ERROR "Error" - IDS_MESSAGE_NO_ERRORS "There are no errors" - IDS_CONFIG_DIALOG_CAPTION "7-Zip Options" - - IDS_FILES_COLON "Files:" - IDS_FOLDERS_COLON "Folders:" - IDS_SIZE_COLON "Size:" - IDS_COMPRESSED_COLON "Compressed size:" - IDS_ARCHIVES_COLON "Archives:" - -END - +#ifdef UNDER_CE #include "../FileManager/PropertyName.rc" +#endif #include "../FileManager/OverwriteDialog.rc" #include "../FileManager/PasswordDialog.rc" -#include "../FileManager/MessagesDialog.rc" #include "../FileManager/ProgressDialog2.rc" #include "Extract.rc" -#include "ExtractDialog.rc" -#include "CompressDialog.rc" -#include "BenchmarkDialog.rc" diff --git a/CPP/7zip/UI/GUI/resource2.h b/CPP/7zip/UI/GUI/resource2.h new file mode 100755 index 00000000..4f8b1573 --- /dev/null +++ b/CPP/7zip/UI/GUI/resource2.h @@ -0,0 +1,3 @@ +#define IDS_COMPRESSED_COLON 2277 +#define IDS_ARCHIVES_COLON 2278 +#define IDS_PROGRESS_COMPRESSING 98 diff --git a/CPP/7zip/UI/GUI/resource2.rc b/CPP/7zip/UI/GUI/resource2.rc new file mode 100755 index 00000000..542717ee --- /dev/null +++ b/CPP/7zip/UI/GUI/resource2.rc @@ -0,0 +1,11 @@ +#include "ExtractDialog.rc" +#include "CompressDialog.rc" +#include "BenchmarkDialog.rc" +#include "resource2.h" + +STRINGTABLE +BEGIN + IDS_COMPRESSED_COLON "Compressed size:" + IDS_ARCHIVES_COLON "Archives:" + IDS_PROGRESS_COMPRESSING "Compressing" +END diff --git a/CPP/7zip/makefile b/CPP/7zip/makefile index dcdabb5d..fde715a4 100755 --- a/CPP/7zip/makefile +++ b/CPP/7zip/makefile @@ -1,6 +1,7 @@ DIRS = \ UI\~ \ Bundles\~ \ + Compress\~ \ all: $(DIRS) @@ -8,4 +9,3 @@ $(DIRS): cd $(@D) $(MAKE) -nologo cd .. - diff --git a/CPP/Build.mak b/CPP/Build.mak index 9d4ac524..3356b8e5 100755 --- a/CPP/Build.mak +++ b/CPP/Build.mak @@ -1,3 +1,5 @@ +LIBS = $(LIBS) oleaut32.lib ole32.lib + !IFDEF CPU !IFNDEF NO_BUFFEROVERFLOWU LIBS = $(LIBS) bufferoverflowU.lib @@ -21,9 +23,22 @@ MY_ML = ml64 !ENDIF !ENDIF + +!IFDEF UNDER_CE +RFLAGS = $(RFLAGS) -dUNDER_CE +!IFDEF MY_CONSOLE +LFLAGS = $(LFLAGS) /ENTRY:mainACRTStartup +!ENDIF +!ELSE +LFLAGS = $(LFLAGS) -OPT:NOWIN98 +CFLAGS = $(CFLAGS) -Gr +LIBS = $(LIBS) user32.lib advapi32.lib shell32.lib +!ENDIF + + COMPL_ASM = $(MY_ML) -c -Fo$O/ $** -CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -WX -EHsc -Gr -Gy -GR- +CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -WX -EHsc -Gy -GR- !IFDEF MY_STATIC_LINK !IFNDEF MY_SINGLE_THREAD @@ -42,7 +57,7 @@ CFLAGS = $(CFLAGS) -W3 CFLAGS_O1 = $(CFLAGS) -O1 CFLAGS_O2 = $(CFLAGS) -O2 -LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98 -OPT:REF -OPT:ICF +LFLAGS = $(LFLAGS) -nologo -OPT:REF -OPT:ICF !IFDEF DEF_FILE LFLAGS = $(LFLAGS) -DLL -DEF:$(DEF_FILE) @@ -50,10 +65,10 @@ LFLAGS = $(LFLAGS) -DLL -DEF:$(DEF_FILE) PROGPATH = $O\$(PROG) -COMPL_O1 = $(CPP) $(CFLAGS_O1) $** -COMPL_O2 = $(CPP) $(CFLAGS_O2) $** -COMPL_PCH = $(CPP) $(CFLAGS_O1) -Yc"StdAfx.h" -Fp$O/a.pch $** -COMPL = $(CPP) $(CFLAGS_O1) -Yu"StdAfx.h" -Fp$O/a.pch $** +COMPL_O1 = $(CC) $(CFLAGS_O1) $** +COMPL_O2 = $(CC) $(CFLAGS_O2) $** +COMPL_PCH = $(CC) $(CFLAGS_O1) -Yc"StdAfx.h" -Fp$O/a.pch $** +COMPL = $(CC) $(CFLAGS_O1) -Yu"StdAfx.h" -Fp$O/a.pch $** all: $(PROGPATH) @@ -65,7 +80,10 @@ $O: $(PROGPATH): $O $(OBJS) $(DEF_FILE) link $(LFLAGS) -out:$(PROGPATH) $(OBJS) $(LIBS) + +!IFNDEF NO_DEFAULT_RES $O\resource.res: $(*B).rc - rc -fo$@ $** + rc $(RFLAGS) -fo$@ $** +!ENDIF $O\StdAfx.obj: $(*B).cpp $(COMPL_PCH) diff --git a/CPP/Common/Buffer.h b/CPP/Common/Buffer.h index b6960fa8..118fe11f 100755 --- a/CPP/Common/Buffer.h +++ b/CPP/Common/Buffer.h @@ -19,7 +19,7 @@ public: } CBuffer(): _capacity(0), _items(0) {}; CBuffer(const CBuffer &buffer): _capacity(0), _items(0) { *this = buffer; } - CBuffer(size_t size): _items(0), _capacity(0) { SetCapacity(size); } + CBuffer(size_t size): _items(0), _capacity(0) { SetCapacity(size); } virtual ~CBuffer() { delete []_items; } operator T *() { return _items; }; operator const T *() const { return _items; }; diff --git a/CPP/Common/MyGuidDef.h b/CPP/Common/MyGuidDef.h index 7cfaba0c..337884f6 100755 --- a/CPP/Common/MyGuidDef.h +++ b/CPP/Common/MyGuidDef.h @@ -47,7 +47,7 @@ inline int operator!=(REFGUID g1, REFGUID g2) { return !(g1 == g2); } #ifdef INITGUID #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - MY_EXTERN_C const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } + MY_EXTERN_C const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } #else #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ MY_EXTERN_C const GUID name diff --git a/CPP/Common/MyInitGuid.h b/CPP/Common/MyInitGuid.h index 4fc15565..d6a48698 100755 --- a/CPP/Common/MyInitGuid.h +++ b/CPP/Common/MyInitGuid.h @@ -1,10 +1,17 @@ // Common/MyInitGuid.h -#ifndef __COMMON_MYINITGUID_H -#define __COMMON_MYINITGUID_H +#ifndef __COMMON_MY_INITGUID_H +#define __COMMON_MY_INITGUID_H #ifdef _WIN32 +#ifdef UNDER_CE +#include <basetyps.h> +#endif #include <initguid.h> +#ifdef UNDER_CE +DEFINE_GUID(IID_IUnknown, +0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46); +#endif #else #define INITGUID #include "MyGuidDef.h" diff --git a/CPP/Common/MyString.cpp b/CPP/Common/MyString.cpp index 2c02e822..3d1ce2b8 100755 --- a/CPP/Common/MyString.cpp +++ b/CPP/Common/MyString.cpp @@ -96,7 +96,7 @@ int MyStringCollate(const wchar_t *s1, const wchar_t *s2) #endif } -#ifndef _WIN32_WCE +#ifndef UNDER_CE int MyStringCollate(const char *s1, const char *s2) { return ConvertCompareResult(CompareStringA( diff --git a/CPP/Common/MyString.h b/CPP/Common/MyString.h index bae239da..e8830092 100755 --- a/CPP/Common/MyString.h +++ b/CPP/Common/MyString.h @@ -4,7 +4,6 @@ #define __COMMON_STRING_H #include <string.h> -// #include <wchar.h> #include "MyVector.h" @@ -39,13 +38,15 @@ inline const wchar_t* MyStringGetPrevCharPointer(const wchar_t *, const wchar_t #ifdef _WIN32 -inline char* MyStringGetNextCharPointer(char *p) - { return CharNextA(p); } inline const char* MyStringGetNextCharPointer(const char *p) - { return CharNextA(p); } +{ + #ifdef UNDER_CE + return p + 1; + #else + return CharNextA(p); + #endif +} -inline char* MyStringGetPrevCharPointer(char *base, char *p) - { return CharPrevA(base, p); } inline const char* MyStringGetPrevCharPointer(const char *base, const char *p) { return CharPrevA(base, p); } @@ -58,8 +59,6 @@ inline wchar_t MyCharUpper(wchar_t c) wchar_t MyCharUpper(wchar_t c); #endif -inline char MyCharLower(char c) - { return (char)(unsigned int)(UINT_PTR)CharLowerA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); } #ifdef _UNICODE inline wchar_t MyCharLower(wchar_t c) { return (wchar_t)(unsigned int)(UINT_PTR)CharLowerW((LPWSTR)(UINT_PTR)(unsigned int)c); } @@ -67,6 +66,13 @@ inline wchar_t MyCharLower(wchar_t c) wchar_t MyCharLower(wchar_t c); #endif +inline char MyCharLower(char c) +#ifdef UNDER_CE + { return (char)MyCharLower((wchar_t)c); } +#else + { return (char)(unsigned int)(UINT_PTR)CharLowerA((LPSTR)(UINT_PTR)(unsigned int)(unsigned char)c); } +#endif + inline char * MyStringUpper(char *s) { return CharUpperA(s); } #ifdef _UNICODE inline wchar_t * MyStringUpper(wchar_t *s) { return CharUpperW(s); } @@ -89,7 +95,7 @@ wchar_t MyCharUpper(wchar_t c); // Compare /* -#ifndef _WIN32_WCE +#ifndef UNDER_CE int MyStringCollate(const char *s1, const char *s2); int MyStringCollateNoCase(const char *s1, const char *s2); #endif @@ -148,12 +154,8 @@ class CStringBase MoveItems(index + size, index); } - static T *GetNextCharPointer(T *p) - { return MyStringGetNextCharPointer(p); } static const T *GetNextCharPointer(const T *p) { return MyStringGetNextCharPointer(p); } - static T *GetPrevCharPointer(T *base, T *p) - { return MyStringGetPrevCharPointer(base, p); } static const T *GetPrevCharPointer(const T *base, const T *p) { return MyStringGetPrevCharPointer(base, p); } protected: @@ -168,10 +170,8 @@ protected: return; /* const int kMaxStringSize = 0x20000000; - #ifndef _WIN32_WCE if (newCapacity > kMaxStringSize || newCapacity < _length) throw 1052337; - #endif */ T *newBuffer = new T[realCapacity]; if (_capacity > 0) @@ -234,6 +234,8 @@ public: operator const T*() const { return _chars;} + T Back() const { return _chars[_length - 1]; } + // The minimum size of the character buffer in characters. // This value does not include space for a null terminator. T* GetBuffer(int minBufLength) @@ -246,10 +248,8 @@ public: void ReleaseBuffer(int newLength) { /* - #ifndef _WIN32_WCE if (newLength >= _capacity) throw 282217; - #endif */ _chars[newLength] = 0; _length = newLength; @@ -316,7 +316,7 @@ public: CStringBase Mid(int startIndex) const { return Mid(startIndex, _length - startIndex); } - CStringBase Mid(int startIndex, int count ) const + CStringBase Mid(int startIndex, int count) const { if (startIndex + count > _length) count = _length - startIndex; @@ -369,7 +369,7 @@ public: int Find(T c) const { return Find(c, 0); } int Find(T c, int startIndex) const { - T *p = _chars + startIndex; + const T *p = _chars + startIndex; for (;;) { if (*p == c) @@ -399,7 +399,7 @@ public: { if (_length == 0) return -1; - T *p = _chars + _length - 1; + const T *p = _chars + _length - 1; for (;;) { if (*p == c) @@ -530,7 +530,7 @@ public: } return number; } - int Delete(int index, int count = 1 ) + int Delete(int index, int count = 1) { if (index + count > _length) count = _length - index; @@ -541,6 +541,7 @@ public: } return _length; } + void DeleteBack() { Delete(_length - 1); } }; template <class T> diff --git a/CPP/Common/MyUnknown.h b/CPP/Common/MyUnknown.h index 136145a7..e9e8666b 100755 --- a/CPP/Common/MyUnknown.h +++ b/CPP/Common/MyUnknown.h @@ -1,22 +1,11 @@ // MyUnknown.h -#ifndef __MYUNKNOWN_H -#define __MYUNKNOWN_H +#ifndef __MY_UNKNOWN_H +#define __MY_UNKNOWN_H #ifdef _WIN32 - -#ifdef _WIN32_WCE -#if (_WIN32_WCE > 300) -#include <basetyps.h> -#else -#define MIDL_INTERFACE(x) struct -#endif -#else #include <basetyps.h> -#endif - #include <unknwn.h> - #else #include "MyWindows.h" #endif diff --git a/CPP/Common/Random.cpp b/CPP/Common/Random.cpp index 9519987e..4bd3fcf9 100755 --- a/CPP/Common/Random.cpp +++ b/CPP/Common/Random.cpp @@ -2,16 +2,25 @@ #include "StdAfx.h" -#include <time.h> #include <stdlib.h> +#ifndef _WIN32 +#include <time.h> +#endif + #include "Random.h" -void CRandom::Init(unsigned int seed) - { srand(seed); } +void CRandom::Init(unsigned int seed) { srand(seed); } void CRandom::Init() - { Init((unsigned int)time(NULL)); } +{ + Init((unsigned int) + #ifdef _WIN32 + GetTickCount() + #else + time(NULL) + #endif + ); +} -int CRandom::Generate() const - { return rand(); } +int CRandom::Generate() const { return rand(); } diff --git a/CPP/Common/StringConvert.cpp b/CPP/Common/StringConvert.cpp index 9bd47deb..681895b7 100755 --- a/CPP/Common/StringConvert.cpp +++ b/CPP/Common/StringConvert.cpp @@ -17,10 +17,8 @@ UString MultiByteToUnicodeString(const AString &srcString, UINT codePage) int numChars = MultiByteToWideChar(codePage, 0, srcString, srcString.Length(), resultString.GetBuffer(srcString.Length()), srcString.Length() + 1); - #ifndef _WIN32_WCE if (numChars == 0) throw 282228; - #endif resultString.ReleaseBuffer(numChars); } return resultString; @@ -38,10 +36,8 @@ AString UnicodeStringToMultiByte(const UString &s, UINT codePage, char defaultCh dest.GetBuffer(numRequiredBytes), numRequiredBytes + 1, &defaultChar, &defUsed); defaultCharWasUsed = (defUsed != FALSE); - #ifndef _WIN32_WCE if (numChars == 0) throw 282229; - #endif dest.ReleaseBuffer(numChars); } return dest; @@ -53,7 +49,7 @@ AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage) return UnicodeStringToMultiByte(srcString, codePage, '_', defaultCharWasUsed); } -#ifndef _WIN32_WCE +#ifndef UNDER_CE AString SystemStringToOemString(const CSysString &srcString) { AString result; @@ -99,4 +95,3 @@ AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage) } #endif - diff --git a/CPP/Common/StringConvert.h b/CPP/Common/StringConvert.h index 0c37eb07..cd737bec 100755 --- a/CPP/Common/StringConvert.h +++ b/CPP/Common/StringConvert.h @@ -1,7 +1,7 @@ // Common/StringConvert.h -#ifndef __COMMON_STRINGCONVERT_H -#define __COMMON_STRINGCONVERT_H +#ifndef __COMMON_STRING_CONVERT_H +#define __COMMON_STRING_CONVERT_H #include "MyWindows.h" #include "MyString.h" @@ -66,7 +66,7 @@ inline AString GetOemString(const UString &unicodeString) { return UnicodeStringToMultiByte(unicodeString, codePage); } #endif -#ifndef _WIN32_WCE +#ifndef UNDER_CE AString SystemStringToOemString(const CSysString &srcString); #endif diff --git a/CPP/Windows/COM.h b/CPP/Windows/COM.h index ceffc97f..cf003d59 100755 --- a/CPP/Windows/COM.h +++ b/CPP/Windows/COM.h @@ -13,7 +13,15 @@ namespace NCOM { class CComInitializer { public: - CComInitializer() { CoInitialize(NULL);}; + CComInitializer() + { + #ifdef UNDER_CE + CoInitializeEx(NULL, COINIT_MULTITHREADED); + #else + // it's single thread. Do we need multithread? + CoInitialize(NULL); + #endif + }; ~CComInitializer() { CoUninitialize(); }; }; diff --git a/CPP/Windows/Clipboard.cpp b/CPP/Windows/Clipboard.cpp index 1e66522f..e1ff62be 100755 --- a/CPP/Windows/Clipboard.cpp +++ b/CPP/Windows/Clipboard.cpp @@ -2,6 +2,10 @@ #include "StdAfx.h" +#ifdef UNDER_CE +#include <winuserm.h> +#endif + #include "Windows/Clipboard.h" #include "Windows/Defs.h" #include "Windows/Memory.h" diff --git a/CPP/Windows/CommonDialog.cpp b/CPP/Windows/CommonDialog.cpp index f794fc88..4ee7412d 100755 --- a/CPP/Windows/CommonDialog.cpp +++ b/CPP/Windows/CommonDialog.cpp @@ -2,10 +2,17 @@ #include "StdAfx.h" +#ifdef UNDER_CE +#include <commdlg.h> +#endif + #ifndef _UNICODE #include "Common/StringConvert.h" #endif #include "Common/MyCom.h" + +#include "Windows/Defs.h" + #include "CommonDialog.h" #ifndef _UNICODE @@ -62,7 +69,15 @@ void CDoubleZeroStringListW::SetForBuffer(LPWSTR buffer) buffer[m_Indexes[i]] = L'\0'; } -bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s, UString &resPath) +#define MY_OFN_PROJECT 0x00400000 +#define MY_OFN_SHOW_ALL 0x01000000 + +bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, + LPCWSTR s, UString &resPath + #ifdef UNDER_CE + , bool openFolder + #endif + ) { const int kBufferSize = MAX_PATH * 2; #ifndef _UNICODE @@ -146,7 +161,12 @@ bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s info.lpstrTitle = title; - info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY; + info.Flags = OFN_EXPLORER | OFN_HIDEREADONLY + #ifdef UNDER_CE + | (openFolder ? (MY_OFN_PROJECT | MY_OFN_SHOW_ALL) : 0) + #endif + ; + info.nFileOffset = 0; info.nFileExtension = 0; info.lpstrDefExt = NULL; diff --git a/CPP/Windows/CommonDialog.h b/CPP/Windows/CommonDialog.h index 250c64f7..f24bb5b2 100755 --- a/CPP/Windows/CommonDialog.h +++ b/CPP/Windows/CommonDialog.h @@ -1,16 +1,18 @@ // Windows/CommonDialog.h -#ifndef __WINDOWS_COMMONDIALOG_H -#define __WINDOWS_COMMONDIALOG_H - -#include <windows.h> +#ifndef __WINDOWS_COMMON_DIALOG_H +#define __WINDOWS_COMMON_DIALOG_H #include "Common/MyString.h" -#include "Windows/Defs.h" namespace NWindows{ -bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, LPCWSTR s, UString &resPath); +bool MyGetOpenFileName(HWND hwnd, LPCWSTR title, LPCWSTR fullFileName, + LPCWSTR s, UString &resPath + #ifdef UNDER_CE + , bool openFolder = false + #endif +); } diff --git a/CPP/Windows/Control/ComboBox.cpp b/CPP/Windows/Control/ComboBox.cpp index d9738f32..40d2f865 100755 --- a/CPP/Windows/Control/ComboBox.cpp +++ b/CPP/Windows/Control/ComboBox.cpp @@ -1,8 +1,5 @@ // Windows/Control/ComboBox.cpp -// #define _UNICODE -// #define UNICODE - #include "StdAfx.h" #ifndef _UNICODE @@ -10,7 +7,6 @@ #endif #include "Windows/Control/ComboBox.h" -#include "Windows/Defs.h" #ifndef _UNICODE extern bool g_IsNT; @@ -59,5 +55,4 @@ LRESULT CComboBox::GetLBText(int index, UString &s) } #endif - }} diff --git a/CPP/Windows/Control/ComboBox.h b/CPP/Windows/Control/ComboBox.h index 58c86703..aa0eb930 100755 --- a/CPP/Windows/Control/ComboBox.h +++ b/CPP/Windows/Control/ComboBox.h @@ -3,11 +3,10 @@ #ifndef __WINDOWS_CONTROL_COMBOBOX_H #define __WINDOWS_CONTROL_COMBOBOX_H -#include "Windows/Window.h" -#include "Windows/Defs.h" - #include <commctrl.h> +#include "../Window.h" + namespace NWindows { namespace NControl { @@ -15,33 +14,34 @@ class CComboBox: public CWindow { public: void ResetContent() { SendMessage(CB_RESETCONTENT, 0, 0); } - LRESULT AddString(LPCTSTR string) { return SendMessage(CB_ADDSTRING, 0, (LPARAM)string); } + LRESULT AddString(LPCTSTR s) { return SendMessage(CB_ADDSTRING, 0, (LPARAM)s); } #ifndef _UNICODE - LRESULT AddString(LPCWSTR string); + LRESULT AddString(LPCWSTR s); #endif LRESULT SetCurSel(int index) { return SendMessage(CB_SETCURSEL, index, 0); } int GetCurSel() { return (int)SendMessage(CB_GETCURSEL, 0, 0); } int GetCount() { return (int)SendMessage(CB_GETCOUNT, 0, 0); } LRESULT GetLBTextLen(int index) { return SendMessage(CB_GETLBTEXTLEN, index, 0); } - LRESULT GetLBText(int index, LPTSTR string) { return SendMessage(CB_GETLBTEXT, index, (LPARAM)string); } + LRESULT GetLBText(int index, LPTSTR s) { return SendMessage(CB_GETLBTEXT, index, (LPARAM)s); } LRESULT GetLBText(int index, CSysString &s); #ifndef _UNICODE LRESULT GetLBText(int index, UString &s); #endif - LRESULT SetItemData(int index, LPARAM lParam) - { return SendMessage(CB_SETITEMDATA, index, lParam); } - LRESULT GetItemData(int index) - { return SendMessage(CB_GETITEMDATA, index, 0); } + LRESULT SetItemData(int index, LPARAM lParam) { return SendMessage(CB_SETITEMDATA, index, lParam); } + LRESULT GetItemData(int index) { return SendMessage(CB_GETITEMDATA, index, 0); } - void ShowDropDown(bool show = true) - { SendMessage(CB_SHOWDROPDOWN, show ? TRUE : FALSE, 0); } + void ShowDropDown(bool show = true) { SendMessage(CB_SHOWDROPDOWN, show ? TRUE : FALSE, 0); } }; +#ifndef UNDER_CE + class CComboBoxEx: public CComboBox { public: + bool SetUnicodeFormat(bool fUnicode) { return LRESULTToBool(SendMessage(CBEM_SETUNICODEFORMAT, BOOLToBool(fUnicode), 0)); } + LRESULT DeleteItem(int index) { return SendMessage(CBEM_DELETEITEM, index, 0); } LRESULT InsertItem(COMBOBOXEXITEM *item) { return SendMessage(CBEM_INSERTITEM, 0, (LPARAM)item); } #ifndef _UNICODE @@ -54,6 +54,8 @@ public: HIMAGELIST SetImageList(HIMAGELIST imageList) { return (HIMAGELIST)SendMessage(CBEM_SETIMAGELIST, 0, (LPARAM)imageList); } }; +#endif + }} -#endif
\ No newline at end of file +#endif diff --git a/CPP/Windows/Control/CommandBar.h b/CPP/Windows/Control/CommandBar.h new file mode 100755 index 00000000..4cbe07b6 --- /dev/null +++ b/CPP/Windows/Control/CommandBar.h @@ -0,0 +1,48 @@ +// Windows/Control/CommandBar.h + +#ifndef __WINDOWS_CONTROL_COMMANDBAR_H +#define __WINDOWS_CONTROL_COMMANDBAR_H + +#ifdef UNDER_CE + +#include "Windows/Window.h" + +namespace NWindows { +namespace NControl { + +class CCommandBar: public NWindows::CWindow +{ +public: + bool Create(HINSTANCE hInst, HWND hwndParent, int idCmdBar) + { + _window = ::CommandBar_Create(hInst, hwndParent, idCmdBar); + return (_window != NULL); + } + + // Macros + // void Destroy() { CommandBar_Destroy(_window); } + bool AddButtons(int iButton, UINT numButtons, LPTBBUTTON buttons) { return BOOLToBool(SendMessage(TB_ADDBUTTONS, (WPARAM)numButtons, (LPARAM)buttons)); } + bool InsertButton(int iButton, LPTBBUTTON button) { return BOOLToBool(SendMessage(TB_INSERTBUTTON, (WPARAM)iButton, (LPARAM)button)); } + BOOL AddToolTips(UINT numToolTips, LPTSTR toolTips) { return BOOLToBool(SendMessage(TB_SETTOOLTIPS, (WPARAM)numToolTips, (LPARAM)toolTips)); } + void AutoSize() { SendMessage(TB_AUTOSIZE, 0, 0); } + + bool AddAdornments(DWORD dwFlags) { return BOOLToBool(::CommandBar_AddAdornments(_window, dwFlags, 0)); } + int AddBitmap(HINSTANCE hInst, int idBitmap, int iNumImages, int iImageWidth, int iImageHeight) { return ::CommandBar_AddBitmap(_window, hInst, idBitmap, iNumImages, iImageWidth, iImageHeight); } + bool DrawMenuBar(WORD iButton) { return BOOLToBool(::CommandBar_DrawMenuBar(_window, iButton)); } + HMENU GetMenu(WORD iButton) { return ::CommandBar_GetMenu(_window, iButton); } + int Height() { return CommandBar_Height(_window); } + HWND InsertComboBox(HINSTANCE hInst, int iWidth, UINT dwStyle, WORD idComboBox, WORD iButton) { return ::CommandBar_InsertComboBox(_window, hInst, iWidth, dwStyle, idComboBox, iButton); } + bool InsertMenubar(HINSTANCE hInst, WORD idMenu, WORD iButton) { return BOOLToBool(::CommandBar_InsertMenubar(_window, hInst, idMenu, iButton)); } + bool InsertMenubarEx(HINSTANCE hInst, LPTSTR pszMenu, WORD iButton) { return BOOLToBool(::CommandBar_InsertMenubarEx(_window, hInst, pszMenu, iButton)); } + bool Show(bool cmdShow) { return BOOLToBool(::CommandBar_Show(_window, BoolToBOOL(cmdShow))); } + + + // CE 4.0 + void AlignAdornments() { CommandBar_AlignAdornments(_window); } +}; + +}} + +#endif + +#endif
\ No newline at end of file diff --git a/CPP/Windows/Control/Dialog.cpp b/CPP/Windows/Control/Dialog.cpp index 8bae85be..dd0cf066 100755 --- a/CPP/Windows/Control/Dialog.cpp +++ b/CPP/Windows/Control/Dialog.cpp @@ -15,8 +15,7 @@ extern bool g_IsNT; namespace NWindows { namespace NControl { -static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message, - WPARAM wParam, LPARAM lParam) +static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam) { CWindow dialogTmp(dialogHWND); if (message == WM_INITDIALOG) @@ -27,30 +26,31 @@ static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message, if (message == WM_INITDIALOG) dialog->Attach(dialogHWND); - return BoolToBOOL(dialog->OnMessage(message, wParam, lParam)); + try { return BoolToBOOL(dialog->OnMessage(message, wParam, lParam)); } + catch(...) { return true; } } bool CDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { - case WM_INITDIALOG: - return OnInit(); - case WM_COMMAND: - return OnCommand(wParam, lParam); - case WM_NOTIFY: - return OnNotify((UINT)wParam, (LPNMHDR) lParam); - case WM_HELP: - { - OnHelp((LPHELPINFO)lParam); + case WM_INITDIALOG: return OnInit(); + case WM_COMMAND: return OnCommand(wParam, lParam); + case WM_NOTIFY: return OnNotify((UINT)wParam, (LPNMHDR) lParam); + case WM_TIMER: return OnTimer(wParam, lParam); + case WM_SIZE: return OnSize(wParam, LOWORD(lParam), HIWORD(lParam)); + case WM_HELP: OnHelp(); return true; + /* + OnHelp( + #ifdef UNDER_CE + (void *) + #else + (LPHELPINFO) + #endif + lParam); return true; - } - case WM_TIMER: - { - return OnTimer(wParam, lParam); - } - default: - return false; + */ + default: return false; } } @@ -70,21 +70,77 @@ bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */) { switch(buttonID) { - case IDOK: - OnOK(); - break; - case IDCANCEL: - OnCancel(); - break; - case IDHELP: - OnHelp(); - break; - default: - return false; + case IDOK: OnOK(); break; + case IDCANCEL: OnCancel(); break; + case IDHELP: OnHelp(); break; + default: return false; } return true; } +static bool GetWorkAreaRect(RECT *rect) +{ + // use another function for multi-monitor. + return BOOLToBool(::SystemParametersInfo(SPI_GETWORKAREA, NULL, rect, NULL)); +} + +bool IsDialogSizeOK(int xSize, int ySize) +{ + // it returns for system font. Real font uses another values + LONG v = GetDialogBaseUnits(); + int x = LOWORD(v); + int y = HIWORD(v); + + RECT rect; + GetWorkAreaRect(&rect); + int wx = RECT_SIZE_X(rect); + int wy = RECT_SIZE_Y(rect); + return + xSize / 4 * x <= wx && + ySize / 8 * y <= wy; +} + +void CDialog::NormalizeSize(bool fullNormalize) +{ + RECT workRect; + GetWorkAreaRect(&workRect); + int xSize = RECT_SIZE_X(workRect); + int ySize = RECT_SIZE_Y(workRect); + RECT rect; + GetWindowRect(&rect); + int xSize2 = RECT_SIZE_X(rect); + int ySize2 = RECT_SIZE_Y(rect); + bool needMove = (xSize2 > xSize || ySize2 > ySize); + if (xSize2 > xSize || (needMove && fullNormalize)) + { + rect.left = workRect.left; + rect.right = workRect.right; + xSize2 = xSize; + } + if (ySize2 > ySize || (needMove && fullNormalize)) + { + rect.top = workRect.top; + rect.bottom = workRect.bottom; + ySize2 = ySize; + } + if (needMove) + { + if (fullNormalize) + Show(SW_SHOWMAXIMIZED); + else + Move(rect.left, rect.top, xSize2, ySize2, true); + } +} + +void CDialog::NormalizePosition() +{ + RECT workRect, rect; + GetWorkAreaRect(&workRect); + GetWindowRect(&rect); + if (rect.bottom > workRect.bottom && rect.top > workRect.top) + Move(rect.left, workRect.top, RECT_SIZE_X(rect), RECT_SIZE_Y(rect), true); +} + bool CModelessDialog::Create(LPCTSTR templateName, HWND parentWindow) { HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this); diff --git a/CPP/Windows/Control/Dialog.h b/CPP/Windows/Control/Dialog.h index daebb1bf..2b5147e7 100755 --- a/CPP/Windows/Control/Dialog.h +++ b/CPP/Windows/Control/Dialog.h @@ -4,7 +4,6 @@ #define __WINDOWS_CONTROL_DIALOG_H #include "Windows/Window.h" -#include "Windows/Defs.h" namespace NWindows { namespace NControl { @@ -24,6 +23,8 @@ public: bool ShowItem(int itemID, int cmdShow) const { return BOOLToBool(::ShowWindow(GetItem(itemID), cmdShow)); } + bool HideItem(int itemID) const { return ShowItem(itemID, SW_HIDE); } + bool SetItemText(int itemID, LPCTSTR s) { return BOOLToBool(SetDlgItemText(_window, itemID, s)); } @@ -50,11 +51,11 @@ public: bool SetItemInt(int itemID, UINT value, bool isSigned) { return BOOLToBool(SetDlgItemInt(_window, itemID, value, BoolToBOOL(isSigned))); } bool GetItemInt(int itemID, bool isSigned, UINT &value) - { - BOOL result; - value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned)); - return BOOLToBool(result); - } + { + BOOL result; + value = GetDlgItemInt(_window, itemID, &result, BoolToBOOL(isSigned)); + return BOOLToBool(result); + } HWND GetNextGroupItem(HWND control, bool previous) { return GetNextDlgGroupItem(_window, control, BoolToBOOL(previous)); } @@ -87,8 +88,17 @@ public: virtual bool OnInit() { return true; } virtual bool OnCommand(WPARAM wParam, LPARAM lParam); virtual bool OnCommand(int code, int itemID, LPARAM lParam); - virtual void OnHelp(LPHELPINFO /* helpInfo */) { OnHelp(); }; + virtual bool OnSize(WPARAM /* wParam */, int /* xSize */, int /* ySize */) { return false; } + + /* + #ifdef UNDER_CE + virtual void OnHelp(void *) { OnHelp(); }; + #else + virtual void OnHelp(LPHELPINFO) { OnHelp(); }; + #endif + */ virtual void OnHelp() {}; + virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); virtual void OnOK() {}; virtual void OnCancel() {}; @@ -99,12 +109,63 @@ public: { return SetLongPtr(DWLP_MSGRESULT, newLongPtr); } LONG_PTR GetMsgResult() const { return GetLongPtr(DWLP_MSGRESULT); } + + + bool GetMargins(int margin, int &x, int &y) + { + RECT rect; + rect.left = 0; + rect.top = 0; + rect.right = margin; + rect.bottom = margin; + if (!MapRect(&rect)) + return false; + x = rect.right - rect.left; + y = rect.bottom - rect.top; + return true; + } + + int Units_To_Pixels_X(int units) + { + RECT rect; + rect.left = 0; + rect.top = 0; + rect.right = units; + rect.bottom = units; + if (!MapRect(&rect)) + return units * 3 / 2; + return rect.right - rect.left; + } + + bool GetItemSizes(int id, int &x, int &y) + { + RECT rect; + if (!::GetWindowRect(GetItem(id), &rect)) + return false; + x = rect.right - rect.left; + y = rect.bottom - rect.top; + return true; + } + + void GetClientRectOfItem(int id, RECT &rect) + { + ::GetWindowRect(GetItem(id), &rect); + ScreenToClient(&rect); + } + + + bool MoveItem(int id, int x, int y, int width, int height, bool repaint = true) + { return BOOLToBool(::MoveWindow(GetItem(id), x, y, width, height, BoolToBOOL(repaint))); } + + void NormalizeSize(bool fullNormalize = false); + void NormalizePosition(); }; class CModelessDialog: public CDialog { public: bool Create(LPCTSTR templateName, HWND parentWindow); + bool Create(UINT resID, HWND parentWindow) { return Create(MAKEINTRESOURCEW(resID), parentWindow); } #ifndef _UNICODE bool Create(LPCWSTR templateName, HWND parentWindow); #endif @@ -116,22 +177,20 @@ class CModalDialog: public CDialog { public: INT_PTR Create(LPCTSTR templateName, HWND parentWindow); - INT_PTR Create(UINT resID, HWND parentWindow) - { return Create(MAKEINTRESOURCEW(resID), parentWindow); } + INT_PTR Create(UINT resID, HWND parentWindow) { return Create(MAKEINTRESOURCEW(resID), parentWindow); } #ifndef _UNICODE INT_PTR Create(LPCWSTR templateName, HWND parentWindow); #endif - bool End(INT_PTR result) - { return BOOLToBool(::EndDialog(_window, result)); } + bool End(INT_PTR result) { return BOOLToBool(::EndDialog(_window, result)); } virtual void OnOK() { End(IDOK); } virtual void OnCancel() { End(IDCANCEL); } }; class CDialogChildControl: public NWindows::CWindow { -public: int m_ID; +public: void Init(const NWindows::NControl::CDialog &parentDialog, int id) { m_ID = id; @@ -139,6 +198,8 @@ public: } }; +bool IsDialogSizeOK(int xSize, int ySize); + }} -#endif
\ No newline at end of file +#endif diff --git a/CPP/Windows/Control/ListView.h b/CPP/Windows/Control/ListView.h index 0daf65f3..1258ec93 100755 --- a/CPP/Windows/Control/ListView.h +++ b/CPP/Windows/Control/ListView.h @@ -4,7 +4,6 @@ #define __WINDOWS_CONTROL_LISTVIEW_H #include "Windows/Window.h" -#include "Windows/Defs.h" #include <commctrl.h> @@ -19,17 +18,14 @@ public: HWND parentWindow, HMENU idOrHMenu, HINSTANCE instance, LPVOID createParam); - bool SetUnicodeFormat(bool fUnicode) - { return BOOLToBool(ListView_SetUnicodeFormat(_window, BOOLToBool(fUnicode))); } + #ifndef UNDER_CE + bool SetUnicodeFormat(bool fUnicode) { return BOOLToBool(ListView_SetUnicodeFormat(_window, BOOLToBool(fUnicode))); } + #endif - bool DeleteAllItems() - { return BOOLToBool(ListView_DeleteAllItems(_window)); } - - bool DeleteColumn(int columnIndex) - { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); } + bool DeleteAllItems() { return BOOLToBool(ListView_DeleteAllItems(_window)); } + bool DeleteColumn(int columnIndex) { return BOOLToBool(ListView_DeleteColumn(_window, columnIndex)); } - int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo) - { return ListView_InsertColumn(_window, columnIndex, columnInfo); } + int InsertColumn(int columnIndex, const LVCOLUMN *columnInfo) { return ListView_InsertColumn(_window, columnIndex, columnInfo); } int InsertColumn(int columnIndex, LPCTSTR text, int width); int InsertItem(const LVITEM* item) { return ListView_InsertItem(_window, item); } int InsertItem(int index, LPCTSTR text); @@ -38,8 +34,7 @@ public: #ifndef _UNICODE - int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo) - { return (int)SendMessage(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); } + int InsertColumn(int columnIndex, const LVCOLUMNW *columnInfo) { return (int)SendMessage(LVM_INSERTCOLUMNW, (WPARAM)columnIndex, (LPARAM)columnInfo); } int InsertColumn(int columnIndex, LPCWSTR text, int width); int InsertItem(const LV_ITEMW* item) { return (int)SendMessage(LVM_INSERTITEMW, 0, (LPARAM)item); } int InsertItem(int index, LPCWSTR text); @@ -48,41 +43,30 @@ public: #endif - bool DeleteItem(int itemIndex) - { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); } + bool DeleteItem(int itemIndex) { return BOOLToBool(ListView_DeleteItem(_window, itemIndex)); } - UINT GetSelectedCount() const - { return ListView_GetSelectedCount(_window); } - int GetItemCount() const - { return ListView_GetItemCount(_window); } + UINT GetSelectedCount() const { return ListView_GetSelectedCount(_window); } + int GetItemCount() const { return ListView_GetItemCount(_window); } - INT GetSelectionMark() const - { return ListView_GetSelectionMark(_window); } + INT GetSelectionMark() const { return ListView_GetSelectionMark(_window); } - void SetItemCount(int numItems) - { ListView_SetItemCount(_window, numItems); } - void SetItemCountEx(int numItems, DWORD flags) - { ListView_SetItemCountEx(_window, numItems, flags); } + void SetItemCount(int numItems) { ListView_SetItemCount(_window, numItems); } + void SetItemCountEx(int numItems, DWORD flags) { ListView_SetItemCountEx(_window, numItems, flags); } - int GetNextItem(int startIndex, UINT flags) const - { return ListView_GetNextItem(_window, startIndex, flags); } - int GetNextSelectedItem(int startIndex) const - { return GetNextItem(startIndex, LVNI_SELECTED); } - int GetFocusedItem() const - { return GetNextItem(-1, LVNI_FOCUSED); } + int GetNextItem(int startIndex, UINT flags) const { return ListView_GetNextItem(_window, startIndex, flags); } + int GetNextSelectedItem(int startIndex) const { return GetNextItem(startIndex, LVNI_SELECTED); } + int GetFocusedItem() const { return GetNextItem(-1, LVNI_FOCUSED); } - bool GetItem(LVITEM* item) const - { return BOOLToBool(ListView_GetItem(_window, item)); } + bool GetItem(LVITEM* item) const { return BOOLToBool(ListView_GetItem(_window, item)); } bool GetItemParam(int itemIndex, LPARAM ¶m) const; - void GetItemText(int itemIndex, int aSubItemIndex, LPTSTR aText, int aTextSizeMax) const - { ListView_GetItemText(_window, itemIndex, aSubItemIndex, aText, aTextSizeMax); } + void GetItemText(int itemIndex, int subItemIndex, LPTSTR text, int textSizeMax) const + { ListView_GetItemText(_window, itemIndex, subItemIndex, text, textSizeMax); } bool SortItems(PFNLVCOMPARE compareFunction, LPARAM dataParam) { return BOOLToBool(ListView_SortItems(_window, compareFunction, dataParam)); } - void SetItemState(int index, UINT state, UINT mask) - { ListView_SetItemState(_window, index, state, mask); } - UINT GetItemState(int index, UINT mask) const - { return ListView_GetItemState(_window, index, mask); } + void SetItemState(int index, UINT state, UINT mask) { ListView_SetItemState(_window, index, state, mask); } + void SetItemState_FocusedSelected(int index) { SetItemState(index, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); } + UINT GetItemState(int index, UINT mask) const { return ListView_GetItemState(_window, index, mask); } bool GetColumn(int columnIndex, LVCOLUMN* columnInfo) const { return BOOLToBool(ListView_GetColumn(_window, columnIndex, columnInfo)); } @@ -91,48 +75,33 @@ public: { return ListView_SetImageList(_window, imageList, imageListType); } // version 4.70: NT5 | (NT4 + ie3) | w98 | (w95 + ie3) - DWORD GetExtendedListViewStyle() - { return ListView_GetExtendedListViewStyle(_window); } - void SetExtendedListViewStyle(DWORD exStyle) - { ListView_SetExtendedListViewStyle(_window, exStyle); } - void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle) - { ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); } - - #ifndef _WIN32_WCE - void SetCheckState(UINT index, bool checkState) - { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)); } - #endif - bool GetCheckState(UINT index) - { return BOOLToBool(ListView_GetCheckState(_window, index)); } + DWORD GetExtendedListViewStyle() { return ListView_GetExtendedListViewStyle(_window); } + void SetExtendedListViewStyle(DWORD exStyle) { ListView_SetExtendedListViewStyle(_window, exStyle); } + void SetExtendedListViewStyle(DWORD exMask, DWORD exStyle) { ListView_SetExtendedListViewStyleEx(_window, exMask, exStyle); } + void SetCheckState(UINT index, bool checkState) { ListView_SetCheckState(_window, index, BoolToBOOL(checkState)); } + bool GetCheckState(UINT index) { return BOOLToBool(ListView_GetCheckState(_window, index)); } - bool EnsureVisible(int index, bool partialOK) - { return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); } + bool EnsureVisible(int index, bool partialOK) { return BOOLToBool(ListView_EnsureVisible(_window, index, BoolToBOOL(partialOK))); } - bool GetItemRect(int index, RECT *rect, int code) - { return BOOLToBool(ListView_GetItemRect(_window, index, rect, code)); } + bool GetItemRect(int index, RECT *rect, int code) { return BOOLToBool(ListView_GetItemRect(_window, index, rect, code)); } - HWND GetEditControl() - { return ListView_GetEditControl(_window) ; } - HWND EditLabel(int itemIndex) - { return ListView_EditLabel(_window, itemIndex) ; } + HWND GetEditControl() { return ListView_GetEditControl(_window) ; } + HWND EditLabel(int itemIndex) { return ListView_EditLabel(_window, itemIndex) ; } - bool RedrawItems(int firstIndex, int lastIndex) - { return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); } + bool RedrawItems(int firstIndex, int lastIndex) { return BOOLToBool(ListView_RedrawItems(_window, firstIndex, lastIndex)); } bool RedrawAllItems() { if (GetItemCount() > 0) return RedrawItems(0, GetItemCount() - 1); return true; } - bool RedrawItem(int index) - { return RedrawItems(index, index); } + bool RedrawItem(int index) { return RedrawItems(index, index); } - int HitTest(LPLVHITTESTINFO info) - { return ListView_HitTest(_window, info); } - - COLORREF GetBkColor() - { return ListView_GetBkColor(_window); } + int HitTest(LPLVHITTESTINFO info) { return ListView_HitTest(_window, info); } + COLORREF GetBkColor() { return ListView_GetBkColor(_window); } + bool SetColumnWidth(int iCol, int cx) { return BOOLToBool(ListView_SetColumnWidth(_window, iCol, cx)); } + bool SetColumnWidthAuto(int iCol) { return SetColumnWidth(iCol, LVSCW_AUTOSIZE); } }; }} diff --git a/CPP/Windows/Control/ProgressBar.h b/CPP/Windows/Control/ProgressBar.h index 6ce837cc..4591880a 100755 --- a/CPP/Windows/Control/ProgressBar.h +++ b/CPP/Windows/Control/ProgressBar.h @@ -3,8 +3,7 @@ #ifndef __WINDOWS_CONTROL_PROGRESSBAR_H #define __WINDOWS_CONTROL_PROGRESSBAR_H -#include "Windows/Window.h" -#include "Windows/Defs.h" +#include "../Window.h" namespace NWindows { namespace NControl { @@ -12,30 +11,21 @@ namespace NControl { class CProgressBar: public CWindow { public: - LRESULT SetPos(int pos) - { return SendMessage(PBM_SETPOS, pos, 0); } - LRESULT DeltaPos(int increment) - { return SendMessage(PBM_DELTAPOS, increment, 0); } - UINT GetPos() - { return (UINT)SendMessage(PBM_GETPOS, 0, 0); } - LRESULT SetRange(unsigned short minValue, unsigned short maxValue) - { return SendMessage(PBM_SETRANGE, 0, MAKELPARAM(minValue, maxValue)); } - DWORD SetRange32(int minValue, int maxValue) - { return (DWORD)SendMessage(PBM_SETRANGE32, minValue, maxValue); } - int SetStep(int step) - { return (int)SendMessage(PBM_SETSTEP, step, 0); } - LRESULT StepIt() - { return SendMessage(PBM_STEPIT, 0, 0); } - - INT GetRange(bool minValue, PPBRANGE range) - { return (INT)SendMessage(PBM_GETRANGE, BoolToBOOL(minValue), (LPARAM)range); } + LRESULT SetPos(int pos) { return SendMessage(PBM_SETPOS, pos, 0); } + LRESULT DeltaPos(int increment) { return SendMessage(PBM_DELTAPOS, increment, 0); } + UINT GetPos() { return (UINT)SendMessage(PBM_GETPOS, 0, 0); } + LRESULT SetRange(unsigned short minValue, unsigned short maxValue) { return SendMessage(PBM_SETRANGE, 0, MAKELPARAM(minValue, maxValue)); } + DWORD SetRange32(int minValue, int maxValue) { return (DWORD)SendMessage(PBM_SETRANGE32, minValue, maxValue); } + int SetStep(int step) { return (int)SendMessage(PBM_SETSTEP, step, 0); } + LRESULT StepIt() { return SendMessage(PBM_STEPIT, 0, 0); } + INT GetRange(bool minValue, PPBRANGE range) { return (INT)SendMessage(PBM_GETRANGE, BoolToBOOL(minValue), (LPARAM)range); } - COLORREF SetBarColor(COLORREF color) - { return (COLORREF)SendMessage(PBM_SETBARCOLOR, 0, color); } - COLORREF SetBackgroundColor(COLORREF color) - { return (COLORREF)SendMessage(PBM_SETBKCOLOR, 0, color); } + #ifndef UNDER_CE + COLORREF SetBarColor(COLORREF color) { return (COLORREF)SendMessage(PBM_SETBARCOLOR, 0, color); } + COLORREF SetBackgroundColor(COLORREF color) { return (COLORREF)SendMessage(PBM_SETBKCOLOR, 0, color); } + #endif }; }} -#endif
\ No newline at end of file +#endif diff --git a/CPP/Windows/Control/PropertyPage.h b/CPP/Windows/Control/PropertyPage.h index e041d289..4e7e088e 100755 --- a/CPP/Windows/Control/PropertyPage.h +++ b/CPP/Windows/Control/PropertyPage.h @@ -3,8 +3,7 @@ #ifndef __WINDOWS_CONTROL_PROPERTYPAGE_H #define __WINDOWS_CONTROL_PROPERTYPAGE_H -#include "Windows/Control/Dialog.h" -#include "Windows/Defs.h" +#include "Dialog.h" namespace NWindows { namespace NControl { @@ -16,21 +15,21 @@ class CPropertyPage: public CDialog public: CPropertyPage(HWND window = NULL): CDialog(window){}; - void Changed() { PropSheet_Changed(GetParent(), HWND(*this)); } - void UnChanged() { PropSheet_UnChanged(GetParent(), HWND(*this)); } + void Changed() { PropSheet_Changed(GetParent(), (HWND)*this); } + void UnChanged() { PropSheet_UnChanged(GetParent(), (HWND)*this); } virtual bool OnNotify(UINT controlID, LPNMHDR lParam); virtual bool OnKillActive() { return false; } // false = OK - virtual bool OnKillActive(const PSHNOTIFY * /* aPSHNOTIFY */) { return OnKillActive(); } + virtual bool OnKillActive(const PSHNOTIFY *) { return OnKillActive(); } virtual LONG OnSetActive() { return false; } // false = OK - virtual LONG OnSetActive(const PSHNOTIFY * /* aPSHNOTIFY */) { return OnKillActive(); } + virtual LONG OnSetActive(const PSHNOTIFY *) { return OnSetActive(); } virtual LONG OnApply() { return PSNRET_NOERROR; } - virtual LONG OnApply(const PSHNOTIFY * /* aPSHNOTIFY */) { return OnApply(); } - virtual void OnNotifyHelp() { } - virtual void OnNotifyHelp(const PSHNOTIFY * /* aPSHNOTIFY */) { OnNotifyHelp(); } - virtual void OnReset() { } - virtual void OnReset(const PSHNOTIFY * /* aPSHNOTIFY */) { OnReset(); } + virtual LONG OnApply(const PSHNOTIFY *) { return OnApply(); } + virtual void OnNotifyHelp() {} + virtual void OnNotifyHelp(const PSHNOTIFY *) { OnNotifyHelp(); } + virtual void OnReset() {} + virtual void OnReset(const PSHNOTIFY *) { OnReset(); } }; struct CPageInfo diff --git a/CPP/Windows/Control/Static.h b/CPP/Windows/Control/Static.h index 5dded0ec..cb3126dd 100755 --- a/CPP/Windows/Control/Static.h +++ b/CPP/Windows/Control/Static.h @@ -3,8 +3,7 @@ #ifndef __WINDOWS_CONTROL_STATIC_H #define __WINDOWS_CONTROL_STATIC_H -#include "Windows/Window.h" -#include "Windows/Defs.h" +#include "../Window.h" namespace NWindows { namespace NControl { @@ -12,16 +11,18 @@ namespace NControl { class CStatic: public CWindow { public: - HICON SetIcon(HICON icon) - { return (HICON)SendMessage(STM_SETICON, (WPARAM)icon, 0); } - HICON GetIcon() - { return (HICON)SendMessage(STM_GETICON, 0, 0); } - HANDLE SetImage(WPARAM imageType, HANDLE handle) - { return (HANDLE)SendMessage(STM_SETIMAGE, imageType, (LPARAM)handle); } - HANDLE GetImage(WPARAM imageType) - { return (HANDLE)SendMessage(STM_GETIMAGE, imageType, 0); } + HANDLE SetImage(WPARAM imageType, HANDLE handle) { return (HANDLE)SendMessage(STM_SETIMAGE, imageType, (LPARAM)handle); } + HANDLE GetImage(WPARAM imageType) { return (HANDLE)SendMessage(STM_GETIMAGE, imageType, 0); } + + #ifdef UNDER_CE + HICON SetIcon(HICON icon) { return (HICON)SetImage(IMAGE_ICON, icon); } + HICON GetIcon() { return (HICON)GetImage(IMAGE_ICON); } + #else + HICON SetIcon(HICON icon) { return (HICON)SendMessage(STM_SETICON, (WPARAM)icon, 0); } + HICON GetIcon() { return (HICON)SendMessage(STM_GETICON, 0, 0); } + #endif }; }} -#endif
\ No newline at end of file +#endif diff --git a/CPP/Windows/Control/ToolBar.h b/CPP/Windows/Control/ToolBar.h index 4bd21531..262184ae 100755 --- a/CPP/Windows/Control/ToolBar.h +++ b/CPP/Windows/Control/ToolBar.h @@ -4,7 +4,6 @@ #define __WINDOWS_CONTROL_TOOLBAR_H #include "Windows/Window.h" -#include "Windows/Defs.h" namespace NWindows { namespace NControl { @@ -12,23 +11,33 @@ namespace NControl { class CToolBar: public NWindows::CWindow { public: + void AutoSize() { SendMessage(TB_AUTOSIZE, 0, 0); } + DWORD GetButtonSize() { return (DWORD)SendMessage(TB_GETBUTTONSIZE, 0, 0); } + bool GetMaxSize(LPSIZE size) - { return LRESULTToBool(SendMessage(TB_GETMAXSIZE, 0, (LPARAM)size)); } - bool EnableButton(UINT buttonID, bool enable) - { return LRESULTToBool(SendMessage(TB_ENABLEBUTTON, buttonID, - MAKELONG(BoolToBOOL(enable), 0))); } - void ButtonStructSize() - { SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON)); } - HIMAGELIST SetImageList(UINT listIndex, HIMAGELIST imageList) - { return HIMAGELIST(SendMessage(TB_SETIMAGELIST, listIndex, (LPARAM)imageList)); } - bool AddButton(UINT numButtons, LPTBBUTTON buttons) - { return LRESULTToBool(SendMessage(TB_ADDBUTTONS, numButtons, (LPARAM)buttons)); } + #ifdef UNDER_CE + { + // maybe it must be fixed for more than 1 buttons + DWORD val = GetButtonSize(); + size->cx = LOWORD(val); + size->cy = HIWORD(val); + return true; + } + #else + { + return LRESULTToBool(SendMessage(TB_GETMAXSIZE, 0, (LPARAM)size)); + } + #endif + + bool EnableButton(UINT buttonID, bool enable) { return LRESULTToBool(SendMessage(TB_ENABLEBUTTON, buttonID, MAKELONG(BoolToBOOL(enable), 0))); } + void ButtonStructSize() { SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON)); } + HIMAGELIST SetImageList(UINT listIndex, HIMAGELIST imageList) { return HIMAGELIST(SendMessage(TB_SETIMAGELIST, listIndex, (LPARAM)imageList)); } + bool AddButton(UINT numButtons, LPTBBUTTON buttons) { return LRESULTToBool(SendMessage(TB_ADDBUTTONS, numButtons, (LPARAM)buttons)); } #ifndef _UNICODE - bool AddButtonW(UINT numButtons, LPTBBUTTON buttons) - { return LRESULTToBool(SendMessage(TB_ADDBUTTONSW, numButtons, (LPARAM)buttons)); } + bool AddButtonW(UINT numButtons, LPTBBUTTON buttons) { return LRESULTToBool(SendMessage(TB_ADDBUTTONSW, numButtons, (LPARAM)buttons)); } #endif }; }} -#endif
\ No newline at end of file +#endif diff --git a/CPP/Windows/Control/Window2.cpp b/CPP/Windows/Control/Window2.cpp index 3900f649..e1299048 100755 --- a/CPP/Windows/Control/Window2.cpp +++ b/CPP/Windows/Control/Window2.cpp @@ -20,15 +20,21 @@ ATOM MyRegisterClass(CONST WNDCLASSW *wndClass); namespace NControl { +#ifdef UNDER_CE +#define MY_START_WM_CREATE WM_CREATE +#else +#define MY_START_WM_CREATE WM_NCCREATE +#endif + static LRESULT CALLBACK WindowProcedure(HWND aHWND, UINT message, WPARAM wParam, LPARAM lParam) { CWindow tempWindow(aHWND); - if (message == WM_NCCREATE) + if (message == MY_START_WM_CREATE) tempWindow.SetUserDataLongPtr( LONG_PTR(((LPCREATESTRUCT)lParam)->lpCreateParams)); CWindow2 *window = (CWindow2*)(tempWindow.GetUserDataLongPtr()); - if (window != NULL && message == WM_NCCREATE) + if (window != NULL && message == MY_START_WM_CREATE) window->Attach(aHWND); if (window == 0) { diff --git a/CPP/Windows/Control/Window2.h b/CPP/Windows/Control/Window2.h index 8af902f8..b016a13d 100755 --- a/CPP/Windows/Control/Window2.h +++ b/CPP/Windows/Control/Window2.h @@ -4,7 +4,6 @@ #define __WINDOWS_CONTROL_WINDOW2_H #include "Windows/Window.h" -#include "Windows/Defs.h" namespace NWindows { namespace NControl { diff --git a/CPP/Windows/DLL.cpp b/CPP/Windows/DLL.cpp index 8a95a256..5afd72d9 100755 --- a/CPP/Windows/DLL.cpp +++ b/CPP/Windows/DLL.cpp @@ -2,12 +2,12 @@ #include "StdAfx.h" -#include "DLL.h" -#include "Defs.h" #ifndef _UNICODE #include "../Common/StringConvert.h" #endif +#include "DLL.h" + #ifndef _UNICODE extern bool g_IsNT; #endif @@ -15,11 +15,6 @@ extern bool g_IsNT; namespace NWindows { namespace NDLL { -CLibrary::~CLibrary() -{ - Free(); -} - bool CLibrary::Free() { if (_module == 0) diff --git a/CPP/Windows/DLL.h b/CPP/Windows/DLL.h index 4c2ffa2b..4a253b32 100755 --- a/CPP/Windows/DLL.h +++ b/CPP/Windows/DLL.h @@ -8,17 +8,25 @@ namespace NWindows { namespace NDLL { +#ifdef UNDER_CE +#define My_GetProcAddress(module, proceName) GetProcAddressA(module, proceName) +#else +#define My_GetProcAddress(module, proceName) ::GetProcAddress(module, proceName) +#endif + class CLibrary { bool LoadOperations(HMODULE newModule); protected: HMODULE _module; public: + CLibrary(): _module(NULL) {}; + ~CLibrary() { Free(); } + operator HMODULE() const { return _module; } HMODULE* operator&() { return &_module; } + bool IsLoaded() const { return (_module != NULL); }; - CLibrary():_module(NULL) {}; - ~CLibrary(); void Attach(HMODULE m) { Free(); @@ -31,8 +39,6 @@ public: return m; } - // operator HMODULE() const { return _module; }; - bool IsLoaded() const { return (_module != NULL); }; bool Free(); bool LoadEx(LPCTSTR fileName, DWORD flags = LOAD_LIBRARY_AS_DATAFILE); bool Load(LPCTSTR fileName); @@ -40,8 +46,7 @@ public: bool LoadEx(LPCWSTR fileName, DWORD flags = LOAD_LIBRARY_AS_DATAFILE); bool Load(LPCWSTR fileName); #endif - FARPROC GetProcAddress(LPCSTR procName) const - { return ::GetProcAddress(_module, procName); } + FARPROC GetProc(LPCSTR procName) const { return My_GetProcAddress(_module, procName); } }; bool MyGetModuleFileName(HMODULE hModule, CSysString &result); diff --git a/CPP/Windows/FileDir.cpp b/CPP/Windows/FileDir.cpp index cffce7f0..81fcd6ef 100755 --- a/CPP/Windows/FileDir.cpp +++ b/CPP/Windows/FileDir.cpp @@ -38,6 +38,8 @@ static CSysString GetSysPath(LPCWSTR sysPath) { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); } #endif +#ifndef UNDER_CE + bool MyGetWindowsDirectory(CSysString &path) { UINT needLength = ::GetWindowsDirectory(path.GetBuffer(MAX_PATH + 1), MAX_PATH + 1); @@ -52,6 +54,8 @@ bool MyGetSystemDirectory(CSysString &path) return (needLength > 0 && needLength <= MAX_PATH); } +#endif + #ifndef _UNICODE bool MyGetWindowsDirectory(UString &path) { @@ -441,7 +445,41 @@ bool RemoveDirectoryWithSubItems(const UString &path) } #endif -#ifndef _WIN32_WCE +bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName) +{ + int index; + if (!MyGetFullPathName(fileName, resultName, index)) + return false; + resultName = resultName.Left(index); + return true; +} + +bool GetOnlyName(LPCTSTR fileName, CSysString &resultName) +{ + int index; + if (!MyGetFullPathName(fileName, resultName, index)) + return false; + resultName = resultName.Mid(index); + return true; +} + +#ifdef UNDER_CE +bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath) +{ + resultPath = fileName; + return true; +} + +bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartStartIndex) +{ + resultPath = fileName; + // change it + fileNamePartStartIndex = resultPath.ReverseFind('\\'); + fileNamePartStartIndex++; + return true; +} + +#else bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath) { @@ -534,15 +572,6 @@ bool MyGetFullPathName(LPCWSTR fileName, UString &path) } #endif -bool GetOnlyName(LPCTSTR fileName, CSysString &resultName) -{ - int index; - if (!MyGetFullPathName(fileName, resultName, index)) - return false; - resultName = resultName.Mid(index); - return true; -} - #ifndef _UNICODE bool GetOnlyName(LPCWSTR fileName, UString &resultName) { @@ -554,15 +583,6 @@ bool GetOnlyName(LPCWSTR fileName, UString &resultName) } #endif -bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName) -{ - int index; - if (!MyGetFullPathName(fileName, resultName, index)) - return false; - resultName = resultName.Left(index); - return true; -} - #ifndef _UNICODE bool GetOnlyDirPrefix(LPCWSTR fileName, UString &resultName) { @@ -603,7 +623,6 @@ bool MyGetCurrentDirectory(UString &path) return true; } #endif -#endif bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension, CSysString &resultPath, UINT32 &filePart) @@ -615,6 +634,7 @@ bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension, resultPath.ReleaseBuffer(); return (value > 0 && value <= MAX_PATH); } +#endif #ifndef _UNICODE bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension, @@ -715,9 +735,13 @@ bool CTempFile::Create(LPCTSTR prefix, CSysString &resultPath) return false; if (Create(tempPath, prefix, resultPath) != 0) return true; + #ifdef UNDER_CE + return false; + #else if (!MyGetWindowsDirectory(tempPath)) return false; return (Create(tempPath, prefix, resultPath) != 0); + #endif } bool CTempFile::Remove() diff --git a/CPP/Windows/FileDir.h b/CPP/Windows/FileDir.h index 279ccdc6..04542d87 100755 --- a/CPP/Windows/FileDir.h +++ b/CPP/Windows/FileDir.h @@ -41,14 +41,16 @@ bool DeleteFileAlways(LPCWSTR name); bool RemoveDirectoryWithSubItems(const UString &path); #endif -#ifndef _WIN32_WCE +bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName); +bool GetOnlyName(LPCTSTR fileName, CSysString &resultName); +#ifdef UNDER_CE +bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath); +bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartStartIndex); +#else bool MyGetShortPathName(LPCTSTR longPath, CSysString &shortPath); -bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath, - int &fileNamePartStartIndex); +bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath, int &fileNamePartStartIndex); bool MyGetFullPathName(LPCTSTR fileName, CSysString &resultPath); -bool GetOnlyName(LPCTSTR fileName, CSysString &resultName); -bool GetOnlyDirPrefix(LPCTSTR fileName, CSysString &resultName); #ifndef _UNICODE bool MyGetFullPathName(LPCWSTR fileName, UString &resultPath, int &fileNamePartStartIndex); @@ -64,31 +66,28 @@ bool MyGetCurrentDirectory(CSysString &resultPath); bool MySetCurrentDirectory(LPCWSTR path); bool MyGetCurrentDirectory(UString &resultPath); #endif -#endif -bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension, - CSysString &resultPath, UINT32 &filePart); +bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension, CSysString &resultPath, UINT32 &filePart); #ifndef _UNICODE -bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension, - UString &resultPath, UINT32 &filePart); +bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension, UString &resultPath, UINT32 &filePart); #endif -inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension, - CSysString &resultPath) +inline bool MySearchPath(LPCTSTR path, LPCTSTR fileName, LPCTSTR extension, CSysString &resultPath) { UINT32 value; return MySearchPath(path, fileName, extension, resultPath, value); } #ifndef _UNICODE -inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension, - UString &resultPath) +inline bool MySearchPath(LPCWSTR path, LPCWSTR fileName, LPCWSTR extension, UString &resultPath) { UINT32 value; return MySearchPath(path, fileName, extension, resultPath, value); } #endif +#endif + bool MyGetTempPath(CSysString &resultPath); #ifndef _UNICODE bool MyGetTempPath(UString &resultPath); diff --git a/CPP/Windows/FileFind.cpp b/CPP/Windows/FileFind.cpp index d0cb2327..e3358f90 100755 --- a/CPP/Windows/FileFind.cpp +++ b/CPP/Windows/FileFind.cpp @@ -61,10 +61,10 @@ bool CFileInfoW::IsDots() const fi.IsDevice = false; /* - #ifndef _WIN32_WCE - fi.ReparseTag = fd.dwReserved0; - #else + #ifdef UNDER_CE fi.ObjectID = fd.dwOID; + #else + fi.ReparseTag = fd.dwReserved0; #endif */ @@ -390,7 +390,7 @@ HANDLE CFindChangeNotification::FindFirst(LPCWSTR pathName, bool watchSubtree, D } #endif -#ifndef _WIN32_WCE +#ifndef UNDER_CE bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings) { driveStrings.Clear(); diff --git a/CPP/Windows/FileFind.h b/CPP/Windows/FileFind.h index 4644d048..63631f66 100755 --- a/CPP/Windows/FileFind.h +++ b/CPP/Windows/FileFind.h @@ -37,10 +37,10 @@ public: bool IsDevice; /* - #ifndef _WIN32_WCE - UINT32 ReparseTag; - #else + #ifdef UNDER_CE DWORD ObjectID; + #else + UINT32 ReparseTag; #endif */ @@ -148,7 +148,7 @@ public: bool FindNext() { return BOOLToBool(::FindNextChangeNotification(_handle)); } }; -#ifndef _WIN32_WCE +#ifndef UNDER_CE bool MyGetLogicalDriveStrings(CSysStringVector &driveStrings); #ifndef _UNICODE bool MyGetLogicalDriveStrings(UStringVector &driveStrings); diff --git a/CPP/Windows/FileIO.cpp b/CPP/Windows/FileIO.cpp index 7279ea15..938e6c70 100755 --- a/CPP/Windows/FileIO.cpp +++ b/CPP/Windows/FileIO.cpp @@ -21,6 +21,14 @@ namespace NFile { #ifdef SUPPORT_DEVICE_FILE bool IsDeviceName(LPCTSTR n) { + #ifdef UNDER_CE + int len = (int)MyStringLen(n); + if (len < 5 || len > 5 || memcmp(n, TEXT("DSK"), 3 * sizeof(TCHAR)) != 0) + return false; + if (n[4] != ':') + return false; + // for reading use SG_REQ sg; if (DeviceIoControl(dsk, IOCTL_DISK_READ)); + #else if (n[0] != '\\' || n[1] != '\\' || n[2] != '.' || n[3] != '\\') return false; int len = (int)MyStringLen(n); @@ -31,6 +39,7 @@ bool IsDeviceName(LPCTSTR n) for (int i = 17; i < len; i++) if (n[i] < '0' || n[i] > '9') return false; + #endif return true; } @@ -241,6 +250,11 @@ void CInFile::GetDeviceLength() { if (_handle != INVALID_HANDLE_VALUE && IsDeviceFile) { + #ifdef UNDER_CE + LengthDefined = true; + Length = 128 << 20; + + #else PARTITION_INFORMATION partInfo; LengthDefined = true; Length = 0; @@ -257,6 +271,7 @@ void CInFile::GetDeviceLength() Length = geom.Cylinders.QuadPart * geom.TracksPerCylinder * geom.SectorsPerTrack * geom.BytesPerSector; } // SeekToBegin(); + #endif } } @@ -360,10 +375,10 @@ bool COutFile::Create(LPCTSTR fileName, bool createAlways) #ifndef _UNICODE bool COutFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes) - { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); } + { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); } bool COutFile::Open(LPCWSTR fileName, DWORD creationDisposition) - { return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); } + { return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); } bool COutFile::Create(LPCWSTR fileName, bool createAlways) { return Open(fileName, GetCreationDisposition(createAlways)); } diff --git a/CPP/Windows/FileIO.h b/CPP/Windows/FileIO.h index 4e7308c7..dce692fe 100755 --- a/CPP/Windows/FileIO.h +++ b/CPP/Windows/FileIO.h @@ -29,10 +29,10 @@ protected: HANDLE _handle; bool Create(LPCTSTR fileName, DWORD desiredAccess, - DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes); + DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes); #ifndef _UNICODE bool Create(LPCWSTR fileName, DWORD desiredAccess, - DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes); + DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes); #endif public: @@ -82,6 +82,7 @@ class CInFile: public CFileBase bool DeviceIoControlOut(DWORD controlCode, LPVOID outBuffer, DWORD outSize) const { return DeviceIoControl(controlCode, NULL, 0, outBuffer, outSize); } + #ifndef UNDER_CE bool GetGeometry(DISK_GEOMETRY *res) const { return DeviceIoControlOut(IOCTL_DISK_GET_DRIVE_GEOMETRY, res, sizeof(*res)); } @@ -90,6 +91,7 @@ class CInFile: public CFileBase bool GetPartitionInfo(PARTITION_INFORMATION *res) { return DeviceIoControlOut(IOCTL_DISK_GET_PARTITION_INFO, LPVOID(res), sizeof(*res)); } + #endif void GetDeviceLength(); #endif diff --git a/CPP/Windows/FileMapping.h b/CPP/Windows/FileMapping.h index 25f5a519..3f0ebd74 100755 --- a/CPP/Windows/FileMapping.h +++ b/CPP/Windows/FileMapping.h @@ -3,46 +3,58 @@ #ifndef __WINDOWS_FILEMAPPING_H #define __WINDOWS_FILEMAPPING_H -#include "Windows/Handle.h" -#include "Windows/Defs.h" +#include "Common/Types.h" + +#include "Handle.h" namespace NWindows { -// namespace NFile { -// namespace NMapping { class CFileMapping: public CHandle { public: - bool Create(HANDLE file, LPSECURITY_ATTRIBUTES attributes, - DWORD protect, UINT64 maximumSize, LPCTSTR name) + WRes Create(DWORD protect, UInt64 maxSize, LPCTSTR name) { - _handle = ::CreateFileMapping(file, attributes, - protect, DWORD(maximumSize >> 32), DWORD(maximumSize), name); - return (_handle != NULL); + _handle = ::CreateFileMapping(INVALID_HANDLE_VALUE, NULL, protect, (DWORD)(maxSize >> 32), (DWORD)maxSize, name); + return ::GetLastError(); } - bool Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name) + WRes Open(DWORD desiredAccess, LPCTSTR name) { - _handle = ::OpenFileMapping(desiredAccess, BoolToBOOL(inheritHandle), name); - return (_handle != NULL); + #ifdef UNDER_CE + WRes res = Create(PAGE_READONLY, 0, name); + if (res == ERROR_ALREADY_EXISTS) + return 0; + Close(); + if (res == 0) + res = ERROR_FILE_NOT_FOUND; + return res; + #else + _handle = ::OpenFileMapping(desiredAccess, FALSE, name); + if (_handle != 0) + return 0; + return ::GetLastError(); + #endif } - LPVOID MapViewOfFile(DWORD desiredAccess, UINT64 fileOffset, - SIZE_T numberOfBytesToMap) + LPVOID Map(DWORD desiredAccess, UInt64 fileOffset, SIZE_T numberOfBytesToMap) { - return ::MapViewOfFile(_handle, desiredAccess, - DWORD(fileOffset >> 32), DWORD(fileOffset), numberOfBytesToMap); + return ::MapViewOfFile(_handle, desiredAccess, (DWORD)(fileOffset >> 32), (DWORD)fileOffset, numberOfBytesToMap); } - LPVOID MapViewOfFileEx(DWORD desiredAccess, UINT64 fileOffset, - SIZE_T numberOfBytesToMap, LPVOID baseAddress) + #ifndef UNDER_CE + LPVOID Map(DWORD desiredAccess, UInt64 fileOffset, SIZE_T numberOfBytesToMap, LPVOID baseAddress) { - return ::MapViewOfFileEx(_handle, desiredAccess, - DWORD(fileOffset >> 32), DWORD(fileOffset), - numberOfBytesToMap, baseAddress); + return ::MapViewOfFileEx(_handle, desiredAccess, (DWORD)(fileOffset >> 32), (DWORD)fileOffset, numberOfBytesToMap, baseAddress); } - + #endif +}; +class CFileUnmapper +{ + const void *_data; +public: + CFileUnmapper(const void *data) : _data(data) {} + ~CFileUnmapper() { ::UnmapViewOfFile(_data); } }; } diff --git a/CPP/Windows/Handle.h b/CPP/Windows/Handle.h index 0791b4ac..bb7cb705 100755 --- a/CPP/Windows/Handle.h +++ b/CPP/Windows/Handle.h @@ -13,6 +13,7 @@ public: operator HANDLE() { return _handle; } CHandle(): _handle(NULL) {} ~CHandle() { Close(); } + bool IsCreated() const { return (_handle != NULL); } bool Close() { if (_handle == NULL) @@ -22,8 +23,7 @@ public: _handle = NULL; return true; } - void Attach(HANDLE handle) - { _handle = handle; } + void Attach(HANDLE handle) { _handle = handle; } HANDLE Detach() { HANDLE handle = _handle; diff --git a/CPP/Windows/Memory.cpp b/CPP/Windows/Memory.cpp index 435ea999..4c23205e 100755 --- a/CPP/Windows/Memory.cpp +++ b/CPP/Windows/Memory.cpp @@ -7,11 +7,6 @@ namespace NWindows { namespace NMemory { -CGlobal::~CGlobal() -{ - Free(); -} - bool CGlobal::Alloc(UINT flags, SIZE_T size) { HGLOBAL newBlock = ::GlobalAlloc(flags, size); @@ -29,29 +24,6 @@ bool CGlobal::Free() return (m_MemoryHandle == NULL); } -void CGlobal::Attach(HGLOBAL hGlobal) -{ - Free(); - m_MemoryHandle = hGlobal; -} - -HGLOBAL CGlobal::Detach() -{ - HGLOBAL h = m_MemoryHandle; - m_MemoryHandle = NULL; - return h; -} - -LPVOID CGlobal::Lock() const -{ - return ::GlobalLock(m_MemoryHandle); -} - -void CGlobal::Unlock() const -{ - ::GlobalUnlock(m_MemoryHandle); -} - bool CGlobal::ReAlloc(SIZE_T size) { HGLOBAL newBlock = ::GlobalReAlloc(m_MemoryHandle, size, GMEM_MOVEABLE); diff --git a/CPP/Windows/Memory.h b/CPP/Windows/Memory.h index 763c9575..1984baf6 100755 --- a/CPP/Windows/Memory.h +++ b/CPP/Windows/Memory.h @@ -11,18 +11,26 @@ class CGlobal HGLOBAL m_MemoryHandle; public: CGlobal(): m_MemoryHandle(NULL){}; - ~CGlobal(); + ~CGlobal() { Free(); } operator HGLOBAL() const { return m_MemoryHandle; }; - void Attach(HGLOBAL hGlobal); - HGLOBAL Detach(); + void Attach(HGLOBAL hGlobal) + { + Free(); + m_MemoryHandle = hGlobal; + } + HGLOBAL Detach() + { + HGLOBAL h = m_MemoryHandle; + m_MemoryHandle = NULL; + return h; + } bool Alloc(UINT flags, SIZE_T size); bool Free(); - LPVOID Lock() const; - void Unlock() const; + LPVOID Lock() const { return GlobalLock(m_MemoryHandle); } + void Unlock() const { GlobalUnlock(m_MemoryHandle); } bool ReAlloc(SIZE_T size); }; - class CGlobalLock { HGLOBAL m_Global; @@ -31,12 +39,12 @@ public: LPVOID GetPointer() const { return m_Pointer; } CGlobalLock(HGLOBAL hGlobal): m_Global(hGlobal) { - m_Pointer = ::GlobalLock(hGlobal); + m_Pointer = GlobalLock(hGlobal); }; ~CGlobalLock() { if (m_Pointer != NULL) - ::GlobalUnlock(m_Global); + GlobalUnlock(m_Global); } }; diff --git a/CPP/Windows/MemoryLock.cpp b/CPP/Windows/MemoryLock.cpp index 284c832c..e0f43099 100755 --- a/CPP/Windows/MemoryLock.cpp +++ b/CPP/Windows/MemoryLock.cpp @@ -5,6 +5,8 @@ namespace NWindows { namespace NSecurity { +#ifndef UNDER_CE + #ifndef _UNICODE typedef BOOL (WINAPI * OpenProcessTokenP)(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle); typedef BOOL (WINAPI * LookupPrivilegeValueP)(LPCTSTR lpSystemName, LPCTSTR lpName, PLUID lpLuid); @@ -75,4 +77,6 @@ bool EnableLockMemoryPrivilege(bool enable) } #endif +#endif + }} diff --git a/CPP/Windows/MemoryLock.h b/CPP/Windows/MemoryLock.h index 321024bd..5fe619de 100755 --- a/CPP/Windows/MemoryLock.h +++ b/CPP/Windows/MemoryLock.h @@ -6,7 +6,9 @@ namespace NWindows { namespace NSecurity { +#ifndef UNDER_CE bool EnableLockMemoryPrivilege(bool enable = true); +#endif }} diff --git a/CPP/Windows/Menu.cpp b/CPP/Windows/Menu.cpp index 0c16a0e9..675f8623 100755 --- a/CPP/Windows/Menu.cpp +++ b/CPP/Windows/Menu.cpp @@ -161,7 +161,20 @@ bool CMenu::InsertItem(UINT itemIndex, bool byPosition, const CMenuItem &item) ConvertItemToSysForm(item, si); if (item.IsString()) si.dwTypeData = (LPWSTR)(LPCWSTR)item.StringValue; + #ifdef UNDER_CE + UINT flags = (item.fType & MFT_SEPARATOR) ? MF_SEPARATOR : MF_STRING; + UINT id = item.wID; + if ((item.fMask & MIIM_SUBMENU) != 0) + { + flags |= MF_POPUP; + id = (UINT)item.hSubMenu; + } + if (!Insert(itemIndex, flags | (byPosition ? MF_BYPOSITION : MF_BYCOMMAND), id, item.StringValue)) + return false; + return SetItemInfo(itemIndex, byPosition, &si); + #else return InsertItem(itemIndex, byPosition, &si); + #endif } } diff --git a/CPP/Windows/Menu.h b/CPP/Windows/Menu.h index f14287de..2563b911 100755 --- a/CPP/Windows/Menu.h +++ b/CPP/Windows/Menu.h @@ -24,6 +24,7 @@ struct CMenuItem // HBITMAP hbmpItem; bool IsString() const // change it MIIM_STRING { return ((fMask & MIIM_TYPE) != 0 && (fType == MFT_STRING)); } + bool IsSeparator() const { return (fType == MFT_SEPARATOR); } CMenuItem(): fMask(0), fType(0), fState(0), wID(0), hSubMenu(0), hbmpChecked(0), hbmpUnchecked(0), dwItemData(0) {} }; @@ -63,23 +64,33 @@ public: } int GetItemCount() - { return GetMenuItemCount(_menu); } + { + #ifdef UNDER_CE + for (int i = 0;; i++) + { + CMenuItem item; + item.fMask = MIIM_STATE; + if (!GetItem(i, true, item)) + return i; + } + #else + return GetMenuItemCount(_menu); + #endif + } - HMENU GetSubMenu(int pos) - { return ::GetSubMenu(_menu, pos); } + HMENU GetSubMenu(int pos) { return ::GetSubMenu(_menu, pos); } + #ifndef UNDER_CE bool GetItemString(UINT idItem, UINT flag, CSysString &result) { result.Empty(); int len = ::GetMenuString(_menu, idItem, 0, 0, flag); - len = ::GetMenuString(_menu, idItem, result.GetBuffer(len + 2), - len + 1, flag); + len = ::GetMenuString(_menu, idItem, result.GetBuffer(len + 2), len + 1, flag); result.ReleaseBuffer(); return (len != 0); } - UINT GetItemID(int pos) - { return ::GetMenuItemID(_menu, pos); } - UINT GetItemState(UINT id, UINT flags) - { return ::GetMenuState(_menu, id, flags); } + UINT GetItemID(int pos) { return ::GetMenuItemID(_menu, pos); } + UINT GetItemState(UINT id, UINT flags) { return ::GetMenuState(_menu, id, flags); } + #endif bool GetItemInfo(UINT itemIndex, bool byPosition, LPMENUITEMINFO itemInfo) { return BOOLToBool(::GetMenuItemInfo(_menu, itemIndex, BoolToBOOL(byPosition), itemInfo)); } @@ -92,11 +103,14 @@ public: bool Insert(UINT position, UINT flags, UINT_PTR idNewItem, LPCTSTR newItem) { return BOOLToBool(::InsertMenu(_menu, position, flags, idNewItem, newItem)); } + #ifndef UNDER_CE bool InsertItem(UINT itemIndex, bool byPosition, LPCMENUITEMINFO itemInfo) { return BOOLToBool(::InsertMenuItem(_menu, itemIndex, BoolToBOOL(byPosition), itemInfo)); } + #endif - bool RemoveItem(UINT item, UINT flags) - { return BOOLToBool(::RemoveMenu(_menu, item, flags)); } + bool RemoveItem(UINT item, UINT flags) { return BOOLToBool(::RemoveMenu(_menu, item, flags)); } + void RemoveAllItemsFrom(UINT index) { while (RemoveItem(index, MF_BYPOSITION)); } + void RemoveAllItems() { RemoveAllItemsFrom(0); } #ifndef _UNICODE bool GetItemInfo(UINT itemIndex, bool byPosition, LPMENUITEMINFOW itemInfo) @@ -112,16 +126,15 @@ public: bool SetItem(UINT itemIndex, bool byPosition, const CMenuItem &item); bool InsertItem(UINT itemIndex, bool byPosition, const CMenuItem &item); - int Track(UINT flags, int x, int y, HWND hWnd) - { return ::TrackPopupMenuEx(_menu, flags, x, y, hWnd, NULL); } + int Track(UINT flags, int x, int y, HWND hWnd) { return ::TrackPopupMenuEx(_menu, flags, x, y, hWnd, NULL); } bool CheckRadioItem(UINT idFirst, UINT idLast, UINT idCheck, UINT flags) { return BOOLToBool(::CheckMenuRadioItem(_menu, idFirst, idLast, idCheck, flags)); } - DWORD CheckItem(UINT id, UINT uCheck) - { return ::CheckMenuItem(_menu, id, uCheck); } - BOOL EnableItem(UINT uIDEnableItem, UINT uEnable) - { return EnableMenuItem(_menu, uIDEnableItem, uEnable); } + DWORD CheckItem(UINT id, UINT uCheck) { return ::CheckMenuItem(_menu, id, uCheck); } + DWORD CheckItemByID(UINT id, bool check) { return CheckItem(id, MF_BYCOMMAND | (check ? MF_CHECKED : MF_UNCHECKED)); } + + BOOL EnableItem(UINT uIDEnableItem, UINT uEnable) { return EnableMenuItem(_menu, uIDEnableItem, uEnable); } }; class CMenuDestroyer diff --git a/CPP/Windows/Net.cpp b/CPP/Windows/Net.cpp index a5c3f15c..b0a18732 100755 --- a/CPP/Windows/Net.cpp +++ b/CPP/Windows/Net.cpp @@ -2,12 +2,12 @@ #include "StdAfx.h" -#include "Windows/Net.h" - #ifndef _UNICODE #include "Common/StringConvert.h" #endif +#include "Windows/Net.h" + #ifndef _UNICODE extern bool g_IsNT; #endif @@ -105,7 +105,7 @@ static void SetComplexString2(LPWSTR *destString, bool defined, const UString &s *destString = 0; } -static void ConvertCResourceToNETRESOURCE(const CResourceW &resource, NETRESOURCEW &netResource) +static void ConvertCResourceToNETRESOURCE(const CResourceW &resource, NETRESOURCEW &netResource) { netResource.dwScope = resource.Scope; netResource.dwType = resource.Type; @@ -209,7 +209,7 @@ DWORD CEnum::Next(CResource &resource) ZeroMemory(lpnrLocal, kBufferSize); DWORD bufferSize = kBufferSize; DWORD numEntries = 1; - DWORD result = Next(&numEntries, lpnrLocal, &bufferSize); + DWORD result = Next(&numEntries, lpnrLocal, &bufferSize); if (result != NO_ERROR) return result; if (numEntries != 1) @@ -230,7 +230,7 @@ DWORD CEnum::Next(CResourceW &resource) ZeroMemory(lpnrLocal, kBufferSize); DWORD bufferSize = kBufferSize; DWORD numEntries = 1; - DWORD result = NextW(&numEntries, lpnrLocal, &bufferSize); + DWORD result = NextW(&numEntries, lpnrLocal, &bufferSize); if (result != NO_ERROR) return result; if (numEntries != 1) @@ -256,7 +256,7 @@ DWORD GetResourceParent(const CResource &resource, CResource &parentResource) DWORD bufferSize = kBufferSize; NETRESOURCE netResource; ConvertCResourceToNETRESOURCE(resource, netResource); - DWORD result = ::WNetGetResourceParent(&netResource, lpnrLocal, &bufferSize); + DWORD result = ::WNetGetResourceParent(&netResource, lpnrLocal, &bufferSize); if (result != NO_ERROR) return result; ConvertNETRESOURCEToCResource(lpnrLocal[0], parentResource); @@ -276,7 +276,7 @@ DWORD GetResourceParent(const CResourceW &resource, CResourceW &parentResource) DWORD bufferSize = kBufferSize; NETRESOURCEW netResource; ConvertCResourceToNETRESOURCE(resource, netResource); - DWORD result = ::WNetGetResourceParentW(&netResource, lpnrLocal, &bufferSize); + DWORD result = ::WNetGetResourceParentW(&netResource, lpnrLocal, &bufferSize); if (result != NO_ERROR) return result; ConvertNETRESOURCEToCResource(lpnrLocal[0], parentResource); diff --git a/CPP/Windows/NtCheck.h b/CPP/Windows/NtCheck.h new file mode 100755 index 00000000..e56318f0 --- /dev/null +++ b/CPP/Windows/NtCheck.h @@ -0,0 +1,44 @@ +// Windows/NtCheck.h + +#ifndef __WINDOWS_NT_CHECK_H +#define __WINDOWS_NT_CHECK_H + +#ifdef _WIN32 + +#if !defined(_WIN64) && !defined(UNDER_CE) +static inline bool IsItWindowsNT() +{ + OSVERSIONINFO vi; + vi.dwOSVersionInfoSize = sizeof(vi); + return (::GetVersionEx(&vi) && vi.dwPlatformId == VER_PLATFORM_WIN32_NT); +} +#endif + +#ifndef _UNICODE + #if defined(_WIN64) || defined(UNDER_CE) + bool g_IsNT = true; + #define SET_IS_NT + #else + bool g_IsNT = false; + #define SET_IS_NT g_IsNT = IsItWindowsNT(); + #endif + #define NT_CHECK_ACTION + // #define NT_CHECK_ACTION { NT_CHECK_FAIL_ACTION } +#else + #if !defined(_WIN64) && !defined(UNDER_CE) + #define NT_CHECK_ACTION if (!IsItWindowsNT()) { NT_CHECK_FAIL_ACTION } + #else + #define NT_CHECK_ACTION + #endif + #define SET_IS_NT +#endif + +#define NT_CHECK NT_CHECK_ACTION SET_IS_NT + +#else + +#define NT_CHECK + +#endif + +#endif diff --git a/CPP/Windows/Process.cpp b/CPP/Windows/Process.cpp new file mode 100755 index 00000000..d600abe0 --- /dev/null +++ b/CPP/Windows/Process.cpp @@ -0,0 +1,81 @@ +// Process.cpp + +#include "StdAfx.h" + +#include "../Common/StringConvert.h" + +#include "Process.h" + +#ifndef _UNICODE +extern bool g_IsNT; +#endif _UNICODE + +namespace NWindows { + +static UString GetQuotedString(const UString &s) +{ + return UString(L'\"') + s + UString(L'\"'); +} + +WRes CProcess::Create(LPCWSTR imageName, const UString ¶ms, LPCWSTR curDir) +{ + Close(); + const UString params2 = + #ifndef UNDER_CE + GetQuotedString(imageName) + L' ' + + #endif + params; + #ifdef UNDER_CE + curDir = 0; + #else + imageName = 0; + #endif + PROCESS_INFORMATION pi; + BOOL result; + #ifndef _UNICODE + if (!g_IsNT) + { + STARTUPINFOA si; + si.cb = sizeof(si); + si.lpReserved = 0; + si.lpDesktop = 0; + si.lpTitle = 0; + si.dwFlags = 0; + si.cbReserved2 = 0; + si.lpReserved2 = 0; + + CSysString curDirA; + if (curDir != 0) + curDirA = GetSystemString(curDir); + result = ::CreateProcessA(NULL, (LPSTR)(LPCSTR)GetSystemString(params2), + NULL, NULL, FALSE, 0, NULL, ((curDir != 0) ? (LPCSTR)curDirA: 0), &si, &pi); + } + else + #endif + { + STARTUPINFOW si; + si.cb = sizeof(si); + si.lpReserved = 0; + si.lpDesktop = 0; + si.lpTitle = 0; + si.dwFlags = 0; + si.cbReserved2 = 0; + si.lpReserved2 = 0; + + result = CreateProcessW(imageName, (LPWSTR)(LPCWSTR)params2, + NULL, NULL, FALSE, 0, NULL, (LPWSTR)curDir, &si, &pi); + } + if (result == 0) + return ::GetLastError(); + ::CloseHandle(pi.hThread); + _handle = pi.hProcess; + return 0; +} + +WRes MyCreateProcess(LPCWSTR imageName, const UString ¶ms) +{ + CProcess process; + return process.Create(imageName, params, 0); +} + +} diff --git a/CPP/Windows/Process.h b/CPP/Windows/Process.h new file mode 100755 index 00000000..5b01c377 --- /dev/null +++ b/CPP/Windows/Process.h @@ -0,0 +1,100 @@ +// Windows/Process.h + +#ifndef __WINDOWS_PROCESS_H +#define __WINDOWS_PROCESS_H + +#include <psapi.h> + +#include "../Common/MyString.h" + +#include "Defs.h" +#include "Handle.h" + +namespace NWindows { + +class CProcess: public CHandle +{ +public: + bool Open(DWORD desiredAccess, bool inheritHandle, DWORD processId) + { + _handle = ::OpenProcess(desiredAccess, inheritHandle, processId); + return (_handle != 0); + } + + #ifndef UNDER_CE + + bool GetExitCodeProcess(LPDWORD lpExitCode) { return BOOLToBool(::GetExitCodeProcess(_handle, lpExitCode)); } + bool Terminate(UINT exitCode) { return BOOLToBool(::TerminateProcess(_handle, exitCode)); } + #if(WINVER >= 0x0500) + DWORD GetGuiResources (DWORD uiFlags) { return ::GetGuiResources(_handle, uiFlags); } + #endif + bool SetPriorityClass(DWORD dwPriorityClass) { return BOOLToBool(::SetPriorityClass(_handle, dwPriorityClass)); } + DWORD GetPriorityClass() { return ::GetPriorityClass(_handle); } + bool GetIoCounters(PIO_COUNTERS lpIoCounters ) { return BOOLToBool(::GetProcessIoCounters(_handle, lpIoCounters )); } + + bool GetTimes(LPFILETIME creationTime, LPFILETIME exitTime, LPFILETIME kernelTime, LPFILETIME userTime) + { return BOOLToBool(::GetProcessTimes(_handle, creationTime, exitTime, kernelTime, userTime)); } + + DWORD WaitForInputIdle(DWORD milliseconds) { return ::WaitForInputIdle(_handle, milliseconds); } + + // Debug + + bool ReadMemory(LPCVOID baseAddress, LPVOID buffer, SIZE_T size, SIZE_T* numberOfBytesRead) + { return BOOLToBool(::ReadProcessMemory(_handle, baseAddress, buffer, size, numberOfBytesRead)); } + + bool WriteMemory(LPVOID baseAddress, LPCVOID buffer, SIZE_T size, SIZE_T* numberOfBytesWritten) + { return BOOLToBool(::WriteProcessMemory(_handle, baseAddress, buffer, size, numberOfBytesWritten)); } + + bool FlushInstructionCache(LPCVOID baseAddress = 0, SIZE_T size = 0) + { return BOOLToBool(::FlushInstructionCache(_handle, baseAddress, size)); } + + LPVOID VirtualAlloc(LPVOID address, SIZE_T size, DWORD allocationType, DWORD protect) + { return VirtualAllocEx(_handle, address, size, allocationType, protect); } + + bool VirtualFree(LPVOID address, SIZE_T size, DWORD freeType) + { return BOOLToBool(::VirtualFreeEx(_handle, address, size, freeType)); } + + // Process Status API (PSAPI) + + bool EmptyWorkingSet() + { return BOOLToBool(::EmptyWorkingSet(_handle)); } + bool EnumModules(HMODULE *hModules, DWORD arraySizeInBytes, LPDWORD receivedBytes) + { return BOOLToBool(::EnumProcessModules(_handle, hModules, arraySizeInBytes, receivedBytes)); } + + DWORD MyGetModuleBaseName(HMODULE hModule, LPTSTR baseName, DWORD size) + { return ::GetModuleBaseName(_handle, hModule, baseName, size); } + bool MyGetModuleBaseName(HMODULE hModule, CSysString &name) + { + const int length = 1000; + DWORD resultLen = MyGetModuleBaseName(hModule, name.GetBuffer(length), length); + name.ReleaseBuffer(); + return (resultLen != 0); + } + + DWORD MyGetModuleFileNameEx(HMODULE hModule, LPTSTR baseName, DWORD size) + { return ::GetModuleFileNameEx(_handle, hModule, baseName, size); } + bool MyGetModuleFileNameEx(HMODULE hModule, CSysString &name) + { + const int length = MAX_PATH + 100; + DWORD resultLen = MyGetModuleFileNameEx(hModule, name.GetBuffer(length), length); + name.ReleaseBuffer(); + return (resultLen != 0); + } + + bool GetModuleInformation(HMODULE hModule, LPMODULEINFO moduleInfo) + { return BOOLToBool(::GetModuleInformation(_handle, hModule, moduleInfo, sizeof(MODULEINFO))); } + bool GetMemoryInfo(PPROCESS_MEMORY_COUNTERS memCounters) + { return BOOLToBool(::GetProcessMemoryInfo(_handle, memCounters, sizeof(PROCESS_MEMORY_COUNTERS))); } + + #endif + + WRes Create(LPCWSTR imageName, const UString ¶ms, LPCWSTR curDir); + + DWORD Wait() { return ::WaitForSingleObject(_handle, INFINITE); } +}; + +WRes MyCreateProcess(LPCWSTR imageName, const UString ¶ms); + +} + +#endif diff --git a/CPP/Windows/PropVariantConversions.cpp b/CPP/Windows/PropVariantConversions.cpp index df8abfb0..2d8456cd 100755 --- a/CPP/Windows/PropVariantConversions.cpp +++ b/CPP/Windows/PropVariantConversions.cpp @@ -2,12 +2,12 @@ #include "StdAfx.h" -#include "PropVariantConversions.h" +#include "Common/IntToString.h" +#include "Common/StringConvert.h" #include "Windows/Defs.h" -#include "Common/StringConvert.h" -#include "Common/IntToString.h" +#include "PropVariantConversions.h" static UString ConvertUInt64ToString(UInt64 value) { @@ -64,10 +64,10 @@ bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime, bool return true; } -UString ConvertFileTimeToString(const FILETIME &fileTime, bool includeTime, bool includeSeconds) +UString ConvertFileTimeToString(const FILETIME &ft, bool includeTime, bool includeSeconds) { char s[32]; - ConvertFileTimeToString(fileTime, s, includeTime, includeSeconds); + ConvertFileTimeToString(ft, s, includeTime, includeSeconds); return GetUnicodeString(s); } @@ -88,12 +88,7 @@ UString ConvertPropVariantToString(const PROPVARIANT &prop) case VT_I4: return ConvertInt64ToString(prop.lVal); case VT_I8: return ConvertInt64ToString(prop.hVal.QuadPart); case VT_BOOL: return VARIANT_BOOLToBool(prop.boolVal) ? L"+" : L"-"; - default: - #ifndef _WIN32_WCE - throw 150245; - #else - return UString(); - #endif + default: throw 150245; } } @@ -105,11 +100,6 @@ UInt64 ConvertPropVariantToUInt64(const PROPVARIANT &prop) case VT_UI2: return prop.uiVal; case VT_UI4: return prop.ulVal; case VT_UI8: return (UInt64)prop.uhVal.QuadPart; - default: - #ifndef _WIN32_WCE - throw 151199; - #else - return 0; - #endif + default: throw 151199; } } diff --git a/CPP/Windows/PropVariantConversions.h b/CPP/Windows/PropVariantConversions.h index 68ad9612..3de4dedb 100755 --- a/CPP/Windows/PropVariantConversions.h +++ b/CPP/Windows/PropVariantConversions.h @@ -1,14 +1,14 @@ // Windows/PropVariantConversions.h -#ifndef __PROPVARIANTCONVERSIONS_H -#define __PROPVARIANTCONVERSIONS_H +#ifndef __PROP_VARIANT_CONVERSIONS_H +#define __PROP_VARIANT_CONVERSIONS_H -#include "Common/Types.h" #include "Common/MyString.h" +#include "Common/Types.h" bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime = true, bool includeSeconds = true); UString ConvertFileTimeToString(const FILETIME &ft, bool includeTime = true, bool includeSeconds = true); -UString ConvertPropVariantToString(const PROPVARIANT &propVariant); -UInt64 ConvertPropVariantToUInt64(const PROPVARIANT &propVariant); +UString ConvertPropVariantToString(const PROPVARIANT &prop); +UInt64 ConvertPropVariantToUInt64(const PROPVARIANT &prop); #endif diff --git a/CPP/Windows/Registry.cpp b/CPP/Windows/Registry.cpp index 96cab0c2..8b25375d 100755 --- a/CPP/Windows/Registry.cpp +++ b/CPP/Windows/Registry.cpp @@ -16,24 +16,6 @@ namespace NRegistry { #define MYASSERT(expr) // _ASSERTE(expr) -CKey::~CKey() -{ - Close(); -} - -HKEY CKey::Detach() -{ - HKEY hKey = _object; - _object = NULL; - return hKey; -} - -void CKey::Attach(HKEY hKey) -{ - MYASSERT(_object == NULL); - _object = hKey; -} - LONG CKey::Create(HKEY parentKey, LPCTSTR keyName, LPTSTR keyClass, DWORD options, REGSAM accessMask, LPSECURITY_ATTRIBUTES securityAttributes, LPDWORD disposition) @@ -224,6 +206,24 @@ LONG CKey::QueryValue(LPCTSTR name, bool &value) return res; } +LONG CKey::GetValue_IfOk(LPCTSTR name, UInt32 &value) +{ + UInt32 newVal; + LONG res = QueryValue(name, newVal); + if (res == ERROR_SUCCESS) + value = newVal; + return res; +} + +LONG CKey::GetValue_IfOk(LPCTSTR name, bool &value) +{ + bool newVal; + LONG res = QueryValue(name, newVal); + if (res == ERROR_SUCCESS) + value = newVal; + return res; +} + LONG CKey::QueryValue(LPCTSTR name, LPTSTR value, UInt32 &count) { MYASSERT(count != NULL); @@ -321,4 +321,49 @@ LONG CKey::EnumKeys(CSysStringVector &keyNames) return ERROR_SUCCESS; } +LONG CKey::SetValue_Strings(LPCTSTR valueName, const UStringVector &strings) +{ + UInt32 numChars = 0; + int i; + for (i = 0; i < strings.Size(); i++) + numChars += strings[i].Length() + 1; + CBuffer<wchar_t> buffer; + buffer.SetCapacity(numChars); + int pos = 0; + for (i = 0; i < strings.Size(); i++) + { + const UString &s = strings[i]; + MyStringCopy((wchar_t *)buffer + pos, (const wchar_t *)s); + pos += s.Length() + 1; + } + return SetValue(valueName, buffer, numChars * sizeof(wchar_t)); +} + +LONG CKey::GetValue_Strings(LPCTSTR valueName, UStringVector &strings) +{ + strings.Clear(); + CByteBuffer buffer; + UInt32 dataSize; + LONG res = QueryValue(valueName, buffer, dataSize); + if (res != ERROR_SUCCESS) + return res; + if (dataSize % sizeof(wchar_t) != 0) + return E_FAIL; + const wchar_t *data = (const wchar_t *)(const Byte *)buffer; + int numChars = dataSize / sizeof(wchar_t); + UString s; + for (int i = 0; i < numChars; i++) + { + wchar_t c = data[i]; + if (c == 0) + { + strings.Add(s); + s.Empty(); + } + else + s += c; + } + return res; +} + }} diff --git a/CPP/Windows/Registry.h b/CPP/Windows/Registry.h index c6b14572..f0561e68 100755 --- a/CPP/Windows/Registry.h +++ b/CPP/Windows/Registry.h @@ -17,19 +17,23 @@ class CKey HKEY _object; public: CKey(): _object(NULL) {} - ~CKey(); + ~CKey() { Close(); } operator HKEY() const { return _object; } + void Attach(HKEY key) { _object = key; } + HKEY Detach() + { + HKEY key = _object; + _object = NULL; + return key; + } - HKEY Detach(); - void Attach(HKEY key); LONG Create(HKEY parentKey, LPCTSTR keyName, LPTSTR keyClass = REG_NONE, DWORD options = REG_OPTION_NON_VOLATILE, REGSAM accessMask = KEY_ALL_ACCESS, LPSECURITY_ATTRIBUTES securityAttributes = NULL, LPDWORD disposition = NULL); - LONG Open(HKEY parentKey, LPCTSTR keyName, - REGSAM accessMask = KEY_ALL_ACCESS); + LONG Open(HKEY parentKey, LPCTSTR keyName, REGSAM accessMask = KEY_ALL_ACCESS); LONG Close(); @@ -52,6 +56,9 @@ public: LONG SetValue(LPCTSTR name, const void *value, UInt32 size); + LONG SetValue_Strings(LPCTSTR valueName, const UStringVector &strings); + LONG GetValue_Strings(LPCTSTR valueName, UStringVector &strings); + LONG SetKeyValue(LPCTSTR keyName, LPCTSTR valueName, LPCTSTR value); LONG QueryValue(LPCTSTR name, UInt32 &value); @@ -59,6 +66,9 @@ public: LONG QueryValue(LPCTSTR name, LPTSTR value, UInt32 &dataSize); LONG QueryValue(LPCTSTR name, CSysString &value); + LONG GetValue_IfOk(LPCTSTR name, UInt32 &value); + LONG GetValue_IfOk(LPCTSTR name, bool &value); + #ifndef _UNICODE LONG QueryValue(LPCWSTR name, LPWSTR value, UInt32 &dataSize); LONG QueryValue(LPCWSTR name, UString &value); diff --git a/CPP/Windows/Security.h b/CPP/Windows/Security.h index 90cf2caf..ba66de44 100755 --- a/CPP/Windows/Security.h +++ b/CPP/Windows/Security.h @@ -3,10 +3,10 @@ #ifndef __WINDOWS_SECURITY_H #define __WINDOWS_SECURITY_H -#include "Defs.h" - #include <NTSecAPI.h> +#include "Defs.h" + namespace NWindows { namespace NSecurity { @@ -128,8 +128,8 @@ public: PLSA_ENUMERATION_INFORMATION *enumerationBuffer, PULONG countReturned) { return LsaEnumerateAccountsWithUserRight(_handle, userRights, (void **)enumerationBuffer, countReturned); } - NTSTATUS EnumerateAccountRights(PSID sid, PLSA_UNICODE_STRING* userRights, PULONG countOfRights) - { return ::LsaEnumerateAccountRights(_handle, sid, userRights, countOfRights); } + NTSTATUS EnumerateAccountRights(PSID sid, PLSA_UNICODE_STRING* userRights, PULONG countOfRights) + { return ::LsaEnumerateAccountRights(_handle, sid, userRights, countOfRights); } NTSTATUS LookupSids(ULONG count, PSID* sids, PLSA_REFERENCED_DOMAIN_LIST* referencedDomains, PLSA_TRANSLATED_NAME* names) diff --git a/CPP/Windows/Shell.cpp b/CPP/Windows/Shell.cpp index f2aee286..010449fb 100755 --- a/CPP/Windows/Shell.cpp +++ b/CPP/Windows/Shell.cpp @@ -2,12 +2,13 @@ #include "StdAfx.h" +#include "Common/MyCom.h" #ifndef _UNICODE #include "Common/StringConvert.h" #endif -#include "Common/MyCom.h" -#include "Windows/Shell.h" + #include "Windows/COM.h" +#include "Windows/Shell.h" #ifndef _UNICODE extern bool g_IsNT; @@ -16,8 +17,9 @@ extern bool g_IsNT; namespace NWindows { namespace NShell { -///////////////////////// -// CItemIDList +#ifndef UNDER_CE + +// SHGetMalloc is unsupported in Windows Mobile? void CItemIDList::Free() { @@ -62,6 +64,7 @@ CItemIDList& CItemIDList::operator=(const CItemIDList &object) return *this; } */ + ///////////////////////////// // CDrop @@ -79,11 +82,6 @@ void CDrop::Free() m_Assigned = false; } -CDrop::~CDrop() -{ - Free(); -} - UINT CDrop::QueryCountOfFiles() { return QueryFile(0xFFFFFFFF, (LPTSTR)NULL, 0); @@ -121,9 +119,6 @@ void CDrop::QueryFileNames(UStringVector &fileNames) } -///////////////////////////// -// Functions - bool GetPathFromIDList(LPCITEMIDLIST itemIDList, CSysString &path) { bool result = BOOLToBool(::SHGetPathFromIDList(itemIDList, path.GetBuffer(MAX_PATH * 2))); @@ -131,6 +126,40 @@ bool GetPathFromIDList(LPCITEMIDLIST itemIDList, CSysString &path) return result; } +#endif + +#ifdef UNDER_CE + +bool BrowseForFolder(LPBROWSEINFO, CSysString) +{ + return false; +} + +bool BrowseForFolder(HWND, LPCTSTR, UINT, LPCTSTR, CSysString &) +{ + return false; +} + +bool BrowseForFolder(HWND owner, LPCTSTR title, + LPCTSTR initialFolder, CSysString &resultPath) +{ + /* + // SHBrowseForFolder doesn't work before CE 6.0 ? + if (GetProcAddress(LoadLibrary(L"ceshell.dll", L"SHBrowseForFolder") == 0) + MessageBoxW(0, L"no", L"", 0); + else + MessageBoxW(0, L"yes", L"", 0); + */ + /* + UString s = L"all files"; + s += L" (*.*)"; + return MyGetOpenFileName(owner, title, initialFolder, s, resultPath, true); + */ + return false; +} + +#else + bool BrowseForFolder(LPBROWSEINFO browseInfo, CSysString &resultPath) { NWindows::NCOM::CComInitializer comInitializer; @@ -145,6 +174,7 @@ bool BrowseForFolder(LPBROWSEINFO browseInfo, CSysString &resultPath) int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM data) { + #ifndef UNDER_CE switch(uMsg) { case BFFM_INITIALIZED: @@ -166,6 +196,7 @@ int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /* lp */, LPARAM da default: break; } + #endif return 0; } @@ -177,8 +208,15 @@ bool BrowseForFolder(HWND owner, LPCTSTR title, UINT ulFlags, BROWSEINFO browseInfo; browseInfo.hwndOwner = owner; browseInfo.pidlRoot = NULL; + + // there are Unicode/astring problems in WinCE SDK!!! + #ifdef UNDER_CE + browseInfo.pszDisplayName = (LPSTR)displayName.GetBuffer(MAX_PATH); + browseInfo.lpszTitle = (LPCSTR)title; + #else browseInfo.pszDisplayName = displayName.GetBuffer(MAX_PATH); browseInfo.lpszTitle = title; + #endif browseInfo.ulFlags = ulFlags; browseInfo.lpfn = (initialFolder != NULL) ? BrowseCallbackProc : NULL; browseInfo.lParam = (LPARAM)initialFolder; @@ -189,7 +227,10 @@ bool BrowseForFolder(HWND owner, LPCTSTR title, LPCTSTR initialFolder, CSysString &resultPath) { return BrowseForFolder(owner, title, - BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT, initialFolder, resultPath); + #ifndef UNDER_CE + BIF_NEWDIALOGSTYLE | + #endif + BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT, initialFolder, resultPath); // BIF_STATUSTEXT; BIF_USENEWUI (Version 5.0) } @@ -289,4 +330,6 @@ bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString & #endif +#endif + }} diff --git a/CPP/Windows/Shell.h b/CPP/Windows/Shell.h index 3990c334..d2b39acf 100755 --- a/CPP/Windows/Shell.h +++ b/CPP/Windows/Shell.h @@ -9,12 +9,12 @@ #include "Common/MyString.h" #include "Windows/Defs.h" - namespace NWindows{ namespace NShell{ ///////////////////////// // CItemIDList +#ifndef UNDER_CE class CItemIDList { @@ -55,9 +55,9 @@ class CDrop bool m_Assigned; void Free(); public: - CDrop(bool mustBeFinished) : m_MustBeFinished(mustBeFinished), - m_Assigned(false) {} - ~CDrop(); + CDrop(bool mustBeFinished) : m_MustBeFinished(mustBeFinished), m_Assigned(false) {} + ~CDrop() { Free(); } + void Attach(HDROP object); operator HDROP() { return m_Object;} bool QueryPoint(LPPOINT point) @@ -74,6 +74,8 @@ public: void QueryFileNames(UStringVector &fileNames); }; +#endif + ///////////////////////////// // Functions @@ -88,5 +90,4 @@ bool BrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString & #endif }} - -#endif
\ No newline at end of file +#endif diff --git a/CPP/Windows/Synchronization.h b/CPP/Windows/Synchronization.h index 54fcf952..dc695f6f 100755 --- a/CPP/Windows/Synchronization.h +++ b/CPP/Windows/Synchronization.h @@ -25,12 +25,10 @@ public: ~CBaseEvent() { Close(); } WRes Close() { return Event_Close(&_object); } #ifdef _WIN32 - WRes Create(bool manualReset, bool initiallyOwn, LPCTSTR name = NULL, - LPSECURITY_ATTRIBUTES securityAttributes = NULL) + WRes Create(bool manualReset, bool initiallyOwn, LPCTSTR name = NULL, LPSECURITY_ATTRIBUTES sa = NULL) { - _object = ::CreateEvent(securityAttributes, BoolToBOOL(manualReset), - BoolToBOOL(initiallyOwn), name); - if (_object != 0) + _object = ::CreateEvent(sa, BoolToBOOL(manualReset), BoolToBOOL(initiallyOwn), name); + if (name == NULL && _object != 0) return 0; return ::GetLastError(); } @@ -95,14 +93,14 @@ public: class CMutex: public CObject { public: - WRes Create(bool initiallyOwn, LPCTSTR name = NULL, - LPSECURITY_ATTRIBUTES securityAttributes = NULL) + WRes Create(bool initiallyOwn, LPCTSTR name = NULL, LPSECURITY_ATTRIBUTES sa = NULL) { - _handle = ::CreateMutex(securityAttributes, BoolToBOOL(initiallyOwn), name); - if (_handle != 0) + _handle = ::CreateMutex(sa, BoolToBOOL(initiallyOwn), name); + if (name == NULL && _handle != 0) return 0; return ::GetLastError(); } + #ifndef UNDER_CE WRes Open(DWORD desiredAccess, bool inheritHandle, LPCTSTR name) { _handle = ::OpenMutex(desiredAccess, BoolToBOOL(inheritHandle), name); @@ -110,6 +108,7 @@ public: return 0; return ::GetLastError(); } + #endif WRes Release() { return ::ReleaseMutex(_handle) ? 0 : ::GetLastError(); diff --git a/CPP/Windows/System.cpp b/CPP/Windows/System.cpp index 8e4069c2..4bc8d2a3 100755 --- a/CPP/Windows/System.cpp +++ b/CPP/Windows/System.cpp @@ -2,6 +2,8 @@ #include "StdAfx.h" +#include "../Common/Defs.h" + #include "System.h" namespace NWindows { @@ -14,6 +16,8 @@ UInt32 GetNumberOfProcessors() return (UInt32)systemInfo.dwNumberOfProcessors; } +#ifndef UNDER_CE + #if !defined(_WIN64) && defined(__GNUC__) typedef struct _MY_MEMORYSTATUSEX { @@ -37,26 +41,30 @@ typedef struct _MY_MEMORYSTATUSEX { typedef BOOL (WINAPI *GlobalMemoryStatusExP)(MY_LPMEMORYSTATUSEX lpBuffer); +#endif + UInt64 GetRamSize() { + #ifndef UNDER_CE MY_MEMORYSTATUSEX stat; stat.dwLength = sizeof(stat); + #endif #ifdef _WIN64 if (!::GlobalMemoryStatusEx(&stat)) return 0; - return stat.ullTotalPhys; + return MyMin(stat.ullTotalVirtual, stat.ullTotalPhys); #else + #ifndef UNDER_CE GlobalMemoryStatusExP globalMemoryStatusEx = (GlobalMemoryStatusExP) - ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), - "GlobalMemoryStatusEx"); - if (globalMemoryStatusEx != 0) - if (globalMemoryStatusEx(&stat)) - return stat.ullTotalPhys; + ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GlobalMemoryStatusEx"); + if (globalMemoryStatusEx != 0 && globalMemoryStatusEx(&stat)) + return MyMin(stat.ullTotalVirtual, stat.ullTotalPhys); + #endif { MEMORYSTATUS stat; stat.dwLength = sizeof(stat); - GlobalMemoryStatus(&stat); - return stat.dwTotalPhys; + ::GlobalMemoryStatus(&stat); + return MyMin(stat.dwTotalVirtual, stat.dwTotalPhys); } #endif } diff --git a/CPP/Windows/Time.cpp b/CPP/Windows/Time.cpp index 810dcbe2..ec9ca47d 100755 --- a/CPP/Windows/Time.cpp +++ b/CPP/Windows/Time.cpp @@ -2,45 +2,129 @@ #include "StdAfx.h" -#include "Time.h" #include "Windows/Defs.h" +#include "Time.h" + namespace NWindows { namespace NTime { -bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime) +static const UInt32 kNumTimeQuantumsInSecond = 10000000; +static const UInt32 kFileTimeStartYear = 1601; +static const UInt32 kDosTimeStartYear = 1980; +static const UInt32 kUnixTimeStartYear = 1970; +static const UInt64 kUnixTimeStartValue = ((UInt64)kNumTimeQuantumsInSecond) * + 60 * 60 * 24 * (89 + 365 * (kUnixTimeStartYear - kFileTimeStartYear)); + +bool DosTimeToFileTime(UInt32 dosTime, FILETIME &ft) { - return BOOLToBool(::DosDateTimeToFileTime((UInt16)(dosTime >> 16), (UInt16)(dosTime & 0xFFFF), &fileTime)); + #if defined(_WIN32) && !defined(UNDER_CE) + return BOOLToBool(::DosDateTimeToFileTime((UInt16)(dosTime >> 16), (UInt16)(dosTime & 0xFFFF), &ft)); + #else + ft.dwLowDateTime = 0; + ft.dwHighDateTime = 0; + UInt64 res; + if (!GetSecondsSince1601(kDosTimeStartYear + (dosTime >> 25), (dosTime >> 21) & 0xF, (dosTime >> 16) & 0x1F, + (dosTime >> 11) & 0x1F, (dosTime >> 5) & 0x3F, (dosTime & 0x1F) * 2, res)) + return false; + res *= kNumTimeQuantumsInSecond; + ft.dwLowDateTime = (UInt32)res; + ft.dwHighDateTime = (UInt32)(res >> 32); + return true; + #endif } static const UInt32 kHighDosTime = 0xFF9FBF7D; static const UInt32 kLowDosTime = 0x210000; -bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime) +#define PERIOD_4 (4 * 365 + 1) +#define PERIOD_100 (PERIOD_4 * 25 - 1) +#define PERIOD_400 (PERIOD_100 * 4 + 1) + +bool FileTimeToDosTime(const FILETIME &ft, UInt32 &dosTime) { + #if defined(_WIN32) && !defined(UNDER_CE) + WORD datePart, timePart; - if (!::FileTimeToDosDateTime(&fileTime, &datePart, &timePart)) + if (!::FileTimeToDosDateTime(&ft, &datePart, &timePart)) { - dosTime = (fileTime.dwHighDateTime >= 0x01C00000) ? kHighDosTime : kLowDosTime; + dosTime = (ft.dwHighDateTime >= 0x01C00000) ? kHighDosTime : kLowDosTime; return false; } dosTime = (((UInt32)datePart) << 16) + timePart; + + #else + + unsigned year, mon, day, hour, min, sec; + UInt64 v64 = ft.dwLowDateTime | ((UInt64)ft.dwHighDateTime << 32); + Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + unsigned temp; + UInt32 v; + v64 += (kNumTimeQuantumsInSecond * 2 - 1); + v64 /= kNumTimeQuantumsInSecond; + sec = (unsigned)(v64 % 60); + v64 /= 60; + min = (unsigned)(v64 % 60); + v64 /= 60; + hour = (unsigned)(v64 % 24); + v64 /= 24; + + v = (UInt32)v64; + + year = (unsigned)(kFileTimeStartYear + v / PERIOD_400 * 400); + v %= PERIOD_400; + + temp = (unsigned)(v / PERIOD_100); + if (temp == 4) + temp = 3; + year += temp * 100; + v -= temp * PERIOD_100; + + temp = v / PERIOD_4; + if (temp == 25) + temp = 24; + year += temp * 4; + v -= temp * PERIOD_4; + + temp = v / 365; + if (temp == 4) + temp = 3; + year += temp; + v -= temp * 365; + + if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) + ms[1] = 29; + for (mon = 1; mon <= 12; mon++) + { + unsigned s = ms[mon - 1]; + if (v < s) + break; + v -= s; + } + day = (unsigned)v + 1; + + dosTime = kLowDosTime; + if (year < kDosTimeStartYear) + return false; + year -= kDosTimeStartYear; + dosTime = kHighDosTime; + if (year >= 128) + return false; + dosTime = (year << 25) | (mon << 21) | (day << 16) | (hour << 11) | (min << 5) | (sec >> 1); + #endif return true; } -static const UInt32 kNumTimeQuantumsInSecond = 10000000; -static const UInt64 kUnixTimeStartValue = ((UInt64)kNumTimeQuantumsInSecond) * 60 * 60 * 24 * 134774; - -void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime) +void UnixTimeToFileTime(UInt32 unixTime, FILETIME &ft) { UInt64 v = kUnixTimeStartValue + ((UInt64)unixTime) * kNumTimeQuantumsInSecond; - fileTime.dwLowDateTime = (DWORD)v; - fileTime.dwHighDateTime = (DWORD)(v >> 32); + ft.dwLowDateTime = (DWORD)v; + ft.dwHighDateTime = (DWORD)(v >> 32); } -bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime) +bool FileTimeToUnixTime(const FILETIME &ft, UInt32 &unixTime) { - UInt64 winTime = (((UInt64)fileTime.dwHighDateTime) << 32) + fileTime.dwLowDateTime; + UInt64 winTime = (((UInt64)ft.dwHighDateTime) << 32) + ft.dwLowDateTime; if (winTime < kUnixTimeStartValue) { unixTime = 0; @@ -60,10 +144,10 @@ bool GetSecondsSince1601(unsigned year, unsigned month, unsigned day, unsigned hour, unsigned min, unsigned sec, UInt64 &resSeconds) { resSeconds = 0; - if (year < 1601 || year >= 10000 || month < 1 || month > 12 || + if (year < kFileTimeStartYear || year >= 10000 || month < 1 || month > 12 || day < 1 || day > 31 || hour > 23 || min > 59 || sec > 59) return false; - UInt32 numYears = year - 1601; + UInt32 numYears = year - kFileTimeStartYear; UInt32 numDays = numYears * 365 + numYears / 4 - numYears / 100 + numYears / 400; Byte ms[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) diff --git a/CPP/Windows/Window.h b/CPP/Windows/Window.h index b7604b8a..729b0f24 100755 --- a/CPP/Windows/Window.h +++ b/CPP/Windows/Window.h @@ -3,7 +3,7 @@ #ifndef __WINDOWS_WINDOW_H #define __WINDOWS_WINDOW_H -#include "Windows/Defs.h" +#include "Defs.h" #include "Common/MyString.h" namespace NWindows { @@ -22,6 +22,13 @@ bool MySetWindowText(HWND wnd, LPCWSTR s); #endif +#ifdef UNDER_CE +#define GWLP_USERDATA GWL_USERDATA +#define GWLP_WNDPROC GWL_WNDPROC +#define BTNS_BUTTON TBSTYLE_BUTTON +#define WC_COMBOBOXW L"ComboBox" +#define DWLP_MSGRESULT DWL_MSGRESULT +#endif class CWindow { @@ -45,9 +52,13 @@ public: return window; } + bool Foreground() { return BOOLToBool(::SetForegroundWindow(_window)); } + HWND GetParent() const { return ::GetParent(_window); } - bool GetWindowRect(LPRECT rect) const { return BOOLToBool(::GetWindowRect(_window,rect )); } + bool GetWindowRect(LPRECT rect) const { return BOOLToBool(::GetWindowRect(_window,rect)); } + #ifndef UNDER_CE bool IsZoomed() const { return BOOLToBool(::IsZoomed(_window)); } + #endif bool ClientToScreen(LPPOINT point) const { return BOOLToBool(::ClientToScreen(_window, point)); } bool ScreenToClient(LPPOINT point) const { return BOOLToBool(::ScreenToClient(_window, point)); } @@ -101,45 +112,73 @@ public: bool IsWindow() { return BOOLToBool(::IsWindow(_window)); } bool Move(int x, int y, int width, int height, bool repaint = true) { return BOOLToBool(::MoveWindow(_window, x, y, width, height, BoolToBOOL(repaint))); } + + bool ChangeSubWindowSizeX(HWND hwnd, int xSize) + { + RECT rect; + ::GetWindowRect(hwnd, &rect); + POINT p1; + p1.x = rect.left; + p1.y = rect.top; + ScreenToClient(&p1); + return BOOLToBool(::MoveWindow(hwnd, p1.x, p1.y, xSize, rect.bottom - rect.top, TRUE)); + } + + void ScreenToClient(RECT *rect) + { + POINT p1, p2; + p1.x = rect->left; + p1.y = rect->top; + p2.x = rect->right; + p2.y = rect->bottom; + ScreenToClient(&p1); + ScreenToClient(&p2); + + rect->left = p1.x; + rect->top = p1.y; + rect->right = p2.x; + rect->bottom = p2.y; + } + bool GetClientRect(LPRECT rect) { return BOOLToBool(::GetClientRect(_window, rect)); } bool Show(int cmdShow) { return BOOLToBool(::ShowWindow(_window, cmdShow)); } + #ifndef UNDER_CE bool SetPlacement(CONST WINDOWPLACEMENT *placement) { return BOOLToBool(::SetWindowPlacement(_window, placement)); } bool GetPlacement(WINDOWPLACEMENT *placement) { return BOOLToBool(::GetWindowPlacement(_window, placement)); } + #endif bool Update() { return BOOLToBool(::UpdateWindow(_window)); } bool InvalidateRect(LPCRECT rect, bool backgroundErase = true) { return BOOLToBool(::InvalidateRect(_window, rect, BoolToBOOL(backgroundErase))); } void SetRedraw(bool redraw = true) { SendMessage(WM_SETREDRAW, BoolToBOOL(redraw), 0); } - #ifndef _WIN32_WCE - LONG_PTR SetStyle(LONG_PTR style) - { return SetLongPtr(GWL_STYLE, style); } - LONG_PTR GetStyle( ) const - { return GetLongPtr(GWL_STYLE); } - #else - LONG SetStyle(LONG_PTR style) - { return SetLong(GWL_STYLE, style); } - DWORD GetStyle( ) const - { return GetLong(GWL_STYLE); } - #endif + LONG_PTR SetStyle(LONG_PTR style) { return SetLongPtr(GWL_STYLE, style); } + LONG_PTR GetStyle() const { return GetLongPtr(GWL_STYLE); } + // bool MyIsMaximized() const { return ((GetStyle() & WS_MAXIMIZE) != 0); } + + LONG_PTR SetLong(int index, LONG newLongPtr) { return ::SetWindowLong(_window, index, newLongPtr); } + LONG_PTR GetLong(int index) const { return ::GetWindowLong(_window, index); } + LONG_PTR SetUserDataLong(LONG newLongPtr) { return SetLong(GWLP_USERDATA, newLongPtr); } + LONG_PTR GetUserDataLong() const { return GetLong(GWLP_USERDATA); } + + + #ifdef UNDER_CE + + LONG_PTR SetLongPtr(int index, LONG_PTR newLongPtr) { return SetLong(index, newLongPtr); } + LONG_PTR GetLongPtr(int index) const { return GetLong(index); } - LONG_PTR SetLong(int index, LONG newLongPtr ) - { return ::SetWindowLong(_window, index, newLongPtr); } - LONG_PTR GetLong(int index) const - { return ::GetWindowLong(_window, index ); } - LONG_PTR SetUserDataLong(LONG newLongPtr ) - { return SetLong(GWLP_USERDATA, newLongPtr); } - LONG_PTR GetUserDataLong() const - { return GetLong(GWLP_USERDATA); } - - #ifndef _WIN32_WCE - LONG_PTR SetLongPtr(int index, LONG_PTR newLongPtr ) + LONG_PTR SetUserDataLongPtr(LONG_PTR newLongPtr) { return SetUserDataLong(newLongPtr); } + LONG_PTR GetUserDataLongPtr() const { return GetUserDataLong(); } + + #else + + LONG_PTR SetLongPtr(int index, LONG_PTR newLongPtr) { return ::SetWindowLongPtr(_window, index, #ifndef _WIN64 (LONG) #endif newLongPtr); } #ifndef _UNICODE - LONG_PTR SetLongPtrW(int index, LONG_PTR newLongPtr ) + LONG_PTR SetLongPtrW(int index, LONG_PTR newLongPtr) { return ::SetWindowLongPtrW(_window, index, #ifndef _WIN64 (LONG) @@ -147,12 +186,10 @@ public: newLongPtr); } #endif - LONG_PTR GetLongPtr(int index) const - { return ::GetWindowLongPtr(_window, index ); } - LONG_PTR SetUserDataLongPtr(LONG_PTR newLongPtr ) - { return SetLongPtr(GWLP_USERDATA, newLongPtr); } - LONG_PTR GetUserDataLongPtr() const - { return GetLongPtr(GWLP_USERDATA); } + LONG_PTR GetLongPtr(int index) const { return ::GetWindowLongPtr(_window, index); } + LONG_PTR SetUserDataLongPtr(LONG_PTR newLongPtr) { return SetLongPtr(GWLP_USERDATA, newLongPtr); } + LONG_PTR GetUserDataLongPtr() const { return GetLongPtr(GWLP_USERDATA); } + #endif /* @@ -202,7 +239,7 @@ public: bool IsEnabled() { return BOOLToBool(::IsWindowEnabled(_window)); } - #ifndef _WIN32_WCE + #ifndef UNDER_CE HMENU GetSystemMenu(bool revert) { return ::GetSystemMenu(_window, BoolToBOOL(revert)); } #endif @@ -211,8 +248,13 @@ public: { return ::SetTimer(_window, idEvent, elapse, timerFunc); } bool KillTimer(UINT_PTR idEvent) {return BOOLToBool(::KillTimer(_window, idEvent)); } + + HICON SetIcon(WPARAM sizeType, HICON icon) { return (HICON)SendMessage(WM_SETICON, sizeType, (LPARAM)icon); } }; +#define RECT_SIZE_X(r) ((r).right - (r).left) +#define RECT_SIZE_Y(r) ((r).bottom - (r).top) + } #endif |