sparsefile

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package sparsefile copies files while preserving holes.

The biggest thing atelet copies is a guest memory image, which is mostly unallocated: a plain io.Copy reads holes as zeroes and writes them as data, inflating a snapshot to its full logical size. That costs disk on every copy, and it destroys the sparseness later stages rely on to tell which parts of guest RAM actually hold anything.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(src, dst *os.File) (int64, error)

Copy copies the open handle src into the open handle dst, preserving holes where it can, and returns the number of logical bytes copied. Neither handle is closed, and both handles' offsets are clobbered. It exists for callers that must control how the endpoints are opened — e.g. a source opened before its directory entry could vanish, or a destination created with O_EXCL.

dst must be empty (freshly created): holes are never written, so any pre-existing destination bytes would show through them, silently corrupting the copy. A non-empty destination is rejected up front.

func CopyFile

func CopyFile(src, dst string) (int64, error)

CopyFile copies src to dst, preserving holes where it can, and returns the number of logical bytes copied. dst is created (truncated if it exists), like os.Create.

Types

This section is empty.

Jump to

Keyboard shortcuts

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