file

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

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

Copy copies a file from src to dst. It returns the number of bytes copied and/or an error.

func ExpandPath

func ExpandPath(path string) string

ExpandPath expands the ~ into to the setting of the $HOME variable.

func Move

func Move(src, dst string) error

Move moves a file from src to dest

Types

type AtomicWrite

type AtomicWrite struct {
	// contains filtered or unexported fields
}

AtomicWrite atomically writes files by using a temp file. When Close is called the temp file is closed and moved to its final destination.

func NewAtomicWrite

func NewAtomicWrite(dst string) *AtomicWrite

NewAtomicWrite creates a io.WriteCloser to atomically write files.

func (*AtomicWrite) Close

func (a *AtomicWrite) Close() error

Close closes the temporary file and moves to the destination

func (*AtomicWrite) Copy

func (a *AtomicWrite) Copy(rdr io.Reader) (written int64, err error)

Copy Reads until EOF or an error occurs. Data is written to the tempfile

func (*AtomicWrite) Write

func (a *AtomicWrite) Write(data []byte) (written int, err error)

Write writes bytes to the tempfile

type Info

type Info interface {
	Name() string       // base name of the file
	Size() int64        // length in bytes for regular files; system-dependent for others
	Mode() fs.FileMode  // file mode bits
	ModTime() time.Time // modification time
	IsDir() bool        // abbreviation for Mode().IsDir()
	Sys() interface{}   // underlying data source (can return nil)
	Path() string       // path to file
	Abs() string        // absolute path to file
	Exists() bool       // true if file exists
}

A Info describes a file and is returned by Stat.

func Stat

func Stat(path string) (Info, error)

Stat wrapper around stat

type Rename

type Rename func(oldpath string, newpath string) error

Rename mock os.Rename

var OsRename Rename = os.Rename

OsRename mocked os.Rename assignment

Jump to

Keyboard shortcuts

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