fsutil

package
v0.0.0-...-69999d2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureDir

func EnsureDir(p string) error

EnsureDir ensures a directory exists.

func EnsurePath

func EnsurePath(p string) error

EnsurePath ensures a directory exists, given a file path. This calls path.Dir(p)

func FileSize

func FileSize(path string) int64

FileSize returns the file size in bytes, or return 0 if there's an error calling os.Stat().

func Reader

func Reader(ctx context.Context, r io.Reader) io.Reader

Reader wraps an io.Reader with one that checks ctx.Done() on each Read call.

If ctx has a deadline and if r has a `SetReadDeadline(time.Time) error` method, then it is called with the deadline.

Imported from https://gist.github.com/dchapes/6c992bf3e943934462509338cd213e99

func Writer

func Writer(ctx context.Context, w io.Writer) io.Writer

Writer wraps an io.Writer with one that checks ctx.Done() on each Write call.

If ctx has a deadline and if w has a `SetWriteDeadline(time.Time) error` method, then it is called with the deadline.

Imported from https://gist.github.com/dchapes/6c992bf3e943934462509338cd213e99

Types

type Hostfile

type Hostfile struct {
	// The path relative to the "root" given to WalkFiles().
	Rel string
	// The absolute path of the file on the host.
	Abs string
	// Size in bytes.
	Size int64
	// LastModified time
	LastModified time.Time
}

Hostfile returns information about a file found by WalkFiles.

func WalkFiles

func WalkFiles(root string) ([]Hostfile, error)

WalkFiles recursively walks a directory, returning a list of files.

Jump to

Keyboard shortcuts

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