sparsefile

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(in io.Reader, destPath string) error

Decode reads an SPF1‑encoded sparse file from in and reconstructs the original sparse layout at destPath. It recreates the file with the recorded logical size and writes only the stored extents at their original offsets so that holes remain sparse on supported filesystems.

func Encode

func Encode(path string, out io.Writer) error

Encode reads a potentially sparse file from the given path and writes a compact representation of its non‑hole data extents to out using the custom SPF1 format. The output format is:

magic(4) | size(uint64) | count(uint64) |
repeated count times: offset(uint64) | length(uint64) | raw data bytes.

Types

type Extent

type Extent struct {
	Offset int64 // Offset is the starting byte position in the original file.
	Length int64 // Length is the number of bytes in this extent.
}

Extent represents a contiguous non‑hole data region in the sparse file.

Jump to

Keyboard shortcuts

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