rwvfs

package module
v0.0.0-...-6e706b4 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2014 License: BSD-3-Clause Imports: 12 Imported by: 0

README

rwvfs

Package rwvfs augments vfs to support write operations.

Build Status

TODO

  • Add corresponding implementations of rwvfs.FileSystem for mapfs and zipfs

Documentation

Overview

Package rwvfs augments vfs to support write operations.

Index

Constants

This section is empty.

Variables

View Source
var ErrReadOnly = errors.New("read-only VFS")

ErrReadOnly occurs when a write method (Create, Mkdir, Remove) is called on a read-only VFS (i.e., one created by ReadOnly).

Functions

func Glob

func Glob(wfs WalkableFileSystem, prefix, pattern string) (matches []string, err error)

Glob returns the names of all files under prefix matching pattern or nil if there is no matching file. The syntax of patterns is the same as in path/filepath.Match.

func MkdirAll

func MkdirAll(fs FileSystem, path string) error

MkdirAll creates a directory named path, along with any necessary parents. If path is already a directory, MkdirAll does nothing and returns nil.

Types

type FileSystem

type FileSystem interface {
	vfs.FileSystem

	// Create creates the named file, truncating it if it already exists.
	Create(path string) (io.WriteCloser, error)

	// Mkdir creates a new directory. If name is already a directory, Mkdir
	// returns an error (that can be detected using os.IsExist).
	Mkdir(name string) error

	// Remove removes the named file or directory.
	Remove(name string) error
}

func Map

func Map(m map[string]string) FileSystem

Map returns a new FileSystem from the provided map. Map keys should be forward slash-separated pathnames and not contain a leading slash.

func OS

func OS(root string) FileSystem

OS returns an implementation of FileSystem reading from the tree rooted at root.

func OSPerm

func OSPerm(root string, filePerm, dirPerm os.FileMode) FileSystem

func ReadOnly

func ReadOnly(fs vfs.FileSystem) FileSystem

ReadOnly returns a FileSystem whose write methods (Create, Mkdir, Remove) return errors. All other methods pass through to the read-only VFS.

func Sub

func Sub(fs FileSystem, prefix string) FileSystem

Sub returns an implementation of FileSystem mounted at prefix on the underlying fs. If fs doesn't have an existing directory at prefix, you can can call Mkdir("/") on the new filesystem to create it.

type WalkableFileSystem

type WalkableFileSystem interface {
	FileSystem
	Join(elem ...string) string
}

func Walkable

func Walkable(fs FileSystem) WalkableFileSystem

Walkable creates a walkable VFS by wrapping fs.

Jump to

Keyboard shortcuts

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