par2test

package
v0.2.41 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package par2test builds PAR2 2.0 metadata packets and index files for tests. It is for tests only: production code must not import it.

Packets carry correct packet MD5s. File IDs are derived the way PAR2 clients do (MD5 of the 16k hash, the length and the name); recovery set IDs are the MD5 of the Main packet body. No recovery slices are written.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileDescBody

func FileDescBody(id par2.ID, name string, data []byte) []byte

FileDescBody returns a File Description packet body.

func FileID

func FileID(name string, data []byte) par2.ID

FileID derives a file's ID from its 16k hash, length and name.

func IFSCBody

func IFSCBody(id par2.ID, sliceSize int64, data []byte) []byte

IFSCBody returns the slice checksum packet body of data.

func Index

func Index(sliceSize int64, files []File) ([]byte, par2.ID)

Index returns a PAR2 index file describing files with the given slice size (a positive multiple of 4), and its recovery set ID.

func MainBody

func MainBody(sliceSize int64, ids []par2.ID) []byte

MainBody returns a Main packet body.

func Packet

func Packet(setID par2.ID, typ string, body []byte) []byte

Packet returns one valid packet of type typ (a par2.Type* constant).

func UniNameBody

func UniNameBody(id par2.ID, name string) []byte

UniNameBody returns a Unicode filename packet body.

Types

type File

type File struct {
	Name string
	Data []byte
	// UniName, if set, adds a Unicode filename packet.
	UniName string
	// NoIFSC omits the file's slice checksum packet.
	NoIFSC bool
}

File is one file to describe.

Jump to

Keyboard shortcuts

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