compositefs

package
v0.0.0-...-113f59a Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package compositefs provides a webdav.FileSystem that is composi

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Child

type Child struct {
	// Name is the name of the child
	Name string
	// FS is the child's FileSystem
	FS webdav.FileSystem
	// Available is a function indicating whether or not the child is currently
	// available.
	Available func() bool
}

Child is a child filesystem of a CompositeFileSystem

type CompositeFileSystem

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

CompositeFileSystem is a webdav.FileSystem that is composed of multiple child webdav.FileSystems. Each child is identified by a name and appears as a folder within the root of the CompositeFileSystem, with the children sorted lexicographically by name.

Children in a CompositeFileSystem can only be added or removed via calls to the AddChild and RemoveChild methods, they cannot be added via operations on the webdav.FileSystem interface like filesystem.Mkdir or filesystem.OpenFile. In other words, the root of the CompositeFileSystem acts as read-only, not permitting the addition, removal or renaming of folders.

Rename is only supported within a single child. Renaming across children is not supported, as it wouldn't be possible to perform it atomically.

func New

func New(opts Options) *CompositeFileSystem

New constructs a CompositeFileSystem that logs using the given logf.

func (*CompositeFileSystem) AddChild

func (cfs *CompositeFileSystem) AddChild(child *Child)

AddChild ads a single child with the given name, replacing any existing child with the same name.

func (*CompositeFileSystem) Close

func (cfs *CompositeFileSystem) Close() error

func (*CompositeFileSystem) GetChild

func (cfs *CompositeFileSystem) GetChild(name string) (webdav.FileSystem, bool)

GetChild returns the child with the given name and a boolean indicating whether or not it was found.

func (*CompositeFileSystem) Mkdir

func (cfs *CompositeFileSystem) Mkdir(ctx context.Context, name string, perm os.FileMode) error

Mkdir implements webdav.Filesystem. The root of this file system is read-only, so any attempts to make directories within the root will fail with os.ErrPermission. Attempts to make directories within one of the child filesystems will be handled by the respective child.

func (*CompositeFileSystem) OpenFile

func (cfs *CompositeFileSystem) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (webdav.File, error)

OpenFile implements interface webdav.Filesystem.

func (*CompositeFileSystem) RemoveAll

func (cfs *CompositeFileSystem) RemoveAll(ctx context.Context, name string) error

RemoveAll implements webdav.File. The root of this file system is read-only, so attempting to call RemoveAll on the root will fail with os.ErrPermission. RemoveAll within a child will be handled by the respective child.

func (*CompositeFileSystem) RemoveChild

func (cfs *CompositeFileSystem) RemoveChild(name string)

RemoveChild removes the child with the given name, if it exists.

func (*CompositeFileSystem) Rename

func (cfs *CompositeFileSystem) Rename(ctx context.Context, oldName, newName string) error

Rename implements interface webdav.FileSystem. The root of this file system is read-only, so any attempt to rename a child within the root of this filesystem will fail with os.ErrPermission. Renaming across children is not supported and will fail with os.ErrPermission. Renaming within a child will be handled by the respective child.

func (*CompositeFileSystem) SetChildren

func (cfs *CompositeFileSystem) SetChildren(children ...*Child)

SetChildren replaces the entire existing set of children with the given ones.

func (*CompositeFileSystem) Stat

func (cfs *CompositeFileSystem) Stat(ctx context.Context, name string) (fs.FileInfo, error)

Stat implements webdav.FileSystem.

type Options

type Options struct {
	// Logf specifies a logging function to use
	Logf logger.Logf
	// StatChildren, if true, causes the CompositeFileSystem to stat its child
	// folders when generating a root directory listing. This gives more
	// accurate information but increases latency.
	StatChildren bool
	// Clock, if specified, determines the current time. If not specified, we
	// default to time.Now().
	Clock tstime.Clock
}

Options specifies options for configuring a CompositeFileSystem.

Jump to

Keyboard shortcuts

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