shared

package
v1.62.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package shared contains types and functions shared by different tailfs packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base added in v1.62.0

func Base(p string) string

Base is like path.Base except that it returns "" for the root folder

func CleanAndSplit

func CleanAndSplit(p string) []string

CleanAndSplit cleans the provided path p and splits it into its constituent parts. This is different from path.Split which just splits a path into prefix and suffix.

func IsRoot

func IsRoot(p string) bool

IsRoot determines whether a given path p is the root path, defined as either empty or "/".

func Join

func Join(parts ...string) string

Join behaves like path.Join() but also includes a leading slash.

Types

type DirFile

type DirFile struct {
	// Info provides the fs.FileInfo for this directory
	Info fs.FileInfo
	// LoadChildren is used to load the fs.FileInfos for this directory's
	// children. It is called at most once in order to support listing
	// children.
	LoadChildren func() ([]fs.FileInfo, error)
	// contains filtered or unexported fields
}

DirFile implements webdav.File for a virtual directory. It mimics the behavior of an os.File that is pointing at a real directory.

func (*DirFile) Close

func (d *DirFile) Close() error

Close implements interface webdav.File. It does nothing and never returns an error.

func (*DirFile) Read

func (d *DirFile) Read(b []byte) (int, error)

Read implements interface webdav.File. As this is a directory, it always fails with an fs.PathError.

func (*DirFile) Readdir

func (d *DirFile) Readdir(count int) ([]fs.FileInfo, error)

Readdir implements interface webdav.File. It lazily loads information about children when it is called.

func (*DirFile) Seek

func (d *DirFile) Seek(offset int64, whence int) (int64, error)

Seek implements interface webdav.File. As this is a directory, it always fails with an fs.PathError.

func (*DirFile) Stat

func (d *DirFile) Stat() (fs.FileInfo, error)

Stat implements interface webdav.File.

func (*DirFile) Write

func (d *DirFile) Write(b []byte) (int, error)

Write implements interface webdav.File. As this is a directory, it always fails with an fs.PathError.

type StaticFileInfo

type StaticFileInfo struct {
	// Named controls Name()
	Named string
	// Sized controls Size()
	Sized int64
	// Moded controls Mode()
	Moded os.FileMode
	// BirthedTime controls BirthTime()
	BirthedTime time.Time
	// BirthedTimeErr stores any error encountered when trying to get BirthTime
	BirthedTimeErr error
	// ModdedTime controls ModTime()
	ModdedTime time.Time
	// Dir controls IsDir()
	Dir bool
}

StaticFileInfo implements a static fs.FileInfo

func ReadOnlyDirInfo

func ReadOnlyDirInfo(name string, ts time.Time) *StaticFileInfo

ReadOnlyDirInfo returns a static fs.FileInfo for a read-only directory

func RenamedFileInfo

func RenamedFileInfo(ctx context.Context, name string, fi fs.FileInfo) *StaticFileInfo

func (*StaticFileInfo) BirthTime

func (fi *StaticFileInfo) BirthTime(_ context.Context) (time.Time, error)

BirthTime implements webdav.BirthTimer

func (*StaticFileInfo) IsDir

func (fi *StaticFileInfo) IsDir() bool

func (*StaticFileInfo) ModTime

func (fi *StaticFileInfo) ModTime() time.Time

func (*StaticFileInfo) Mode

func (fi *StaticFileInfo) Mode() os.FileMode

func (*StaticFileInfo) Name

func (fi *StaticFileInfo) Name() string

func (*StaticFileInfo) Size

func (fi *StaticFileInfo) Size() int64

func (*StaticFileInfo) Sys

func (fi *StaticFileInfo) Sys() any

Jump to

Keyboard shortcuts

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