splitfile

package
v0.0.0-...-28beed0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownChecksumAlgo = errors.New("unknown checksum algorithm")
)

Functions

func FormatChunkFilename

func FormatChunkFilename(mainFilename string, n int) string

func FormatSplitfileFilename

func FormatSplitfileFilename(mainFilename string) string

Types

type Checksum

type Checksum []byte

Checksum represents a hash checksum.

Implmentens TextMarshaler and TextUnmarshaler.

func (Checksum) MarshalText

func (chk Checksum) MarshalText() (text []byte, err error)

func (*Checksum) UnmarshalText

func (chk *Checksum) UnmarshalText(text []byte) error

type ChecksumAlgo

type ChecksumAlgo string

ChecksumAlgo represents a checksum algorithm.

const (
	ChecksumAlgoNone  ChecksumAlgo = "None"
	ChecksumAlgoCRC32 ChecksumAlgo = "CRC32"
)

type File

type File struct {
	// Original filename at time of chunk creation.
	Filename string `json:"filename"`
	// Checksum of the file.
	Checksum Checksum `json:"checksum"`
	// Size of the file.
	Size int64 `json:"size"`
}

File represents a file, either a main file or an specific chunk.

type HasherFunc

type HasherFunc func() hash.Hash

HasherFunc is a function that returns a new implementation of hash.Hash.

There is one implementation for every supported checksum algorithm. ChecksumAlgoNone returns a nil HasherFunc and no error.

func GetHasher

func GetHasher(checksumAlgo ChecksumAlgo) (hasherFunc HasherFunc, err error)

type Splitfile

type Splitfile struct {
	// Algorithm used for all checksums in the file.
	ChecksumAlgo ChecksumAlgo `json:"checksum_algo"`

	// The whole main file the chunks were derived from. The checksum is of the
	// whole file.
	MainFile *File `json:"main_file"`
	// The chunks that were derived from the main file. Number of chunks can be
	// derived from the number of elements, and their order represents their
	// actual order of concatenation to recreate the main file.
	Chunks []*File `json:"chunks"`
}

Splitfile is the structure of a of a .split file.

Jump to

Keyboard shortcuts

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