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 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 FileReader
- type Interface
- type LocalFS
- func (LocalFS) Create(_ context.Context, path string) (io.WriteCloser, error)
- func (LocalFS) CreateTempFile(_ context.Context, dir, pattern string) (TempFile, 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) (FileReader, 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 TempFile
- type UnseekableFileReader
- type UnsupportedWriter
- func (UnsupportedWriter) Create(_ context.Context, _ string) (io.WriteCloser, error)
- func (UnsupportedWriter) CreateTempFile(_ context.Context, dir, pattern string) (TempFile, 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 FileReader ¶ added in v0.0.31
FileReader composes interfaces from io that readable files from the vfs must implement.
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.
func (LocalFS) CreateTempFile ¶ added in v0.0.31
CreateTempFile 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) (FileReader, 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 TempFile ¶ added in v0.0.31
type TempFile interface { io.WriteCloser Name() string }
TempFile composes io.WriteCloser and access to its "name". For file-based implementations, this should be the full path to the full.
type UnseekableFileReader ¶ added in v0.0.31
type UnseekableFileReader struct {
io.ReadCloser
}
UnseekableFileReader implements the io.Seeker and io.ReaderAt at portion of FileReader with stubs that always return ErrNotSupported.
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) CreateTempFile ¶ added in v0.0.31
CreateTempFile implements part of the VFS 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) // CreateTempFile creates a new temp file returning a TempFile. The // name of the file is constructed from dir pattern and per // ioutil.TempFile: // The filename is generated by taking pattern and adding a random // string to the end. If pattern includes a "*", the random string // replaces the last "*". If dir is the empty string, CreateTempFile // uses an unspecified default directory. CreateTempFile(ctx context.Context, dir, pattern string) (TempFile, 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.