filesystem

package
v0.0.0-...-6ed8234 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package filesystem contains types and methods for interacting with the underlying file system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	Name        string
	Size        int64
	IsDirectory bool
	ModTime     time.Time
}

The FileInfo struct contains information on a file

type FileReader

type FileReader interface {
	io.ReadCloser
}

The FileReader interface describes files that can be read from

type FileSystem

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

The FileSystem type contains methods for manipulating files on the host system.

func New

func New(root string) *FileSystem

New creates a new FileSystem instance that works on the given root directory path.

func (*FileSystem) Clear

func (fs *FileSystem) Clear() error

Clear all files from the file system

func (*FileSystem) Copy

func (fs *FileSystem) Copy(src, dest string) error

Copy a file from one location to another. Returns an error if a file already exists at the destination.

func (*FileSystem) Delete

func (fs *FileSystem) Delete(name string) error

Delete a file from the system.

func (*FileSystem) List

func (fs *FileSystem) List(name string) ([]*FileInfo, error)

List all files within a directory

func (*FileSystem) Move

func (fs *FileSystem) Move(src, dest string) error

Move a file from one location to another.

func (*FileSystem) Reader

func (fs *FileSystem) Reader(name string) (FileReader, error)

Reader opens a new reader for the given file.

func (*FileSystem) Stat

func (fs *FileSystem) Stat(name string) (*FileInfo, error)

Stat returns info about a file from the filesystem. Returns an error if it does not exist.

func (*FileSystem) Walk

func (fs *FileSystem) Walk(loc string, fn WalkFunc) error

Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links.

func (*FileSystem) Writer

func (fs *FileSystem) Writer(name string) (FileWriter, error)

Writer creates a new writer for the given file, if it does not exist, the file will be created.

type FileWriter

type FileWriter interface {
	io.WriteCloser
	io.WriterAt
}

The FileWriter interface describes files that can be written to

type WalkFunc

type WalkFunc func(path string, info *FileInfo) error

WalkFunc is a function passed to the filesystem's walk function and is invoked for each file in the system.

Jump to

Keyboard shortcuts

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