diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2015-01-03 03:00:00 +0300 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:53 +0300 |
commit | 0713a3ab803e57401f18432148b4139e5fe6e5dd (patch) | |
tree | b66fd26676cf817f2bc2a889b6123c00da96d6d0 /CPP/7zip/Archive | |
parent | 7e021179cd9f46b5bf2d48aac84783ff431dd5ac (diff) |
9.389.38
Diffstat (limited to 'CPP/7zip/Archive')
36 files changed, 194 insertions, 99 deletions
diff --git a/CPP/7zip/Archive/7z/7zHandler.cpp b/CPP/7zip/Archive/7z/7zHandler.cpp index af673a73..2b86ed22 100644 --- a/CPP/7zip/Archive/7z/7zHandler.cpp +++ b/CPP/7zip/Archive/7z/7zHandler.cpp @@ -321,13 +321,13 @@ STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data if (/* _db.IsTree && propID == kpidName || !_db.IsTree && */ propID == kpidPath) { - const wchar_t *name = _db.GetName(index); - if (name) + if (_db.NameOffsets && _db.NamesBuf) { - size_t size = (_db.NameOffsets[index + 1] - _db.NameOffsets[index]) * 2; + size_t offset = _db.NameOffsets[index]; + size_t size = (_db.NameOffsets[index + 1] - offset) * 2; if (size < ((UInt32)1 << 31)) { - *data = (void *)name; + *data = (const void *)(_db.NamesBuf + offset * 2); *dataSize = (UInt32)size; *propType = NPropDataType::kUtf16z; } @@ -607,7 +607,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val } */ - case kpidPath: return _db.GetPath(index, value); + case kpidPath: return _db.GetPath_Prop(index, value); #ifndef _SFX case kpidMethod: return SetMethodToProp(_db.FileIndexToFolderIndexMap[index2], value); case kpidBlock: diff --git a/CPP/7zip/Archive/7z/7zHandler.h b/CPP/7zip/Archive/7z/7zHandler.h index dad943e0..c33617c4 100644 --- a/CPP/7zip/Archive/7z/7zHandler.h +++ b/CPP/7zip/Archive/7z/7zHandler.h @@ -102,7 +102,7 @@ class CHandler: { public: MY_QUERYINTERFACE_BEGIN2(IInArchive) - // MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps) + MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps) #ifdef __7Z_SET_PROPERTIES MY_QUERYINTERFACE_ENTRY(ISetProperties) #endif diff --git a/CPP/7zip/Archive/7z/7zHandlerOut.cpp b/CPP/7zip/Archive/7z/7zHandlerOut.cpp index 2f6a4c37..5e113207 100644 --- a/CPP/7zip/Archive/7z/7zHandlerOut.cpp +++ b/CPP/7zip/Archive/7z/7zHandlerOut.cpp @@ -301,10 +301,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt const CFileItem &fi = db->Files[ui.IndexInArchive]; if (!ui.NewProps) { - NCOM::CPropVariant prop; - RINOK(_db.GetPath(ui.IndexInArchive, &prop)); - if (prop.vt == VT_BSTR) - name = prop.bstrVal; + _db.GetPath(ui.IndexInArchive, name); } ui.IsDir = fi.IsDir; ui.Size = fi.Size; diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp index d84cf0b0..4f04aa83 100644 --- a/CPP/7zip/Archive/7z/7zIn.cpp +++ b/CPP/7zip/Archive/7z/7zIn.cpp @@ -2,6 +2,12 @@ #include "StdAfx.h" +#ifdef _WIN32 +#include <wchar.h> +#else +#include <ctype.h> +#endif + #include "../../../../C/7zCrc.h" #include "../../../../C/CpuArch.h" @@ -496,26 +502,83 @@ void CFolders::ParseFolderInfo(unsigned folderIndex, CFolder &folder) const } -HRESULT CDatabase::GetPath(unsigned index, PROPVARIANT *path) const +void CDatabase::GetPath(unsigned index, UString &path) const +{ + path.Empty(); + if (!NameOffsets || !NamesBuf) + return; + + size_t offset = NameOffsets[index]; + size_t size = NameOffsets[index + 1] - offset - 1; + + if (size >= (1 << 20)) + return; + + wchar_t *s = path.GetBuffer((unsigned)size); + + const Byte *p = ((const Byte *)NamesBuf + offset * 2); + + #if defined(_WIN32) && defined(MY_CPU_LE) + + wmemcpy(s, (const wchar_t *)p, size); + + #else + + for (size_t i = 0; i < size; i++) + { + *s = Get16(p); + p += 2; + s++; + } + + #endif + + path.ReleaseBuffer((unsigned)size); +} + +HRESULT CDatabase::GetPath_Prop(unsigned index, PROPVARIANT *path) const throw() { PropVariant_Clear(path); if (!NameOffsets || !NamesBuf) return S_OK; + size_t offset = NameOffsets[index]; + size_t size = NameOffsets[index + 1] - offset; + + if (size >= (1 << 14)) + return S_OK; + + RINOK(PropVarEm_Alloc_Bstr(path, (unsigned)size - 1)); + wchar_t *s = path->bstrVal; + + const Byte *p = ((const Byte *)NamesBuf + offset * 2); + + for (size_t i = 0; i < size; i++) + { + wchar_t c = Get16(p); + p += 2; + #if WCHAR_PATH_SEPARATOR != L'/' + if (c == L'/') + c = WCHAR_PATH_SEPARATOR; + #endif + *s++ = c; + } + + return S_OK; + + /* unsigned cur = index; unsigned size = 0; - // for (int i = 0;; i++) + for (int i = 0;; i++) { size_t len = NameOffsets[cur + 1] - NameOffsets[cur]; size += (unsigned)len; - if (/* i > 256 || */ len > (1 << 12) || size > (1 << 14)) + if (i > 256 || len > (1 << 14) || size > (1 << 14)) return PropVarEm_Set_Str(path, "[TOO-LONG]"); - /* cur = Files[cur].Parent; if (cur < 0) break; - */ } size--; @@ -539,16 +602,13 @@ HRESULT CDatabase::GetPath(unsigned index, PROPVARIANT *path) const *s = c; } while (--len); - /* const CFileItem &file = Files[cur]; cur = file.Parent; if (cur < 0) - */ return S_OK; - /* *(--s) = (file.IsAltStream ? ':' : WCHAR_PATH_SEPARATOR); - */ } + */ } void CInArchive::WaitId(UInt64 id) diff --git a/CPP/7zip/Archive/7z/7zIn.h b/CPP/7zip/Archive/7z/7zIn.h index 1836a06b..373000f7 100644 --- a/CPP/7zip/Archive/7z/7zIn.h +++ b/CPP/7zip/Archive/7z/7zIn.h @@ -111,7 +111,7 @@ struct CDatabase: public CFolders */ CByteBuffer NamesBuf; - CObjArray<size_t> NameOffsets; // numFiles + 1, conatins offsets of UINt16 symbols. + CObjArray<size_t> NameOffsets; // numFiles + 1, offsets of utf-16 symbols /* void ClearSecure() @@ -148,14 +148,15 @@ struct CDatabase: public CFolders bool IsItemAnti(unsigned index) const { return (index < IsAnti.Size() && IsAnti[index]); } // bool IsItemAux(unsigned index) const { return (index < IsAux.Size() && IsAux[index]); } - const wchar_t * GetName(unsigned index) const + const void * GetName(unsigned index) const { if (!NameOffsets || !NamesBuf) return NULL; - return (const wchar_t *)(const Byte *)NamesBuf + NameOffsets[index]; + return (const void *)((const Byte *)NamesBuf + NameOffsets[index] * 2); }; - HRESULT GetPath(unsigned index, PROPVARIANT *path) const; + void GetPath(unsigned index, UString &path) const; + HRESULT GetPath_Prop(unsigned index, PROPVARIANT *path) const throw(); }; struct CInArchiveInfo diff --git a/CPP/7zip/Archive/7z/7zUpdate.cpp b/CPP/7zip/Archive/7z/7zUpdate.cpp index 96befa23..7875ed5b 100644 --- a/CPP/7zip/Archive/7z/7zUpdate.cpp +++ b/CPP/7zip/Archive/7z/7zUpdate.cpp @@ -1018,7 +1018,7 @@ HRESULT Update( else { GetFile(*db, ui.IndexInArchive, file, file2); - name = db->GetName(ui.IndexInArchive); + db->GetPath(ui.IndexInArchive, name); } /* @@ -1152,7 +1152,8 @@ HRESULT Update( CFileItem file; CFileItem2 file2; GetFile(*db, fi, file, file2); - UString name = db->GetName(fi); + UString name; + db->GetPath(fi, name); if (file.HasStream) { indexInFolder++; @@ -1278,7 +1279,7 @@ HRESULT Update( else { GetFile(*db, ui.IndexInArchive, file, file2); - name = db->GetName(ui.IndexInArchive); + db->GetPath(ui.IndexInArchive, name); } if (file2.IsAnti || file.IsDir) return E_FAIL; diff --git a/CPP/7zip/Archive/ApmHandler.cpp b/CPP/7zip/Archive/ApmHandler.cpp index 04cd06fa..96656733 100644 --- a/CPP/7zip/Archive/ApmHandler.cpp +++ b/CPP/7zip/Archive/ApmHandler.cpp @@ -114,6 +114,7 @@ API_FUNC_static_IsArc IsArc_Apm(const Byte *p, size_t size) return k_IsArc_Res_NO; return k_IsArc_Res_YES; } +} HRESULT CHandler::ReadTables(IInStream *stream) { diff --git a/CPP/7zip/Archive/ArchiveExports.cpp b/CPP/7zip/Archive/ArchiveExports.cpp index c7d6611b..0a520413 100644 --- a/CPP/7zip/Archive/ArchiveExports.cpp +++ b/CPP/7zip/Archive/ArchiveExports.cpp @@ -15,7 +15,7 @@ static unsigned g_NumArcs = 0; static unsigned g_DefaultArcIndex = 0; static const CArcInfo *g_Arcs[kNumArcsMax]; -void RegisterArc(const CArcInfo *arcInfo) +void RegisterArc(const CArcInfo *arcInfo) throw() { if (g_NumArcs < kNumArcsMax) { diff --git a/CPP/7zip/Archive/ArjHandler.cpp b/CPP/7zip/Archive/ArjHandler.cpp index ad44c62a..737b8fc9 100644 --- a/CPP/7zip/Archive/ArjHandler.cpp +++ b/CPP/7zip/Archive/ArjHandler.cpp @@ -160,6 +160,7 @@ API_FUNC_static_IsArc IsArc_Arj(const Byte *p, size_t size) return k_IsArc_Res_YES; } +} static HRESULT ReadString(const Byte *p, unsigned &size, AString &res) { diff --git a/CPP/7zip/Archive/Bz2Handler.cpp b/CPP/7zip/Archive/Bz2Handler.cpp index 704cdc73..a49e8293 100644 --- a/CPP/7zip/Archive/Bz2Handler.cpp +++ b/CPP/7zip/Archive/Bz2Handler.cpp @@ -131,6 +131,7 @@ API_FUNC_static_IsArc IsArc_BZip2(const Byte *p, size_t size) return k_IsArc_Res_YES; return k_IsArc_Res_NO; } +} STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *) { diff --git a/CPP/7zip/Archive/Common/MultiStream.h b/CPP/7zip/Archive/Common/MultiStream.h index 2a1a4a43..c10cd455 100644 --- a/CPP/7zip/Archive/Common/MultiStream.h +++ b/CPP/7zip/Archive/Common/MultiStream.h @@ -15,14 +15,19 @@ class CMultiStream: UInt64 _pos; UInt64 _totalLength; unsigned _streamIndex; + public: + struct CSubStreamInfo { CMyComPtr<IInStream> Stream; UInt64 Size; UInt64 GlobalOffset; UInt64 LocalPos; + + CSubStreamInfo(): Size(0), GlobalOffset(0), LocalPos(0) {} }; + CObjectVector<CSubStreamInfo> Streams; HRESULT Init() diff --git a/CPP/7zip/Archive/CpioHandler.cpp b/CPP/7zip/Archive/CpioHandler.cpp index 9c1271c4..431d315d 100644 --- a/CPP/7zip/Archive/CpioHandler.cpp +++ b/CPP/7zip/Archive/CpioHandler.cpp @@ -120,10 +120,10 @@ struct CItem UInt64 HeaderPos; bool IsBin() const { return Type == k_Type_BinLe || Type == k_Type_BinBe; } - bool IsCrcFormat() const { return Type == k_Type_HexCrc; }; + bool IsCrcFormat() const { return Type == k_Type_HexCrc; } bool IsDir() const { return (Mode & 0170000) == 0040000; } bool IsTrailer() const { return strcmp(Name, kName_TRAILER) == 0; } - UInt64 GetDataPosition() const { return HeaderPos + HeaderSize; }; + UInt64 GetDataPosition() const { return HeaderPos + HeaderSize; } }; enum EErrorType @@ -273,6 +273,7 @@ API_FUNC_static_IsArc IsArc_Cpio(const Byte *p, size_t size) return k_IsArc_Res_NO; return k_IsArc_Res_YES; } +} #define READ_STREAM(_dest_, _size_) \ { size_t processed = (_size_); RINOK(Read(_dest_, &processed)); \ diff --git a/CPP/7zip/Archive/DllExports.cpp b/CPP/7zip/Archive/DllExports.cpp index fa40d024..37f53cd7 100644 --- a/CPP/7zip/Archive/DllExports.cpp +++ b/CPP/7zip/Archive/DllExports.cpp @@ -2,6 +2,10 @@ #include "StdAfx.h" +#if defined(_7ZIP_LARGE_PAGES) +#include "../../../C/Alloc.h" +#endif + #include "../../Common/MyInitGuid.h" #include "../../Common/ComTry.h" @@ -40,7 +44,7 @@ STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject) STDAPI SetLargePageMode() { - #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES) + #if defined(_7ZIP_LARGE_PAGES) SetLargePageSize(); #endif return S_OK; diff --git a/CPP/7zip/Archive/DllExports2.cpp b/CPP/7zip/Archive/DllExports2.cpp index beb758a2..aa023524 100644 --- a/CPP/7zip/Archive/DllExports2.cpp +++ b/CPP/7zip/Archive/DllExports2.cpp @@ -4,7 +4,7 @@ #include "../../Common/MyInitGuid.h" -#if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES) +#if defined(_7ZIP_LARGE_PAGES) #include "../../../C/Alloc.h" #endif @@ -67,7 +67,7 @@ STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject) STDAPI SetLargePageMode() { - #if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES) + #if defined(_7ZIP_LARGE_PAGES) SetLargePageSize(); #endif return S_OK; diff --git a/CPP/7zip/Archive/ElfHandler.cpp b/CPP/7zip/Archive/ElfHandler.cpp index 1736219f..5e378ba8 100644 --- a/CPP/7zip/Archive/ElfHandler.cpp +++ b/CPP/7zip/Archive/ElfHandler.cpp @@ -641,8 +641,8 @@ static const STATPROPSTG kProps[] = { NULL, kpidVa, VT_UI8 }, { NULL, kpidType, VT_BSTR }, { NULL, kpidCharacts, VT_BSTR } - , { L"Link Section", kpidLinkSection, VT_BSTR} - , { L"Info Section", kpidInfoSection, VT_BSTR} + , { (LPOLESTR)L"Link Section", kpidLinkSection, VT_BSTR} + , { (LPOLESTR)L"Info Section", kpidInfoSection, VT_BSTR} }; IMP_IInArchive_Props_WITH_NAME diff --git a/CPP/7zip/Archive/FatHandler.cpp b/CPP/7zip/Archive/FatHandler.cpp index 51064a1a..970330cc 100644 --- a/CPP/7zip/Archive/FatHandler.cpp +++ b/CPP/7zip/Archive/FatHandler.cpp @@ -118,6 +118,7 @@ API_FUNC_static_IsArc IsArc_Fat(const Byte *p, size_t size) CHeader h; return h.Parse(p) ? k_IsArc_Res_YES : k_IsArc_Res_NO; } +} bool CHeader::Parse(const Byte *p) { @@ -801,12 +802,12 @@ static const STATPROPSTG kArcProps[] = { NULL, kpidMTime, VT_FILETIME}, { NULL, kpidVolumeName, VT_BSTR}, - { L"FATs", kpidNumFats, VT_UI4}, + { (LPOLESTR)L"FATs", kpidNumFats, VT_UI4}, { NULL, kpidSectorSize, VT_UI4}, { NULL, kpidId, VT_UI4}, - // { L"OEM Name", kpidOemName, VT_BSTR}, - // { L"Volume Name", kpidVolName, VT_BSTR}, - // { L"File System Type", kpidFileSysType, VT_BSTR} + // { (LPOLESTR)L"OEM Name", kpidOemName, VT_BSTR}, + // { (LPOLESTR)L"Volume Name", kpidVolName, VT_BSTR}, + // { (LPOLESTR)L"File System Type", kpidFileSysType, VT_BSTR} // { NULL, kpidSectorsPerTrack, VT_UI4}, // { NULL, kpidNumHeads, VT_UI4}, // { NULL, kpidHiddenSectors, VT_UI4} diff --git a/CPP/7zip/Archive/GzHandler.cpp b/CPP/7zip/Archive/GzHandler.cpp index 69b3c3be..766cefbf 100644 --- a/CPP/7zip/Archive/GzHandler.cpp +++ b/CPP/7zip/Archive/GzHandler.cpp @@ -318,6 +318,7 @@ API_FUNC_static_IsArc IsArc_Gz(const Byte *p, size_t size) return Is_Deflate(p, size); } +} HRESULT CItem::ReadHeader(NDecoder::CCOMCoder *stream) { diff --git a/CPP/7zip/Archive/IArchive.h b/CPP/7zip/Archive/IArchive.h index 63e16ac3..a57a9b8f 100644 --- a/CPP/7zip/Archive/IArchive.h +++ b/CPP/7zip/Archive/IArchive.h @@ -183,17 +183,26 @@ Notes: Some IInArchive handlers will work incorrectly in that case. */ +/* MSVC allows the code where there is throw() in declaration of function, + but there is no throw() in definition of function. */ + +#ifdef _MSC_VER + #define MY_NO_THROW_DECL_ONLY throw() +#else + #define MY_NO_THROW_DECL_ONLY +#endif + #define INTERFACE_IInArchive(x) \ - STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openCallback) throw() x; \ - STDMETHOD(Close)() throw() x; \ - STDMETHOD(GetNumberOfItems)(UInt32 *numItems) throw() x; \ - STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) throw() x; \ - STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback) throw() x; \ - STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) throw() x; \ - STDMETHOD(GetNumberOfProperties)(UInt32 *numProps) throw() x; \ - STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) throw() x; \ - STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProps) throw() x; \ - STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) throw() x; + STDMETHOD(Open)(IInStream *stream, const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openCallback) MY_NO_THROW_DECL_ONLY x; \ + STDMETHOD(Close)() MY_NO_THROW_DECL_ONLY x; \ + STDMETHOD(GetNumberOfItems)(UInt32 *numItems) MY_NO_THROW_DECL_ONLY x; \ + STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) MY_NO_THROW_DECL_ONLY x; \ + STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, Int32 testMode, IArchiveExtractCallback *extractCallback) MY_NO_THROW_DECL_ONLY x; \ + STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value) MY_NO_THROW_DECL_ONLY x; \ + STDMETHOD(GetNumberOfProperties)(UInt32 *numProps) MY_NO_THROW_DECL_ONLY x; \ + STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) MY_NO_THROW_DECL_ONLY x; \ + STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProps) MY_NO_THROW_DECL_ONLY x; \ + STDMETHOD(GetArchivePropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) MY_NO_THROW_DECL_ONLY x; ARCHIVE_INTERFACE(IInArchive, 0x60) { @@ -444,7 +453,7 @@ ARCHIVE_INTERFACE(IArchiveAllowTail, 0x05) // #define k_IsArc_Res_YES_LOW_PROB 3 #define API_FUNC_IsArc EXTERN_C UInt32 WINAPI -#define API_FUNC_static_IsArc EXTERN_C static UInt32 WINAPI +#define API_FUNC_static_IsArc extern "C" { static UInt32 WINAPI extern "C" { diff --git a/CPP/7zip/Archive/IhexHandler.cpp b/CPP/7zip/Archive/IhexHandler.cpp index bc468401..00816f0c 100644 --- a/CPP/7zip/Archive/IhexHandler.cpp +++ b/CPP/7zip/Archive/IhexHandler.cpp @@ -219,6 +219,7 @@ API_FUNC_static_IsArc IsArc_Ihex(const Byte *p, size_t size) return k_IsArc_Res_YES; } +} STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *) { diff --git a/CPP/7zip/Archive/Iso/IsoHandler.cpp b/CPP/7zip/Archive/Iso/IsoHandler.cpp index eaa94bd8..aef920b0 100644 --- a/CPP/7zip/Archive/Iso/IsoHandler.cpp +++ b/CPP/7zip/Archive/Iso/IsoHandler.cpp @@ -88,7 +88,7 @@ static void AddString(AString &s, const char *name, const Byte *p, unsigned size } } -#define ADD_STRING(n, v) AddString(s, n, vol. ## v, sizeof(vol. ## v)) +#define ADD_STRING(n, v) AddString(s, n, vol. v, sizeof(vol. v)) static void AddErrorMessage(AString &s, const char *message) { diff --git a/CPP/7zip/Archive/LzhHandler.cpp b/CPP/7zip/Archive/LzhHandler.cpp index 74f713f6..ef4b4196 100644 --- a/CPP/7zip/Archive/LzhHandler.cpp +++ b/CPP/7zip/Archive/LzhHandler.cpp @@ -73,6 +73,7 @@ API_FUNC_static_IsArc IsArc_Lzh(const Byte *p, size_t size) return k_IsArc_Res_NO; return k_IsArc_Res_YES; } +} struct CItem { diff --git a/CPP/7zip/Archive/LzmaHandler.cpp b/CPP/7zip/Archive/LzmaHandler.cpp index d1e19677..04aa4685 100644 --- a/CPP/7zip/Archive/LzmaHandler.cpp +++ b/CPP/7zip/Archive/LzmaHandler.cpp @@ -332,6 +332,7 @@ API_FUNC_static_IsArc IsArc_Lzma(const Byte *p, size_t size) return k_IsArc_Res_NO; return k_IsArc_Res_YES; } +} API_FUNC_static_IsArc IsArc_Lzma86(const Byte *p, size_t size) { @@ -342,6 +343,7 @@ API_FUNC_static_IsArc IsArc_Lzma86(const Byte *p, size_t size) return k_IsArc_Res_NO; return IsArc_Lzma(p + 1, size - 1); } +} STDMETHODIMP CHandler::Open(IInStream *inStream, const UInt64 *, IArchiveOpenCallback *) { diff --git a/CPP/7zip/Archive/MbrHandler.cpp b/CPP/7zip/Archive/MbrHandler.cpp index 309bc286..abc981f3 100644 --- a/CPP/7zip/Archive/MbrHandler.cpp +++ b/CPP/7zip/Archive/MbrHandler.cpp @@ -342,9 +342,9 @@ static const STATPROPSTG kProps[] = { NULL, kpidSize, VT_UI8}, { NULL, kpidFileSystem, VT_BSTR}, { NULL, kpidOffset, VT_UI8}, - { L"Primary", kpidPrimary, VT_BOOL}, - { L"Begin CHS", kpidBegChs, VT_BSTR}, - { L"End CHS", kpidEndChs, VT_BSTR} + { (LPOLESTR)L"Primary", kpidPrimary, VT_BOOL}, + { (LPOLESTR)L"Begin CHS", kpidBegChs, VT_BSTR}, + { (LPOLESTR)L"End CHS", kpidEndChs, VT_BSTR} }; IMP_IInArchive_Props_WITH_NAME diff --git a/CPP/7zip/Archive/Nsis/NsisDecode.h b/CPP/7zip/Archive/Nsis/NsisDecode.h index 2ccaaf65..0b95d4b2 100644 --- a/CPP/7zip/Archive/Nsis/NsisDecode.h +++ b/CPP/7zip/Archive/Nsis/NsisDecode.h @@ -63,7 +63,7 @@ public: } - HRESULT CDecoder::SetToPos(UInt64 pos, ICompressProgressInfo *progress); // for solid + HRESULT SetToPos(UInt64 pos, ICompressProgressInfo *progress); // for solid HRESULT Decode(CByteBuffer *outBuf, bool unpackSizeDefined, UInt32 unpackSize, ISequentialOutStream *realOutStream, ICompressProgressInfo *progress, UInt32 &packSizeRes, UInt32 &unpackSizeRes); diff --git a/CPP/7zip/Archive/Nsis/NsisHandler.cpp b/CPP/7zip/Archive/Nsis/NsisHandler.cpp index 868ca6cb..233edd52 100644 --- a/CPP/7zip/Archive/Nsis/NsisHandler.cpp +++ b/CPP/7zip/Archive/Nsis/NsisHandler.cpp @@ -582,13 +582,13 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems, if (!dataError) { - UInt32 unpackSize = 0; - bool unpackSize_Defined = false; + // UInt32 unpackSize = 0; + // bool unpackSize_Defined = false; bool writeToTemp1 = writeToTemp; if (item.IsUninstaller) { - unpackSize = item.PatchSize; - unpackSize_Defined = true; + // unpackSize = item.PatchSize; + // unpackSize_Defined = true; if (!readFromTemp) writeToTemp = true; writeToTemp1 = writeToTemp; diff --git a/CPP/7zip/Archive/Nsis/NsisIn.cpp b/CPP/7zip/Archive/Nsis/NsisIn.cpp index 71791c03..dc570ec2 100644 --- a/CPP/7zip/Archive/Nsis/NsisIn.cpp +++ b/CPP/7zip/Archive/Nsis/NsisIn.cpp @@ -3777,7 +3777,7 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh) for (UInt32 j = i - 1; j >= kkk + 3; j--) { - const Byte *pCmd = p - kCmdSize * (kkk - j); + const Byte *pCmd = p + kCmdSize * (j - kkk); AddParam(GET_CMD_PARAM(pCmd, 0)); } NewLine(); diff --git a/CPP/7zip/Archive/NtfsHandler.cpp b/CPP/7zip/Archive/NtfsHandler.cpp index dfe5eade..6661492f 100644 --- a/CPP/7zip/Archive/NtfsHandler.cpp +++ b/CPP/7zip/Archive/NtfsHandler.cpp @@ -97,11 +97,11 @@ bool CHeader::Parse(const Byte *p) if (p[0x1FE] != 0x55 || p[0x1FF] != 0xAA) return false; - int codeOffset = 0; + // int codeOffset = 0; switch (p[0]) { - case 0xE9: codeOffset = 3 + (Int16)Get16(p + 1); break; - case 0xEB: if (p[2] != 0x90) return false; codeOffset = 2 + (int)(signed char)p[1]; break; + case 0xE9: /* codeOffset = 3 + (Int16)Get16(p + 1); */ break; + case 0xEB: if (p[2] != 0x90) return false; /* codeOffset = 2 + (int)(signed char)p[1]; */ break; default: return false; } unsigned sectorsPerClusterLog; @@ -2175,20 +2175,20 @@ static const STATPROPSTG kProps[] = // { NULL, kpidLink, VT_BSTR}, - // { L"Link 2", kpidLink2, VT_BSTR}, - // { L"Link Type", kpidLinkType, VT_UI2}, + // { (LPOLESTR)L"Link 2", kpidLink2, VT_BSTR}, + // { (LPOLESTR)L"Link Type", kpidLinkType, VT_UI2}, { NULL, kpidINode, VT_UI8}, { NULL, kpidMTime, VT_FILETIME}, { NULL, kpidCTime, VT_FILETIME}, { NULL, kpidATime, VT_FILETIME}, - // { L"Record Modified", kpidRecMTime, VT_FILETIME}, + // { (LPOLESTR)L"Record Modified", kpidRecMTime, VT_FILETIME}, - // { L"Modified 2", kpidMTime2, VT_FILETIME}, - // { L"Created 2", kpidCTime2, VT_FILETIME}, - // { L"Accessed 2", kpidATime2, VT_FILETIME}, - // { L"Record Modified 2", kpidRecMTime2, VT_FILETIME}, + // { (LPOLESTR)L"Modified 2", kpidMTime2, VT_FILETIME}, + // { (LPOLESTR)L"Created 2", kpidCTime2, VT_FILETIME}, + // { (LPOLESTR)L"Accessed 2", kpidATime2, VT_FILETIME}, + // { (LPOLESTR)L"Record Modified 2", kpidRecMTime2, VT_FILETIME}, { NULL, kpidAttrib, VT_UI4}, { NULL, kpidNumBlocks, VT_UI4}, @@ -2223,7 +2223,7 @@ static const STATPROPSTG kArcProps[] = { NULL, kpidFileSystem, VT_BSTR}, { NULL, kpidClusterSize, VT_UI4}, { NULL, kpidSectorSize, VT_UI4}, - { L"Record Size", kpidRecordSize, VT_UI4}, + { (LPOLESTR)L"Record Size", kpidRecordSize, VT_UI4}, { NULL, kpidHeadersSize, VT_UI8}, { NULL, kpidCTime, VT_FILETIME}, { NULL, kpidId, VT_UI8}, diff --git a/CPP/7zip/Archive/PeHandler.cpp b/CPP/7zip/Archive/PeHandler.cpp index 08bcd062..ae7553df 100644 --- a/CPP/7zip/Archive/PeHandler.cpp +++ b/CPP/7zip/Archive/PeHandler.cpp @@ -784,27 +784,27 @@ static const STATPROPSTG kArcProps[] = { NULL, kpidChecksum, VT_UI4}, { NULL, kpidName, VT_BSTR}, - { L"Image Size", kpidImageSize, VT_UI4}, - { L"Section Alignment", kpidSectAlign, VT_UI4}, - { L"File Alignment", kpidFileAlign, VT_UI4}, - { L"Code Size", kpidCodeSize, VT_UI4}, - { L"Initialized Data Size", kpidInitDataSize, VT_UI4}, - { L"Uninitialized Data Size", kpidUnInitDataSize, VT_UI4}, - { L"Linker Version", kpidLinkerVer, VT_BSTR}, - { L"OS Version", kpidOsVer, VT_BSTR}, - { L"Image Version", kpidImageVer, VT_BSTR}, - { L"Subsystem Version", kpidSubsysVer, VT_BSTR}, - { L"Subsystem", kpidSubSystem, VT_BSTR}, - { L"DLL Characteristics", kpidDllCharacts, VT_BSTR}, - { L"Stack Reserve", kpidStackReserve, VT_UI8}, - { L"Stack Commit", kpidStackCommit, VT_UI8}, - { L"Heap Reserve", kpidHeapReserve, VT_UI8}, - { L"Heap Commit", kpidHeapCommit, VT_UI8}, - { L"Image Base", kpidImageBase, VT_UI8}, + { (LPOLESTR)L"Image Size", kpidImageSize, VT_UI4}, + { (LPOLESTR)L"Section Alignment", kpidSectAlign, VT_UI4}, + { (LPOLESTR)L"File Alignment", kpidFileAlign, VT_UI4}, + { (LPOLESTR)L"Code Size", kpidCodeSize, VT_UI4}, + { (LPOLESTR)L"Initialized Data Size", kpidInitDataSize, VT_UI4}, + { (LPOLESTR)L"Uninitialized Data Size", kpidUnInitDataSize, VT_UI4}, + { (LPOLESTR)L"Linker Version", kpidLinkerVer, VT_BSTR}, + { (LPOLESTR)L"OS Version", kpidOsVer, VT_BSTR}, + { (LPOLESTR)L"Image Version", kpidImageVer, VT_BSTR}, + { (LPOLESTR)L"Subsystem Version", kpidSubsysVer, VT_BSTR}, + { (LPOLESTR)L"Subsystem", kpidSubSystem, VT_BSTR}, + { (LPOLESTR)L"DLL Characteristics", kpidDllCharacts, VT_BSTR}, + { (LPOLESTR)L"Stack Reserve", kpidStackReserve, VT_UI8}, + { (LPOLESTR)L"Stack Commit", kpidStackCommit, VT_UI8}, + { (LPOLESTR)L"Heap Reserve", kpidHeapReserve, VT_UI8}, + { (LPOLESTR)L"Heap Commit", kpidHeapCommit, VT_UI8}, + { (LPOLESTR)L"Image Base", kpidImageBase, VT_UI8}, { NULL, kpidComment, VT_BSTR}, - // { L"Address Of Entry Point", kpidAddressOfEntryPoint, VT_UI8}, - // { L"Base Of Code", kpidBaseOfCode, VT_UI8}, - // { L"Base Of Data", kpidBaseOfData32, VT_UI8}, + // { (LPOLESTR)L"Address Of Entry Point", kpidAddressOfEntryPoint, VT_UI8}, + // { (LPOLESTR)L"Base Of Code", kpidBaseOfCode, VT_UI8}, + // { (LPOLESTR)L"Base Of Data", kpidBaseOfData32, VT_UI8}, }; static const Byte kProps[] = @@ -2089,6 +2089,7 @@ API_FUNC_static_IsArc IsArc_Pe(const Byte *p, size_t size) return k_IsArc_Res_NO; return k_IsArc_Res_YES; } +} HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback) { @@ -2719,6 +2720,7 @@ API_FUNC_static_IsArc IsArc_Te(const Byte *p, size_t size) return k_IsArc_Res_NO; return k_IsArc_Res_YES; } +} struct CSection @@ -2799,8 +2801,8 @@ static const STATPROPSTG kArcProps[] = { // { NULL, kpidHeadersSize, VT_UI4 }, { NULL, kpidCpu, VT_BSTR}, - { L"Subsystem", kpidSubSystem, VT_BSTR }, - // { L"Image Base", kpidImageBase, VT_UI8 } + { (LPOLESTR)L"Subsystem", kpidSubSystem, VT_BSTR }, + // { (LPOLESTR)L"Image Base", kpidImageBase, VT_UI8 } }; IMP_IInArchive_Props diff --git a/CPP/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp index d54995ef..c26d72f9 100644 --- a/CPP/7zip/Archive/Rar/RarHandler.cpp +++ b/CPP/7zip/Archive/Rar/RarHandler.cpp @@ -359,7 +359,7 @@ static int ReadTime(const Byte *p, unsigned size, Byte mask, CRarTime &rarTime) #define READ_TIME_2(_mask_, _def_, _ttt_) \ _def_ = ((_mask_ & 8) != 0); if (_def_) \ { if (size < 4) return false; \ - _ttt_ ## .DosTime = Get32(p); p += 4; size -= 4; \ + _ttt_ .DosTime = Get32(p); p += 4; size -= 4; \ READ_TIME(_mask_, _ttt_); } \ bool CInArchive::ReadHeaderReal(const Byte *p, unsigned size, CItem &item) diff --git a/CPP/7zip/Archive/SquashfsHandler.cpp b/CPP/7zip/Archive/SquashfsHandler.cpp index 617a1d66..1f70bb8e 100644 --- a/CPP/7zip/Archive/SquashfsHandler.cpp +++ b/CPP/7zip/Archive/SquashfsHandler.cpp @@ -801,6 +801,8 @@ struct CItem int Node; int Parent; UInt32 Ptr; + + CItem(): Node(-1), Parent(-1), Ptr(0) {} }; struct CData @@ -1198,7 +1200,7 @@ HRESULT CHandler::Decompress(ISequentialOutStream *outStream, Byte *outBuf, bool { ECoderStatus status; XzUnpacker_Init(&_xz); - SRes res = XzUnpacker_Code(&_xz, dest, &destLen, _inputBuffer, &srcLen, LZMA_FINISH_END, &status); + SRes res = XzUnpacker_Code(&_xz, dest, &destLen, _inputBuffer, &srcLen, CODER_FINISH_END, &status); if (res != 0) return SResToHRESULT(res); if (status != CODER_STATUS_NEEDS_MORE_INPUT || !XzUnpacker_IsStreamWasFinished(&_xz)) diff --git a/CPP/7zip/Archive/SwfHandler.cpp b/CPP/7zip/Archive/SwfHandler.cpp index 7cfea330..85c61fe2 100644 --- a/CPP/7zip/Archive/SwfHandler.cpp +++ b/CPP/7zip/Archive/SwfHandler.cpp @@ -61,6 +61,7 @@ API_FUNC_static_IsArc IsArc_Swf(const Byte *p, size_t size) return k_IsArc_Res_NO; return k_IsArc_Res_YES; } +} API_FUNC_static_IsArc IsArc_Swfc(const Byte *p, size_t size) { @@ -100,6 +101,7 @@ API_FUNC_static_IsArc IsArc_Swfc(const Byte *p, size_t size) return k_IsArc_Res_YES; } +} struct CItem { diff --git a/CPP/7zip/Archive/Tar/TarHandler.cpp b/CPP/7zip/Archive/Tar/TarHandler.cpp index fc7de5ae..5b587529 100644 --- a/CPP/7zip/Archive/Tar/TarHandler.cpp +++ b/CPP/7zip/Archive/Tar/TarHandler.cpp @@ -226,6 +226,7 @@ STDMETHODIMP CHandler::OpenSeq(ISequentialInStream *stream) { Close(); _seqStream = stream; + _isArc = true; return S_OK; } diff --git a/CPP/7zip/Archive/UefiHandler.cpp b/CPP/7zip/Archive/UefiHandler.cpp index 2aaf7d8f..a6760b36 100644 --- a/CPP/7zip/Archive/UefiHandler.cpp +++ b/CPP/7zip/Archive/UefiHandler.cpp @@ -556,7 +556,7 @@ struct CCapsuleHeader UInt32 OffsetToLongDescription; UInt32 OffsetToApplicableDevices; - void Clear() { memset(this, 0, sizeof(this)); } + void Clear() { memset(this, 0, sizeof(*this)); } void Parse(const Byte *p) { diff --git a/CPP/7zip/Archive/VhdHandler.cpp b/CPP/7zip/Archive/VhdHandler.cpp index 5268bd0b..a2126811 100644 --- a/CPP/7zip/Archive/VhdHandler.cpp +++ b/CPP/7zip/Archive/VhdHandler.cpp @@ -612,10 +612,10 @@ static const STATPROPSTG kArcProps[] = { NULL, kpidCTime, VT_FILETIME}, { NULL, kpidClusterSize, VT_UI8}, { NULL, kpidMethod, VT_BSTR}, - { L"Parent", kpidParent, VT_BSTR}, + { (LPOLESTR)L"Parent", kpidParent, VT_BSTR}, { NULL, kpidCreatorApp, VT_BSTR}, { NULL, kpidHostOS, VT_BSTR}, - { L"Saved State", kpidSavedState, VT_BOOL}, + { (LPOLESTR)L"Saved State", kpidSavedState, VT_BOOL}, { NULL, kpidId, VT_BSTR} }; diff --git a/CPP/7zip/Archive/Wim/WimHandler.cpp b/CPP/7zip/Archive/Wim/WimHandler.cpp index 6f0b10e2..886d8d77 100644 --- a/CPP/7zip/Archive/Wim/WimHandler.cpp +++ b/CPP/7zip/Archive/Wim/WimHandler.cpp @@ -63,8 +63,8 @@ static const STATPROPSTG kArcProps[] = { NULL, kpidIsVolume, VT_BOOL}, { NULL, kpidVolume, VT_UI4}, { NULL, kpidNumVolumes, VT_UI4}, - { L"Images", kpidNumImages, VT_UI4}, - { L"Boot Image", kpidBootImage, VT_UI4} + { (LPOLESTR)L"Images", kpidNumImages, VT_UI4}, + { (LPOLESTR)L"Boot Image", kpidBootImage, VT_UI4} }; static const char *kMethodLZX = "LZX"; diff --git a/CPP/7zip/Archive/ZHandler.cpp b/CPP/7zip/Archive/ZHandler.cpp index 459f3e35..7635f22d 100644 --- a/CPP/7zip/Archive/ZHandler.cpp +++ b/CPP/7zip/Archive/ZHandler.cpp @@ -100,6 +100,7 @@ API_FUNC_static_IsArc IsArc_Z(const Byte *p, size_t size) return k_IsArc_Res_NO; return k_IsArc_Res_YES; } +} STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 * /* maxCheckStartPosition */, |