Skip to content

naldodj/naldodj-totvs-include-decompress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

naldodj-totvs-include-decompress

Getting Started

This is an example of how to decompress .ch and .th binary files.

Prerequisites

This is an example of how to list things you need to use the software and how to install them.

Source (Phyton)

  import zlib
  import sys

  with open(sys.argv[1], 'rb') as f:
      content = f.read()

  decompress = zlib.decompressobj(-zlib.MAX_WBITS)
  inflated = decompress.decompress(content[14:])
  inflated += decompress.flush()

  print(inflated[:-1].decode('utf-8', errors='ignore'))

Usage (Phyton)

    ./decompress.py .\includes\sigawin.ch > sigawin.ch

Source (pwsh)

      param (
          [string]$filePath
      )

      Add-Type -AssemblyName System.IO.Compression

      $bytes = [System.IO.File]::ReadAllBytes($filePath)
      $compressedContent = $bytes[14..($bytes.Length - 1)]
      $stream = New-Object System.IO.MemoryStream
      $stream.Write($compressedContent, 0, $compressedContent.Length)
      $stream.Position = 0

      $decompressor = New-Object System.IO.Compression.DeflateStream($stream, [System.IO.Compression.CompressionMode]::Decompress)
      $reader = New-Object System.IO.StreamReader($decompressor, [System.Text.Encoding]::UTF8)

      $inflated = $reader.ReadToEnd()
      $reader.Close()

      Write-Output ($inflated.Trim())

Usage (pwsh)

     pwsh .\decompress.ps1 -filePath ".\includes\sigawin.ch" > .\sigawin.ch

Reference

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

About

Descompactar arquivos TOTVS Microsiga Protheus (Header: ch, .th)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published