gzip

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: BSD-3-Clause Imports: 10 Imported by: 37

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compress

func Compress(r io.Reader, w io.Writer, level int, blocksize int, processes int) error

Compress takes input from io.Reader and deflates it using pgzip to io.Writer. Data is compressed in blocksize (KB) chunks using upto the number of CPU cores specified.

func Decompress

func Decompress(r io.Reader, w io.Writer, blocksize int, processes int) error

Decompress takes gzip compressed input from io.Reader and expands it using pgzip to io.Writer. Data is read in blocksize (KB) chunks using upto the number of CPU cores specified.

Types

type File

type File struct {
	Path    string
	Options *Options
}

File is a file path to be compressed or decompressed.

func (*File) CheckOutputPath

func (f *File) CheckOutputPath() error

CheckOutputPath checks if output is attempting to write binary to stdout if stdout is a device. Also checks if output path already exists. Allow override via force option.

func (*File) CheckOutputStdout

func (f *File) CheckOutputStdout() error

CheckOutputStdout checks if output is attempting to write binary to stdout if stdout is a device.

func (*File) CheckPath

func (f *File) CheckPath() error

CheckPath validates the input file path. Checks on compression if the path has the correct suffix, and on decompression checks that it doesn't have the suffix. Allows override by force option. Skip if the input is a Stdin.

func (*File) Cleanup

func (f *File) Cleanup() error

Cleanup removes input file. Overrided with keep option. Skipped if stdout or test option is true.

func (*File) Process

func (f *File) Process() error

Process either compresses or decompressed the input file based on the associated file.options.

type Options

type Options struct {
	Blocksize  int
	Level      int
	Processes  int
	Decompress bool
	Force      bool
	Help       bool
	Keep       bool
	Quiet      bool
	Stdin      bool
	Stdout     bool
	Test       bool
	Verbose    bool
	Suffix     string
}

Options represents the CLI options possible, controlling how gzip operates on the given input data.

func (*Options) ParseArgs

func (o *Options) ParseArgs(args []string, cmdLine *flag.FlagSet) error

ParseArgs takes CLI args and parses them via a Flagset into fields in the Options struct. Returns any errors from parsing and validating options.

Jump to

Keyboard shortcuts

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