Skip to content

Commit

Permalink
Identify archives only by extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ikremniou committed Dec 3, 2023
1 parent 05bd295 commit 06c0416
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/7z-assembly.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ArchiveHandler handlers[] = {
SzHandlerGuid,
L"sz",
L"",
0,
NArcInfoFlags::kByExtOnlyOpen,
{0x53, 0x5A},
false,
[]() -> void* {
Expand All @@ -38,7 +38,7 @@ const ArchiveHandler handlers[] = {
SzeHandlerGuid,
L"sze",
L"",
NArcInfoFlags::kAltStreams,
NArcInfoFlags::kByExtOnlyOpen,
{0x53, 0x45},
true,
[]() -> void* {
Expand Down
2 changes: 2 additions & 0 deletions src/archive/sz-archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ HRESULT SzInArchive::Open(IInStream* stream,
IArchiveOpenCallback* openCallback) noexcept {
char buffer[8];
UInt32 processed = 0;
UInt64 seek_stub = 0;
stream->Seek(0, STREAM_SEEK_CUR, &seek_stub);
stream->Read(buffer, sizeof(buffer), &processed);
if (buffer[0] != 'S' && buffer[0] != 'Z') {
return S_FALSE;
Expand Down
24 changes: 12 additions & 12 deletions src/archive/sze-archive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,25 +170,25 @@ void SzeInArchive::UpdateItemsInMemItems(
UInt32 indexInArchive;
HRESULT res = updateCallback->GetUpdateItemInfo(i, &newData, &newProps,
&indexInArchive);
if (newData == 0 && newProps == 0) {
if (indexInArchive != -1) {
new_items.push_back(items_[indexInArchive]);
continue;
} else {
new_items.push_back(File{});
}
indexInArchive = static_cast<UInt32>(new_items.size() - 1);

CMyComPtr<ISequentialInStream> in_stream;
res = updateCallback->GetStream(i, &in_stream);
if (FAILED(res)) {
if (newData == 0 && newProps == 0) {
continue;
}

File file{};
if (indexInArchive == -1) {
new_items.push_back(file);
indexInArchive = static_cast<UInt32>(new_items.size() - 1);
}

ArchiveReader reader(in_stream);
if (newData) {
CMyComPtr<ISequentialInStream> in_stream;
res = updateCallback->GetStream(i, &in_stream);
if (FAILED(res)) {
continue;
}

ArchiveReader reader(in_stream);
new_items[indexInArchive].content.clear();
for (byte b : reader) {
new_items[indexInArchive].content.push_back(b);
Expand Down

0 comments on commit 06c0416

Please sign in to comment.