ZipReader ignored DirectoryEntry completely #732

Closed
opened 2026-01-29 22:16:33 +00:00 by claunia · 5 comments
Owner

Originally created by @zhuxb711 on GitHub (Nov 28, 2025).

Originally assigned to: @Copilot on GitHub.

ZipReader -> ignored DirectoryEntry completely | Could not extract the zip using ZipReader
095c871174/src/SharpCompress/Readers/Zip/ZipReader.cs (L63-L85)

ZipArchive -> processed DirectoryEntry | Could extract the zip using ZipArchive
095c871174/src/SharpCompress/Archives/Zip/ZipArchive.cs (L261-L296)

Originally created by @zhuxb711 on GitHub (Nov 28, 2025). Originally assigned to: @Copilot on GitHub. ZipReader -> ignored DirectoryEntry completely | Could not extract the zip using ZipReader https://github.com/adamhathcock/sharpcompress/blob/095c871174585c436541d8dcb3b189e89040c093/src/SharpCompress/Readers/Zip/ZipReader.cs#L63-L85 ZipArchive -> processed DirectoryEntry | Could extract the zip using ZipArchive https://github.com/adamhathcock/sharpcompress/blob/095c871174585c436541d8dcb3b189e89040c093/src/SharpCompress/Archives/Zip/ZipArchive.cs#L261-L296
claunia added the questionnot bug labels 2026-01-29 22:16:33 +00:00
Author
Owner

@zhuxb711 commented on GitHub (Nov 29, 2025):

@adamhathcock Would you please take a look about this issue?

@zhuxb711 commented on GitHub (Nov 29, 2025): @adamhathcock Would you please take a look about this issue?
Author
Owner

@adamhathcock commented on GitHub (Nov 29, 2025):

I think I'm intentionally skipping them or used to. Will get copilot to check

@adamhathcock commented on GitHub (Nov 29, 2025): I think I'm intentionally skipping them or used to. Will get copilot to check
Author
Owner

@zhuxb711 commented on GitHub (Nov 29, 2025):

I think I'm intentionally skipping them or used to. Will get copilot to check

Why will ignore the directory entry intentionally? It doesn't make sense. This behavior makes it hard to extract a zip with nested directory inside. All I got is an empty output~ Sad...

@zhuxb711 commented on GitHub (Nov 29, 2025): > I think I'm intentionally skipping them or used to. Will get copilot to check Why will ignore the directory entry intentionally? It doesn't make sense. This behavior makes it hard to extract a zip with nested directory inside. All I got is an empty output~ Sad...
Author
Owner

@adamhathcock commented on GitHub (Nov 29, 2025):

I think I'm intentionally skipping them or used to. Will get copilot to check

Why will ignore the directory entry intentionally? It doesn't make sense. This behavior makes it hard to extract a zip with nested directory inside. All I got is an empty output~ Sad...

I first wrote this for myself and skipped directory entries as I thought they didn't make sense with paths. I've since walked back on that. Formats are inconsistent though

@adamhathcock commented on GitHub (Nov 29, 2025): > > I think I'm intentionally skipping them or used to. Will get copilot to check > > Why will ignore the directory entry intentionally? It doesn't make sense. This behavior makes it hard to extract a zip with nested directory inside. All I got is an empty output~ Sad... I first wrote this for myself and skipped directory entries as I thought they didn't make sense with paths. I've since walked back on that. Formats are inconsistent though
Author
Owner

@adamhathcock commented on GitHub (Nov 29, 2025):

Ah, right. Here's the real reason as found by AI:
// DirectoryEntry headers in the central directory are intentionally skipped.
// In streaming mode, we can only read forward, and DirectoryEntry headers
// reference LocalEntry headers that have already been processed. The file
// data comes from LocalEntry headers, not DirectoryEntry headers.
// For multi-volume ZIPs where file data spans multiple files, use ZipArchive
// instead, which requires seekable streams.

@adamhathcock commented on GitHub (Nov 29, 2025): Ah, right. Here's the real reason as found by AI: // DirectoryEntry headers in the central directory are intentionally skipped. // In streaming mode, we can only read forward, and DirectoryEntry headers // reference LocalEntry headers that have already been processed. The file // data comes from LocalEntry headers, not DirectoryEntry headers. // For multi-volume ZIPs where file data spans multiple files, use ZipArchive // instead, which requires seekable streams.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#732