Skip to content

Commit

Permalink
Fix crash issue when using Open Inside # mode for the .NET Single Fil…
Browse files Browse the repository at this point in the history
…e Application bundle readonly support for NanaZip.Codecs.
  • Loading branch information
MouriNaruto committed Feb 4, 2025
1 parent 4c69477 commit 9bc18ff
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions NanaZip.Codecs/NanaZip.Codecs.Archive.DotNetSingleFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ namespace NanaZip::Codecs::Archive
private:

IInStream* m_FileStream = nullptr;
std::uint64_t m_FullSize = 0;
std::vector<BundleFileEntry> m_FilePaths;
bool m_IsInitialized = false;

Expand Down Expand Up @@ -455,6 +456,7 @@ namespace NanaZip::Codecs::Archive
Current += RelativePathLength;
Files.emplace(Entry.RelativePath, Entry);
}
this->m_FullSize = BundleHeaderOffset + Current;
}
catch (...)
{
Expand All @@ -464,7 +466,7 @@ namespace NanaZip::Codecs::Archive
HeaderBuffer.clear();

std::uint64_t TotalFiles = Files.size();
std::uint64_t TotalBytes = BundleSize;
std::uint64_t TotalBytes = this->m_FullSize;

if (OpenCallback)
{
Expand Down Expand Up @@ -496,6 +498,7 @@ namespace NanaZip::Codecs::Archive
{
this->m_IsInitialized = false;
this->m_FilePaths.clear();
this->m_FullSize = 0;
if (this->m_FileStream)
{
this->m_FileStream->Release();
Expand Down Expand Up @@ -672,8 +675,6 @@ namespace NanaZip::Codecs::Archive
_In_ PROPID PropId,
_Inout_ LPPROPVARIANT Value)
{
UNREFERENCED_PARAMETER(PropId);

if (!this->m_IsInitialized)
{
return S_FALSE;
Expand All @@ -684,6 +685,18 @@ namespace NanaZip::Codecs::Archive
return E_INVALIDARG;
}

switch (PropId)
{
case SevenZipArchivePhysicalSize:
{
Value->uhVal.QuadPart = this->m_FullSize;
Value->vt = VT_UI8;
break;
}
default:
break;
}

return S_OK;
}

Expand Down

0 comments on commit 9bc18ff

Please sign in to comment.