vfs

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2015 License: Apache-2.0 Imports: 6 Imported by: 25

Documentation

Overview

Package vfs defines a generic file system interface commonly used by Kythe libraries.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSupported = errors.New("operation not supported")

ErrNotSupported is returned for all unsupported VFS operations.

Functions

func Create

func Create(ctx context.Context, path string) (io.WriteCloser, error)

Create creates a new file for writing, using the Default VFS.

func Glob

func Glob(ctx context.Context, glob string) ([]string, error)

Glob returns all the paths matching the specified glob pattern, using the Default VFS.

func MkdirAll

func MkdirAll(ctx context.Context, path string, mode os.FileMode) error

MkdirAll recursively creates the specified directory path with the given permissions, using the Default VFS.

func Open

func Open(ctx context.Context, path string) (io.ReadCloser, error)

Open opens an existing file for reading, using the Default VFS.

func ReadFile

func ReadFile(ctx context.Context, filename string) ([]byte, error)

ReadFile is the equivalent of ioutil.ReadFile using the Default VFS.

func Remove

func Remove(ctx context.Context, path string) error

Remove deletes the file specified by path, using the Default VFS.

func Rename

func Rename(ctx context.Context, oldPath, newPath string) error

Rename renames oldPath to newPath, using the Default VFS, overwriting newPath if it exists.

func Stat

func Stat(ctx context.Context, path string) (os.FileInfo, error)

Stat returns file status information for path, using the Default VFS.

Types

type Interface

type Interface interface {
	Reader
	Writer
}

Interface is a virtual file system interface for reading and writing files. It is used to wrap the normal os package functions so that other file storage implementations be used in lieu. For instance, there could be implementations for cloud storage back-ends or databases. Depending on the implementation, the Writer methods can be unsupported and always return ErrNotSupported.

var Default Interface = LocalFS{}

Default is the global default VFS used by Kythe libraries that wish to access the file system. This is usually the LocalFS and should only be changed in very specialized cases (i.e. don't change it).

type LocalFS

type LocalFS struct{}

LocalFS implements the VFS interface using the standard Go library.

func (LocalFS) Create

func (LocalFS) Create(_ context.Context, path string) (io.WriteCloser, error)

Create implements part of the VFS interface.

func (LocalFS) Glob

func (LocalFS) Glob(_ context.Context, glob string) ([]string, error)

Glob implements part of the VFS interface.

func (LocalFS) MkdirAll

func (LocalFS) MkdirAll(_ context.Context, path string, mode os.FileMode) error

MkdirAll implements part of the VFS interface.

func (LocalFS) Open

func (LocalFS) Open(_ context.Context, path string) (io.ReadCloser, error)

Open implements part of the VFS interface.

func (LocalFS) Remove

func (LocalFS) Remove(_ context.Context, path string) error

Remove implements part of the VFS interface.

func (LocalFS) Rename

func (LocalFS) Rename(_ context.Context, oldPath, newPath string) error

Rename implements part of the VFS interface.

func (LocalFS) Stat

func (LocalFS) Stat(_ context.Context, path string) (os.FileInfo, error)

Stat implements part of the VFS interface.

type Reader

type Reader interface {
	// Stat returns file status information for path, as os.Stat.
	Stat(ctx context.Context, path string) (os.FileInfo, error)

	// Open opens an existing file for reading, as os.Open.
	Open(ctx context.Context, path string) (io.ReadCloser, error)

	// Glob returns all the paths matching the specified glob pattern, as
	// filepath.Glob.
	Glob(ctx context.Context, glob string) ([]string, error)
}

Reader is a virtual file system interface for reading files.

type UnsupportedWriter

type UnsupportedWriter struct{ Reader }

UnsupportedWriter implements the Writer interface methods with stubs that always return ErrNotSupported.

func (UnsupportedWriter) Create

Create implements part of Writer interface. It is not supported.

func (UnsupportedWriter) MkdirAll

MkdirAll implements part of Writer interface. It is not supported.

func (UnsupportedWriter) Remove

Remove implements part of Writer interface. It is not supported.

func (UnsupportedWriter) Rename

func (UnsupportedWriter) Rename(_ context.Context, _, _ string) error

Rename implements part of Writer interface. It is not supported.

type Writer

type Writer interface {
	// MkdirAll recursively creates the specified directory path with the given
	// permissions, as os.MkdirAll.
	MkdirAll(ctx context.Context, path string, mode os.FileMode) error

	// Create creates a new file for writing, as os.Create.
	Create(ctx context.Context, path string) (io.WriteCloser, error)

	// Rename renames oldPath to newPath, as os.Rename, overwriting newPath if
	// it exists.
	Rename(ctx context.Context, oldPath, newPath string) error

	// Remove deletes the file specified by path, as os.Remove.
	Remove(ctx context.Context, path string) error
}

Writer is a virtual file system interface for writing files.

Directories

Path Synopsis
Package gcs implements an indexpack VFS backed by Google Cloud Storage.
Package gcs implements an indexpack VFS backed by Google Cloud Storage.
Package zip defines a VFS implementation that understands a zip archive as an isolated, read-only file system.
Package zip defines a VFS implementation that understands a zip archive as an isolated, read-only file system.

Jump to

Keyboard shortcuts

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