uncozip

package module
v0.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 14 Imported by: 0

README

GoDev

uncozip

This is a command and package to UNzip COrrupted ZIP file that does not have the central directory records.

Even when the archive is so large that zip -FF Corrupted.zip --out New.zip fails, sometimes uncozip succeeds.
( For example, the case Corrupted.zip is larger than 4GB )

The uncozip is also useful on non-Windows OSes to unpack archives with non-UTF8 filenames such as Shift_JIS. (uncozip -decode Shift_JIS foo.zip)

Usage

uncozip {OPTIONS} ZIPFILENAME [list...]

uncozip {OPTIONS} - [list...] < ZIPFILENAME

uncozip {OPTIONS} < ZIPFILENAME
  • -d string the directory where to extract
  • -debug Enable debug output
  • -strict quit immediately on CRC-Error
  • -t Test CRC32 only
  • -decode IANA-NAME specify IANA-registered-name to decode filename when UTF8 flag is not set (for example: -decode Shift_JIS)

Install

Download the binary package from Releases and extract the executable.

for scoop-installer
scoop install https://raw.githubusercontent.com/hymkor/uncozip/master/uncozip.json

or

scoop bucket add hymkor https://github.com/hymkor/scoop-bucket
scoop install uncozip

package "github.com/hymkor/uncozip"

Unlike "archive/zip", uncozip can

  • read an archive from io.Reader.
    ( "archive/zip" requires archive's filename[^zip.OpenReader] or io.ReaderAt and size information[^zip.NewReader] )
  • handle encrypted archive.
    ( You have to call RegisterPasswordHandler )
  • decode filename from any encoding
    ( You have to call RegisterNameDecoder )

[^zip.OpenReader]: See also https://pkg.go.dev/archive/zip#OpenReader [^zip.NewReader]: See also https://pkg.go.dev/archive/zip#NewReader

Reference

Documentation

Index

Constants

View Source
const (
	Store   = 0
	Deflate = 8
)

Variables

View Source
var (
	ErrLocalFileHeaderSignatureNotFound = errors.New("signature not found")
)

Functions

This section is empty.

Types

type CorruptedZip

type CorruptedZip struct {
	LastModificationTime time.Time
	LastAccessTime       time.Time
	CreationTime         time.Time

	// Debug outputs debug-log. When the field is not set, debug-log is dropped.
	Debug func(...any)
	// contains filtered or unexported fields
}

CorruptedZip is a reader for a ZIP archive that reads from io.Reader instead of io.ReaderAt

func New

func New(r io.Reader) *CorruptedZip

New returns a CorruptedZip instance that reads a ZIP archive.

func (*CorruptedZip) Body added in v0.1.0

func (cz *CorruptedZip) Body() io.Reader

Body returns the reader of the most recent file by a call to Scan.

func (*CorruptedZip) CRC32 added in v0.4.1

func (cz *CorruptedZip) CRC32() uint32

CRC32 returns the current file's CRC32 written in "local file header" or "data descriptor". When an "data descriptor" exists, it waits until file data stream is read all. This field is sed by Scan method

func (*CorruptedZip) Close added in v0.7.1

func (cz *CorruptedZip) Close()

Close releases resources used on the Scan method previous called.

func (*CorruptedZip) CompressedSize added in v0.4.0

func (cz *CorruptedZip) CompressedSize() uint64

CompressedSize returns the current file's compressed size written in "local file header" or "data descriptor". When an "data descriptor" exists, it waits until file data stream is read all. This field is sed by Scan method

func (*CorruptedZip) Err added in v0.1.0

func (cz *CorruptedZip) Err() error

Err returns the error encountered by the CorruptedZip.

func (*CorruptedZip) IsDir added in v0.7.1

func (cz *CorruptedZip) IsDir() bool

IsDir returns true when the current file is a directory.

func (*CorruptedZip) Method added in v0.4.1

func (cz *CorruptedZip) Method() uint16

Method returns the mothod to compress the current entry data

func (*CorruptedZip) Name added in v0.1.0

func (cz *CorruptedZip) Name() string

Name returns the name of the most recent file by a call to Scan.

func (*CorruptedZip) OriginalSize added in v0.4.0

func (cz *CorruptedZip) OriginalSize() uint64

originalSize returns the current file's uncompressed size written in "local file header" or "data descriptor". When an "data descriptor" exists, it waits until file data stream is read all. This field is sed by Scan method

func (*CorruptedZip) RegisterNameDecoder added in v0.7.1

func (cz *CorruptedZip) RegisterNameDecoder(f func([]byte) (string, error))

RegisterNameDecoder sets callback function to translate nonUTF8 filename to UTF8

func (*CorruptedZip) RegisterPasswordHandler added in v0.6.0

func (cz *CorruptedZip) RegisterPasswordHandler(f func(filename string) (password []byte, err error))

RegisterPasswordHandler sets a callback function to query password to an user.

func (*CorruptedZip) Scan

func (cz *CorruptedZip) Scan() bool

Scan advances the CorruptedZip to the next single file in a ZIP archive.

type ErrPassword added in v0.4.0

type ErrPassword struct {
	// contains filtered or unexported fields
}

ErrPassword is an error reporting that password is invalid.

func (*ErrPassword) Error added in v0.4.0

func (e *ErrPassword) Error() string

Error returns an error message.

func (*ErrPassword) Name added in v0.4.0

func (e *ErrPassword) Name() string

Name returns a entry filename where an error occured

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL