mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-04 05:25:00 +00:00
Cannot Add Empty Directories to Archives #669
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @adanddev on GitHub (Nov 20, 2024).
Originally assigned to: @Copilot on GitHub.
Description
Currently, SharpCompress lacks support for adding empty directories to archives. When using
IWriterorIWritableArchiveinterfaces to add entries, there is no straightforward way to include empty directories, as the library appears to ignore directory entries that lack files. This limits use cases where the exact directory structure, including empty folders, is essential, such as preserving the file structure during compression or in deployment packages.Motivation
Including empty directories is important in scenarios where the directory structure needs to be faithfully recreated after decompression. This is especially useful for:
Proposed Solution
Consider adding a way to support empty directory entries in
IWriterorIWritableArchive, allowing aStream.Nullor a specific method for empty directories, similar to:archive.AddDirectoryEntry(relativePath);or ensuring that calling
AddEntrywithStream.Nulland size: 0 explicitly adds an empty directory entry.Alternative Workaround
Currently, the only workaround is to create a temporary file in each empty directory or use a marker file to ensure that the directory is not skipped, which is not ideal and requires post-extraction cleanup.
Thank you for considering this feature enhancement.