https://github.com/sailro/llziplib
Low-level Zip Library, allowing advanced tweaks (injecting/removing blocks, crafting special archives)
https://github.com/sailro/llziplib
crafting injecting low-level zip
Last synced: about 2 months ago
JSON representation
Low-level Zip Library, allowing advanced tweaks (injecting/removing blocks, crafting special archives)
- Host: GitHub
- URL: https://github.com/sailro/llziplib
- Owner: sailro
- License: mit
- Created: 2016-02-28T03:00:19.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-11-14T07:39:47.000Z (6 months ago)
- Last Synced: 2025-03-27T12:17:22.252Z (about 2 months ago)
- Topics: crafting, injecting, low-level, zip
- Language: C#
- Homepage:
- Size: 4.25 MB
- Stars: 35
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# LLZipLib
[](https://github.com/sailro/LLZipLib/actions?query=workflow%3ACI)
[](https://www.nuget.org/packages/LLZipLib/)Low-level Zip Library, allowing advanced tweaks (injecting/removing extra blocks, altering flags, crafting special archives). Self contained, no third party dependencies. If you just want to unzip files, this is not for you :)
.ZIP File Format Specification:
https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXTHow to use it:
## Changing file content
```csharp
var zip = ZipArchive.Read(filename);var entry = zip.Entries.FirstOrDefault(e => e.LocalFileHeader.Filename == "readme.txt");
if (entry != null)
{
entry.Data = zip.StringConverter.GetBytes("This is my new content", StringConverterContext.Content);
// this is not compressed
entry.LocalFileHeader.Compression = entry.CentralDirectoryHeader.Compression = 0;
}zip.Write(filename);
```## Processing file names
```csharp
var zip = ZipArchive.Read(filename);foreach (var entry in zip.Entries)
{
entry.LocalFileHeader.Filename = "foo." + entry.LocalFileHeader.Filename;
entry.CentralDirectoryHeader.Filename = entry.LocalFileHeader.Filename;
}zip.Write(filename);
```## Creating archive / adding entry
```csharp
var zip = new ZipArchive();
var entry = new ZipEntry();zip.Entries.Add(entry);
entry.LocalFileHeader.Filename = entry.CentralDirectoryHeader.Filename = "foo.txt";
entry.Data = zip.StringConverter.GetBytes("Hello world!", StringConverterContext.Content);zip.Write("foo.zip");
```## Removing all data descriptors
```csharp
var zip = ZipArchive.Read(filename);foreach (var entry in zip.Entries.Where(entry => entry.HasDataDescriptor))
{
entry.LocalFileHeader.CompressedSize = entry.DataDescriptor.CompressedSize;
entry.LocalFileHeader.UncompressedSize = entry.DataDescriptor.UncompressedSize;
entry.LocalFileHeader.Crc = entry.DataDescriptor.Crc;
entry.HasDataDescriptor = false;
}zip.Write(filename);
```## Removing all extra blocks
```csharp
var zip = ZipArchive.Read(filename);foreach (var entry in zip.Entries)
{
entry.LocalFileHeader.Extra = new byte[0];
entry.CentralDirectoryHeader.Extra = new byte[0];
}zip.Write(filename);
```