Documentation
¶
Overview ¶
Package gosparse provides cross-platform support for sparse files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PunchHole ¶
PunchHole deallocates a range of a file. The arguments fd, offset, and size are the file descriptor, byte offset, and byte size of the range to deallocate.
The range [offset offset+size) is zeroed out, and deallocated if possible (whether deallocation occurs depends on the OS, filesystem, and file type). For example, on Windows, the range is deallocated only if the file is sparse.
This is a cross-platform implementation that uses build tags to select the correct underlying system call.
func PunchHoles ¶
PunchHoles performs multiple punch hole operations.
All holes are processed, and any errors encountered are collected and returned as a single error at the end.
Types ¶
type Hole ¶
type Hole struct {
Fd int // File descriptor
Offset int64 // Byte offset of the hole
Size int64 // Size of the hole in bytes
}
func OptimizeHoles ¶
OptimizeHoles merges any overlapping or contiguous holes contained in the slice, so that the smallest possible number of PunchHole operations is needed.
OptimizeHoles may modify the contents of the slice.