...

Package preallocate

Overview ▾

Package preallocate allocates disk space efficiently via syscall (on supported platforms and filesystems) or by writing null bytes.

Files opened with O_APPEND are not supported.

Constants

NullBufferSize determines the maximum size of NULL byte blocks written to files when falling back to WriteSeeker.

const NullBufferSize = 512 * 1024 // 512 KiB

func File

func File(file *os.File, size int64) error

File preallocates a file via syscall (when supported) or WriteSeeker.

func TempFile

func TempFile(dir string, pattern string, size int64) (*os.File, error)

TempFile preallocates a temporary file (see File and ioutil.TempFile).

func WriteSeeker

func WriteSeeker(w io.WriteSeeker, size int64) error

WriteSeeker preallocates an io.WriteSeeker by writing null bytes.