Description
Currently, SharpCompress lacks support for adding empty directories to archives. When using IWriter or IWritableArchiveinterfaces 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 IWriteror IWritableArchive, allowing a Stream.Null or a specific method for empty directories, similar to:
archive.AddDirectoryEntry(relativePath);
or ensuring that calling AddEntrywith Stream.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.
Description Currently, SharpCompress lacks support for adding empty directories to archives. When using
IWriter
orIWritableArchive
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:
Proposed Solution Consider adding a way to support empty directory entries in
IWriter
orIWritableArchive
, allowing aStream.Null
or a specific method for empty directories, similar to:archive.AddDirectoryEntry(relativePath);
or ensuring that calling
AddEntry
withStream.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.