From 83911c8529146922f2d32b04d8d6107aaf338fb8 Mon Sep 17 00:00:00 2001 From: Igor Pavlov Date: Thu, 13 Apr 2006 00:00:00 +0000 Subject: 4.38 beta --- 7zip/Archive/7z/7zUpdate.cpp | 18 +- 7zip/Archive/Cab/CabHandler.cpp | 4 +- 7zip/Archive/Common/CodecsPath.cpp | 6 +- 7zip/Archive/Common/FilterCoder.cpp | 8 +- 7zip/Archive/Common/ItemNameUtils.cpp | 13 +- 7zip/Archive/Common/ItemNameUtils.h | 6 + 7zip/Archive/GZip/GZipHandlerOut.cpp | 2 +- 7zip/Archive/Iso/IsoHandler.cpp | 2 +- 7zip/Archive/Iso/IsoHeader.h | 2 +- 7zip/Archive/Iso/IsoIn.h | 4 +- 7zip/Archive/Lzh/LzhHandler.cpp | 2 +- 7zip/Archive/Lzh/LzhItem.h | 2 +- 7zip/Archive/Rar/RarHandler.cpp | 9 +- 7zip/Bundles/SFXCon/Main.cpp | 11 +- 7zip/Bundles/SFXSetup/ExtractCallback.cpp | 43 +--- 7zip/Bundles/SFXSetup/ExtractCallback.h | 9 +- 7zip/Bundles/SFXSetup/ExtractEngine.cpp | 99 ++++---- 7zip/Bundles/SFXSetup/ExtractEngine.h | 10 +- 7zip/Bundles/SFXSetup/Main.cpp | 133 +++++++---- 7zip/Bundles/SFXSetup/resource.h | 2 + 7zip/Bundles/SFXSetup/resource.rc | 2 + 7zip/Common/FilePathAutoRename.cpp | 12 +- 7zip/Compress/Deflate/Deflate.dsp | 4 +- 7zip/Compress/Deflate/DeflateDecoder.cpp | 7 +- 7zip/Compress/Deflate/DeflateDecoder.h | 15 +- 7zip/Compress/Deflate/DllExports.cpp | 25 +- 7zip/Compress/Deflate/makefile | 2 +- 7zip/Compress/LZMA/LZMA.dsp | 4 +- 7zip/Compress/LZMA/makefile | 2 +- 7zip/Guid.txt | 1 + 7zip/MyVersion.h | 9 +- 7zip/MyVersionInfo.rc | 2 +- 7zip/UI/Common/ArchiveCommandLine.cpp | 13 +- 7zip/UI/Common/ArchiveName.cpp | 2 +- 7zip/UI/Common/ArchiverInfo.cpp | 8 +- 7zip/UI/Common/ExtractingFilePath.cpp | 8 +- 7zip/UI/Common/Update.h | 2 +- 7zip/UI/Console/Main.cpp | 34 ++- 7zip/UI/Console/UserInputUtils.cpp | 1 + 7zip/UI/Explorer/ContextMenu.cpp | 77 ++---- 7zip/UI/Explorer/ContextMenu.h | 2 - 7zip/UI/GUI/CompressDialog.cpp | 2 +- Common/MyWindows.h | 10 + Common/StdOutStream.cpp | 7 + Common/StdOutStream.h | 1 + Common/TextConfig.cpp | 4 +- Common/Vector.h | 17 ++ Common/Wildcard.cpp | 10 +- DOC/7zip.nsi | 11 +- DOC/7zip.wxs | 385 ++++++++++++++++++++++++++++++ DOC/Methods.txt | 26 +- DOC/readme.txt | 2 +- Windows/FileDir.cpp | 12 +- Windows/FileName.h | 2 +- 54 files changed, 798 insertions(+), 308 deletions(-) create mode 100755 DOC/7zip.wxs diff --git a/7zip/Archive/7z/7zUpdate.cpp b/7zip/Archive/7z/7zUpdate.cpp index c45c85f3..b75219a3 100755 --- a/7zip/Archive/7z/7zUpdate.cpp +++ b/7zip/Archive/7z/7zUpdate.cpp @@ -73,11 +73,19 @@ static HRESULT WriteRange(IInStream *inStream, size, progress, currentComplexity); } +static int GetReverseSlashPos(const UString &name) +{ + int slashPos = name.ReverseFind(L'/'); + #ifdef _WIN32 + int slash1Pos = name.ReverseFind(L'\\'); + slashPos = MyMax(slashPos, slash1Pos); + #endif + return slashPos; +} + int CUpdateItem::GetExtensionPos() const { - int slash1Pos = Name.ReverseFind(L'\\'); - int slash2Pos = Name.ReverseFind(L'/'); - int slashPos = MyMax(slash1Pos, slash2Pos); + int slashPos = GetReverseSlashPos(Name); int dotPos = Name.ReverseFind(L'.'); if (dotPos < 0 || (dotPos < slashPos && slashPos >= 0)) return Name.Length(); @@ -220,9 +228,7 @@ struct CRefItem { if (sortByType) { - int slash1Pos = updateItem.Name.ReverseFind(L'\\'); - int slash2Pos = updateItem.Name.ReverseFind(L'/'); - int slashPos = MyMax(slash1Pos, slash2Pos); + int slashPos = GetReverseSlashPos(updateItem.Name); if (slashPos >= 0) NamePos = slashPos + 1; else diff --git a/7zip/Archive/Cab/CabHandler.cpp b/7zip/Archive/Cab/CabHandler.cpp index c3dd061f..bf97fc0f 100755 --- a/7zip/Archive/Cab/CabHandler.cpp +++ b/7zip/Archive/Cab/CabHandler.cpp @@ -20,6 +20,8 @@ #include "../../Compress/Lzx/LzxDecoder.h" #include "../../Compress/Quantum/QuantumDecoder.h" +#include "../Common/ItemNameUtils.h" + using namespace NWindows; namespace NArchive { @@ -123,7 +125,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va if (!ConvertUTF8ToUnicode(item.Name, unicodeName)) propVariant = L""; else - propVariant = unicodeName; + propVariant = (const wchar_t *)NItemName::WinNameToOSName(unicodeName); } else propVariant = MultiByteToUnicodeString(item.Name, CP_ACP); diff --git a/7zip/Archive/Common/CodecsPath.cpp b/7zip/Archive/Common/CodecsPath.cpp index d2d27ed3..7ee89875 100755 --- a/7zip/Archive/Common/CodecsPath.cpp +++ b/7zip/Archive/Common/CodecsPath.cpp @@ -15,7 +15,7 @@ static CSysString GetLibraryPath() static CSysString GetLibraryFolderPrefix() { CSysString path = GetLibraryPath(); - int pos = path.ReverseFind(TEXT('\\')); + int pos = path.ReverseFind(TEXT(CHAR_PATH_SEPARATOR)); return path.Left(pos + 1); } @@ -24,11 +24,11 @@ CSysString GetBaseFolderPrefix() CSysString libPrefix = GetLibraryFolderPrefix(); CSysString temp = libPrefix; temp.Delete(temp.Length() - 1); - int pos = temp.ReverseFind(TEXT('\\')); + int pos = temp.ReverseFind(TEXT(CHAR_PATH_SEPARATOR)); return temp.Left(pos + 1); } CSysString GetCodecsFolderPrefix() { - return GetBaseFolderPrefix() + TEXT("Codecs\\"); + return GetBaseFolderPrefix() + (CSysString)(TEXT("Codecs")) + (CSysString)(TEXT(STRING_PATH_SEPARATOR)); } diff --git a/7zip/Archive/Common/FilterCoder.cpp b/7zip/Archive/Common/FilterCoder.cpp index 19ba8b81..4dce89bf 100755 --- a/7zip/Archive/Common/FilterCoder.cpp +++ b/7zip/Archive/Common/FilterCoder.cpp @@ -200,7 +200,13 @@ STDMETHODIMP CFilterCoder::Read(void *data, UInt32 size, UInt32 *processedSize) _convertedPosEnd = Filter->Filter(_buffer, _bufferPos); if (_convertedPosEnd == 0) { - break; + if (_bufferPos == 0) + break; + else + { + _convertedPosEnd = _bufferPos; // check it + continue; + } } if (_convertedPosEnd > _bufferPos) { diff --git a/7zip/Archive/Common/ItemNameUtils.cpp b/7zip/Archive/Common/ItemNameUtils.cpp index 4cfecd41..fcb8f544 100755 --- a/7zip/Archive/Common/ItemNameUtils.cpp +++ b/7zip/Archive/Common/ItemNameUtils.cpp @@ -7,8 +7,8 @@ namespace NArchive { namespace NItemName { -static const wchar_t kOSDirDelimiter = '\\'; -static const wchar_t kDirDelimiter = '/'; +static const wchar_t kOSDirDelimiter = WCHAR_PATH_SEPARATOR; +static const wchar_t kDirDelimiter = L'/'; UString MakeLegalName(const UString &name) { @@ -47,4 +47,13 @@ bool HasTailSlash(const AString &name, UINT codePage) return (*prev == '/'); } +#ifndef _WIN32 +UString WinNameToOSName(const UString &name) +{ + UString newName = name; + newName.Replace(L'\\', kOSDirDelimiter); + return newName; +} +#endif + }} diff --git a/7zip/Archive/Common/ItemNameUtils.h b/7zip/Archive/Common/ItemNameUtils.h index 90dcba5b..63a01563 100755 --- a/7zip/Archive/Common/ItemNameUtils.h +++ b/7zip/Archive/Common/ItemNameUtils.h @@ -13,6 +13,12 @@ namespace NItemName { UString GetOSName2(const UString &name); bool HasTailSlash(const AString &name, UINT codePage); + #ifdef _WIN32 + inline UString WinNameToOSName(const UString &name) { return name; } + #else + UString WinNameToOSName(const UString &name); + #endif + }} #endif diff --git a/7zip/Archive/GZip/GZipHandlerOut.cpp b/7zip/Archive/GZip/GZipHandlerOut.cpp index c58fcb52..be71a0f5 100755 --- a/7zip/Archive/GZip/GZipHandlerOut.cpp +++ b/7zip/Archive/GZip/GZipHandlerOut.cpp @@ -110,7 +110,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt if(!FileTimeToUnixTime(utcTime, newItem.Time)) return E_INVALIDARG; newItem.Name = UnicodeStringToMultiByte(name, CP_ACP); - int dirDelimiterPos = newItem.Name.ReverseFind('\\'); + int dirDelimiterPos = newItem.Name.ReverseFind(CHAR_PATH_SEPARATOR); if (dirDelimiterPos >= 0) newItem.Name = newItem.Name.Mid(dirDelimiterPos + 1); diff --git a/7zip/Archive/Iso/IsoHandler.cpp b/7zip/Archive/Iso/IsoHandler.cpp index 18bb2ddf..793ddc48 100755 --- a/7zip/Archive/Iso/IsoHandler.cpp +++ b/7zip/Archive/Iso/IsoHandler.cpp @@ -115,7 +115,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val { // wchar_t name[32]; // ConvertUInt64ToString(index + 1, name); - UString s = L"[BOOT]\\"; + UString s = L"[BOOT]" WSTRING_PATH_SEPARATOR; // s += name; // s += L"-"; s += be.GetName(); diff --git a/7zip/Archive/Iso/IsoHeader.h b/7zip/Archive/Iso/IsoHeader.h index db070c1b..9702d70a 100755 --- a/7zip/Archive/Iso/IsoHeader.h +++ b/7zip/Archive/Iso/IsoHeader.h @@ -33,7 +33,7 @@ namespace NBootEntryId const Byte kValidationEntry = 1; const Byte kInitialEntryNotBootable = 0; const Byte kInitialEntryBootable = 0x88; -}; +} namespace NBootPlatformId { diff --git a/7zip/Archive/Iso/IsoIn.h b/7zip/Archive/Iso/IsoIn.h index fe85343f..f1d33aaa 100755 --- a/7zip/Archive/Iso/IsoIn.h +++ b/7zip/Archive/Iso/IsoIn.h @@ -62,7 +62,7 @@ struct CDir: public CDirRecord if (cur->Parent == 0) break; p--; - *p = '\\'; + *p = CHAR_PATH_SEPARATOR; } s.ReleaseBuffer(); return s; @@ -92,7 +92,7 @@ struct CDir: public CDirRecord if (cur->Parent == 0) break; p--; - *p = L'\\'; + *p = WCHAR_PATH_SEPARATOR; } s.ReleaseBuffer(); return s; diff --git a/7zip/Archive/Lzh/LzhHandler.cpp b/7zip/Archive/Lzh/LzhHandler.cpp index f66cf352..fd420c3f 100755 --- a/7zip/Archive/Lzh/LzhHandler.cpp +++ b/7zip/Archive/Lzh/LzhHandler.cpp @@ -140,7 +140,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va { case kpidPath: { - const UString s = NItemName::GetOSName2(MultiByteToUnicodeString(item.GetName(), CP_OEMCP)); + const UString s = NItemName::WinNameToOSName(MultiByteToUnicodeString(item.GetName(), CP_OEMCP)); if (!s.IsEmpty()) propVariant = s; break; diff --git a/7zip/Archive/Lzh/LzhItem.h b/7zip/Archive/Lzh/LzhItem.h index b9b5f914..448d8b33 100755 --- a/7zip/Archive/Lzh/LzhItem.h +++ b/7zip/Archive/Lzh/LzhItem.h @@ -154,7 +154,7 @@ public: if (!dirName.IsEmpty()) { char c = dirName[dirName.Length() - 1]; - if (c != '\\' && c != '/') + if (c != '\\') dirName += '\\'; } return dirName + GetFileName(); diff --git a/7zip/Archive/Rar/RarHandler.cpp b/7zip/Archive/Rar/RarHandler.cpp index 56187156..cd654ec2 100755 --- a/7zip/Archive/Rar/RarHandler.cpp +++ b/7zip/Archive/Rar/RarHandler.cpp @@ -23,6 +23,7 @@ #include "../Common/CoderLoader.h" #include "../Common/CodecsPath.h" #include "../Common/FilterCoder.h" +#include "../Common/ItemNameUtils.h" #include "../7z/7zMethods.h" @@ -186,11 +187,15 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va switch(propID) { case kpidPath: + { + UString u; if (item.HasUnicodeName() && !item.UnicodeName.IsEmpty()) - propVariant = item.UnicodeName; + u = item.UnicodeName; else - propVariant = (const wchar_t *)MultiByteToUnicodeString(item.Name, CP_OEMCP); + u = MultiByteToUnicodeString(item.Name, CP_OEMCP); + propVariant = (const wchar_t *)NItemName::WinNameToOSName(u); break; + } case kpidIsFolder: propVariant = item.IsDirectory(); break; diff --git a/7zip/Bundles/SFXCon/Main.cpp b/7zip/Bundles/SFXCon/Main.cpp index d707a37a..12599e87 100755 --- a/7zip/Bundles/SFXCon/Main.cpp +++ b/7zip/Bundles/SFXCon/Main.cpp @@ -40,7 +40,10 @@ static const char *kCopyrightString = static const int kNumSwitches = 6; -const wchar_t *defaultExt = L".exe"; +#ifdef _WIN32 +static const wchar_t *kDefaultExt = L".exe"; +static const int kDefaultExtLength = 4; +#endif namespace NKey { enum Enum @@ -383,8 +386,10 @@ int Main2( bool yesToAll = parser[NKey::kYes].ThereIs; - if (archiveName.Right(4).CompareNoCase(defaultExt) != 0) - archiveName += defaultExt; + #ifdef _WIN32 + if (archiveName.Right(kDefaultExtLength).CompareNoCase(kDefaultExt) != 0) + archiveName += kDefaultExt; + #endif // NExtractMode::EEnum extractMode; // bool isExtractGroupCommand = command.IsFromExtractGroup(extractMode); diff --git a/7zip/Bundles/SFXSetup/ExtractCallback.cpp b/7zip/Bundles/SFXSetup/ExtractCallback.cpp index ea4cc9bb..dfa66e43 100755 --- a/7zip/Bundles/SFXSetup/ExtractCallback.cpp +++ b/7zip/Bundles/SFXSetup/ExtractCallback.cpp @@ -23,9 +23,9 @@ static LPCWSTR kErrorTitle = L"7-Zip"; static LPCWSTR kCantDeleteFile = L"Can not delete output file"; static LPCWSTR kCantOpenFile = L"Can not open output file"; static LPCWSTR kUnsupportedMethod = L"Unsupported Method"; -static LPCWSTR kCRCFailed = L"CRC Failed"; -static LPCWSTR kDataError = L"Data Error"; -// static LPCTSTR kUnknownError = TEXT("Unknown Error"); +// static LPCWSTR kCRCFailed = L"CRC Failed"; +// static LPCWSTR kDataError = L"Data Error"; +// static LPCWSTR kUnknownError = L""Unknown Error"; void CExtractCallbackImp::Init(IInArchive *archiveHandler, const UString &directoryPath, @@ -33,7 +33,8 @@ void CExtractCallbackImp::Init(IInArchive *archiveHandler, const FILETIME &utcLastWriteTimeDefault, UInt32 attributesDefault) { - _numErrors = 0; + _message.Empty(); + _isCorrupt = false; _itemDefaultName = itemDefaultName; _utcLastWriteTimeDefault = utcLastWriteTimeDefault; _attributesDefault = attributesDefault; @@ -170,14 +171,8 @@ STDMETHODIMP CExtractCallbackImp::GetStream(UInt32 index, { if (!NDirectory::DeleteFileAlways(fullProcessedPath)) { - #ifdef _SILENT _message = kCantDeleteFile; - #else - MessageBoxW(0, kCantDeleteFile, kErrorTitle, 0); - #endif - // g_StdOut << GetOemString(fullProcessedPath); - // return E_ABORT; - return E_ABORT; + return E_FAIL; } } @@ -187,12 +182,8 @@ STDMETHODIMP CExtractCallbackImp::GetStream(UInt32 index, CMyComPtr outStreamLoc(_outFileStreamSpec); if (!_outFileStreamSpec->Create(fullProcessedPath, true)) { - #ifdef _SILENT _message = kCantOpenFile; - #else - MessageBoxW(0, kCantOpenFile, kErrorTitle, 0); - #endif - return E_ABORT; + return E_FAIL; } _outFileStream = outStreamLoc; *outStream = outStreamLoc.Detach(); @@ -228,30 +219,23 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 resultEOperationResul } default: { - _numErrors++; - UString errorMessage; _outFileStream.Release(); switch(resultEOperationResult) { case NArchive::NExtract::NOperationResult::kUnSupportedMethod: - errorMessage = kUnsupportedMethod; + _message = kUnsupportedMethod; break; case NArchive::NExtract::NOperationResult::kCRCError: - errorMessage = kCRCFailed; + _isCorrupt = true; + // _message = kCRCFailed; break; case NArchive::NExtract::NOperationResult::kDataError: - errorMessage = kDataError; + _isCorrupt = true; + // _message = kDataError; break; - /* default: - errorMessage = kUnknownError; - */ + _isCorrupt = true; } - #ifdef _SILENT - _message = errorMessage; - #else - MessageBoxW(0, errorMessage, kErrorTitle, 0); - #endif return E_FAIL; } } @@ -263,4 +247,3 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 resultEOperationResul return S_OK; } - diff --git a/7zip/Bundles/SFXSetup/ExtractCallback.h b/7zip/Bundles/SFXSetup/ExtractCallback.h index b983e90b..f3880890 100755 --- a/7zip/Bundles/SFXSetup/ExtractCallback.h +++ b/7zip/Bundles/SFXSetup/ExtractCallback.h @@ -11,15 +11,12 @@ #include "../../Archive/IArchive.h" #include "../../Common/FileStreams.h" -// #include "../../Common/ZipSettings.h" #include "../../ICoder.h" #ifndef _NO_PROGRESS #include "../../FileManager/Resource/ProgressDialog/ProgressDialog.h" #endif -// #include "../../Explorer/MyMessages.h" - class CExtractCallbackImp: public IArchiveExtractCallback, public CMyUnknownImp @@ -67,9 +64,8 @@ public: CProgressDialog ProgressDialog; #endif - #ifdef _SILENT + bool _isCorrupt; UString _message; - #endif void Init(IInArchive *archiveHandler, const UString &directoryPath, @@ -77,8 +73,6 @@ public: const FILETIME &utcLastWriteTimeDefault, UInt32 attributesDefault); - UInt64 _numErrors; - #ifndef _NO_PROGRESS HRESULT StartProgressDialog(const UString &title) { @@ -92,7 +86,6 @@ public: } ProgressDialog.Show(SW_SHOWNORMAL); - // _progressDialog.Start(m_ParentWindow, PROGDLG_MODAL | PROGDLG_AUTOTIME); return S_OK; } virtual ~CExtractCallbackImp() { ProgressDialog.Destroy(); } diff --git a/7zip/Bundles/SFXSetup/ExtractEngine.cpp b/7zip/Bundles/SFXSetup/ExtractEngine.cpp index b98de9f3..19fcb0d2 100755 --- a/7zip/Bundles/SFXSetup/ExtractEngine.cpp +++ b/7zip/Bundles/SFXSetup/ExtractEngine.cpp @@ -1,4 +1,4 @@ -// ExtractEngine.h +// ExtractEngine.cpp #include "StdAfx.h" @@ -21,7 +21,6 @@ using namespace NWindows; struct CThreadExtracting { - // CMyComPtr ArchiveHandler; CArchiveLink ArchiveLink; CExtractCallbackImp *ExtractCallbackSpec; @@ -29,12 +28,15 @@ struct CThreadExtracting #ifndef _NO_PROGRESS HRESULT Result; - + + HRESULT Extract() + { + return ArchiveLink.GetArchive()->Extract(0, (UInt32)-1 , BoolToInt(false), ExtractCallback); + } DWORD Process() { ExtractCallbackSpec->ProgressDialog.WaitCreating(); - Result = ArchiveLink.GetArchive()->Extract(0, (UInt32)-1 , BoolToInt(false), - ExtractCallback); + Result = Extract(); ExtractCallbackSpec->ProgressDialog.MyClose(); return 0; } @@ -45,26 +47,22 @@ struct CThreadExtracting #endif }; -static const LPCTSTR kCantFindArchive = TEXT("Can not find archive file"); -static const LPCTSTR kCantOpenArchive = TEXT("File is not correct archive"); +static const LPCWSTR kCantFindArchive = L"Can not find archive file"; +static const LPCWSTR kCantOpenArchive = L"File is not correct archive"; HRESULT ExtractArchive( const UString &fileName, const UString &folderName, - COpenCallbackGUI *openCallback - #ifdef _SILENT - , UString &resultMessage - #endif - ) + COpenCallbackGUI *openCallback, + bool showProgress, + bool &isCorrupt, + UString &errorMessage) { + isCorrupt = false; NFile::NFind::CFileInfoW archiveFileInfo; if (!NFile::NFind::FindFile(fileName, archiveFileInfo)) { - #ifndef _SILENT - MessageBox(0, kCantFindArchive, TEXT("7-Zip"), 0); - #else - resultMessage = kCantFindArchive; - #endif + errorMessage = kCantFindArchive; return E_FAIL; } @@ -72,18 +70,10 @@ HRESULT ExtractArchive( HRESULT result = MyOpenArchive(fileName, extracter.ArchiveLink, openCallback); - /* - CArchiverInfo archiverInfoResult; - int subExtIndex; - HRESULT result = OpenArchive(fileName, &extracter.ArchiveHandler, - archiverInfoResult, subExtIndex, NULL); - */ if (result != S_OK) { - #ifdef _SILENT - resultMessage = kCantOpenArchive; - #endif - return E_FAIL; + errorMessage = kCantOpenArchive; + return result; } UString directoryPath = folderName; @@ -105,54 +95,45 @@ HRESULT ExtractArchive( if(!NFile::NDirectory::CreateComplexDirectory(directoryPath)) { - #ifndef _SILENT - MyMessageBox(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, + errorMessage = MyFormatNew(IDS_CANNOT_CREATE_FOLDER, #ifdef LANG 0x02000603, #endif - directoryPath)); - #else - resultMessage = TEXT("Can not create output folder"); - #endif + directoryPath); return E_FAIL; } extracter.ExtractCallbackSpec = new CExtractCallbackImp; extracter.ExtractCallback = extracter.ExtractCallbackSpec; - // anExtractCallBackSpec->StartProgressDialog(); - - // anExtractCallBackSpec->m_ProgressDialog.ShowWindow(SW_SHOWNORMAL); - extracter.ExtractCallbackSpec->Init( extracter.ArchiveLink.GetArchive(), directoryPath, L"Default", archiveFileInfo.LastWriteTime, 0); #ifndef _NO_PROGRESS - CThread thread; - if (!thread.Create(CThreadExtracting::MyThreadFunction, &extracter)) - throw 271824; - - UString title; - #ifdef LANG - title = LangLoadString(IDS_PROGRESS_EXTRACTING, 0x02000890); - #else - title = NWindows::MyLoadStringW(IDS_PROGRESS_EXTRACTING); - #endif - extracter.ExtractCallbackSpec->StartProgressDialog(title); - return extracter.Result; - - #else + if (showProgress) + { + CThread thread; + if (!thread.Create(CThreadExtracting::MyThreadFunction, &extracter)) + throw 271824; + + UString title; + #ifdef LANG + title = LangLoadString(IDS_PROGRESS_EXTRACTING, 0x02000890); + #else + title = NWindows::MyLoadStringW(IDS_PROGRESS_EXTRACTING); + #endif + extracter.ExtractCallbackSpec->StartProgressDialog(title); + result = extracter.Result; + } + else - result = extracter.ArchiveHandler->Extract(0, (UInt32)-1, - BoolToInt(false), extracter.ExtractCallback); - #ifdef _SILENT - resultMessage = extracter.ExtractCallbackSpec->_message; #endif + { + result = extracter.Extract(); + } + errorMessage = extracter.ExtractCallbackSpec->_message; + isCorrupt = extracter.ExtractCallbackSpec->_isCorrupt; return result; - #endif } - - - diff --git a/7zip/Bundles/SFXSetup/ExtractEngine.h b/7zip/Bundles/SFXSetup/ExtractEngine.h index c1b670e2..595d2b29 100755 --- a/7zip/Bundles/SFXSetup/ExtractEngine.h +++ b/7zip/Bundles/SFXSetup/ExtractEngine.h @@ -9,11 +9,9 @@ HRESULT ExtractArchive( const UString &fileName, const UString &folderName, - COpenCallbackGUI *openCallback - #ifdef _SILENT - , UString &resultMessage - #endif - ); + COpenCallbackGUI *openCallback, + bool showProgress, + bool &isCorrupt, + UString &errorMessage); #endif - diff --git a/7zip/Bundles/SFXSetup/Main.cpp b/7zip/Bundles/SFXSetup/Main.cpp index 72cae080..abc34506 100755 --- a/7zip/Bundles/SFXSetup/Main.cpp +++ b/7zip/Bundles/SFXSetup/Main.cpp @@ -14,6 +14,7 @@ #include "Windows/FileFind.h" #include "Windows/FileName.h" #include "Windows/DLL.h" +#include "Windows/ResourceString.h" #include "../../IPassword.h" #include "../../ICoder.h" @@ -24,13 +25,16 @@ #include "ExtractEngine.h" - -HINSTANCE g_hInstance; +#include "resource.h" using namespace NWindows; +HINSTANCE g_hInstance; + static LPCTSTR kTempDirPrefix = TEXT("7zS"); +#define _SHELL_EXECUTE + static bool ReadDataString(LPCWSTR fileName, LPCSTR startID, LPCSTR endID, AString &stringResult) { @@ -143,17 +147,14 @@ int APIENTRY WinMain( InitCommonControls(); UString archiveName, switches; + #ifdef _SHELL_EXECUTE + UString executeFile, executeParameters; + #endif NCommandLineParser::SplitCommandLine(GetCommandLineW(), archiveName, switches); UString fullPath; NDLL::MyGetModuleFileName(g_hInstance, fullPath); - AString config; - if (!ReadDataString(fullPath, kStartID, kEndID, config)) - { - MyMessageBox(L"Can't load config info"); - return 1; - } switches.Trim(); bool assumeYes = false; if (switches.Left(2).CompareNoCase(UString(L"-y")) == 0) @@ -163,21 +164,34 @@ int APIENTRY WinMain( switches.Trim(); } -#ifdef _SHELL_EXECUTE - bool executeMode = false; -#endif + AString config; + if (!ReadDataString(fullPath, kStartID, kEndID, config)) + { + if (!assumeYes) + MyMessageBox(L"Can't load config info"); + return 1; + } + + UString dirPrefix = L".\\"; UString appLaunched; + bool showProgress = true; if (!config.IsEmpty()) { CObjectVector pairs; if (!GetTextConfig(config, pairs)) { - MyMessageBox(L"Config failed"); + if (!assumeYes) + MyMessageBox(L"Config failed"); return 1; } UString friendlyName = GetTextConfigValue(pairs, L"Title"); UString installPrompt = GetTextConfigValue(pairs, L"BeginPrompt"); - + UString progress = GetTextConfigValue(pairs, L"Progress"); + if (progress.CompareNoCase(L"no") == 0) + showProgress = false; + int index = FindTextConfigItem(pairs, L"Directory"); + if (index >= 0) + dirPrefix = pairs[index].String; if (!installPrompt.IsEmpty() && !assumeYes) { if (MessageBoxW(0, installPrompt, friendlyName, MB_YESNO | @@ -185,33 +199,41 @@ int APIENTRY WinMain( return 0; } appLaunched = GetTextConfigValue(pairs, L"RunProgram"); -#ifdef _SHELL_EXECUTE - if (appLaunched.IsEmpty()) - { - executeMode = true; - appLaunched = GetTextConfigValue(pairs, L"Execute"); - } -#endif + + #ifdef _SHELL_EXECUTE + executeFile = GetTextConfigValue(pairs, L"ExecuteFile"); + executeParameters = GetTextConfigValue(pairs, L"ExecuteParameters") + switches; + #endif } NFile::NDirectory::CTempDirectory tempDir; if (!tempDir.Create(kTempDirPrefix)) { - MyMessageBox(L"Can not create temp folder archive"); + if (!assumeYes) + MyMessageBox(L"Can not create temp folder archive"); return 1; } COpenCallbackGUI openCallback; UString tempDirPath = GetUnicodeString(tempDir.GetPath()); - HRESULT result = ExtractArchive(fullPath, tempDirPath, &openCallback); + bool isCorrupt = false; + UString errorMessage; + HRESULT result = ExtractArchive(fullPath, tempDirPath, &openCallback, showProgress, + isCorrupt, errorMessage); if (result != S_OK) { - if (result == S_FALSE) - MyMessageBox(L"Can not open archive"); - else if (result != E_ABORT) - ShowErrorMessage(result); + if (!assumeYes) + { + if (result == S_FALSE || isCorrupt) + { + errorMessage = NWindows::MyLoadStringW(IDS_EXTRACTION_ERROR_MESSAGE); + result = E_FAIL; + } + if (result != E_ABORT && !errorMessage.IsEmpty()) + ::MessageBoxW(0, errorMessage, NWindows::MyLoadStringW(IDS_EXTRACTION_ERROR_TITLE), MB_ICONERROR); + } return 1; } @@ -220,30 +242,11 @@ int APIENTRY WinMain( if (!SetCurrentDirectory(tempDir.GetPath())) return 1; - if (appLaunched.IsEmpty()) - { - appLaunched = L"setup.exe"; - if (!NFile::NFind::DoesFileExist(GetSystemString(appLaunched))) - { - MyMessageBox(L"Can not find setup.exe"); - return 1; - } - } - - { - UString s2 = tempDirPath; - NFile::NName::NormalizeDirPathPrefix(s2); - appLaunched.Replace(L"%%T\\", s2); - } - - appLaunched.Replace(L"%%T", tempDirPath); - - HANDLE hProcess = 0; #ifdef _SHELL_EXECUTE - if (executeMode) + if (!executeFile.IsEmpty()) { - CSysString filePath = GetSystemString(appLaunched); + CSysString filePath = GetSystemString(executeFile); SHELLEXECUTEINFO execInfo; execInfo.cbSize = sizeof(execInfo); execInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_DDEWAIT; @@ -251,11 +254,14 @@ int APIENTRY WinMain( execInfo.lpVerb = NULL; execInfo.lpFile = filePath; - CSysString switchesSys = GetSystemString(switches); - if (switchesSys.IsEmpty()) + if (!switches.IsEmpty()) + executeParameters += switches; + + CSysString parametersSys = GetSystemString(executeParameters); + if (parametersSys.IsEmpty()) execInfo.lpParameters = NULL; else - execInfo.lpParameters = switchesSys; + execInfo.lpParameters = parametersSys; execInfo.lpDirectory = NULL; execInfo.nShow = SW_SHOWNORMAL; @@ -264,7 +270,8 @@ int APIENTRY WinMain( result = (UINT32)execInfo.hInstApp; if(result <= 32) { - MyMessageBox(L"Can not open file"); + if (!assumeYes) + MyMessageBox(L"Can not open file"); return 1; } hProcess = execInfo.hProcess; @@ -272,6 +279,25 @@ int APIENTRY WinMain( else #endif { + if (appLaunched.IsEmpty()) + { + appLaunched = L"setup.exe"; + if (!NFile::NFind::DoesFileExist(GetSystemString(appLaunched))) + { + if (!assumeYes) + MyMessageBox(L"Can not find setup.exe"); + return 1; + } + } + + { + UString s2 = tempDirPath; + NFile::NName::NormalizeDirPathPrefix(s2); + appLaunched.Replace(L"%%T\\", s2); + } + + appLaunched.Replace(L"%%T", tempDirPath); + if (!switches.IsEmpty()) { appLaunched += L' '; @@ -288,14 +314,15 @@ int APIENTRY WinMain( PROCESS_INFORMATION processInformation; - CSysString appLaunchedSys = CSysString(TEXT(".\\")) + GetSystemString(appLaunched); + CSysString appLaunchedSys = GetSystemString(dirPrefix + appLaunched); BOOL createResult = CreateProcess(NULL, (LPTSTR)(LPCTSTR)appLaunchedSys, NULL, NULL, FALSE, 0, NULL, NULL /*tempDir.GetPath() */, &startupInfo, &processInformation); if (createResult == 0) { - ShowLastErrorMessage(); + if (!assumeYes) + ShowLastErrorMessage(); return 1; } ::CloseHandle(processInformation.hThread); diff --git a/7zip/Bundles/SFXSetup/resource.h b/7zip/Bundles/SFXSetup/resource.h index 94102b5d..2c7e5a22 100755 --- a/7zip/Bundles/SFXSetup/resource.h +++ b/7zip/Bundles/SFXSetup/resource.h @@ -1,4 +1,6 @@ #define IDI_ICON3 159 +#define IDS_EXTRACTION_ERROR_TITLE 7 +#define IDS_EXTRACTION_ERROR_MESSAGE 8 #define IDS_CANNOT_CREATE_FOLDER 9 #define IDS_PROGRESS_EXTRACTING 69 diff --git a/7zip/Bundles/SFXSetup/resource.rc b/7zip/Bundles/SFXSetup/resource.rc index 5dfa9d0c..4bf6a585 100755 --- a/7zip/Bundles/SFXSetup/resource.rc +++ b/7zip/Bundles/SFXSetup/resource.rc @@ -7,6 +7,8 @@ IDI_ICON3 ICON "setup.ico" STRINGTABLE BEGIN + IDS_EXTRACTION_ERROR_TITLE "Extraction Failed" + IDS_EXTRACTION_ERROR_MESSAGE "File is corrupt" IDS_CANNOT_CREATE_FOLDER "Cannot create folder '{0}'" IDS_PROGRESS_EXTRACTING "Extracting" END diff --git a/7zip/Common/FilePathAutoRename.cpp b/7zip/Common/FilePathAutoRename.cpp index 3283aa45..3c5b910f 100755 --- a/7zip/Common/FilePathAutoRename.cpp +++ b/7zip/Common/FilePathAutoRename.cpp @@ -26,11 +26,15 @@ bool AutoRenamePath(UString &fullProcessedPath) { UString path; int dotPos = fullProcessedPath.ReverseFind(L'.'); - int slashDot1 = fullProcessedPath.ReverseFind(L'\\'); - int slashDot2 = fullProcessedPath.ReverseFind(L'/'); - int slashDot = MyMin(slashDot1, slashDot2); + + int slashPos = fullProcessedPath.ReverseFind(L'/'); + #ifdef _WIN32 + int slash1Pos = fullProcessedPath.ReverseFind(L'\\'); + slashPos = MyMax(slashPos, slash1Pos); + #endif + UString name, extension; - if (dotPos > slashDot && dotPos > 0) + if (dotPos > slashPos && dotPos > 0) { name = fullProcessedPath.Left(dotPos); extension = fullProcessedPath.Mid(dotPos); diff --git a/7zip/Compress/Deflate/Deflate.dsp b/7zip/Compress/Deflate/Deflate.dsp index 965c39a4..ef33fb8c 100755 --- a/7zip/Compress/Deflate/Deflate.dsp +++ b/7zip/Compress/Deflate/Deflate.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEFLATE_EXPORTS" /YX /FD /c -# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEFLATE_EXPORTS" /Yu"StdAfx.h" /FD /c +# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEFLATE_EXPORTS" /D "_ST_MODE" /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" @@ -70,7 +70,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEFLATE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEFLATE_EXPORTS" /Yu"StdAfx.h" /FD /GZ /c +# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "DEFLATE_EXPORTS" /D "_ST_MODE" /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" diff --git a/7zip/Compress/Deflate/DeflateDecoder.cpp b/7zip/Compress/Deflate/DeflateDecoder.cpp index 629d9981..78a4e47f 100755 --- a/7zip/Compress/Deflate/DeflateDecoder.cpp +++ b/7zip/Compress/Deflate/DeflateDecoder.cpp @@ -11,7 +11,10 @@ namespace NDecoder { static const int kLenIdFinished = -1; static const int kLenIdNeedInit = -2; -CCoder::CCoder(bool deflate64Mode): _deflate64Mode(deflate64Mode), _keepHistory(false) {} +CCoder::CCoder(bool deflate64Mode, bool deflateNSIS): + _deflate64Mode(deflate64Mode), + _deflateNSIS(deflateNSIS), + _keepHistory(false) {} UInt32 CCoder::ReadBits(int numBits) { @@ -70,6 +73,8 @@ bool CCoder::ReadTables(void) int numBitsForAlign = (int)(currentBitPosition > 0 ? (8 - currentBitPosition): 0); ReadBits(numBitsForAlign); m_StoredBlockSize = ReadBits(kStoredBlockLengthFieldSize); + if (_deflateNSIS) + return true; return (m_StoredBlockSize == (UInt16)~ReadBits(kStoredBlockLengthFieldSize)); } diff --git a/7zip/Compress/Deflate/DeflateDecoder.h b/7zip/Compress/Deflate/DeflateDecoder.h index a44833ad..99928b72 100755 --- a/7zip/Compress/Deflate/DeflateDecoder.h +++ b/7zip/Compress/Deflate/DeflateDecoder.h @@ -40,6 +40,7 @@ class CCoder: UInt32 _numDistLevels; + bool _deflateNSIS; bool _deflate64Mode; bool _keepHistory; Int32 _remainLen; @@ -75,7 +76,7 @@ class CCoder: HRESULT CodeSpec(UInt32 curSize); public: - CCoder(bool deflate64Mode); + CCoder(bool deflate64Mode, bool deflateNSIS = false); void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; } HRESULT CodeReal(ISequentialInStream *inStream, @@ -110,15 +111,19 @@ public: STDMETHOD(GetInStreamProcessedSize)(UInt64 *value); }; -class CCOMCoder : - public CCoder +class CCOMCoder : public CCoder { public: CCOMCoder(): CCoder(false) {} }; -class CCOMCoder64 : - public CCoder +class CNsisCOMCoder : public CCoder +{ +public: + CNsisCOMCoder(): CCoder(false, true) {} +}; + +class CCOMCoder64 : public CCoder { public: CCOMCoder64(): CCoder(true) {} diff --git a/7zip/Compress/Deflate/DllExports.cpp b/7zip/Compress/Deflate/DllExports.cpp index 9cac0523..cbfc8f44 100755 --- a/7zip/Compress/Deflate/DllExports.cpp +++ b/7zip/Compress/Deflate/DllExports.cpp @@ -25,6 +25,11 @@ DEFINE_GUID(CLSID_CCompressDeflateEncoder, DEFINE_GUID(CLSID_CCompressDeflate64Encoder, 0x23170F69, 0x40C1, 0x278B, 0x04, 0x01, 0x09, 0x00, 0x00, 0x00, 0x01, 0x00); + +// {23170F69-40C1-278B-0409-010000000000} +DEFINE_GUID(CLSID_CCompressDeflateNsisDecoder, +0x23170F69, 0x40C1, 0x278B, 0x04, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00); + extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) { @@ -43,6 +48,12 @@ STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject) return E_NOINTERFACE; coder = (ICompressCoder *)new NCompress::NDeflate::NDecoder::CCOMCoder(); } + else if (*clsid == CLSID_CCompressDeflateNsisDecoder) + { + if (!correctInterface) + return E_NOINTERFACE; + coder = (ICompressCoder *)new NCompress::NDeflate::NDecoder::CNsisCOMCoder(); + } else if (*clsid == CLSID_CCompressDeflateEncoder) { if (!correctInterface) @@ -81,11 +92,16 @@ struct CDeflateMethodItem &CLSID_CCompress ## Name ## Decoder, \ &CLSID_CCompress ## Name ## Encoder } +#define METHOD_ITEM_DE(Name, id1, id2, UserName) \ + { { 0x04, id1, id2 }, UserName, \ + &CLSID_CCompress ## Name ## Decoder, NULL } + static CDeflateMethodItem g_Methods[] = { - METHOD_ITEM(Deflate, 0x08, L"Deflate"), - METHOD_ITEM(Deflate64, 0x09, L"Deflate64") + METHOD_ITEM(Deflate, 0x08, L"Deflate"), + METHOD_ITEM(Deflate64, 0x09, L"Deflate64"), + METHOD_ITEM_DE(DeflateNsis, 0x09, 0x01, L"DeflateNSIS") }; STDAPI GetNumberOfMethods(UINT32 *numMethods) @@ -117,9 +133,12 @@ STDAPI GetMethodProperty(UINT32 index, PROPID propID, PROPVARIANT *value) value->vt = VT_BSTR; return S_OK; case NMethodPropID::kEncoder: - if ((value->bstrVal = ::SysAllocStringByteLen( + if (method.Encoder) + { + if ((value->bstrVal = ::SysAllocStringByteLen( (const char *)method.Encoder, sizeof(GUID))) != 0) value->vt = VT_BSTR; + } return S_OK; } return S_OK; diff --git a/7zip/Compress/Deflate/makefile b/7zip/Compress/Deflate/makefile index e0d3a309..74e243d6 100755 --- a/7zip/Compress/Deflate/makefile +++ b/7zip/Compress/Deflate/makefile @@ -1,6 +1,6 @@ PROG = Deflate.dll DEF_FILE = ../Codec.def -CFLAGS = $(CFLAGS) -I ../../../ +CFLAGS = $(CFLAGS) -I ../../../ -D_ST_MODE LIBS = $(LIBS) oleaut32.lib DEFLATE_OBJS = \ diff --git a/7zip/Compress/LZMA/LZMA.dsp b/7zip/Compress/LZMA/LZMA.dsp index af3418aa..12842272 100755 --- a/7zip/Compress/LZMA/LZMA.dsp +++ b/7zip/Compress/LZMA/LZMA.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /YX /FD /c -# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /D "COMPRESS_MF_MT" /Yu"StdAfx.h" /FD /c +# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /D "COMPRESS_MF_MT" /D "_ST_MODE" /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" @@ -70,7 +70,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /D "COMPRESS_MF_MT" /Yu"StdAfx.h" /FD /GZ /c +# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /D "COMPRESS_MF_MT" /D "_ST_MODE" /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" diff --git a/7zip/Compress/LZMA/makefile b/7zip/Compress/LZMA/makefile index 14672b6a..aae16966 100755 --- a/7zip/Compress/LZMA/makefile +++ b/7zip/Compress/LZMA/makefile @@ -1,6 +1,6 @@ PROG = LZMA.dll DEF_FILE = ../Codec.def -CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MF_MT +CFLAGS = $(CFLAGS) -I ../../../ -DCOMPRESS_MF_MT -D_ST_MODE LIBS = $(LIBS) oleaut32.lib LZMA_OBJS = \ diff --git a/7zip/Guid.txt b/7zip/Guid.txt index 4acc9147..664c37f7 100755 --- a/7zip/Guid.txt +++ b/7zip/Guid.txt @@ -114,6 +114,7 @@ Handler GUIDs: 06 Lzh 07 7z 08 Cab +09 Nsis E7 Iso E8 Bkf diff --git a/7zip/MyVersion.h b/7zip/MyVersion.h index 72af8bae..bffb59bc 100755 --- a/7zip/MyVersion.h +++ b/7zip/MyVersion.h @@ -1,7 +1,8 @@ #define MY_VER_MAJOR 4 -#define MY_VER_MINOR 37 -#define MY_VERSION "4.37 beta" -#define MY_7ZIP_VERSION "7-Zip 4.37 beta" -#define MY_DATE "2006-03-18" +#define MY_VER_MINOR 38 +#define MY_VER_BUILD 2 +#define MY_VERSION "4.38 beta" +#define MY_7ZIP_VERSION "7-Zip 4.38 beta" +#define MY_DATE "2006-04-13" #define MY_COPYRIGHT "Copyright (c) 1999-2006 Igor Pavlov" #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE diff --git a/7zip/MyVersionInfo.rc b/7zip/MyVersionInfo.rc index 26d74e9a..fd52d6aa 100755 --- a/7zip/MyVersionInfo.rc +++ b/7zip/MyVersionInfo.rc @@ -1,7 +1,7 @@ #include #include "MyVersion.h" -#define MY_VER MY_VER_MAJOR,MY_VER_MINOR,0,0 +#define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0 #ifdef DEBUG #define DBG_FL VS_FF_DEBUG diff --git a/7zip/UI/Common/ArchiveCommandLine.cpp b/7zip/UI/Common/ArchiveCommandLine.cpp index 68937e89..f05abff1 100755 --- a/7zip/UI/Common/ArchiveCommandLine.cpp +++ b/7zip/UI/Common/ArchiveCommandLine.cpp @@ -27,13 +27,14 @@ using namespace NCommandLineParser; using namespace NWindows; using namespace NFile; -static const int kNumSwitches = 27; +static const int kNumSwitches = 28; namespace NKey { enum Enum { kHelp1 = 0, kHelp2, + kHelp3, kDisableHeaders, kDisablePercents, kArchiveType, @@ -68,7 +69,12 @@ static const wchar_t kRecursedIDChar = 'R'; static const wchar_t *kRecursedPostCharSet = L"0-"; static const wchar_t *kDefaultArchiveType = L"7z"; -static const wchar_t *kSFXExtension = L"exe"; +static const wchar_t *kSFXExtension = + #ifdef _WIN32 + L"exe"; + #else + L""; + #endif namespace NRecursedPostCharIndex { enum EEnum @@ -99,6 +105,7 @@ static const CSwitchForm kSwitchForms[kNumSwitches] = { { L"?", NSwitchType::kSimple, false }, { L"H", NSwitchType::kSimple, false }, + { L"-HELP", NSwitchType::kSimple, false }, { L"BA", NSwitchType::kSimple, false }, { L"BD", NSwitchType::kSimple, false }, { L"T", NSwitchType::kUnLimitedPostString, false, 1 }, @@ -711,7 +718,7 @@ void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings, options.IsStdErrTerminal = (isatty(fileno(stderr)) != 0); options.StdOutMode = parser[NKey::kStdOut].ThereIs; options.EnableHeaders = !parser[NKey::kDisableHeaders].ThereIs; - options.HelpMode = parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs; + options.HelpMode = parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs || parser[NKey::kHelp3].ThereIs; #ifdef _WIN32 options.LargePages = false; diff --git a/7zip/UI/Common/ArchiveName.cpp b/7zip/UI/Common/ArchiveName.cpp index 22fa9ecb..2d50ede1 100755 --- a/7zip/UI/Common/ArchiveName.cpp +++ b/7zip/UI/Common/ArchiveName.cpp @@ -34,7 +34,7 @@ UString CreateArchiveName(const UString &srcName, bool fromPrev, bool keepName) if (!fileInfo.IsDirectory() && !keepName) { int dotPos = resultName.ReverseFind('.'); - if (dotPos >= 0) + if (dotPos > 0) { UString archiveName2 = resultName.Left(dotPos); if (archiveName2.ReverseFind('.') < 0) diff --git a/7zip/UI/Common/ArchiverInfo.cpp b/7zip/UI/Common/ArchiverInfo.cpp index 428aa405..ac3c8351 100755 --- a/7zip/UI/Common/ArchiverInfo.cpp +++ b/7zip/UI/Common/ArchiverInfo.cpp @@ -57,15 +57,15 @@ static UString GetModuleFolderPrefix() { UString path; NDLL::MyGetModuleFileName(g_hInstance, path); - int pos = path.ReverseFind(L'\\'); + int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); return path.Left(pos + 1); } static wchar_t *kFormatFolderName = L"Formats"; -static LPCTSTR kRegistryPath = TEXT("Software\\7-zip"); -static LPCWSTR kProgramPathValue = L"Path"; #ifdef _WIN32 +static LPCTSTR kRegistryPath = TEXT("Software\\7-zip"); +static LPCWSTR kProgramPathValue = L"Path"; static bool ReadPathFromRegistry(HKEY baseKey, UString &path) { NRegistry::CKey key; @@ -244,7 +244,7 @@ void ReadArchiverInfoList(CObjectVector &archivers) #else UString folderPath = GetBaseFolderPrefixFromRegistry() + - kFormatFolderName + L"\\"; + (UString)kFormatFolderName + (UString)WSTRING_PATH_SEPARATOR; NFind::CEnumeratorW enumerator(folderPath + L"*"); NFind::CFileInfoW fileInfo; while (enumerator.Next(fileInfo)) diff --git a/7zip/UI/Common/ExtractingFilePath.cpp b/7zip/UI/Common/ExtractingFilePath.cpp index b1a6d876..a0b17282 100755 --- a/7zip/UI/Common/ExtractingFilePath.cpp +++ b/7zip/UI/Common/ExtractingFilePath.cpp @@ -41,14 +41,20 @@ UString GetCorrectPath(const UString &path) break; while(result.Length() > first) { - if (result[first] == L'\\' || result[first] == L'/') + if ( + #ifdef _WIN32 + result[first] == L'\\' || + #endif + result[first] == L'/') { result.Delete(first); continue; } break; } + #ifdef _WIN32 result.Replace(L"..\\", L""); + #endif result.Replace(L"../", L""); ReplaceDisk(result); diff --git a/7zip/UI/Common/Update.h b/7zip/UI/Common/Update.h index ed7e8885..d94ffcc9 100755 --- a/7zip/UI/Common/Update.h +++ b/7zip/UI/Common/Update.h @@ -31,7 +31,7 @@ struct CArchivePath if (Name.IsEmpty()) return; int dotPos = Name.ReverseFind(L'.'); - if (dotPos < 0) + if (dotPos <= 0) return; if (dotPos == Name.Length() - 1) { diff --git a/7zip/UI/Console/Main.cpp b/7zip/UI/Console/Main.cpp index 7259a2a6..8322db4f 100755 --- a/7zip/UI/Console/Main.cpp +++ b/7zip/UI/Console/Main.cpp @@ -18,6 +18,7 @@ #include "Windows/FileName.h" #include "Windows/Defs.h" #include "Windows/Error.h" +// #include "Windows/System.h" #ifdef _WIN32 #include "Windows/MemoryLock.h" #endif @@ -63,7 +64,9 @@ static const char *kCopyrightString = "\n7-Zip" static const char *kHelpString = "\nUsage: 7z" -#ifdef EXCLUDE_COM +#ifdef _NO_CRYPTO + "r" +#elif EXCLUDE_COM "a" #endif " [...] [...]\n" @@ -109,11 +112,6 @@ static const char *kUserErrorMessage = "Incorrect command line"; // NExitCode:: static const wchar_t *kDefaultSfxModule = L"7zCon.sfx"; -static void PrintHelp(CStdOutStream &s) -{ - s << kHelpString; -} - static void ShowMessageAndThrowException(CStdOutStream &s, LPCSTR message, NExitCode::EEnum code) { s << message << endl; @@ -122,7 +120,7 @@ static void ShowMessageAndThrowException(CStdOutStream &s, LPCSTR message, NExit static void PrintHelpAndExit(CStdOutStream &s) // yyy { - PrintHelp(s); + s << kHelpString; ShowMessageAndThrowException(s, kUserErrorMessage, NExitCode::kUserError); } @@ -143,6 +141,20 @@ static void GetArguments(int numArguments, const char *arguments[], UStringVecto } #endif +static void ShowCopyrightAndHelp(CStdOutStream &s, bool needHelp) +{ + s << kCopyrightString; + /* + UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors(); + s << "System configuration: " << (UInt64)numCPUs << " CPU"; + if (numCPUs > 1) + s << "s"; + s << "\n"; + */ + if (needHelp) + s << kHelpString; +} + int Main2( #ifndef _WIN32 int numArguments, const char *arguments[] @@ -162,8 +174,7 @@ int Main2( if(commandStrings.Size() == 1) { - g_StdOut << kCopyrightString; - g_StdOut << kHelpString; + ShowCopyrightAndHelp(g_StdOut, true); return 0; } commandStrings.Delete(0); @@ -176,8 +187,7 @@ int Main2( if(options.HelpMode) { - g_StdOut << kCopyrightString; - PrintHelp(g_StdOut); + ShowCopyrightAndHelp(g_StdOut, true); return 0; } @@ -190,7 +200,7 @@ int Main2( g_StdStream = &stdStream; if (options.EnableHeaders) - stdStream << kCopyrightString; + ShowCopyrightAndHelp(stdStream, false); parser.Parse2(options); diff --git a/7zip/UI/Console/UserInputUtils.cpp b/7zip/UI/Console/UserInputUtils.cpp index e8904a75..1ec64dd1 100755 --- a/7zip/UI/Console/UserInputUtils.cpp +++ b/7zip/UI/Console/UserInputUtils.cpp @@ -53,6 +53,7 @@ NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream) UString GetPassword(CStdOutStream *outStream) { (*outStream) << "\nEnter password:"; + outStream->Flush(); AString oemPassword = g_StdIn.ScanStringUntilNewLine(); return MultiByteToUnicodeString(oemPassword, CP_OEMCP); } diff --git a/7zip/UI/Explorer/ContextMenu.cpp b/7zip/UI/Explorer/ContextMenu.cpp index ca3fd030..7af6e138 100755 --- a/7zip/UI/Explorer/ContextMenu.cpp +++ b/7zip/UI/Explorer/ContextMenu.cpp @@ -229,25 +229,11 @@ void CZipContextMenu::FillCommand(ECommandInternalID id, return; const CContextMenuCommand &command = g_Commands[i]; commandMapItem.CommandInternalID = command.CommandInternalID; - commandMapItem.Verb = command.Verb; + commandMapItem.Verb = (UString)kMainVerb + (UString)command.Verb; commandMapItem.HelpString = LangString(command.ResourceHelpID, command.LangID + 1); mainString = LangString(command.ResourceID, command.LangID); } -void CZipContextMenu::FillCommand2(ECommandInternalID id, - UString &mainString, CCommandMapItem &commandMapItem) -{ - int i = FindCommand(id); - if (i < 0) - return; - const CContextMenuCommand &command = g_Commands[i]; - commandMapItem.CommandInternalID = command.CommandInternalID; - commandMapItem.Verb = command.Verb; - commandMapItem.HelpString = LangString(command.ResourceHelpID, command.LangID + 1); - mainString = LangString(command.ResourceID, command.LangID); -} - - static bool MyInsertMenu(CMenu &menu, int pos, UINT id, const UString &s) { CMenuItem menuItem; @@ -397,7 +383,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, { CCommandMapItem commandMapItem; UString s; - FillCommand2(kExtractTo, s, commandMapItem); + FillCommand(kExtractTo, s, commandMapItem); UString folder; if (_fileNames.Size() == 1) folder = GetSubFolderNameForExtract(fileInfo.Name); @@ -446,7 +432,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, { CCommandMapItem commandMapItem; UString s; - FillCommand2(kCompressTo, s, commandMapItem); + FillCommand(kCompressTo, s, commandMapItem); if (_dropMode) commandMapItem.Folder = _dropPath; else @@ -473,7 +459,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, { CCommandMapItem commandMapItem; UString s; - FillCommand2(kCompressToEmail, s, commandMapItem); + FillCommand(kCompressToEmail, s, commandMapItem); commandMapItem.Archive = archiveName7z; UString t = UString(L"\"") + GetReducedString(archiveName7z) + UString(L"\""); s = MyFormatNew(s, t); @@ -528,55 +514,25 @@ static UString GetProgramCommand() STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo) { + // ::OutputDebugStringA("1"); int commandOffset; - - if(HIWORD(commandInfo->lpVerb) == 0) - commandOffset = LOWORD(commandInfo->lpVerb); - else - commandOffset = FindVerb(GetUnicodeString(commandInfo->lpVerb)); - /* - #ifdef _UNICODE - if(commandInfo->cbSize == sizeof(CMINVOKECOMMANDINFOEX)) - { - if ((commandInfo->fMask & CMIC_MASK_UNICODE) != 0) - { - LPCMINVOKECOMMANDINFOEX aCommandInfoEx = (LPCMINVOKECOMMANDINFOEX)commandInfo; - if(HIWORD(aCommandInfoEx->lpVerb) == 0) - commandOffset = LOWORD(aCommandInfoEx->lpVerb); - else - { - MessageBox(0, TEXT("1"), TEXT("1"), 0); - return E_FAIL; - } - } - else - { - if(HIWORD(commandInfo->lpVerb) == 0) - commandOffset = LOWORD(commandInfo->lpVerb); - else - commandOffset = FindVerb(commandInfo->lpVerb); - } - // return E_FAIL; - } - else + + // It's fix for bug: crashing in XP. See example in MSDN: "Creating Context Menu Handlers". + + if (commandInfo->cbSize == sizeof(CMINVOKECOMMANDINFOEX) && + (commandInfo->fMask & CMIC_MASK_UNICODE) != 0) { - if(HIWORD(commandInfo->lpVerb) == 0) + LPCMINVOKECOMMANDINFOEX commandInfoEx = (LPCMINVOKECOMMANDINFOEX)commandInfo; + if(HIWORD(commandInfoEx->lpVerbW) == 0) commandOffset = LOWORD(commandInfo->lpVerb); else - commandOffset = FindVerb(commandInfo->lpVerb); + commandOffset = FindVerb(commandInfoEx->lpVerbW); } - - #else - - { + else if(HIWORD(commandInfo->lpVerb) == 0) commandOffset = LOWORD(commandInfo->lpVerb); else - commandOffset = FindVerb(commandInfo->lpVerb); - } - - #endif - */ + commandOffset = FindVerb(GetUnicodeString(commandInfo->lpVerb)); if(commandOffset < 0 || commandOffset >= _commandMap.Size()) return E_FAIL; @@ -666,8 +622,7 @@ STDMETHODIMP CZipContextMenu::GetCommandString(UINT_PTR commandOffset, UINT uTyp } if(uType == GCS_VERBA || uType == GCS_VERBW) { - MyCopyString(pszName, _commandMap[commandOffset].Verb, - uType == GCS_VERBW); + MyCopyString(pszName, _commandMap[commandOffset].Verb, uType == GCS_VERBW); return NO_ERROR; } return E_FAIL; diff --git a/7zip/UI/Explorer/ContextMenu.h b/7zip/UI/Explorer/ContextMenu.h index a5a96c07..f3693ca2 100755 --- a/7zip/UI/Explorer/ContextMenu.h +++ b/7zip/UI/Explorer/ContextMenu.h @@ -75,8 +75,6 @@ private: void FillCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &commandMapItem); - void FillCommand2(ECommandInternalID id, UString &mainString, - CCommandMapItem &commandMapItem); public: CZipContextMenu(); ~CZipContextMenu(); diff --git a/7zip/UI/GUI/CompressDialog.cpp b/7zip/UI/GUI/CompressDialog.cpp index f25fc51b..211e8cf6 100755 --- a/7zip/UI/GUI/CompressDialog.cpp +++ b/7zip/UI/GUI/CompressDialog.cpp @@ -650,7 +650,7 @@ void CCompressDialog::SetArchiveName(const UString &name) { int dotPos = fileName.ReverseFind('.'); int slashPos = MyMax(fileName.ReverseFind('\\'), fileName.ReverseFind('/')); - if (dotPos > slashPos) + if (dotPos >= 0 && dotPos > slashPos + 1) fileName = fileName.Left(dotPos); } } diff --git a/Common/MyWindows.h b/Common/MyWindows.h index 6df08d6f..9cc0394d 100755 --- a/Common/MyWindows.h +++ b/Common/MyWindows.h @@ -7,8 +7,18 @@ #include +#define CHAR_PATH_SEPARATOR '\\' +#define WCHAR_PATH_SEPARATOR L'\\' +#define STRING_PATH_SEPARATOR "\\" +#define WSTRING_PATH_SEPARATOR L"\\" + #else +#define CHAR_PATH_SEPARATOR '/' +#define WCHAR_PATH_SEPARATOR L'/' +#define STRING_PATH_SEPARATOR "/" +#define WSTRING_PATH_SEPARATOR L"/" + #include // for wchar_t #include diff --git a/Common/StdOutStream.cpp b/Common/StdOutStream.cpp index b00fc399..5ab0f10b 100755 --- a/Common/StdOutStream.cpp +++ b/Common/StdOutStream.cpp @@ -31,6 +31,13 @@ bool CStdOutStream::Close() return !_streamIsOpen; } +bool CStdOutStream::Flush() +{ + if(!_streamIsOpen) + return false; + return (fflush(_stream) == 0); +} + CStdOutStream::~CStdOutStream () { Close(); diff --git a/Common/StdOutStream.h b/Common/StdOutStream.h index bf63bb3a..e8aba74a 100755 --- a/Common/StdOutStream.h +++ b/Common/StdOutStream.h @@ -17,6 +17,7 @@ public: ~CStdOutStream (); bool Open(const char *fileName); bool Close(); + bool Flush(); CStdOutStream & operator<<(CStdOutStream & (* aFunction)(CStdOutStream &)); CStdOutStream & operator<<(const char *string); diff --git a/Common/TextConfig.cpp b/Common/TextConfig.cpp index 8e3a8c49..1d355e8a 100755 --- a/Common/TextConfig.cpp +++ b/Common/TextConfig.cpp @@ -120,7 +120,7 @@ bool GetTextConfig(const AString &string, CObjectVector &pairs) return true; } -int FindItem(const CObjectVector &pairs, const UString &id) +int FindTextConfigItem(const CObjectVector &pairs, const UString &id) { for (int i = 0; i < pairs.Size(); i++) if (pairs[i].ID.Compare(id) == 0) @@ -130,7 +130,7 @@ int FindItem(const CObjectVector &pairs, const UString &id) UString GetTextConfigValue(const CObjectVector &pairs, const UString &id) { - int index = FindItem(pairs, id); + int index = FindTextConfigItem(pairs, id); if (index < 0) return UString(); return pairs[index].String; diff --git a/Common/Vector.h b/Common/Vector.h index 984fddc1..210c385e 100755 --- a/Common/Vector.h +++ b/Common/Vector.h @@ -78,6 +78,23 @@ public: operator[](j) = temp; } + int FindInSorted(const T& item) const + { + int left = 0, right = Size(); + while (left != right) + { + int mid = (left + right) / 2; + const T& midValue = (*this)[mid]; + if (item == midValue) + return mid; + if (item < midValue) + right = mid; + else + left = mid + 1; + } + return -1; + } + void Sort(int left, int right) { if (right - left < 2) diff --git a/Common/Wildcard.cpp b/Common/Wildcard.cpp index 1923a339..c9fd73f2 100755 --- a/Common/Wildcard.cpp +++ b/Common/Wildcard.cpp @@ -8,7 +8,9 @@ static const wchar_t kPeriodChar = L'.'; static const wchar_t kAnyCharsChar = L'*'; static const wchar_t kAnyCharChar = L'?'; +#ifdef _WIN32 static const wchar_t kDirDelimiter1 = L'\\'; +#endif static const wchar_t kDirDelimiter2 = L'/'; static const UString kWildCardCharSet = L"?*"; @@ -23,7 +25,11 @@ static const UString kIllegalFileNameChars = kIllegalWildCardFileNameChars + static inline bool IsCharDirLimiter(wchar_t c) { - return (c == kDirDelimiter1 || c == kDirDelimiter2); + return ( + #ifdef _WIN32 + c == kDirDelimiter1 || + #endif + c == kDirDelimiter2); } // ----------------------------------------- @@ -408,7 +414,7 @@ void CCensor::AddItem(bool include, const UString &path, bool recursive) if (DoesNameContainWildCard(front)) break; prefix += front; - prefix += L'\\'; + prefix += WCHAR_PATH_SEPARATOR; pathParts.Delete(0); } int index = FindPrefix(prefix); diff --git a/DOC/7zip.nsi b/DOC/7zip.nsi index 5a92a48f..8841b64f 100755 --- a/DOC/7zip.nsi +++ b/DOC/7zip.nsi @@ -2,7 +2,7 @@ ;Defines !define VERSION_MAJOR 4 -!define VERSION_MINOR 37 +!define VERSION_MINOR 38 !define VERSION_POSTFIX_FULL " beta" !ifdef WIN64 !ifdef IA64 @@ -53,7 +53,8 @@ ;Compressor !ifndef NO_COMPRESSION - SetCompressor /SOLID lzma + SetCompressor /solid lzma + SetCompressorFilter 1 !ifdef IA64 SetCompressorDictSize 8 !else @@ -67,8 +68,6 @@ ;-------------------------------- ;Variables - Var "MyDllPath" - ;-------------------------------- ;Interface Settings @@ -228,6 +227,8 @@ Section File sl.txt File sq.txt File sr.txt + File sr-spc.txt + File sr-spl.txt File sv.txt File ta.txt File th.txt @@ -433,6 +434,8 @@ Section "Uninstall" Delete $INSTDIR\Lang\sl.txt Delete $INSTDIR\Lang\sq.txt Delete $INSTDIR\Lang\sr.txt + Delete $INSTDIR\Lang\sr-spc.txt + Delete $INSTDIR\Lang\sr-spl.txt Delete $INSTDIR\Lang\sv.txt Delete $INSTDIR\Lang\ta.txt Delete $INSTDIR\Lang\th.txt diff --git a/DOC/7zip.wxs b/DOC/7zip.wxs new file mode 100755 index 00000000..2ff6a48e --- /dev/null +++ b/DOC/7zip.wxs @@ -0,0 +1,385 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + Privileged + + + + + + + + + + + + + + + + + + + + + + Privileged + + + + + + Privileged + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DOC/Methods.txt b/DOC/Methods.txt index 34e1a5a9..393e1b0c 100755 --- a/DOC/Methods.txt +++ b/DOC/Methods.txt @@ -1,9 +1,26 @@ -Compression method IDs (4.27) +Compression method IDs (4.38) ----------------------------- Each compression method in 7z has unique binary value (ID). The length of ID in bytes is arbitrary but it can not exceed 15 bytes. +If you want to add some new ID, you have two ways: +1) Write request for allocating IDs to 7-zip developers. +2) Use such random ID: + 03 E0 ZZ ... ZZ MM ... MM VV ... VV + + ZZ != 0, MM != 0, VV != 0 + + 03 E0 - Prefix for random IDs + ZZ ... ZZ - Developer ID. (length >= 4). Use real random bytes. + You can notify 7-Zip developers about your Developer ID. + MM ... MM - Method ID (length >= 1) + VV ... VV - Version (length >= 1) + + Note: Use new ID (MM ... MM VV .. VV) only if old codec can not decode + data encoded with new version. + + List of defined IDs ------------------- @@ -41,6 +58,10 @@ List of defined IDs 04 - PPMD 01 - Version + 80 - reserved for independent developers + + E0 - Random IDs + 04 - Misc 00 - Reserved 01 - Zip @@ -63,6 +84,9 @@ List of defined IDs 06 - Lzh 07 - Reserved for 7z 08 - Cab + 09 - NSIS + 01 - DeflateNSIS + 02 - BZip2NSIS 06 - Crypto diff --git a/DOC/readme.txt b/DOC/readme.txt index 105b35a0..ec4f8a57 100755 --- a/DOC/readme.txt +++ b/DOC/readme.txt @@ -1,4 +1,4 @@ -7-Zip 4.37 Sources +7-Zip 4.38 Sources ------------------ 7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP. diff --git a/Windows/FileDir.cpp b/Windows/FileDir.cpp index 3d0430c6..2c8ace90 100755 --- a/Windows/FileDir.cpp +++ b/Windows/FileDir.cpp @@ -138,7 +138,7 @@ bool CreateComplexDirectory(LPCTSTR pathName) bool CreateComplexDirectory(LPCTSTR _aPathName) { CSysString pathName = _aPathName; - int pos = pathName.ReverseFind(TEXT('\\')); + int pos = pathName.ReverseFind(TEXT(CHAR_PATH_SEPARATOR)); if (pos > 0 && pos == pathName.Length() - 1) { if (pathName.Length() == 3 && pathName[1] == ':') @@ -160,7 +160,7 @@ bool CreateComplexDirectory(LPCTSTR _aPathName) return false; break; } - pos = pathName.ReverseFind(TEXT('\\')); + pos = pathName.ReverseFind(TEXT(CHAR_PATH_SEPARATOR)); if (pos < 0 || pos == 0) return false; if (pathName[pos - 1] == ':') @@ -170,7 +170,7 @@ bool CreateComplexDirectory(LPCTSTR _aPathName) pathName = pathName2; while(pos < pathName.Length()) { - pos = pathName.Find(TEXT('\\'), pos + 1); + pos = pathName.Find(TEXT(CHAR_PATH_SEPARATOR), pos + 1); if (pos < 0) pos = pathName.Length(); if(!MyCreateDirectory(pathName.Left(pos))) @@ -184,7 +184,7 @@ bool CreateComplexDirectory(LPCTSTR _aPathName) bool CreateComplexDirectory(LPCWSTR _aPathName) { UString pathName = _aPathName; - int pos = pathName.ReverseFind(L'\\'); + int pos = pathName.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos > 0 && pos == pathName.Length() - 1) { if (pathName.Length() == 3 && pathName[1] == L':') @@ -206,7 +206,7 @@ bool CreateComplexDirectory(LPCWSTR _aPathName) return false; break; } - pos = pathName.ReverseFind(L'\\'); + pos = pathName.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos < 0 || pos == 0) return false; if (pathName[pos - 1] == L':') @@ -216,7 +216,7 @@ bool CreateComplexDirectory(LPCWSTR _aPathName) pathName = pathName2; while(pos < pathName.Length()) { - pos = pathName.Find(L'\\', pos + 1); + pos = pathName.Find(WCHAR_PATH_SEPARATOR, pos + 1); if (pos < 0) pos = pathName.Length(); if(!MyCreateDirectory(pathName.Left(pos))) diff --git a/Windows/FileName.h b/Windows/FileName.h index 255c06c0..f8567652 100755 --- a/Windows/FileName.h +++ b/Windows/FileName.h @@ -9,7 +9,7 @@ namespace NWindows { namespace NFile { namespace NName { -const TCHAR kDirDelimiter = '\\'; +const TCHAR kDirDelimiter = CHAR_PATH_SEPARATOR; const TCHAR kAnyStringWildcard = '*'; void NormalizeDirPathPrefix(CSysString &dirPath); // ensures that it ended with '\\' -- cgit v1.2.3