fs

package
v1.13.12 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(destFile string, src http.File) (err error)

Download downloads from a http.File.

func File

func File(name string, r ContentReader) http.File

File implements a http.File by a ContentReader which may implement optional interface{ ModTime() time.Time } and io.Closer.

func Files

func Files(files ...string) http.FileSystem

Files implements a http.FileSystem by a list of file name and content file.

func FilesWithContent

func FilesWithContent(files ...string) http.FileSystem

FilesWithContent implements a http.FileSystem by a list of file name and content.

func HttpFile

func HttpFile(name string, resp *http.Response) http.File

HttpFile implements a http.File by a http.Response object.

func LocalCheck

func LocalCheck(fsys http.FileSystem) (string, bool)

LocalCheck checks a FileSystem is local or not.

func Parent

func Parent(parentDir string, fs http.FileSystem) http.FileSystem

Parent returns a FileSystem that fs is located in the `parentDir` directory.

func Plugins

func Plugins(fs http.FileSystem, plugins ...interface{}) http.FileSystem

Plugins implements a filesystem with plugins by specified (ext string, plugin Plugin) pairs.

func Root

func Root() http.FileSystem

Root implements a http.FileSystem that only have a root directory.

func SequenceFile

func SequenceFile(name string, body io.ReadCloser) http.File

SequenceFile implements a http.File by a io.ReadCloser object.

func Sub

func Sub(fs http.FileSystem, subDir string) http.FileSystem

Sub returns a FileSystem corresponding to the subtree rooted at fs's subDir.

func Union

func Union(fs ...http.FileSystem) http.FileSystem

Union merge a list of http.FileSystem into a union http.FileSystem object.

func Unseekable

func Unseekable(file http.File) io.ReadCloser

Unseekable convert a http.File into a io.ReadCloser object without io.Seeker. Note you should stop using the origin http.File object to read data. This method is used to reduce unnecessary memory usage.

func WithTracker

func WithTracker(fs http.FileSystem, trackerInit interface{}, exts ...string) http.FileSystem

WithTracker implements a http.FileSystem by pactching large file access like git lfs. Here trackerInit should be (urlBase string) or (httpfs *fs.HttpFS).

Types

type ContentReader

type ContentReader interface {
	io.Reader
	io.Seeker
	Size() int64
}

type DirInfo

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

DirInfo describes a single directory in an file system. It implements fs.FileInfo and io.Closer and Stat().

func NewDirInfo

func NewDirInfo(name string) *DirInfo

NewDirInfo creates a DirInfo that describes a single directory in an file system. It implements fs.FileInfo and io.Closer and Stat().

func (*DirInfo) Close

func (p *DirInfo) Close() error

io.Closer

func (*DirInfo) IsDir

func (p *DirInfo) IsDir() bool

for fs.FileInfo, fs.DirEntry

func (*DirInfo) ModTime

func (p *DirInfo) ModTime() time.Time

for fs.FileInfo

func (*DirInfo) Mode

func (p *DirInfo) Mode() fs.FileMode

for fs.FileInfo

func (*DirInfo) Name

func (p *DirInfo) Name() string

for fs.FileInfo, fs.DirEntry

func (*DirInfo) Size

func (p *DirInfo) Size() int64

for fs.FileInfo

func (*DirInfo) Stat

func (p *DirInfo) Stat() (fs.FileInfo, error)

for fs.File, http.File

func (*DirInfo) Sys

func (p *DirInfo) Sys() interface{}

for fs.FileInfo

type FileInfo

type FileInfo struct {
	Mtime time.Time
	// contains filtered or unexported fields
}

FileInfo describes a single file in an file system. It implements fs.FileInfo and fs.DirEntry.

func NewFileInfo

func NewFileInfo(name string, size int64) *FileInfo

NewFileInfo creates a FileInfo that describes a single file in an file system. It implements fs.FileInfo and fs.DirEntry.

func (*FileInfo) Info

func (p *FileInfo) Info() (fs.FileInfo, error)

fs.DirEntry

func (*FileInfo) IsDir

func (p *FileInfo) IsDir() bool

for fs.FileInfo, fs.DirEntry

func (*FileInfo) ModTime

func (p *FileInfo) ModTime() time.Time

for fs.FileInfo

func (*FileInfo) Mode

func (p *FileInfo) Mode() fs.FileMode

for fs.FileInfo

func (*FileInfo) Name

func (p *FileInfo) Name() string

for fs.FileInfo, fs.DirEntry

func (*FileInfo) Size

func (p *FileInfo) Size() int64

for fs.FileInfo

func (*FileInfo) Sys

func (p *FileInfo) Sys() interface{}

for fs.FileInfo

func (*FileInfo) Type

func (p *FileInfo) Type() fs.FileMode

fs.DirEntry

type HttpFS

type HttpFS struct {
	HttpOpener
	// contains filtered or unexported fields
}

func Http

func Http(urlBase string, ctx ...context.Context) *HttpFS

Http creates a HttpFS which implements a http.FileSystem by http.Get join(urlBase, name).

func (*HttpFS) Open

func (p *HttpFS) Open(name string) (file http.File, err error)

Open is required by http.File.

func (HttpFS) With

func (fs HttpFS) With(client *http.Client, header http.Header) *HttpFS

With specifies http.Client and http.Header used by http.Get.

type HttpOpener

type HttpOpener struct {
	Client *http.Client
	Header http.Header
}

func (*HttpOpener) Open

func (p *HttpOpener) Open(ctx context.Context, url string) (file http.File, err error)

Open opens a http.File from an url.

type Plugin

type Plugin = func(fs http.FileSystem, name string) (file http.File, err error)

Directories

Path Synopsis
dir
lfs

Jump to

Keyboard shortcuts

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