From 8304895f29dcbf005fe291a69fc1d32a1828eb43 Mon Sep 17 00:00:00 2001 From: Igor Pavlov Date: Sun, 12 Mar 2006 00:00:00 +0000 Subject: 4.36 beta --- 7zip/Archive/Iso/DllExports.cpp | 88 +++++ 7zip/Archive/Iso/Iso.dsp | 273 +++++++++++++++ 7zip/Archive/Iso/Iso.dsw | 29 ++ 7zip/Archive/Iso/Iso.ico | Bin 0 -> 3638 bytes 7zip/Archive/Iso/IsoHandler.cpp | 301 ++++++++++++++++ 7zip/Archive/Iso/IsoHandler.h | 59 ++++ 7zip/Archive/Iso/IsoHeader.cpp | 21 ++ 7zip/Archive/Iso/IsoHeader.h | 61 ++++ 7zip/Archive/Iso/IsoIn.cpp | 423 +++++++++++++++++++++++ 7zip/Archive/Iso/IsoIn.h | 276 +++++++++++++++ 7zip/Archive/Iso/IsoItem.h | 71 ++++ 7zip/Archive/Iso/StdAfx.cpp | 3 + 7zip/Archive/Iso/StdAfx.h | 9 + 7zip/Archive/Iso/makefile | 55 +++ 7zip/Archive/Iso/resource.rc | 5 + 7zip/Archive/Tar/TarHandlerOut.cpp | 5 +- 7zip/Archive/Zip/ZipHandlerOut.cpp | 4 +- 7zip/Archive/makefile | 1 + 7zip/Common/OutBuffer.cpp | 5 +- 7zip/Compress/LZ/LZOutWindow.h | 10 +- 7zip/FileManager/App.h | 1 + 7zip/FileManager/FM.dsp | 6 +- 7zip/FileManager/MyLoadMenu.cpp | 4 + 7zip/FileManager/Panel.cpp | 2 + 7zip/FileManager/Panel.h | 1 + 7zip/FileManager/PanelCrc.cpp | 354 +++++++++++++++++++ 7zip/FileManager/Resource/SystemPage/resource.rc | 4 +- 7zip/FileManager/makefile | 1 + 7zip/FileManager/resource.h | 12 + 7zip/FileManager/resource.rc | 12 + 7zip/Guid.txt | 1 + 7zip/MyVersion.h | 8 +- 7zip/UI/Common/UpdatePair.cpp | 14 +- 7zip/UI/Console/Console.dsp | 4 + DOC/7zip.nsi | 5 +- DOC/readme.txt | 2 +- Windows/Time.h | 15 + 37 files changed, 2120 insertions(+), 25 deletions(-) create mode 100755 7zip/Archive/Iso/DllExports.cpp create mode 100755 7zip/Archive/Iso/Iso.dsp create mode 100755 7zip/Archive/Iso/Iso.dsw create mode 100755 7zip/Archive/Iso/Iso.ico create mode 100755 7zip/Archive/Iso/IsoHandler.cpp create mode 100755 7zip/Archive/Iso/IsoHandler.h create mode 100755 7zip/Archive/Iso/IsoHeader.cpp create mode 100755 7zip/Archive/Iso/IsoHeader.h create mode 100755 7zip/Archive/Iso/IsoIn.cpp create mode 100755 7zip/Archive/Iso/IsoIn.h create mode 100755 7zip/Archive/Iso/IsoItem.h create mode 100755 7zip/Archive/Iso/StdAfx.cpp create mode 100755 7zip/Archive/Iso/StdAfx.h create mode 100755 7zip/Archive/Iso/makefile create mode 100755 7zip/Archive/Iso/resource.rc create mode 100755 7zip/FileManager/PanelCrc.cpp diff --git a/7zip/Archive/Iso/DllExports.cpp b/7zip/Archive/Iso/DllExports.cpp new file mode 100755 index 00000000..0e6ee9b1 --- /dev/null +++ b/7zip/Archive/Iso/DllExports.cpp @@ -0,0 +1,88 @@ +// DLLExports.cpp + +#include "StdAfx.h" + +#include "Common/MyInitGuid.h" +#include "Common/ComTry.h" +#include "Windows/PropVariant.h" +#include "../../ICoder.h" +#include "IsoHandler.h" + +// {23170F69-40C1-278A-1000-000110E70000} +DEFINE_GUID(CLSID_CIsoHandler, + 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE7, 0x00, 0x00); + +extern "C" +BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) +{ + return TRUE; +} + +STDAPI CreateObject( + const GUID *classID, + const GUID *interfaceID, + void **outObject) +{ + COM_TRY_BEGIN + *outObject = 0; + if (*classID != CLSID_CIsoHandler) + return CLASS_E_CLASSNOTAVAILABLE; + int needIn = *interfaceID == IID_IInArchive; + // int needOut = *interfaceID == IID_IOutArchive; + if (needIn /*|| needOut */) + { + NArchive::NIso::CHandler *temp = new NArchive::NIso::CHandler; + if (needIn) + { + CMyComPtr inArchive = (IInArchive *)temp; + *outObject = inArchive.Detach(); + } + /* + else + { + CMyComPtr outArchive = (IOutArchive *)temp; + *outObject = outArchive.Detach(); + } + */ + } + else + return E_NOINTERFACE; + COM_TRY_END + return S_OK; +} + +STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value) +{ + NWindows::NCOM::CPropVariant propVariant; + switch(propID) + { + case NArchive::kName: + propVariant = L"Iso"; + break; + case NArchive::kClassID: + { + if ((value->bstrVal = ::SysAllocStringByteLen( + (const char *)&CLSID_CIsoHandler, sizeof(GUID))) != 0) + value->vt = VT_BSTR; + return S_OK; + } + case NArchive::kExtension: + propVariant = L"iso"; + break; + case NArchive::kUpdate: + propVariant = true; + break; + case NArchive::kKeepName: + propVariant = false; + break; + case NArchive::kStartSignature: + { + const unsigned char sig[] = { 'C', 'D', '0', '0', '1', 0x1 }; + if ((value->bstrVal = ::SysAllocStringByteLen((const char *)sig, 7)) != 0) + value->vt = VT_BSTR; + return S_OK; + } + } + propVariant.Detach(value); + return S_OK; +} diff --git a/7zip/Archive/Iso/Iso.dsp b/7zip/Archive/Iso/Iso.dsp new file mode 100755 index 00000000..a204e9cd --- /dev/null +++ b/7zip/Archive/Iso/Iso.dsp @@ -0,0 +1,273 @@ +# Microsoft Developer Studio Project File - Name="Iso" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=Iso - Win32 Debug +!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 "Iso.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 "Iso.mak" CFG="Iso - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Iso - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Iso - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Iso - 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 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /YX /FD /c +# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /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 0x419 /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 /dll /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 /nologo /dll /machine:I386 /out:"C:\Program Files\7-Zip\Formats\Iso.dll" /opt:NOWIN98 +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "Iso - 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 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 "TAR_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /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 0x419 /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 /dll /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 /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-Zip\Formats\Iso.dll" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "Iso - Win32 Release" +# Name "Iso - Win32 Debug" +# Begin Group "Spec" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\Archive.def +# End Source File +# Begin Source File + +SOURCE=.\DllExports.cpp +# End Source File +# Begin Source File + +SOURCE=.\Iso.ico +# End Source File +# Begin Source File + +SOURCE=.\resource.rc +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"StdAfx.h" +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\..\Common\Alloc.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Alloc.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Buffer.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\NewHandler.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\NewHandler.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\String.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\String.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\Vector.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Vector.h +# End Source File +# End Group +# Begin Group "Windows" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\..\Windows\PropVariant.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\PropVariant.h +# End Source File +# End Group +# Begin Group "Compress" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\Compress\Copy\CopyCoder.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Compress\Copy\CopyCoder.h +# End Source File +# End Group +# Begin Group "Engine" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\IsoHandler.cpp +# End Source File +# Begin Source File + +SOURCE=.\IsoHandler.h +# End Source File +# Begin Source File + +SOURCE=.\IsoHeader.cpp +# End Source File +# Begin Source File + +SOURCE=.\IsoHeader.h +# End Source File +# Begin Source File + +SOURCE=.\IsoIn.cpp +# End Source File +# Begin Source File + +SOURCE=.\IsoIn.h +# End Source File +# Begin Source File + +SOURCE=.\IsoItem.h +# End Source File +# End Group +# Begin Group "Archive Common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\Common\ItemNameUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\Common\ItemNameUtils.h +# End Source File +# End Group +# Begin Group "7zip Common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\Common\LimitedStreams.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Common\LimitedStreams.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\StreamUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Common\StreamUtils.h +# End Source File +# End Group +# End Target +# End Project diff --git a/7zip/Archive/Iso/Iso.dsw b/7zip/Archive/Iso/Iso.dsw new file mode 100755 index 00000000..27728dd2 --- /dev/null +++ b/7zip/Archive/Iso/Iso.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "Iso"=.\Iso.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/7zip/Archive/Iso/Iso.ico b/7zip/Archive/Iso/Iso.ico new file mode 100755 index 00000000..2538e408 Binary files /dev/null and b/7zip/Archive/Iso/Iso.ico differ diff --git a/7zip/Archive/Iso/IsoHandler.cpp b/7zip/Archive/Iso/IsoHandler.cpp new file mode 100755 index 00000000..2c961ad0 --- /dev/null +++ b/7zip/Archive/Iso/IsoHandler.cpp @@ -0,0 +1,301 @@ +// Iso/Handler.cpp + +#include "StdAfx.h" + +#include "IsoHandler.h" + +#include "Common/Defs.h" +#include "Common/StringConvert.h" +#include "Common/IntToString.h" +#include "Common/NewHandler.h" +#include "Common/ComTry.h" + +#include "Windows/Time.h" +#include "Windows/PropVariant.h" + +#include "../../Common/ProgressUtils.h" +#include "../../Common/LimitedStreams.h" +#include "../../Compress/Copy/CopyCoder.h" + +#include "../Common/ItemNameUtils.h" + +using namespace NWindows; +using namespace NTime; + +namespace NArchive { +namespace NIso { + +STATPROPSTG kProperties[] = +{ + { NULL, kpidPath, VT_BSTR}, + { NULL, kpidIsFolder, VT_BOOL}, + { NULL, kpidSize, VT_UI8}, + { NULL, kpidPackedSize, VT_UI8}, + { NULL, kpidLastWriteTime, VT_FILETIME} +}; + +STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) +{ + value->vt = VT_EMPTY; + return S_OK; +} + +STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties) +{ + *numProperties = sizeof(kProperties) / sizeof(kProperties[0]); + return S_OK; +} + +STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, + BSTR *name, PROPID *propID, VARTYPE *varType) +{ + if(index >= sizeof(kProperties) / sizeof(kProperties[0])) + return E_INVALIDARG; + const STATPROPSTG &srcItem = kProperties[index]; + *propID = srcItem.propid; + *varType = srcItem.vt; + *name = 0; + return S_OK; +} + +STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) +{ + *numProperties = 0; + return S_OK; +} + +STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 index, + BSTR *name, PROPID *propID, VARTYPE *varType) +{ + return E_INVALIDARG; +} + +STDMETHODIMP CHandler::Open(IInStream *stream, + const UInt64 *maxCheckStartPosition, + IArchiveOpenCallback *openArchiveCallback) +{ + COM_TRY_BEGIN + bool mustBeClosed = true; + Close(); + // try + { + if(_archive.Open(stream) != S_OK) + return S_FALSE; + _inStream = stream; + } + // catch(...) { return S_FALSE; } + return S_OK; + COM_TRY_END +} + +STDMETHODIMP CHandler::Close() +{ + _archive.Clear(); + _inStream.Release(); + return S_OK; +} + +STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) +{ + *numItems = _archive.Refs.Size() + _archive.BootEntries.Size(); + return S_OK; +} + +STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) +{ + COM_TRY_BEGIN + NWindows::NCOM::CPropVariant propVariant; + if (index >= (UInt32)_archive.Refs.Size()) + { + index -= _archive.Refs.Size(); + const CBootInitialEntry &be = _archive.BootEntries[index]; + switch(propID) + { + case kpidPath: + { + // wchar_t name[32]; + // ConvertUInt64ToString(index + 1, name); + UString s = L"[BOOT]\\"; + // s += name; + // s += L"-"; + s += be.GetName(); + propVariant = (const wchar_t *)s; + break; + } + case kpidIsFolder: + propVariant = false; + break; + case kpidSize: + case kpidPackedSize: + { + propVariant = (UInt64)be.GetSize(); + break; + } + } + } + else + { + const CRef &ref = _archive.Refs[index]; + const CDir &item = ref.Dir->_subItems[ref.Index]; + switch(propID) + { + case kpidPath: + if (item.FileId.GetCapacity() >= 0) + { + UString s; + if (_archive.IsJoliet()) + s = item.GetPathU(); + else + s = MultiByteToUnicodeString(item.GetPath(), CP_OEMCP); + + int pos = s.ReverseFind(L';'); + if (pos >= 0 && pos == s.Length() - 2) + if (s[s.Length() - 1] == L'1') + s = s.Left(pos); + if (!s.IsEmpty()) + if (s[s.Length() - 1] == L'.') + s = s.Left(s.Length() - 1); + propVariant = (const wchar_t *)NItemName::GetOSName2(s); + } + break; + case kpidIsFolder: + propVariant = item.IsDir(); + break; + case kpidSize: + case kpidPackedSize: + if (!item.IsDir()) + propVariant = (UInt64)item.DataLength; + break; + case kpidLastWriteTime: + { + FILETIME utcFileTime; + if (item.DateTime.GetFileTime(utcFileTime)) + propVariant = utcFileTime; + /* + else + { + utcFileTime.dwLowDateTime = 0; + utcFileTime.dwHighDateTime = 0; + } + */ + break; + } + } + } + propVariant.Detach(value); + return S_OK; + COM_TRY_END +} + +STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, + Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +{ + COM_TRY_BEGIN + bool testMode = (_aTestMode != 0); + bool allFilesMode = (numItems == UInt32(-1)); + if (allFilesMode) + numItems = _archive.Refs.Size(); + UInt64 totalSize = 0; + if(numItems == 0) + return S_OK; + UInt32 i; + for(i = 0; i < numItems; i++) + { + UInt32 index = (allFilesMode ? i : indices[i]); + if (index < (UInt32)_archive.Refs.Size()) + { + const CRef &ref = _archive.Refs[index]; + const CDir &item = ref.Dir->_subItems[ref.Index]; + totalSize += item.DataLength; + } + else + { + const CBootInitialEntry &be = _archive.BootEntries[index - _archive.Refs.Size()]; + totalSize += be.GetSize(); + } + } + extractCallback->SetTotal(totalSize); + + UInt64 currentTotalSize = 0; + UInt64 currentItemSize; + + CMyComPtr copyCoder; + + for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize) + { + currentItemSize = 0; + RINOK(extractCallback->SetCompleted(¤tTotalSize)); + CMyComPtr realOutStream; + Int32 askMode; + askMode = testMode ? NArchive::NExtract::NAskMode::kTest : NArchive::NExtract::NAskMode::kExtract; + UInt32 index = allFilesMode ? i : indices[i]; + + RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); + + UInt64 blockIndex; + if (index < (UInt32)_archive.Refs.Size()) + { + const CRef &ref = _archive.Refs[index]; + const CDir &item = ref.Dir->_subItems[ref.Index]; + if(item.IsDir()) + { + RINOK(extractCallback->PrepareOperation(askMode)); + RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + continue; + } + currentItemSize = item.DataLength; + blockIndex = item.ExtentLocation; + } + else + { + const CBootInitialEntry &be = _archive.BootEntries[index - _archive.Refs.Size()]; + currentItemSize = be.GetSize(); + blockIndex = be.LoadRBA; + } + + if(!testMode && (!realOutStream)) + continue; + + RINOK(extractCallback->PrepareOperation(askMode)); + { + if (testMode) + { + RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + continue; + } + + RINOK(_inStream->Seek(blockIndex * _archive.BlockSize, STREAM_SEEK_SET, NULL)); + CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream; + CMyComPtr inStream(streamSpec); + streamSpec->Init(_inStream, currentItemSize); + + CLocalProgress *localProgressSpec = new CLocalProgress; + CMyComPtr progress = localProgressSpec; + localProgressSpec->Init(extractCallback, false); + + CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo; + CMyComPtr compressProgress = localCompressProgressSpec; + localCompressProgressSpec->Init(progress, ¤tTotalSize, ¤tTotalSize); + + Int32 res = NArchive::NExtract::NOperationResult::kOK; + if(!copyCoder) + { + copyCoder = new NCompress::CCopyCoder; + } + try + { + RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, compressProgress)); + } + catch(...) + { + res = NArchive::NExtract::NOperationResult::kDataError; + } + realOutStream.Release(); + RINOK(extractCallback->SetOperationResult(res)); + } + } + return S_OK; + COM_TRY_END +} + +}} diff --git a/7zip/Archive/Iso/IsoHandler.h b/7zip/Archive/Iso/IsoHandler.h new file mode 100755 index 00000000..e545d2a7 --- /dev/null +++ b/7zip/Archive/Iso/IsoHandler.h @@ -0,0 +1,59 @@ +// Tar/Handler.h + +#ifndef __ISO_HANDLER_H +#define __ISO_HANDLER_H + +#include "Common/MyCom.h" +#include "../IArchive.h" + +#include "IsoItem.h" +#include "IsoIn.h" + +namespace NArchive { +namespace NIso { + +class CHandler: + public IInArchive, + // public IOutArchive, + public CMyUnknownImp +{ +public: + MY_UNKNOWN_IMP1( + IInArchive + // IOutArchive + ) + + STDMETHOD(Open)(IInStream *stream, + const UInt64 *maxCheckStartPosition, + IArchiveOpenCallback *openArchiveCallback); + STDMETHOD(Close)(); + STDMETHOD(GetNumberOfItems)(UInt32 *numItems); + STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value); + STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback); + + STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value); + + STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties); + STDMETHOD(GetPropertyInfo)(UInt32 index, + BSTR *name, PROPID *propID, VARTYPE *varType); + + STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties); + STDMETHOD(GetArchivePropertyInfo)(UInt32 index, + BSTR *name, PROPID *propID, VARTYPE *varType); + + /* + // IOutArchive + STDMETHOD(UpdateItems)(ISequentialOutStream *outStream, UInt32 numItems, + IArchiveUpdateCallback *updateCallback); + STDMETHOD(GetFileTimeType)(UInt32 *type); + */ + +private: + CMyComPtr _inStream; + CInArchive _archive; +}; + +}} + +#endif diff --git a/7zip/Archive/Iso/IsoHeader.cpp b/7zip/Archive/Iso/IsoHeader.cpp new file mode 100755 index 00000000..9555e49b --- /dev/null +++ b/7zip/Archive/Iso/IsoHeader.cpp @@ -0,0 +1,21 @@ +// Archive/Iso/Header.h + +#include "StdAfx.h" + +#include "IsoHeader.h" + +namespace NArchive { +namespace NIso { + +const char *kElToritoSpec = "EL TORITO SPECIFICATION\0\0\0\0\0\0\0\0\0"; + +const wchar_t *kMediaTypes[5] = +{ + L"NoEmulation", + L"1.2M", + L"1.44M", + L"2.88M", + L"HardDisk" +}; + +}} diff --git a/7zip/Archive/Iso/IsoHeader.h b/7zip/Archive/Iso/IsoHeader.h new file mode 100755 index 00000000..db070c1b --- /dev/null +++ b/7zip/Archive/Iso/IsoHeader.h @@ -0,0 +1,61 @@ +// Archive/IsoHeader.h + +#ifndef __ARCHIVE_ISO_HEADER_H +#define __ARCHIVE_ISO_HEADER_H + +#include "Common/Types.h" + +namespace NArchive { +namespace NIso { + +namespace NVolDescType +{ + const Byte kBootRecord = 0; + const Byte kPrimaryVol = 1; + const Byte kSupplementaryVol = 2; + const Byte kVolParttition = 3; + const Byte kTerminator = 255; +} + +const Byte kVersion = 1; + +namespace NFileFlags +{ + const Byte kDirectory = 1 << 1; +} + +extern const char *kElToritoSpec; + +const UInt32 kStartPos = 0x8000; + +namespace NBootEntryId +{ + const Byte kValidationEntry = 1; + const Byte kInitialEntryNotBootable = 0; + const Byte kInitialEntryBootable = 0x88; +}; + +namespace NBootPlatformId +{ + const Byte kX86 = 0; + const Byte kPowerPC = 1; + const Byte kMac = 2; +} + +const BYTE kBootMediaTypeMask = 0xF; + +namespace NBootMediaType +{ + const Byte kNoEmulation = 0; + const Byte k1d2Floppy = 1; + const Byte k1d44Floppy = 2; + const Byte k2d88Floppy = 3; + const Byte kHardDisk = 4; +} + +const int kNumBootMediaTypes = 5; +extern const wchar_t *kMediaTypes[]; + +}} + +#endif diff --git a/7zip/Archive/Iso/IsoIn.cpp b/7zip/Archive/Iso/IsoIn.cpp new file mode 100755 index 00000000..5a504955 --- /dev/null +++ b/7zip/Archive/Iso/IsoIn.cpp @@ -0,0 +1,423 @@ +// Archive/IsoIn.cpp + +#include "StdAfx.h" + +#include "IsoIn.h" +#include "IsoHeader.h" + +#include "Windows/Defs.h" + +#include "../../Common/StreamUtils.h" + +namespace NArchive { +namespace NIso { + +HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize) +{ + return ReadStream(_stream, data, size, &processedSize); +} + +Byte CInArchive::ReadByte() +{ + if (m_BufferPos >= BlockSize) + m_BufferPos = 0; + if (m_BufferPos == 0) + { + UInt32 processedSize; + if (ReadBytes(m_Buffer, BlockSize, processedSize) != S_OK) + throw 1; + if (processedSize != BlockSize) + throw 1; + } + Byte b = m_Buffer[m_BufferPos++]; + _position++; + return b; +} + +void CInArchive::ReadBytes(Byte *data, UInt32 size) +{ + for (UInt32 i = 0; i < size; i++) + data[i] = ReadByte(); +} + +void CInArchive::Skeep(size_t size) +{ + while (size-- != 0) + ReadByte(); +} + +void CInArchive::SkeepZeros(size_t size) +{ + while (size-- != 0) + { + Byte b = ReadByte(); + if (b != 0) + throw 1; + } +} + +UInt16 CInArchive::ReadUInt16Spec() +{ + UInt16 value = 0; + for (int i = 0; i < 2; i++) + value |= ((UInt16)(ReadByte()) << (8 * i)); + return value; +} + + +UInt16 CInArchive::ReadUInt16() +{ + Byte b[4]; + ReadBytes(b, 4); + UInt32 value = 0; + for (int i = 0; i < 2; i++) + { + if (b[i] != b[3 - i]) + throw 1; + value |= ((UInt16)(b[i]) << (8 * i)); + } + return value; +} + +UInt32 CInArchive::ReadUInt32Le() +{ + UInt32 value = 0; + for (int i = 0; i < 4; i++) + value |= ((UInt32)(ReadByte()) << (8 * i)); + return value; +} + +UInt32 CInArchive::ReadUInt32Be() +{ + UInt32 value = 0; + for (int i = 0; i < 4; i++) + { + value <<= 8; + value |= ReadByte(); + } + return value; +} + +UInt32 CInArchive::ReadUInt32() +{ + Byte b[8]; + ReadBytes(b, 8); + UInt32 value = 0; + for (int i = 0; i < 4; i++) + { + if (b[i] != b[7 - i]) + throw 1; + value |= ((UInt32)(b[i]) << (8 * i)); + } + return value; +} + +UInt32 CInArchive::ReadDigits(int numDigits) +{ + UInt32 res = 0; + for (int i = 0; i < numDigits; i++) + { + Byte b = ReadByte(); + if (b < '0' || b > '9') + { + if (b == 0) // it's bug in some CD's + b = '0'; + else + throw 1; + } + UInt32 d = (UInt32)(b - '0'); + res *= 10; + res += d; + } + return res; +} + +void CInArchive::ReadDateTime(CDateTime &d) +{ + d.Year = ReadDigits(4); + d.Month = ReadDigits(2); + d.Day = ReadDigits(2); + d.Hour = ReadDigits(2); + d.Minute = ReadDigits(2); + d.Second = ReadDigits(2); + d.Hundredths = ReadDigits(2); + d.GmtOffset = (signed char)ReadByte(); +} + +void CInArchive::ReadBootRecordDescriptor(CBootRecordDescriptor &d) +{ + ReadBytes(d.BootSystemId, sizeof(d.BootSystemId)); + ReadBytes(d.BootId, sizeof(d.BootId)); + ReadBytes(d.BootSystemUse, sizeof(d.BootSystemUse)); +} + +void CInArchive::ReadRecordingDateTime(CRecordingDateTime &t) +{ + t.Year = ReadByte(); + t.Month = ReadByte(); + t.Day = ReadByte(); + t.Hour = ReadByte(); + t.Minute = ReadByte(); + t.Second = ReadByte(); + t.GmtOffset = (signed char)ReadByte(); +} + +void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len) +{ + r.ExtendedAttributeRecordLen = ReadByte(); + if (r.ExtendedAttributeRecordLen != 0) + throw 1; + r.ExtentLocation = ReadUInt32(); + r.DataLength = ReadUInt32(); + ReadRecordingDateTime(r.DateTime); + r.FileFlags = ReadByte(); + r.FileUnitSize = ReadByte(); + r.InterleaveGapSize = ReadByte(); + r.VolSequenceNumber = ReadUInt16(); + Byte idLen = ReadByte(); + r.FileId.SetCapacity(idLen); + ReadBytes((Byte *)r.FileId, idLen); + int padSize = 1 - (idLen & 1); + + // SkeepZeros(1 - (idLen & 1)); + Skeep(1 - (idLen & 1)); // it's bug in some cd's. Must be zeros + + int curPos = 33 + idLen + padSize; + if (curPos > len) + throw 1; + int rem = len - curPos; + r.SystemUse.SetCapacity(rem); + ReadBytes((Byte *)r.SystemUse, rem); +} + +void CInArchive::ReadDirRecord(CDirRecord &r) +{ + Byte len = ReadByte(); + ReadDirRecord2(r, len); +} + +void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d) +{ + d.VolFlags = ReadByte(); + ReadBytes(d.SystemId, sizeof(d.SystemId)); + ReadBytes(d.VolumeId, sizeof(d.VolumeId)); + SkeepZeros(8); + d.VolumeSpaceSize = ReadUInt32(); + ReadBytes(d.EscapeSequence, sizeof(d.EscapeSequence)); + d.VolumeSetSize = ReadUInt16(); + d.VolumeSequenceNumber = ReadUInt16(); + d.LogicalBlockSize = ReadUInt16(); + d.PathTableSize = ReadUInt32(); + d.LPathTableLocation = ReadUInt32Le(); + d.LOptionalPathTableLocation = ReadUInt32Le(); + d.MPathTableLocation = ReadUInt32Be(); + d.MOptionalPathTableLocation = ReadUInt32Be(); + ReadDirRecord(d.RootDirRecord); + ReadBytes(d.VolumeSetId, sizeof(d.VolumeSetId)); + ReadBytes(d.PublisherId, sizeof(d.PublisherId)); + ReadBytes(d.DataPreparerId, sizeof(d.DataPreparerId)); + ReadBytes(d.ApplicationId, sizeof(d.ApplicationId)); + ReadBytes(d.CopyrightFileId, sizeof(d.CopyrightFileId)); + ReadBytes(d.AbstractFileId, sizeof(d.AbstractFileId)); + ReadBytes(d.BibFileId, sizeof(d.BibFileId)); + ReadDateTime(d.CreationTime); + ReadDateTime(d.ModificationTime); + ReadDateTime(d.ExpirationTime); + ReadDateTime(d.EffectiveTime); + d.FileStructureVersion = ReadByte(); // = 1 + SkeepZeros(1); + ReadBytes(d.ApplicationUse, sizeof(d.ApplicationUse)); + SkeepZeros(653); +} + +static inline bool CheckDescriptorSignature(const Byte *sig) +{ + return sig[0] == 'C' && + sig[1] == 'D' && + sig[2] == '0' && + sig[3] == '0' && + sig[4] == '1'; +} + +void CInArchive::SeekToBlock(UInt32 blockIndex) +{ + if (_stream->Seek((UInt64)blockIndex * VolDescs[MainVolDescIndex].LogicalBlockSize, STREAM_SEEK_SET, &_position) != S_OK) + throw 1; + m_BufferPos = 0; +} + +void CInArchive::ReadDir(CDir &d, int level) +{ + if (!d.IsDir()) + return; + SeekToBlock(d.ExtentLocation); + UInt64 startPos = _position; + + while(true) + { + UInt64 offset = _position - startPos; + if (offset >= d.DataLength) + break; + Byte len = ReadByte(); + if (len == 0) + continue; + CDir subItem; + ReadDirRecord2(subItem, len); + if (!subItem.IsSystemItem()) + d._subItems.Add(subItem); + } + for (int i = 0; i < d._subItems.Size(); i++) + ReadDir(d._subItems[i], level + 1); +} + +void CInArchive::CreateRefs(CDir &d) +{ + if (!d.IsDir()) + return; + for (int i = 0; i < d._subItems.Size(); i++) + { + CRef ref; + CDir &subItem = d._subItems[i]; + subItem.Parent = &d; + ref.Dir = &d; + ref.Index = i; + Refs.Add(ref); + CreateRefs(subItem); + } +} + +void CInArchive::ReadBootInfo() +{ + if (!_bootIsDefined) + return; + if (memcmp(_bootDesc.BootSystemId, kElToritoSpec, sizeof(_bootDesc.BootSystemId)) != 0) + return; + + const Byte *p = (const Byte *)_bootDesc.BootSystemUse; + UInt32 blockIndex = p[0] | ((UInt32)p[1] << 8) | ((UInt32)p[2] << 16) | ((UInt32)p[3] << 24); + SeekToBlock(blockIndex); + Byte b = ReadByte(); + if (b != NBootEntryId::kValidationEntry) + return; + { + CBootValidationEntry e; + e.PlatformId = ReadByte(); + if (ReadUInt16Spec() != 0) + throw 1; + ReadBytes(e.Id, sizeof(e.Id)); + UInt16 checkSum = ReadUInt16Spec(); + if (ReadByte() != 0x55) + throw 1; + if (ReadByte() != 0xAA) + throw 1; + } + b = ReadByte(); + if (b == NBootEntryId::kInitialEntryBootable || b == NBootEntryId::kInitialEntryNotBootable) + { + CBootInitialEntry e; + e.Bootable = (b == NBootEntryId::kInitialEntryBootable); + e.BootMediaType = ReadByte(); + e.LoadSegment = ReadUInt16Spec(); + e.SystemType = ReadByte(); + if (ReadByte() != 0) + throw 1; + e.SectorCount = ReadUInt16Spec(); + e.LoadRBA = ReadUInt32Le(); + if (ReadByte() != 0) + throw 1; + BootEntries.Add(e); + } + else + return; +} + +HRESULT CInArchive::Open2() +{ + Clear(); + RINOK(_stream->Seek(kStartPos, STREAM_SEEK_CUR, &_position)); + + bool primVolDescDefined = false; + m_BufferPos = 0; + BlockSize = kBlockSize; + VolDescs.Add(CVolumeDescriptor()); + while(true) + { + Byte sig[6]; + ReadBytes(sig, 6); + if (!CheckDescriptorSignature(sig + 1)) + return S_FALSE; + if (ReadByte() != kVersion) + throw 1; + if (sig[0] == NVolDescType::kTerminator) + break; + switch(sig[0]) + { + case NVolDescType::kBootRecord: + { + _bootIsDefined = true; + ReadBootRecordDescriptor(_bootDesc); + break; + } + case NVolDescType::kPrimaryVol: + { + if (primVolDescDefined) + return S_FALSE; + primVolDescDefined = true; + CVolumeDescriptor &volDesc = VolDescs[0]; + ReadVolumeDescriptor(volDesc); + // some burners write "Joliet" Escape Sequence to primary volume + memset(volDesc.EscapeSequence, 0, sizeof(volDesc.EscapeSequence)); + break; + } + case NVolDescType::kSupplementaryVol: + { + CVolumeDescriptor sd; + ReadVolumeDescriptor(sd); + VolDescs.Add(sd); + break; + } + default: + break; + } + } + MainVolDescIndex = 0; + if (!primVolDescDefined) + return S_FALSE; + for (int i = VolDescs.Size() - 1; i >= 0; i--) + { + if (VolDescs[i].IsJoliet()) + { + MainVolDescIndex = i; + break; + } + } + // MainVolDescIndex = 0; // to read primary volume + if (VolDescs[MainVolDescIndex].LogicalBlockSize != kBlockSize) + return S_FALSE; + (CDirRecord &)_rootDir = VolDescs[MainVolDescIndex].RootDirRecord; + ReadDir(_rootDir, 0); + CreateRefs(_rootDir); + ReadBootInfo(); + return S_OK; +} + +HRESULT CInArchive::Open(IInStream *inStream) +{ + _stream = inStream; + HRESULT res = S_FALSE; + try { res = Open2(); } + catch(...) { Clear(); res = S_FALSE; } + _stream.Release(); + return res; +} + +void CInArchive::Clear() +{ + Refs.Clear(); + _rootDir.Clear(); + VolDescs.Clear(); + _bootIsDefined = false; + BootEntries.Clear(); +} + +}} diff --git a/7zip/Archive/Iso/IsoIn.h b/7zip/Archive/Iso/IsoIn.h new file mode 100755 index 00000000..e91d7812 --- /dev/null +++ b/7zip/Archive/Iso/IsoIn.h @@ -0,0 +1,276 @@ +// Archive/IsoIn.h + +#ifndef __ARCHIVE_ISO_IN_H +#define __ARCHIVE_ISO_IN_H + +#include "Common/MyCom.h" +#include "Common/IntToString.h" + +#include "../../IStream.h" + +#include "IsoItem.h" +#include "IsoHeader.h" + +namespace NArchive { +namespace NIso { + +struct CDir: public CDirRecord +{ + CDir *Parent; + CObjectVector _subItems; + + void Clear() + { + Parent = 0; + _subItems.Clear(); + } + + int GetLength() const + { + int len = FileId.GetCapacity(); + if (Parent != 0) + if (Parent->Parent != 0) + len += 1 + Parent->GetLength(); + return len; + } + + int GetLengthU() const + { + int len = FileId.GetCapacity() / 2; + if (Parent != 0) + if (Parent->Parent != 0) + len += 1 + Parent->GetLengthU(); + return len; + } + + AString GetPath() const + { + AString s; + int len = GetLength(); + char *p = s.GetBuffer(len + 1); + p += len; + *p = 0; + const CDir *cur = this; + while(true) + { + int curLen = cur->FileId.GetCapacity(); + p -= curLen; + memmove(p, (const char *)(const Byte *)cur->FileId, curLen); + cur = cur->Parent; + if (cur == 0) + break; + if (cur->Parent == 0) + break; + p--; + *p = '\\'; + } + s.ReleaseBuffer(); + return s; + } + + UString GetPathU() const + { + UString s; + int len = GetLengthU(); + wchar_t *p = s.GetBuffer(len + 1); + p += len; + *p = 0; + const CDir *cur = this; + while(true) + { + int curLen = cur->FileId.GetCapacity() / 2; + p -= curLen; + for (int i = 0; i < curLen; i++) + { + Byte b0 = ((const Byte *)cur->FileId)[i * 2]; + Byte b1 = ((const Byte *)cur->FileId)[i * 2 + 1]; + p[i] = ((wchar_t)b0 << 8) | (wchar_t)b1; + } + cur = cur->Parent; + if (cur == 0) + break; + if (cur->Parent == 0) + break; + p--; + *p = L'\\'; + } + s.ReleaseBuffer(); + return s; + } +}; + +struct CDateTime +{ + UInt16 Year; + Byte Month; + Byte Day; + Byte Hour; + Byte Minute; + Byte Second; + Byte Hundredths; + signed char GmtOffset; // min intervals from -48 (West) to +52 (East) recorded. + bool NotSpecified() const { return Year == 0 && Month == 0 && Day == 0 && + Hour == 0 && Minute == 0 && Second == 0 && GmtOffset == 0; } +}; + +struct CBootRecordDescriptor +{ + Byte BootSystemId[32]; // a-characters + Byte BootId[32]; // a-characters + Byte BootSystemUse[1977]; +}; + +struct CBootValidationEntry +{ + Byte PlatformId; + Byte Id[24]; // to identify the manufacturer/developer of the CD-ROM. +}; + +struct CBootInitialEntry +{ + bool Bootable; + Byte BootMediaType; + UInt16 LoadSegment; + /* This is the load segment for the initial boot image. If this + value is 0 the system will use the traditional segment of 7C0. If this value + is non-zero the system will use the specified segment. This applies to x86 + architectures only. For "flat" model architectures (such as Motorola) this + is the address divided by 10. */ + Byte SystemType; // This must be a copy of byte 5 (System Type) from the + // Partition Table found in the boot image. + UInt16 SectorCount; // This is the number of virtual/emulated sectors the system + // will store at Load Segment during the initial boot procedure. + UInt32 LoadRBA; // This is the start address of the virtual disk. CD’s use + // Relative/Logical block addressing. + + UInt64 GetSize() const + { + // if (BootMediaType == NBootMediaType::k1d44Floppy) (1440 << 10); + return SectorCount * 512; + } + + UString GetName() const + { + UString s; + if (Bootable) + s += L"Bootable"; + else + s += L"NotBootable"; + s += L"_"; + if (BootMediaType >= kNumBootMediaTypes) + { + wchar_t name[32]; + ConvertUInt64ToString(BootMediaType, name); + s += name; + } + else + s += kMediaTypes[BootMediaType]; + s += L".img"; + return s; + } +}; + +struct CVolumeDescriptor +{ + Byte VolFlags; + Byte SystemId[32]; // a-characters. An identification of a system + // which can recognize and act upon the content of the Logical + // Sectors with logical Sector Numbers 0 to 15 of the volume. + Byte VolumeId[32]; // d-characters. An identification of the volume. + UInt32 VolumeSpaceSize; // the number of Logical Blocks in which the Volume Space of the volume is recorded + Byte EscapeSequence[32]; + UInt16 VolumeSetSize; + UInt16 VolumeSequenceNumber; // the ordinal number of the volume in the Volume Set of which the volume is a member. + UInt16 LogicalBlockSize; + UInt32 PathTableSize; + UInt32 LPathTableLocation; + UInt32 LOptionalPathTableLocation; + UInt32 MPathTableLocation; + UInt32 MOptionalPathTableLocation; + CDirRecord RootDirRecord; + Byte VolumeSetId[128]; + Byte PublisherId[128]; + Byte DataPreparerId[128]; + Byte ApplicationId[128]; + Byte CopyrightFileId[37]; + Byte AbstractFileId[37]; + Byte BibFileId[37]; + CDateTime CreationTime; + CDateTime ModificationTime; + CDateTime ExpirationTime; + CDateTime EffectiveTime; + Byte FileStructureVersion; // = 1; + Byte ApplicationUse[512]; + + bool IsJoliet() const + { + if ((VolFlags & 1) != 0) + return false; + Byte b = EscapeSequence[2]; + return (EscapeSequence[0] == 0x25 && EscapeSequence[1] == 0x2F && + (b == 0x40 || b == 0x43 || b == 0x45)); + } +}; + +struct CRef +{ + CDir *Dir; + UInt32 Index; +}; + +const UInt32 kBlockSize = 1 << 11; + +class CInArchive +{ + CMyComPtr _stream; + UInt64 _position; + + Byte m_Buffer[kBlockSize]; + UInt32 m_BufferPos; + + CDir _rootDir; + bool _bootIsDefined; + CBootRecordDescriptor _bootDesc; + + HRESULT ReadBytes(void *data, UInt32 size, UInt32 &processedSize); + void Skeep(size_t size); + void SkeepZeros(size_t size); + Byte ReadByte(); + void ReadBytes(Byte *data, UInt32 size); + UInt16 ReadUInt16Spec(); + UInt16 ReadUInt16(); + UInt32 ReadUInt32Le(); + UInt32 ReadUInt32Be(); + UInt32 ReadUInt32(); + UInt64 ReadUInt64(); + UInt32 ReadDigits(int numDigits); + void ReadDateTime(CDateTime &d); + void ReadRecordingDateTime(CRecordingDateTime &t); + void ReadDirRecord2(CDirRecord &r, Byte len); + void ReadDirRecord(CDirRecord &r); + + void ReadBootRecordDescriptor(CBootRecordDescriptor &d); + void ReadVolumeDescriptor(CVolumeDescriptor &d); + + void SeekToBlock(UInt32 blockIndex); + void ReadDir(CDir &d, int level); + void CreateRefs(CDir &d); + + void ReadBootInfo(); + HRESULT Open2(); +public: + HRESULT Open(IInStream *inStream); + void Clear(); + + CObjectVector Refs; + CObjectVector VolDescs; + int MainVolDescIndex; + UInt32 BlockSize; + CObjectVector BootEntries; + + bool IsJoliet() const { return VolDescs[MainVolDescIndex].IsJoliet(); } +}; + +}} + +#endif diff --git a/7zip/Archive/Iso/IsoItem.h b/7zip/Archive/Iso/IsoItem.h new file mode 100755 index 00000000..dd3377c7 --- /dev/null +++ b/7zip/Archive/Iso/IsoItem.h @@ -0,0 +1,71 @@ +// Archive/IsoItem.h + +#ifndef __ARCHIVE_ISO_ITEM_H +#define __ARCHIVE_ISO_ITEM_H + +#include "Common/Types.h" +#include "Common/String.h" +#include "Common/Buffer.h" + +#include "IsoHeader.h" + +namespace NArchive { +namespace NIso { + +struct CRecordingDateTime +{ + Byte Year; + Byte Month; + Byte Day; + Byte Hour; + Byte Minute; + Byte Second; + signed char GmtOffset; // min intervals from -48 (West) to +52 (East) recorded. + + bool GetFileTime(FILETIME &ft) const + { + SYSTEMTIME st; + st.wYear = Year + 1900; + st.wMonth = Month; + st.wDayOfWeek = 0; // check it + st.wDay = Day; + st.wHour = Hour; + st.wMinute = Minute; + st.wSecond = Second; + st.wMilliseconds = 0; + if (!SystemTimeToFileTime(&st, &ft)) + return false; + UInt64 value = (((UInt64)ft.dwHighDateTime) << 32) + ft.dwLowDateTime; + value += (UInt64)((Int64)(int)GmtOffset * 15 * 60); + ft.dwLowDateTime = (DWORD)value; + ft.dwHighDateTime = DWORD(value >> 32); + return true; + } +}; + +struct CDirRecord +{ + Byte ExtendedAttributeRecordLen; + UInt32 ExtentLocation; + UInt32 DataLength; + CRecordingDateTime DateTime; + Byte FileFlags; + Byte FileUnitSize; + Byte InterleaveGapSize; + UInt16 VolSequenceNumber; + CByteBuffer FileId; + CByteBuffer SystemUse; + + bool IsDir() const { return (FileFlags & NFileFlags::kDirectory) != 0; } + bool IsSystemItem() const + { + if (FileId.GetCapacity() != 1) + return false; + Byte b = *(const Byte *)FileId; + return (b == 0 || b == 1); + } +}; + +}} + +#endif diff --git a/7zip/Archive/Iso/StdAfx.cpp b/7zip/Archive/Iso/StdAfx.cpp new file mode 100755 index 00000000..d0feea85 --- /dev/null +++ b/7zip/Archive/Iso/StdAfx.cpp @@ -0,0 +1,3 @@ +// StdAfx.cpp + +#include "StdAfx.h" diff --git a/7zip/Archive/Iso/StdAfx.h b/7zip/Archive/Iso/StdAfx.h new file mode 100755 index 00000000..2e4be10b --- /dev/null +++ b/7zip/Archive/Iso/StdAfx.h @@ -0,0 +1,9 @@ +// StdAfx.h + +#ifndef __STDAFX_H +#define __STDAFX_H + +#include "../../../Common/MyWindows.h" +#include "../../../Common/NewHandler.h" + +#endif diff --git a/7zip/Archive/Iso/makefile b/7zip/Archive/Iso/makefile new file mode 100755 index 00000000..100a3cd0 --- /dev/null +++ b/7zip/Archive/Iso/makefile @@ -0,0 +1,55 @@ +PROG = iso.dll +DEF_FILE = ../Archive.def +CFLAGS = $(CFLAGS) -I ../../../ +LIBS = $(LIBS) oleaut32.lib user32.lib + +TAR_OBJS = \ + $O\DllExports.obj \ + $O\IsoHandler.obj \ + $O\IsoHeader.obj \ + $O\IsoIn.obj \ + +COMMON_OBJS = \ + $O\Alloc.obj \ + $O\IntToString.obj \ + $O\NewHandler.obj \ + $O\String.obj \ + $O\StringConvert.obj \ + $O\Vector.obj \ + +WIN_OBJS = \ + $O\PropVariant.obj \ + +7ZIP_COMMON_OBJS = \ + $O\LimitedStreams.obj \ + $O\ProgressUtils.obj \ + $O\StreamUtils.obj \ + +AR_COMMON_OBJS = \ + $O\ItemNameUtils.obj \ + +OBJS = \ + $O\StdAfx.obj \ + $(TAR_OBJS) \ + $(COMMON_OBJS) \ + $(WIN_OBJS) \ + $(7ZIP_COMMON_OBJS) \ + $(AR_COMMON_OBJS) \ + $(COMPRESS_TAR_OBJS) \ + $O\CopyCoder.obj \ + $O\resource.res + +!include "../../../Build.mak" + +$(TAR_OBJS): $(*B).cpp + $(COMPL) +$(COMMON_OBJS): ../../../Common/$(*B).cpp + $(COMPL) +$(WIN_OBJS): ../../../Windows/$(*B).cpp + $(COMPL) +$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp + $(COMPL) +$(AR_COMMON_OBJS): ../Common/$(*B).cpp + $(COMPL) +$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp + $(COMPL) diff --git a/7zip/Archive/Iso/resource.rc b/7zip/Archive/Iso/resource.rc new file mode 100755 index 00000000..86929b0e --- /dev/null +++ b/7zip/Archive/Iso/resource.rc @@ -0,0 +1,5 @@ +#include "../../MyVersionInfo.rc" + +MY_VERSION_INFO_DLL("Iso Plugin", "iso") + +101 ICON "iso.ico" diff --git a/7zip/Archive/Tar/TarHandlerOut.cpp b/7zip/Archive/Tar/TarHandlerOut.cpp index a54bb58d..110833fb 100755 --- a/7zip/Archive/Tar/TarHandlerOut.cpp +++ b/7zip/Archive/Tar/TarHandlerOut.cpp @@ -100,7 +100,10 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt updateItem.Name += '/'; if(!FileTimeToUnixTime(utcTime, updateItem.Time)) - return E_INVALIDARG; + { + updateItem.Time = 0; + // return E_INVALIDARG; + } } if (IntToBool(newData)) { diff --git a/7zip/Archive/Zip/ZipHandlerOut.cpp b/7zip/Archive/Zip/ZipHandlerOut.cpp index 310233a9..71ad128a 100755 --- a/7zip/Archive/Zip/ZipHandlerOut.cpp +++ b/7zip/Archive/Zip/ZipHandlerOut.cpp @@ -116,7 +116,9 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt if(!FileTimeToLocalFileTime(&utcFileTime, &localFileTime)) return E_INVALIDARG; if(!FileTimeToDosTime(localFileTime, updateItem.Time)) - return E_INVALIDARG; + { + // return E_INVALIDARG; + } if (!isDirectoryStatusDefined) updateItem.IsDirectory = ((updateItem.Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0); diff --git a/7zip/Archive/makefile b/7zip/Archive/makefile index 24df1961..6f465c04 100755 --- a/7zip/Archive/makefile +++ b/7zip/Archive/makefile @@ -7,6 +7,7 @@ DIRS = \ Cpio\~ \ Deb\~ \ GZip\~ \ + Iso\~ \ Lzh\~ \ Rar\~ \ RPM\~ \ diff --git a/7zip/Common/OutBuffer.cpp b/7zip/Common/OutBuffer.cpp index f4ec1a30..a73fa7c5 100755 --- a/7zip/Common/OutBuffer.cpp +++ b/7zip/Common/OutBuffer.cpp @@ -57,8 +57,7 @@ HRESULT COutBuffer::FlushPart() UInt32 size = (_streamPos >= _pos) ? (_bufferSize - _streamPos) : (_pos - _streamPos); HRESULT result = S_OK; #ifdef _NO_EXCEPTIONS - if (ErrorCode != S_OK) - result = ErrorCode; + result = ErrorCode; #endif if (_buffer2 != 0) { @@ -68,7 +67,7 @@ HRESULT COutBuffer::FlushPart() if (_stream != 0 #ifdef _NO_EXCEPTIONS - && (ErrorCode != S_OK) + && (ErrorCode == S_OK) #endif ) { diff --git a/7zip/Compress/LZ/LZOutWindow.h b/7zip/Compress/LZ/LZOutWindow.h index 027f2070..3c50c6e7 100755 --- a/7zip/Compress/LZ/LZOutWindow.h +++ b/7zip/Compress/LZ/LZOutWindow.h @@ -6,17 +6,9 @@ #include "../../IStream.h" #include "../../Common/OutBuffer.h" -/* #ifndef _NO_EXCEPTIONS -class CLZOutWindowException -{ -public: - HRESULT ErrorCode; - CLZOutWindowException(HRESULT errorCode): ErrorCode(errorCode) {} -}; -#endif -*/ typedef COutBufferException CLZOutWindowException; +#endif class CLZOutWindow: public COutBuffer { diff --git a/7zip/FileManager/App.h b/7zip/FileManager/App.h index 45436ccb..ecb5345e 100755 --- a/7zip/FileManager/App.h +++ b/7zip/FileManager/App.h @@ -202,6 +202,7 @@ public: { OnCopy(true, false, GetFocusedPanelIndex()); } void Delete(bool toRecycleBin) { GetFocusedPanel().DeleteItems(toRecycleBin); } + void CalculateCrc(); void Split(); void Combine(); void Properties() diff --git a/7zip/FileManager/FM.dsp b/7zip/FileManager/FM.dsp index d3ae908b..9dc279a2 100755 --- a/7zip/FileManager/FM.dsp +++ b/7zip/FileManager/FM.dsp @@ -72,7 +72,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 "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /Gz /W3 /Gm /GX /ZI /Od /I "..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /Yu"StdAfx.h" /FD /GZ /c +# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /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" @@ -355,6 +355,10 @@ SOURCE=.\PanelCopy.cpp # End Source File # Begin Source File +SOURCE=.\PanelCrc.cpp +# End Source File +# Begin Source File + SOURCE=.\PanelDrag.cpp # End Source File # Begin Source File diff --git a/7zip/FileManager/MyLoadMenu.cpp b/7zip/FileManager/MyLoadMenu.cpp index 084aadfc..9670fc9c 100755 --- a/7zip/FileManager/MyLoadMenu.cpp +++ b/7zip/FileManager/MyLoadMenu.cpp @@ -77,6 +77,7 @@ static CIDLangPair kIDLangPairs[] = { IDM_DELETE, 0x03000233 }, { IDM_FILE_PROPERTIES, 0x03000240 }, { IDM_FILE_COMMENT, 0x03000241 }, + { IDM_FILE_CRC, 0x03000242 }, { IDM_FILE_SPLIT, 0x03000270 }, { IDM_FILE_COMBINE, 0x03000271 }, { IDM_CREATE_FOLDER, 0x03000250 }, @@ -500,6 +501,9 @@ bool ExecuteFileCommand(int id) g_App.Delete(!shift); break; } + case IDM_FILE_CRC: + g_App.CalculateCrc(); + break; case IDM_FILE_SPLIT: g_App.Split(); break; diff --git a/7zip/FileManager/Panel.cpp b/7zip/FileManager/Panel.cpp index 73a7f4ad..b54b7cd7 100755 --- a/7zip/FileManager/Panel.cpp +++ b/7zip/FileManager/Panel.cpp @@ -632,6 +632,8 @@ bool CPanel::OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result) return CWindow2::OnCommand(code, itemID, lParam, result); } +void CPanel::MessageBoxInfo(LPCWSTR message, LPCWSTR caption) + { ::MessageBoxW(HWND(*this), message, caption, MB_OK); } void CPanel::MessageBox(LPCWSTR message, LPCWSTR caption) { ::MessageBoxW(HWND(*this), message, caption, MB_OK | MB_ICONSTOP); } void CPanel::MessageBox(LPCWSTR message) diff --git a/7zip/FileManager/Panel.h b/7zip/FileManager/Panel.h index dc0f1d62..50002b24 100755 --- a/7zip/FileManager/Panel.h +++ b/7zip/FileManager/Panel.h @@ -434,6 +434,7 @@ public: void RefreshListCtrl(); + void MessageBoxInfo(LPCWSTR message, LPCWSTR caption); void MessageBox(LPCWSTR message); void MessageBox(LPCWSTR message, LPCWSTR caption); void MessageBoxMyError(LPCWSTR message); diff --git a/7zip/FileManager/PanelCrc.cpp b/7zip/FileManager/PanelCrc.cpp new file mode 100755 index 00000000..998a0468 --- /dev/null +++ b/7zip/FileManager/PanelCrc.cpp @@ -0,0 +1,354 @@ +// PanelSplitFile.cpp + +#include "StdAfx.h" + +#include "resource.h" + +#include "Common/Alloc.h" +#include "Common/CRC.h" +#include "Common/IntToString.h" +#include "Common/StringConvert.h" + +#include "Windows/FileIO.h" +#include "Windows/FileFind.h" +#include "Windows/FileName.h" +#include "Windows/Thread.h" +#include "Windows/Error.h" + +#include "Resource/ProgressDialog2/ProgressDialog.h" +#include "Resource/OverwriteDialog/resource.h" + +#include "App.h" +#include "FormatUtils.h" +#include "LangUtils.h" + +using namespace NWindows; +using namespace NFile; +using namespace NName; + +static const UInt32 kBufSize = (1 << 15); + +struct CDirEnumerator +{ + UString BasePrefix; + UStringVector FileNames; + + CObjectVector Enumerators; + UStringVector Prefixes; + int Index; + bool GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath, DWORD &errorCode); + void Init(); +}; + +void CDirEnumerator::Init() +{ + Enumerators.Clear(); + Prefixes.Clear(); + Index = 0; +} + +bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath, DWORD &errorCode) +{ + filled = false; + while(true) + { + if (Enumerators.IsEmpty()) + { + if (Index >= FileNames.Size()) + return true; + const UString &path = FileNames[Index]; + if (!NFind::FindFile(BasePrefix + path, fileInfo)) + { + errorCode = ::GetLastError(); + resPath = path; + return false; + } + Index++; + resPath.Empty(); + break; + } + bool found; + if (!Enumerators.Back().Next(fileInfo, found)) + { + errorCode = ::GetLastError(); + resPath = Prefixes.Back(); + return false; + } + if (found) + { + resPath = Prefixes.Back(); + break; + } + Enumerators.DeleteBack(); + Prefixes.DeleteBack(); + } + resPath += fileInfo.Name; + if (fileInfo.IsDirectory()) + { + UString prefix = resPath + (UString)(wchar_t)kDirDelimiter; + Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)kAnyStringWildcard)); + Prefixes.Add(prefix); + } + filled = true; + return true; +} + +struct CThreadCrc +{ + 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); } + }; + + CProgressDialog *ProgressDialog; + + CDirEnumerator DirEnumerator; + + UInt64 NumFiles; + UInt64 NumFolders; + UInt64 DataSize; + UInt32 DataCrcSum; + UInt32 DataNameCrcSum; + + HRESULT Result; + DWORD ErrorCode; + UString ErrorPath; + UString Error; + bool ThereIsError; + + void Process2() + { + DataSize = NumFolders = NumFiles = DataCrcSum = DataNameCrcSum = 0; + ProgressDialog->WaitCreating(); + + CMyBuffer bufferObject; + if (!bufferObject.Allocate(kBufSize)) + { + Error = L"Can not allocate memory"; + ThereIsError = true; + return; + } + Byte *buffer = (Byte *)(void *)bufferObject; + + UInt64 totalSize = 0; + + DirEnumerator.Init(); + + UString scanningStr = LangString(IDS_SCANNING, 0x03020800); + scanningStr += L" "; + + while (true) + { + 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.IsDirectory()) + totalSize += fileInfo.Size; + ProgressDialog->ProgressSynch.SetCurrentFileName(scanningStr + resPath); + ProgressDialog->ProgressSynch.SetProgress(totalSize, 0); + Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(0); + if (Result != S_OK) + return; + } + + ProgressDialog->ProgressSynch.SetProgress(totalSize, 0); + + DirEnumerator.Init(); + + while(true) + { + NFile::NFind::CFileInfoW fileInfo; + bool filled; + UString resPath; + if (!DirEnumerator.GetNextFile(fileInfo, filled, resPath, ErrorCode)) + { + ThereIsError = true; + ErrorPath = resPath; + return; + } + if (!filled) + break; + + CCRC crc; + if (fileInfo.IsDirectory()) + NumFolders++; + else + { + NFile::NIO::CInFile inFile; + if (!inFile.Open(DirEnumerator.BasePrefix + resPath)) + { + ErrorCode = ::GetLastError(); + ThereIsError = true; + ErrorPath = resPath; + return; + } + NumFiles++; + ProgressDialog->ProgressSynch.SetCurrentFileName(resPath); + while(true) + { + UInt32 processedSize; + if (!inFile.Read(buffer, kBufSize, processedSize)) + { + ErrorCode = ::GetLastError(); + ThereIsError = true; + ErrorPath = resPath; + return; + } + if (processedSize == 0) + break; + crc.Update(buffer, processedSize); + DataSize += processedSize; + Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize); + if (Result != S_OK) + return; + } + DataCrcSum += crc.GetDigest(); + } + for (int i = 0; i < resPath.Length(); i++) + { + wchar_t c = resPath[i]; + crc.UpdateByte(c & 0xFF); + crc.UpdateByte((c >> 8) & 0xFF); + } + DataNameCrcSum += crc.GetDigest(); + Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize); + if (Result != S_OK) + return; + } + } + DWORD Process() + { + try { Process2(); } + catch(...) { Error = L"Error"; ThereIsError = true;} + ProgressDialog->MyClose(); + return 0; + } + + static DWORD WINAPI MyThreadFunction(void *param) + { + return ((CThreadCrc *)param)->Process(); + } +}; + +static void ConvertUInt32ToHex(UInt32 value, wchar_t *s) +{ + for (int i = 0; i < 8; i++) + { + int t = value & 0xF; + value >>= 4; + s[7 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10))); + } + s[8] = L'\0'; +} + +void CApp::CalculateCrc() +{ + int srcPanelIndex = GetFocusedPanelIndex(); + CPanel &srcPanel = Panels[srcPanelIndex]; + if (!srcPanel.IsFSFolder()) + { + srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208)); + return; + } + CRecordVector indices; + srcPanel.GetOperatedItemIndices(indices); + if (indices.IsEmpty()) + return; + + CThreadCrc combiner; + for (int i = 0; i < indices.Size(); i++) + combiner.DirEnumerator.FileNames.Add(srcPanel.GetItemName(indices[i])); + combiner.DirEnumerator.BasePrefix = srcPanel._currentFolderPrefix; + + CProgressDialog progressDialog; + combiner.ProgressDialog = &progressDialog; + combiner.ErrorCode = 0; + combiner.Result = S_OK; + combiner.ThereIsError = 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" "); + + CThread thread; + if (!thread.Create(CThreadCrc::MyThreadFunction, &combiner)) + throw 271824; + 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; + } + srcPanel.MessageBoxInfo(s, LangString(IDS_CHECKSUM_INFORMATION, 0x03020720)); + } +} diff --git a/7zip/FileManager/Resource/SystemPage/resource.rc b/7zip/FileManager/Resource/SystemPage/resource.rc index 4d3b3b12..cf19d11b 100755 --- a/7zip/FileManager/Resource/SystemPage/resource.rc +++ b/7zip/FileManager/Resource/SystemPage/resource.rc @@ -2,11 +2,11 @@ #include "../../../GuiCommon.rc" #define xSize2 238 -#define ySize2 204 +#define ySize2 214 #define xSize (xSize2 + marg + marg) #define ySize (ySize2 + marg + marg) #define gSpace 30 -#define g0Size 105 +#define g0Size 110 #define gYSize (ySize2 - 20 - bYSize) diff --git a/7zip/FileManager/makefile b/7zip/FileManager/makefile index 00f657b6..697b1507 100755 --- a/7zip/FileManager/makefile +++ b/7zip/FileManager/makefile @@ -22,6 +22,7 @@ FM_OBJS = \ $O\OptionsDialog.obj \ $O\Panel.obj \ $O\PanelCopy.obj \ + $O\PanelCrc.obj \ $O\PanelDrag.obj \ $O\PanelFolderChange.obj \ $O\PanelItemOpen.obj \ diff --git a/7zip/FileManager/resource.h b/7zip/FileManager/resource.h index d7063043..0b3d1d50 100755 --- a/7zip/FileManager/resource.h +++ b/7zip/FileManager/resource.h @@ -16,6 +16,7 @@ #define IDM_FILE_COMBINE 239 #define IDM_FILE_PROPERTIES 240 #define IDM_FILE_COMMENT 241 +#define IDM_FILE_CRC 242 #define IDM_CREATE_FOLDER 250 #define IDM_CREATE_FILE 251 #define IDM_EDIT_CUT 320 @@ -105,6 +106,10 @@ #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 #define IDS_CANNOT_UPDATE_FILE 2281 @@ -135,3 +140,10 @@ #define IDS_COMBINE 4030 #define IDS_COMBINE_TO 4031 #define IDS_COMBINING 4032 + +#define IDS_CHECKSUM_CALCULATING 4040 +#define IDS_CHECKSUM_INFORMATION 4041 +#define IDS_CHECKSUM_CRC_DATA 4042 +#define IDS_CHECKSUM_CRC_DATA_NAMES 4043 + +#define IDS_SCANNING 4050 diff --git a/7zip/FileManager/resource.rc b/7zip/FileManager/resource.rc index 8e92d804..d5a7ee64 100755 --- a/7zip/FileManager/resource.rc +++ b/7zip/FileManager/resource.rc @@ -33,6 +33,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "P&roperties\tAlt+Enter", IDM_FILE_PROPERTIES MENUITEM "Comme&nt\tCtrl+Z", IDM_FILE_COMMENT + MENUITEM "Calculate checksum", IDM_FILE_CRC MENUITEM SEPARATOR MENUITEM "Create Folder\tF7", IDM_CREATE_FOLDER MENUITEM "Create File\tCtrl+N", IDM_CREATE_FILE @@ -138,6 +139,13 @@ BEGIN IDS_COMBINE "Combine Files" IDS_COMBINE_TO "&Combine to:" IDS_COMBINING "Combining..." + IDS_CHECKSUM_CALCULATING "Checksum calculating..." + IDS_CHECKSUM_INFORMATION "Checksum information" + IDS_CHECKSUM_CRC_DATA "CRC checksum for data:" + IDS_CHECKSUM_CRC_DATA_NAMES "CRC checksum for data and names:" + + IDS_SCANNING "Scanning..." + IDS_OPERATION_IS_NOT_SUPPORTED "Operation is not supported." IDS_CONFIRM_FILE_DELETE "Confirm File Delete" @@ -166,6 +174,10 @@ 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_PROPERTY_TOTAL_SIZE "Total Size" IDS_PROPERTY_FREE_SPACE "Free Space" IDS_PROPERTY_CLUSTER_SIZE "Cluster Size" diff --git a/7zip/Guid.txt b/7zip/Guid.txt index d6423714..7544f42f 100755 --- a/7zip/Guid.txt +++ b/7zip/Guid.txt @@ -115,6 +115,7 @@ Handler GUIDs: 07 7z 08 Cab +E7 Iso E8 Bkf E9 Chm EA Split diff --git a/7zip/MyVersion.h b/7zip/MyVersion.h index 3388eac7..b8ae159a 100755 --- a/7zip/MyVersion.h +++ b/7zip/MyVersion.h @@ -1,7 +1,7 @@ #define MY_VER_MAJOR 4 -#define MY_VER_MINOR 35 -#define MY_VERSION "4.35 beta" -#define MY_7ZIP_VERSION "7-Zip 4.35 beta" -#define MY_DATE "2006-03-03" +#define MY_VER_MINOR 36 +#define MY_VERSION "4.36 beta" +#define MY_7ZIP_VERSION "7-Zip 4.36 beta" +#define MY_DATE "2006-03-12" #define MY_COPYRIGHT "Copyright (c) 1999-2006 Igor Pavlov" #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE diff --git a/7zip/UI/Common/UpdatePair.cpp b/7zip/UI/Common/UpdatePair.cpp index ce8f2dd7..dd51646f 100755 --- a/7zip/UI/Common/UpdatePair.cpp +++ b/7zip/UI/Common/UpdatePair.cpp @@ -24,18 +24,28 @@ static int MyCompareTime(NFileTimeType::EEnum fileTimeType, { UInt32 unixTime1, unixTime2; if (!FileTimeToUnixTime(time1, unixTime1)) - throw 4191614; + { + unixTime1 = 0; + // throw 4191614; + } if (!FileTimeToUnixTime(time2, unixTime2)) - throw 4191615; + { + unixTime2 = 0; + // throw 4191615; + } return MyCompare(unixTime1, unixTime2); } case NFileTimeType::kDOS: { UInt32 dosTime1, dosTime2; + FileTimeToDosTime(time1, dosTime1); + FileTimeToDosTime(time2, dosTime2); + /* if (!FileTimeToDosTime(time1, dosTime1)) throw 4191616; if (!FileTimeToDosTime(time2, dosTime2)) throw 4191617; + */ return MyCompare(dosTime1, dosTime2); } } diff --git a/7zip/UI/Console/Console.dsp b/7zip/UI/Console/Console.dsp index 4ce596ec..e457008c 100755 --- a/7zip/UI/Console/Console.dsp +++ b/7zip/UI/Console/Console.dsp @@ -306,6 +306,10 @@ SOURCE=..\..\..\Windows\Registry.cpp SOURCE=..\..\..\Windows\Registry.h # End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Time.h +# End Source File # End Group # Begin Group "Common" diff --git a/DOC/7zip.nsi b/DOC/7zip.nsi index 32364a11..d8ff3295 100755 --- a/DOC/7zip.nsi +++ b/DOC/7zip.nsi @@ -2,7 +2,7 @@ ;Defines !define VERSION_MAJOR 4 -!define VERSION_MINOR 35 +!define VERSION_MINOR 36 !define VERSION_POSTFIX_FULL " beta" !ifdef WIN64 !ifdef IA64 @@ -155,6 +155,7 @@ Section File cpio.dll File deb.dll File gz.dll + File iso.dll File lzh.dll File rar.dll File rpm.dll @@ -359,6 +360,7 @@ Section "Uninstall" Delete $INSTDIR\Formats\cpio.dll Delete $INSTDIR\Formats\deb.dll Delete $INSTDIR\Formats\gz.dll + Delete $INSTDIR\Formats\iso.dll Delete $INSTDIR\Formats\lzh.dll Delete $INSTDIR\Formats\rar.dll Delete $INSTDIR\Formats\rpm.dll @@ -498,6 +500,7 @@ Section "Uninstall" DeleteRegKey HKCR "7-Zip.cpio" DeleteRegKey HKCR "7-Zip.deb" DeleteRegKey HKCR "7-Zip.gz" + DeleteRegKey HKCR "7-Zip.iso" DeleteRegKey HKCR "7-Zip.rar" DeleteRegKey HKCR "7-Zip.rpm" DeleteRegKey HKCR "7-Zip.split" diff --git a/DOC/readme.txt b/DOC/readme.txt index ef867a71..ca1592c9 100755 --- a/DOC/readme.txt +++ b/DOC/readme.txt @@ -1,4 +1,4 @@ -7-Zip 4.35 Sources +7-Zip 4.36 Sources ------------------ 7-Zip is a file archiver for Windows 95/98/ME/NT/2000/2003/XP. diff --git a/Windows/Time.h b/Windows/Time.h index 3dcf1051..fbba2ddb 100755 --- a/Windows/Time.h +++ b/Windows/Time.h @@ -15,11 +15,20 @@ inline bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime) UInt16(dosTime & 0xFFFF), &fileTime)); } +const UInt32 kHighDosTime = 0xFF9FBF7D; +const UInt32 kLowDosTime = 0x210000; + inline bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime) { WORD datePart, timePart; if (!::FileTimeToDosDateTime(&fileTime, &datePart, &timePart)) + { + if (fileTime.dwHighDateTime >= 0x01C00000) // 2000 + dosTime = kHighDosTime; + else + dosTime = kLowDosTime; return false; + } dosTime = (((UInt32)datePart) << 16) + timePart; return true; } @@ -38,10 +47,16 @@ inline bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime) { UInt64 winTime = (((UInt64)fileTime.dwHighDateTime) << 32) + fileTime.dwLowDateTime; if (winTime < kUnixTimeStartValue) + { + unixTime = 0; return false; + } winTime = (winTime - kUnixTimeStartValue) / kNumTimeQuantumsInSecond; if (winTime > 0xFFFFFFFF) + { + unixTime = 0xFFFFFFFF; return false; + } unixTime = (UInt32)winTime; return true; } -- cgit v1.2.3