fileio

package
v0.0.0-...-3a238e9 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2016 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignedBuffer

func AlignedBuffer(size int, align int) ([]byte, error)

AlignedBuffer allocates aligned buffer.

Allocate a buffer of at least size bytes, aligned to align bytes.

size and align must be multiple of 512 bytes.

Examples:

AlignedBuffer(1048576, 4096)

func OpenFile

func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)

OpenFile opens a file with direct I/O enabled.

Write and read to the file must use AlignedBuffer.

func Receive

func Receive(path string, reader io.Reader, size int64, offset int64, progress Progress) (received int64, err error)

Receive copies size bytes from reader to path, staring at offset.

Todo:

  • Check the option of Operation struct keeping the current progress, like the Python version. Can be useful when we need to add cancling support.
  • There are too many parameters, would be nice to accept options struct instead.

Types

type Progress

type Progress interface {
	Set(value int64)
}

Progress is an interface for reporting operation progress.

Jump to

Keyboard shortcuts

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