compressor

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompressionProcess

type CompressionProcess struct {
	OriginalFileInfo []*FileInfo
	OriginalPaths    []string
	TempFiles        map[string][]TempFile

	Results  map[string][]*CompressionResult
	Wrappers map[string]string

	MinDecodeTime         time.Duration
	AreDecodeTimeComputed bool
	// contains filtered or unexported fields
}

func NewCompressionProcess

func NewCompressionProcess(
	paths []string,
	wrappers map[string]string,
	printLog *log.Logger,
	warnLog *log.Logger,
	toolOutput io.Writer,
) (c *CompressionProcess, allOk bool)

func (*CompressionProcess) BenchmarkDecodeTime

func (c *CompressionProcess) BenchmarkDecodeTime(minTime time.Duration) (done chan struct{})

func (*CompressionProcess) CleanUp

func (c *CompressionProcess) CleanUp()

func (*CompressionProcess) CompressAll

func (c *CompressionProcess) CompressAll(ctx context.Context, tools map[string]ExecutedTool) (done chan struct{})

func (*CompressionProcess) CompressSingle

func (c *CompressionProcess) CompressSingle(fileIdx int, ctx context.Context, tools map[string]ExecutedTool) (done chan struct{})

func (*CompressionProcess) IsErrorFree

func (c *CompressionProcess) IsErrorFree() (ok bool)

func (*CompressionProcess) SaveResultsAndReport

func (c *CompressionProcess) SaveResultsAndReport(writeMode WriteMode) (allOk bool)

type CompressionResult

type CompressionResult struct {
	Command   *exec.Cmd
	Arguments []string

	TimeTaken time.Duration

	OriginalSize int64
	FinalSize    int64

	CreateError        error
	CommandError       error
	ReadFinalSizeError error

	Decode DecodeTimeBench
}

func (*CompressionResult) HasError

func (r *CompressionResult) HasError() bool

type DecodeTimeBench

type DecodeTimeBench struct {
	Total   time.Duration
	Average time.Duration
	Trials  int

	Err error
}

func (DecodeTimeBench) MSAverageToString

func (dt DecodeTimeBench) MSAverageToString() string

func (DecodeTimeBench) MSAverageWithTrialsCountString

func (dt DecodeTimeBench) MSAverageWithTrialsCountString() string

type ExecutedTool

type ExecutedTool struct {
	*config.CompressionTool
	Arguments []string
}

func ToolConfigToExecutedTool

func ToolConfigToExecutedTool(tool *config.ToolConfig, argPreset string) (result ExecutedTool, ok bool)

type FileInfo

type FileInfo struct {
	Path string

	Directory string
	FileName  string
	BaseName  string
	Extension string

	Size int64

	Decode DecodeTimeBench
}

type TempFile

type TempFile struct {
	Path        string
	CreateError error
}

type WriteMode

type WriteMode int
const (
	KeepBest  WriteMode = iota // Copies the best compressed file onto the same directory as the input file
	KeepAll                    // Copy all compressed files onto the same directory as the input file
	Overwrite                  // Overwrites the input file with the best compressed file
	None                       // Do not produce a new file even if the file is successfully compressed
)

Jump to

Keyboard shortcuts

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