Skip to content

v2.1.0

Latest
Compare
Choose a tag to compare
@santisq santisq released this 10 Jan 22:52
· 1 commit to main since this release

What's Changed

  • Code improvements.

  • Instance methods .OpenRead() and .OpenWrite() moved from ZipEntryFile to ZipEntryBase.

  • Adds support to operate from input Stream. This means you can now:

    • List entries:

      PS ..\PSCompression> $uri = 'https://www.powershellgallery.com/api/v2/package/PSCompression'
      PS ..\PSCompression> Invoke-WebRequest $uri | Get-ZipEntry | Select-Object -First 5
      
      Directory: /
      
      Type                    LastWriteTime  CompressedSize            Size Name
      ----                    -------------  --------------            ---- ----
      Archive            11/6/2024 10:29 PM       227.00  B       785.00  B [Content_Types].xml
      Archive            11/6/2024 10:27 PM       516.00  B         2.50 KB PSCompression.Format.ps1xml
      Archive            11/6/2024 10:29 PM       598.00  B         1.58 KB PSCompression.nuspec
      Archive            11/6/2024 10:27 PM         1.66 KB         5.45 KB PSCompression.psd1
      
      Directory: /_rels/
      
      Type                    LastWriteTime  CompressedSize            Size Name
      ----                    -------------  --------------            ---- ----
      Archive            11/6/2024 10:29 PM       276.00  B       507.00  B .rels
    • Read their content:

      PS ..\PSCompression> $entry = Invoke-WebRequest $uri | Get-ZipEntry -Include *.psd1
      PS ..\PSCompression> $entry | Get-ZipEntryContent -Raw | Invoke-Expression
      
      Name                           Value
      ----                           -----
      FunctionsToExport              {}
      PowerShellVersion              5.1
      GUID                           c63aa90e-ae64-4ae1-b1c8-456e0d13967e
      FormatsToProcess               {PSCompression.Format.ps1xml}
      RootModule                     bin/netstandard2.0/PSCompression.dll
      Author                         Santiago Squarzon
      ModuleVersion                  2.0.10
      CompanyName                    Unknown
      PrivateData                    {[PSData, System.Collections.Hashtable]}
      Description                    Zip and GZip utilities for PowerShell!
      Copyright                      (c) Santiago Squarzon. All rights reserved.
      CmdletsToExport                {Get-ZipEntry, Get-ZipEntryContent, Set-ZipEntryContent, Remove-ZipEntry…}
      VariablesToExport              {}
      AliasesToExport                {gziptofile, gzipfromfile, gziptostring, gzipfromstring…}
      RequiredAssemblies             {System.IO.Compression, System.IO.Compression.FileSystem}
    • Extract them:

      PS ..\PSCompression> $file = $entry | Expand-ZipEntry -PassThru
      PS ..\PSCompression> $file
      
      Mode                 LastWriteTime         Length Name
      ----                 -------------         ------ ----
      -a---           11/6/2024 10:27 PM           5584 PSCompression.psd1
      
      PS ..\PSCompression> Get-Content $file.FullName -TotalCount 3
      #
      # Module manifest for module 'PSCompression'
      #

    Other operations are not supported and will throw an error:

    PS ..\PSCompression> $entry | Remove-ZipEntry
    Remove-ZipEntry: The operation is not supported for entries created from input Stream.

Full Changelog: v2.0.10...v2.1.0