router

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: BSD-2-Clause Imports: 10 Imported by: 2

README

billy-router

GoDoc

This library provides a virtual billy.Filesystem backed by other filesystems. You create it with a root filesystem, and then mount/overlay other filesystems over it.

For example, you could use an in-memory tempfs for /tmp and use emptyfs to keep /var/empty empty:

func main() {
	root := osfs.New("/")
	r := router.New(root)
	r.Mount("/tmp", memfs.New())
	r.Mount("/var/empty", emptyfs.New())
}

Directories don't have to exist to be mounted on. In fact, any intermediate directory will implicitly be created (and removed when Umounted).

Documentation

Overview

Package router allows you to mount Billy.Filesystems over another.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

type Router struct {
	// contains filtered or unexported fields
}

func New

func New(root billy.Basic) *Router

New creates a new billy.Filesystem that forwards all calls to the given root filesystem. After this you can call Mount() to overlay other filesystems over it.

func (*Router) Capabilities

func (r *Router) Capabilities() billy.Capability

func (*Router) Chmod

func (r *Router) Chmod(p string, mode os.FileMode) error

func (*Router) Chown

func (r *Router) Chown(p string, uid, gid int) error

func (*Router) Chroot

func (r *Router) Chroot(p string) (billy.Filesystem, error)

func (*Router) Chtimes

func (r *Router) Chtimes(p string, atime, mtime time.Time) error

func (*Router) Create

func (r *Router) Create(p string) (billy.File, error)

func (*Router) Join

func (r *Router) Join(elem ...string) string

func (*Router) Lchown

func (r *Router) Lchown(p string, uid, gid int) error

func (*Router) Lstat

func (r *Router) Lstat(p string) (os.FileInfo, error)

func (*Router) MkdirAll

func (r *Router) MkdirAll(p string, perm os.FileMode) error

func (*Router) Mount

func (r *Router) Mount(p string, fs billy.Basic)

Mount the given filesystem at the given path. Any calls to inside that path will be sent to the given filesystem. Any intermediate directories up to your mountpoint are implicitly created.

func (*Router) Open

func (r *Router) Open(p string) (billy.File, error)

func (*Router) OpenFile

func (r *Router) OpenFile(p string, flag int, mode os.FileMode) (billy.File, error)

func (*Router) ReadDir

func (r *Router) ReadDir(p string) ([]os.FileInfo, error)
func (r *Router) Readlink(p string) (string, error)

func (*Router) Remove

func (r *Router) Remove(p string) error

func (*Router) Rename

func (r *Router) Rename(from, to string) error

func (*Router) Root

func (r *Router) Root() string

func (*Router) SetCrossFilesystemRenameCallback

func (r *Router) SetCrossFilesystemRenameCallback(f func(fromFS, toFS billy.Filesystem, fromPath, toPath string) error)

SetCrossFilesystemRenameCallback is called to provide an implementation of cross filesystem renaming. Renaming cross filesystem is impossible to implement correctly (atomicity can't be done through the billy.Filesystem API). However, many people will be okay with an imperfect implementation (like just copy+remove), so you can specify your own implementation. The default callback just returns an error.

func (*Router) Stat

func (r *Router) Stat(p string) (os.FileInfo, error)
func (r *Router) Symlink(target, link string) error

func (*Router) TempFile

func (r *Router) TempFile(dir, prefix string) (billy.File, error)

func (*Router) Umount

func (r *Router) Umount(p string)

Umount undoes a previous Mount() call. It panics if you umount something that wasn't mounted. Any implicit intermediate directories created by Mount() are cleaned up automatically.

Directories

Path Synopsis
Package emptyfs provides a read-only filesystem that always remains empty.
Package emptyfs provides a read-only filesystem that always remains empty.

Jump to

Keyboard shortcuts

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