Documentation ¶
Overview ¶
Package vfs defines a generic file system interface commonly used by Kythe libraries.
Index ¶
- Variables
- func Create(ctx context.Context, path string) (io.WriteCloser, error)
- func Glob(ctx context.Context, glob string) ([]string, error)
- func MkdirAll(ctx context.Context, path string, mode os.FileMode) error
- func Open(ctx context.Context, path string) (io.ReadCloser, error)
- func ReadFile(ctx context.Context, filename string) ([]byte, error)
- func Remove(ctx context.Context, path string) error
- func Rename(ctx context.Context, oldPath, newPath string) error
- func Stat(ctx context.Context, path string) (os.FileInfo, error)
- type Interface
- type LocalFS
- func (LocalFS) Create(_ context.Context, path string) (io.WriteCloser, error)
- func (LocalFS) Glob(_ context.Context, glob string) ([]string, error)
- func (LocalFS) MkdirAll(_ context.Context, path string, mode os.FileMode) error
- func (LocalFS) Open(_ context.Context, path string) (io.ReadCloser, error)
- func (LocalFS) Remove(_ context.Context, path string) error
- func (LocalFS) Rename(_ context.Context, oldPath, newPath string) error
- func (LocalFS) Stat(_ context.Context, path string) (os.FileInfo, error)
- type Reader
- type UnsupportedWriter
- func (UnsupportedWriter) Create(_ context.Context, _ string) (io.WriteCloser, error)
- func (UnsupportedWriter) MkdirAll(_ context.Context, _ string, _ os.FileMode) error
- func (UnsupportedWriter) Remove(_ context.Context, _ string) error
- func (UnsupportedWriter) Rename(_ context.Context, _, _ string) error
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ErrNotSupported = errors.New("operation not supported")
ErrNotSupported is returned for all unsupported VFS operations.
Functions ¶
func MkdirAll ¶
MkdirAll recursively creates the specified directory path with the given permissions, using the Default VFS.
Types ¶
type Interface ¶
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.
type LocalFS ¶
type LocalFS struct{}
LocalFS implements the VFS interface using the standard Go library.
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 ¶
func (UnsupportedWriter) Create(_ context.Context, _ string) (io.WriteCloser, error)
Create implements part of Writer interface. It is not supported.
func (UnsupportedWriter) MkdirAll ¶
MkdirAll 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.