Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
37b7cc2
progress on zlib
santisq Apr 15, 2025
35b45b5
progress on deflate
santisq Apr 15, 2025
8759f03
progress on brotli
santisq Apr 15, 2025
89d7ef8
replaces existing logic for Gzip adding package SharpZipLib
santisq Apr 15, 2025
1c15427
bunch of alias renaming
santisq Apr 15, 2025
73de2b5
few improvements on existing classes
santisq Apr 15, 2025
2c8e6b0
few improvements on existing classes
santisq Apr 15, 2025
43ea188
hides CompressionLevel parameter for ConvertToBrotliStringCommand
santisq Apr 18, 2025
48c929c
adds base class CommandToCompressedFileBase to use in all compression…
santisq Apr 18, 2025
60745ea
adds base class CommandToCompressedFileBase to use in all compression…
santisq Apr 18, 2025
448840c
adds warning if CompressionLevel on Brotli commands
santisq Apr 18, 2025
c904428
Brotli has SetQuality method :facepalm:
santisq Apr 18, 2025
9e2371f
Brotli has SetQuality method :facepalm:
santisq Apr 18, 2025
08d5f13
better naming for ext. methods
santisq Apr 18, 2025
6470492
extension method to create compressed brotli stream
santisq Apr 18, 2025
43616cf
huge update
santisq Jun 17, 2025
72a45f1
fixing tests
santisq Jun 17, 2025
9fb9375
adding to and from compression tests
santisq Jun 17, 2025
be1707d
adding some compresstararchive tests
santisq Jun 17, 2025
01df67c
adding some compresstararchive tests
santisq Jun 17, 2025
a6e001e
missing .test.ps1 file name on test file
santisq Jun 17, 2025
6cbe59c
chagning Brotli.NET to BrotliSharpLib :pray:
santisq Jun 17, 2025
51f14ca
updating changelog
santisq Jun 17, 2025
02f9350
starting with expandtararchivecommand
santisq Jun 18, 2025
53734f4
done with expandtararchive
santisq Jun 19, 2025
727e159
some code improvements. simplifications...
santisq Jun 19, 2025
45484e9
adding tests
santisq Jun 19, 2025
93a994b
adding tests
santisq Jun 21, 2025
5787df4
adding tests
santisq Jun 21, 2025
0097c37
adding tests
santisq Jun 21, 2025
06ec32c
adds gettarentrycommand tests
santisq Jun 21, 2025
f1abe36
corrects a few tests
santisq Jun 21, 2025
822adae
corrects a few tests
santisq Jun 21, 2025
985bf60
bug...
santisq Jun 21, 2025
68e1af6
bug...
santisq Jun 21, 2025
63d30c7
adding tests for GetTarEntryContent command
santisq Jun 22, 2025
e7c1563
adding tests for GetTarEntryContent command
santisq Jun 22, 2025
41b36dd
typo..
santisq Jun 22, 2025
148d655
typo..
santisq Jun 22, 2025
655c24a
adds expandtarentry command tests
santisq Jun 22, 2025
d5dbc54
i tink done with tests
santisq Jun 22, 2025
438ca51
i tink done with tests
santisq Jun 22, 2025
903bcbc
done with docs fucking finally
santisq Jun 23, 2025
3075a0e
updates aliases. solves #43
santisq Jun 24, 2025
336b281
updates readme and changelog
santisq Jun 24, 2025
5f6cc38
updates readme and changelog
santisq Jun 24, 2025
5a877d5
updates readme and changelog
santisq Jun 24, 2025
80271d8
updates readme and changelog
santisq Jun 24, 2025
a47fda2
updates readme and changelog
santisq Jun 24, 2025
8a3e0bf
updates readme and changelog
santisq Jun 24, 2025
1ba9bca
updates readme and changelog
santisq Jun 24, 2025
7fb72a9
updates readme and changelog
santisq Jun 24, 2025
8e95c8b
updates readme and changelog
santisq Jun 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# CHANGELOG

## 06/23/2025

