dirfs

package
v1.64.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package dirfs provides a webdav.FileSystem that looks like a read-only directory containing only subdirectories.

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

	// Available is a function indicating whether or not the child is currently
	// available. Unavailable children are excluded from the FS's directory
	// listing. Available must be safe for concurrent use.
	Available func() bool
}

Child is subdirectory of an FS.

type FS

type FS struct {
	// Children configures the full set of children of this FS.
	Children []*Child

	// Clock, if given, will cause this FS to use Clock.now() as the current
	// time.
	Clock tstime.Clock

	// StaticRoot, if given, will insert the given name as a static root into
	// every path.
	StaticRoot string
}

FS is a read-only webdav.FileSystem that is composed of multiple child folders.

When listing the contents of this FileSystem's root directory, children will be ordered in the order they're given to the FS.

Children in an FS cannot be added, removed or renamed via operations on the webdav.FileSystem interface like filesystem.Mkdir or filesystem.OpenFile.

Any attempts to perform operations on paths inside of children will result in a panic, as these are not expected to be performed on this FS.

An FS an optionally have a StaticRoot, which will insert a folder with that StaticRoot into the tree, like this:

-- <StaticRoot> ----- <Child> ----- <Child>

func (*FS) Mkdir

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

Mkdir implements webdav.FileSystem. All attempts to Mkdir a directory that already exists will succeed. All other attempts will fail with os.ErrPermission.

func (*FS) OpenFile

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

OpenFile implements interface webdav.Filesystem.

func (*FS) RemoveAll

func (dfs *FS) RemoveAll(ctx context.Context, name string) error

RemoveAll implements webdav.File. No removal is supported and this always returns os.ErrPermission.

func (*FS) Rename

func (dfs *FS) Rename(ctx context.Context, oldName, newName string) error

Rename implements interface webdav.FileSystem. No renaming is supported and this always returns os.ErrPermission.

func (*FS) Stat

func (dfs *FS) Stat(ctx context.Context, name string) (fs.FileInfo, error)

Stat implements webdav.FileSystem.

Jump to

Keyboard shortcuts

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