file

package
v0.32.3 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OsFs

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

OsFs is the struct that defines the os filesystem singleton instance.

func NewOsFs

func NewOsFs() *OsFs

func (*OsFs) Chmod

func (o *OsFs) Chmod(filePath string, mode os.FileMode) error

Chmod is a wrapper around afero.Chmod that changes the file/folder permissions.

func (*OsFs) Create

func (o *OsFs) Create(path string) (afero.File, error)

Create is a wrapper around afero.Create that creates a file.

func (*OsFs) DownloadFile

func (o *OsFs) DownloadFile(ctx context.Context, filepath, url string, progressUpdater ui.ProgressUpdateFunc) error

DownloadFile will download url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory. We pass an io.TeeReader into Copy() to report progress on the download.

func (*OsFs) MkdirAll

func (o *OsFs) MkdirAll(path string, perm os.FileMode) error

MkdirAll is a wrapper around afero.Mkdirall that creates the full path directory tree.

func (*OsFs) Open

func (o *OsFs) Open(path string) (afero.File, error)

Open is a wrapper around afero.Open that opens a file.

func (*OsFs) Remove

func (o *OsFs) Remove(filePath string) error

Remove is a wrapper around afero.Remove that removes a file.

func (*OsFs) SetFSInstance

func (o *OsFs) SetFSInstance(fs afero.Fs)

SetFSInstance sets the FS instance. Should be only used for testing purpose.

func (*OsFs) Stat

func (o *OsFs) Stat(path string) (os.FileInfo, error)

Stat is a wrapper around afero.Stat that returns the FileInfo for the given path.

func (*OsFs) WalkPathTree

func (o *OsFs) WalkPathTree(path string, walker func(path string, info os.FileInfo, err error) error) error

WalkPathTree is a wrapper around afero.Walk that walks the file tree starting with the given path and calls the walker function for every object it finds.

Jump to

Keyboard shortcuts

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