- Added commands supporting several algorithms to compress and decompress strings:
- `ConvertFrom-BrotliString` & `ConvertTo-BrotliString` (using to BrotliSharpLib)
- `ConvertFrom-DeflateString` & `ConvertTo-DeflateString` (from CLR)
- `ConvertFrom-ZlibString` & `ConvertTo-ZlibString` (custom implementation)
- Added commands for `.tar` entry management with a reduced set of operations compared to `zip` entry management:
- `Get-TarEntry`: Lists entries, serving as the main entry point for `TarEntry` cmdlets.
- `Get-TarEntryContent`: Retrieves the content of a tar entry.
- `Expand-TarEntry`: Extracts a tar entry to a file.
- Added commands to compress files and folders into `.tar` archives and extract `.tar` archives with various compression algorithms:
- `Compress-TarArchive` & `Expand-TarArchive`: Supported compression algorithms include `gz`, `bz2`, `zst`, `lz`, and `none` (no compression).
- Removed commands:
- `Compress-GzipArchive` & `Expand-GzipArchive`: These were deprecated as they only supported single-file compression, which is now better handled by the module’s `.tar` archive functionality. For a workaround to compress or decompress single files using gzip, see [Example 2 in `ConvertTo-GzipString`][example2converttogzipstring], which demonstrates using:

```powershell
[System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($path)) | ConvertFrom-GzipString
```

This update was made possible by the following projects. If you find them helpful, please consider starring their repositories:

