Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Add Empty Directories to Archives #881

Open
adanddev opened this issue Nov 20, 2024 · 0 comments
Open

Cannot Add Empty Directories to Archives #881

adanddev opened this issue Nov 20, 2024 · 0 comments

Comments

@adanddev
Copy link

adanddev commented Nov 20, 2024

Description
Currently, SharpCompress lacks support for adding empty directories to archives. When using IWriter or IWritableArchive interfaces 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:

  • Deployment packages where empty folders are placeholders for future files.
  • Compression of directories with empty folders that need to be preserved, ensuring consistency in archive content.
  • Development and build systems that rely on specific folder structures, including empty directories, to function correctly.

Proposed Solution
Consider adding a way to support empty directory entries in IWriter or IWritableArchive, allowing a Stream.Null or a specific method for empty directories, similar to:

archive.AddDirectoryEntry(relativePath);

or ensuring that calling AddEntry with Stream.Null and 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants