WriteEntryToDirectory not working on Linux #414

Open
opened 2026-01-29 22:11:34 +00:00 by claunia · 3 comments
Owner

Originally created by @JoshClose on GitHub (Sep 2, 2020).

The .zip file was created on Windows. I'm not sure if that matters or not.

In ExtractionMethods.WriteEntryToDirectory the second line makes a call to Path.GetFileName(entry.Key). The key looks like "a\\b.txt". Since this is running on Linux the file name I get back is "a\\b.txt" instead of "b.txt". This is causing all the files to have names like a\b.txt instead of creating the folder structure and putting the file in it.

Originally created by @JoshClose on GitHub (Sep 2, 2020). The .zip file was created on Windows. I'm not sure if that matters or not. In `ExtractionMethods.WriteEntryToDirectory` the second line makes a call to `Path.GetFileName(entry.Key)`. The key looks like `"a\\b.txt"`. Since this is running on Linux the file name I get back is `"a\\b.txt"` instead of `"b.txt"`. This is causing all the files to have names like `a\b.txt` instead of creating the folder structure and putting the file in it.
claunia added the questionnot bugwontfix labels 2026-01-29 22:11:34 +00:00
Author
Owner

@JoshClose commented on GitHub (Sep 2, 2020):

Looks like zips created with 7zip and with Windows Send to Compressed (zipped) folder both create entries with keys using / and not \. I'll figure out how this file was created.

@JoshClose commented on GitHub (Sep 2, 2020): Looks like zips created with 7zip and with Windows Send to Compressed (zipped) folder both create entries with keys using `/` and not `\`. I'll figure out how this file was created.
Author
Owner

@JoshClose commented on GitHub (Sep 3, 2020):

It was created using PowerShell's Compress-Archive module. A bug was submitted that was fixed and released in PowerShell 6.2.1 and 7.0.

Would it be beneficial to try and handle invalid zip files like this?

@JoshClose commented on GitHub (Sep 3, 2020): It was created using PowerShell's `Compress-Archive` module. A bug was submitted that was fixed and released in PowerShell 6.2.1 and 7.0. Would it be beneficial to try and handle invalid zip files like this?
Author
Owner

@adamhathcock commented on GitHub (Sep 3, 2020):

I don't believe it is. Slashes mean directories in zip keys. If there's an extra one, that's not the fault of the decoder. The encoder shouldn't have it.

@adamhathcock commented on GitHub (Sep 3, 2020): I don't believe it is. Slashes mean directories in zip keys. If there's an extra one, that's not the fault of the decoder. The encoder shouldn't have it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#414