- [SharpZipLib](https://github.com/icsharpcode/SharpZipLib)
- [SharpCompress](https://github.com/adamhathcock/sharpcompress)
- [BrotliSharpLib](https://github.com/master131/BrotliSharpLib)
- [ZstdSharp](https://github.com/oleg-st/ZstdSharp)

## 01/10/2025

- Code improvements.
Expand Down Expand Up @@ -38,3 +64,5 @@
- Moved from `[PSCompression.ZipEntryExtensions]::NormalizePath` to `[PSCompression.Extensions.PathExtensions]::NormalizePath`.
- `Get-ZipEntry` command:
- Renamed Parameter `-EntryType` to `-Type`.

[example2converttogzipstring]: https://github.com/santisq/PSCompression/blob/main/docs/en-US/ConvertTo-GzipString.md#example-2-create-a-gzip-compressed-file-from-a-string
289 changes: 150 additions & 139 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">PSCompression</h1>
<div align="center">
<sub>Zip and GZip utilities for PowerShell</sub>
<sub>Zip, tar, and string compression utilities for PowerShell!</sub>
<br/><br/>

[![build](https://github.com/santisq/PSCompression/actions/workflows/ci.yml/badge.svg)](https://github.com/santisq/PSCompression/actions/workflows/ci.yml)
Expand All @@ -11,157 +11,156 @@

</div>

PSCompression is a PowerShell Module that provides Zip and Gzip utilities for compression, expansion and management. It also solves a few issues with Zip compression existing in _built-in PowerShell_.
`PSCompression` is a PowerShell module that provides utilities for creating, managing, and extracting zip and tar archives, as well as compressing and decompressing strings. It overcomes limitations in built-in PowerShell archive cmdlets (e.g., 2 GB zip file limits) and supports multiple compression algorithms, including gzip, bzip2, Zstandard, lzip, Brotli, Deflate, and Zlib. Built for cross-platform use, it’s compatible with Windows, Linux, and macOS.

## What does this Module offer?
## Features

### Zip Cmdlets
- __Zip Archive Management__: Create, list, extract, retrieve content, modify, and remove entries in zip archives with pipeline support.
- __Tar Archive Management__: Compress and extract tar archives with support for `gz`, `bz2`, `zst`, `lz`, and uncompressed (`none`) formats.
- __Tar Entry Management__: List, extract, and retrieve content from individual tar entries.
- __String Compression__: Compress and decompress strings using Brotli, Deflate, Gzip, and Zlib algorithms.

<div class="zipcmdlets">
<table>
<tr>
<th>Cmdlet</th>
<th>Description</th>
</tr>
<tr>
<td colspan="1" width="230" height="60">

[`Get-ZipEntry`](docs/en-US/Get-ZipEntry.md)

</td>
<td>

Main entry point for the `*-ZipEntry` cmdlets in this module. It can list zip archive entries from specified paths or input stream.

</td>
</tr>
<tr>
<td colspan="1" width="230" height="60">

[`Expand-ZipEntry`](docs/en-US/Expand-ZipEntry.md)

</td>
<td>

Expands zip entries to a destination directory.

</td>
</tr>
<tr>
<td colspan="1" width="230" height="60">

[`Get-ZipEntryContent`](docs/en-US/Get-ZipEntryContent.md)

</td>
<td>

Gets the content of one or more zip entries.

</td>
</tr>
<tr>
<td colspan="1" width="230" height="60">

[`New-ZipEntry`](docs/en-US/New-ZipEntry.md)

</td>
<td>Creates zip entries from specified path or paths.</td>
</tr>
<tr>
<td colspan="1" width="230" height="60">

[`Remove-ZipEntry`](docs/en-US/Remove-ZipEntry.md)

</td>
<td>Removes zip entries from one or more zip archives.</td>
</tr>
<tr>
<td colspan="1" width="230" height="60">

[`Rename-ZipEntry`](docs/en-US/Rename-ZipEntry.md)

</td>
<td>Renames zip entries from one or more zip archives.</td>
</tr>
<tr>
<td colspan="1" width="230" height="60">

[`Set-ZipEntryContent`](docs/en-US/Set-ZipEntryContent.md)

</td>
<td>Sets or appends content to a zip entry.</td>
</tr>
<tr>
<td colspan="1" width="230" height="60">
# Cmdlets

[`Compress-ZipArchive`](docs/en-US/Compress-ZipArchive.md)
## Cmdlets

</td>
<td>
### Zip Archive Cmdlets

Similar capabilities as
[`Compress-Archive`](docs/en-US/https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/compress-archive?view=powershell-7.2)
and overcomes a few issues with the built-in cmdlet (2 GB limit and more).

</td>
</tr>
<table>
<tr>
<th>Cmdlet</th>
<th>Alias</th>
<th>Description</th>
</tr>
<tr>
<td colspan="1" width="220"><a href="docs/en-US/Compress-ZipArchive.md">Compress-ZipArchive</a></td>
<td><code>zipcompress</code></td>
<td>Compresses files and folders into a zip archive, overcoming built-in PowerShell limitations.</td>
</tr>
<tr>
<td><a href="docs/en-US/Expand-ZipEntry.md">Expand-ZipEntry</a></td>
<td><code>unzipentry</code></td>
<td>Extracts individual zip entries to a destination directory.</td>
</tr>
<tr>
<td><a href="docs/en-US/Get-ZipEntry.md">Get-ZipEntry</a></td>
<td><code>zipge</code></td>
<td>Lists zip archive entries from paths or streams, serving as the entry point for zip cmdlets.</td>
</tr>
<tr>
<td><a href="docs/en-US/Get-ZipEntryContent.md">Get-ZipEntryContent</a></td>
<td><code>zipgec</code></td>
<td>Retrieves the content of zip entries as text or bytes.</td>
</tr>
<tr>
<td><a href="docs/en-US/New-ZipEntry.md">New-ZipEntry</a></td>
<td><code>zipne</code></td>
<td>Adds new entries to a zip archive from files or paths.</td>
</tr>
<tr>
<td><a href="docs/en-US/Remove-ZipEntry.md">Remove-ZipEntry</a></td>
<td><code>ziprm</code></td>
<td>Removes entries from one or more zip archives.</td>
</tr>
<tr>
<td><a href="docs/en-US/Rename-ZipEntry.md">Rename-ZipEntry</a></td>
<td><code>zipren</code></td>
<td>Renames entries in one or more zip archives.</td>
</tr>
<tr>
<td><a href="docs/en-US/Set-ZipEntryContent.md">Set-ZipEntryContent</a></td>
<td><code>zipsc</code></td>
<td>Sets or appends content to a zip entry.</td>
</tr>
</table>
</div>

### Gzip Cmdlets
### Tar Archive Cmdlets

<div class="gzipcmdlets">
<table>
<tr>
<th>Cmdlet</th>
<th>Description</th>
</tr>
<tr>
<td colspan="1" width="230" height="60">

[`Compress-GzipArchive`](docs/en-US/Compress-GzipArchive.md)

</td>
<td>
Can compress one or more specified file paths into a Gzip file.
</td>
</tr>
<tr>
<td colspan="1" width="230" height="60">

[`ConvertFrom-GzipString`](docs/en-US/ConvertFrom-GzipString.md)

</td>
<td>
Expands Gzip Base64 input strings.
</td>
</tr>

<tr>
<td colspan="1" width="230" height="60">

[`ConvertTo-GzipString`](docs/en-US/ConvertTo-GzipString.md)

</td>
<td>
Can compress input strings into Gzip Base64 strings or raw bytes.
</td>
</tr>

<tr>
<td colspan="1" width="230" height="60">

[`Expand-GzipArchive`](docs/en-US/Expand-GzipArchive.md)

</td>
<td>
<tr>
<th>Cmdlet</th>
<th>Alias</th>
<th>Description</th>
</tr>
<tr>
<td colspan="1" width="220"><a href="docs/en-US/Compress-TarArchive.md">Compress-TarArchive</a></td>
<td><code>tarcompress</code></td>
<td>Compresses files and folders into a tar archive with optional compression (gz, bz2, zst, lz, none).</td>
</tr>
<tr>
<td><a href="docs/en-US/Expand-TarArchive.md">Expand-TarArchive</a></td>
<td><code>untar</code></td>
<td>Extracts a tar archive with support for gz, bz2, zst, lz, and uncompressed formats.</td>
</tr>
<tr>
<td><a href="docs/en-US/Expand-TarEntry.md">Expand-TarEntry</a></td>
<td><code>untarentry</code></td>
<td>Extracts individual tar entries to a destination directory.</td>
</tr>
<tr>
<td><a href="docs/en-US/Get-TarEntry.md">Get-TarEntry</a></td>
<td><code>targe</code></td>
<td>Lists tar archive entries from paths or streams, serving as the entry point for tar cmdlets.</td>
</tr>
<tr>
<td><a href="docs/en-US/Get-TarEntryContent.md">Get-TarEntryContent</a></td>
<td><code>targc</code></td>
<td>Retrieves the content of tar entries as text or bytes.</td>
</tr>
</table>

Expands Gzip compressed files to a destination path or to the [success stream](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_output_streams?view=powershell-7.3#success-stream).
### String Compression Cmdlets

</td>
</tr>
<table>
<tr>
<th>Cmdlet</th>
<th>Alias</th>
<th>Description</th>
</tr>
<tr>
<td colspan="1" width="220"><a href="docs/en-US/ConvertFrom-BrotliString.md">ConvertFrom-BrotliString</a></td>
<td><code>frombrotlistring</code></td>
<td>Decompresses a Brotli-compressed string.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertFrom-DeflateString.md">ConvertFrom-DeflateString</a></td>
<td><code>fromdeflatestring</code></td>
<td>Decompresses a Deflate-compressed string.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertFrom-GzipString">ConvertFrom-GzipString</a></td>
<td><code>fromgzipstring</code></td>
<td>Decompresses a Gzip-compressed string.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertFrom-ZlibString.md">ConvertFrom-ZlibString</a></td>
<td><code>fromzlibstring</code></td>
<td>Decompresses a Zlib-compressed string.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertTo-BrotliString.md">ConvertTo-BrotliString</a></td>
<td><code>tobrotlistring</code></td>
<td>Compresses a string using Brotli.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertTo-DeflateString.md">ConvertTo-DeflateString</a></td>
<td><code>todeflatestring</code></td>
<td>Compresses a string using Deflate.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertTo-GzipString.md">ConvertTo-GzipString</a></td>
<td><code>togzipstring</code></td>
<td>Compresses a string using Gzip to Base64 or raw bytes.</td>
</tr>
<tr>
<td><a href="docs/en-US/ConvertTo-ZlibString.md">ConvertTo-ZlibString</a></td>
<td><code>tozlibstring</code></td>
<td>Compresses a string using Zlib.</td>
</tr>
</table>
</div>

> [!NOTE]
> The `Compress-GzipArchive` and `Expand-GzipArchive` cmdlets have been removed, as their single-file gzip functionality is now handled by `Compress-TarArchive` and `Expand-TarArchive`. For a workaround to compress or decompress single files using gzip, see [Example 2 in `ConvertTo-GzipString`](./docs/en-US/ConvertTo-GzipString.md#example-2-create-a-gzip-compressed-file-from-a-string).

## Documentation

Expand Down Expand Up @@ -189,6 +188,18 @@ Set-Location ./PSCompression

This module has no external requirements and is compatible with __Windows PowerShell 5.1__ and [__PowerShell 7+__](https://github.com/PowerShell/PowerShell).

## Acknowledgments

This module is powered by the following open-source projects:

- [SharpZipLib](https://github.com/icsharpcode/SharpZipLib)
- [SharpCompress](https://github.com/adamhathcock/sharpcompress)
- [BrotliSharpLib](https://github.com/master131/BrotliSharpLib)
- [ZstdSharp](https://github.com/oleg-st/ZstdSharp)
- [System.IO.Compression](https://learn.microsoft.com/en-us/dotnet/api/system.io.compression)

If you find these projects helpful, consider starring their repositories!

## Contributing

Contributions are more than welcome, if you wish to contribute, fork this repository and submit a pull request with the changes.
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (-not ('ProjectBuilder.ProjectInfo' -as [type])) {
}
}

$projectInfo = [ProjectBuilder.ProjectInfo]::Create($PSScriptRoot, $Configuration)
$projectInfo = [ProjectBuilder.ProjectInfo]::Create($PSScriptRoot, $Configuration, $PSVersionTable.PSVersion)
$projectInfo.GetRequirements() | Import-Module -DisableNameChecking -Force

$ErrorActionPreference = $prev
Expand Down
Loading