fsys

package
v0.0.0-...-5d27ecb Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File interface {
	io.Reader
	io.Writer
	io.Closer

	// Name returns the name of the file
	Name() string

	// Size returns the size of the file
	Size() int64

	// Sync attempts to sync the file with the underlying storage or errors if it
	// can't not succeed.
	Sync() error
}

File is an abstraction for reading, writing and also closing a file. These interfaces already exist, it's just a matter of composing them to be more usable by other components.

type FileSystem

type FileSystem interface {

	// Create takes a path, creates the file and then returns a File back that
	// can be used. This returns an error if the file can not be created in
	// some way.
	Create(string) (File, error)

	// Open takes a path, opens a potential file and then returns a File if
	// that file exists, otherwise it returns an error if the file wasn't found.
	Open(string) (File, error)

	// OpenFile takes a path, opens a potential file and then returns a File if
	// that file exists, otherwise it returns an error if the file wasn't found.
	OpenFile(path string, flag int, perm os.FileMode) (File, error)

	// Exists takes a path and checks to see if the potential file exists or
	// not.
	// Note: If there is an error trying to read that file, it will return false
	// even if the file already exists.
	Exists(string) bool

	// Remove takes a path and attempts to remove the file supplied.
	Remove(string) error
}

FileSystem is an abstraction over the native filesystem

type LocalFile

type LocalFile struct {
	*os.File
	io.Reader
	io.Closer
}

LocalFile is an abstraction for reading, writing and also closing a file.

func (LocalFile) Close

func (f LocalFile) Close() error

func (LocalFile) Read

func (f LocalFile) Read(p []byte) (int, error)

func (LocalFile) Size

func (f LocalFile) Size() int64

Size returns the size of the file

type LocalFileSystem

type LocalFileSystem struct{}

func NewLocalFileSystem

func NewLocalFileSystem() LocalFileSystem

NewLocalFileSystem yields a local disk filesystem.

func (LocalFileSystem) Create

func (LocalFileSystem) Create(path string) (File, error)

Create takes a path, creates the file and then returns a File back that can be used. This returns an error if the file can not be created in some way.

func (LocalFileSystem) Exists

func (LocalFileSystem) Exists(path string) bool

Exists takes a path and checks to see if the potential file exists or not. Note: If there is an error trying to read that file, it will return false even if the file already exists.

func (LocalFileSystem) Open

func (fs LocalFileSystem) Open(path string) (File, error)

Open takes a path, opens a potential file and then returns a File if that file exists, otherwise it returns an error if the file wasn't found.

func (LocalFileSystem) OpenFile

func (fs LocalFileSystem) OpenFile(path string, flag int, perm os.FileMode) (File, error)

OpenFile takes a path, opens a potential file and then returns a File if that file exists, otherwise it returns an error if the file wasn't found.

func (LocalFileSystem) Remove

func (LocalFileSystem) Remove(path string) error

Remove takes a path, removes a potential file, if no file doesn't exist it will return not found.

type Releaser

type Releaser interface {

	// Release given lock or returns error upon failure.
	Release() error
}

Releaser is returned by Lock calls.

Jump to

Keyboard shortcuts

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