localfs

package
v0.0.0-...-7139df7 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 13 Imported by: 5

README

Package cloudeng.io/file/localfs

import cloudeng.io/file/localfs

Constants

DefaultLargeFileBlockSize
DefaultLargeFileBlockSize = 1024 * 1024 * 16 // Default block size is 16 MiB.


Functions

Func NewLevelScanner
func NewLevelScanner(path string, openwait time.Duration) filewalk.LevelScanner

Types

Type LargeFile
type LargeFile struct {
	// contains filtered or unexported fields
}

LargeFile is a wrapper around a file that supports reading large files in blocks. It implements the largefile.Reader interface.

Functions
func NewLargeFile(file *os.File, blockSize int, digest digests.Hash) (*LargeFile, error)

NewLargeFile creates a new LargeFile instance that wraps the provided file and uses the specified block size for reading. The supplied digest is simply returned by the Digest() method and is not used to validate the file's contents directly.

Methods
func (lf *LargeFile) ContentLengthAndBlockSize() (int64, int)

ContentLengthAndBlockSize implements largefile.Reader.

func (lf *LargeFile) Digest() digests.Hash

Digest implements largefile.Reader.

func (lf *LargeFile) GetReader(_ context.Context, from, _ int64) (io.ReadCloser, largefile.RetryResponse, error)

GetReader implements largefile.Reader.

func (lf *LargeFile) Name() string

Name implements largefile.Reader.

Type Option
type Option func(o *options)
Functions
func WithScannerOpenWait(d time.Duration) Option

WithScannerOpenWait configures the amount of time to wait for the scanner to open a file before timing out. If zero then no timeout is applied and open is called directly.

Type R
type R struct {
	*T
	// contains filtered or unexported fields
}

R represents a local filesystem tree that is rooted at a specified directory.

Functions
func NewRoot(root string, opts ...Option) *R

NewRoot returns an instance of file.FS that provides access to the local filesystem tree rooted at the specified directory.

Methods
func (f *R) Base(path string) string
func (f *R) Delete(ctx context.Context, path string) error
func (f *R) DeleteAll(ctx context.Context, path string) error
func (f *R) EnsurePrefix(ctx context.Context, path string, perm fs.FileMode) error
func (f *R) Get(ctx context.Context, path string) ([]byte, error)
func (f *R) IsNotExist(err error) bool
func (f *R) IsPermissionError(err error) bool
func (f *R) Join(components ...string) string
func (f *R) LevelScanner(prefix string) filewalk.LevelScanner
func (f *R) Lstat(ctx context.Context, path string) (file.Info, error)
func (f *R) Open(name string) (fs.File, error)
func (f *R) OpenCtx(ctx context.Context, name string) (fs.File, error)
func (f *R) Put(ctx context.Context, path string, perm fs.FileMode, data []byte) error
func (f *R) ReadFile(name string) ([]byte, error)
func (f *R) ReadFileCtx(ctx context.Context, name string) ([]byte, error)
func (f *R) Readlink(ctx context.Context, path string) (string, error)
func (f *R) Scheme() string
func (f *R) Stat(ctx context.Context, path string) (file.Info, error)
func (f *R) SysXAttr(existing any, merge file.XAttr) any
func (f *R) WriteFile(name string, data []byte, perm fs.FileMode) error
func (f *R) WriteFileCtx(ctx context.Context, name string, data []byte, perm fs.FileMode) error
func (f *R) XAttr(ctx context.Context, name string, info file.Info) (file.XAttr, error)
Type T
type T struct {
	// contains filtered or unexported fields
}

T represents the local filesystem. It implements FS, ObjectFS and filewalk.FS

Functions
func New(opts ...Option) *T

New returns an instance of file.FS that provides access to the local filesystem.

Methods
func (f *T) Base(path string) string
func (f *T) Delete(_ context.Context, path string) error
func (f *T) DeleteAll(_ context.Context, path string) error
func (f *T) EnsurePrefix(_ context.Context, path string, perm fs.FileMode) error
func (f *T) Get(_ context.Context, path string) ([]byte, error)
func (f *T) IsNotExist(err error) bool
func (f *T) IsPermissionError(err error) bool
func (f *T) Join(components ...string) string
func (f *T) LevelScanner(prefix string) filewalk.LevelScanner
func (f *T) Lstat(_ context.Context, path string) (file.Info, error)
func (f *T) Open(name string) (fs.File, error)
func (f *T) OpenCtx(_ context.Context, name string) (fs.File, error)
func (f *T) Put(_ context.Context, path string, perm fs.FileMode, data []byte) error
func (f *T) ReadFile(name string) ([]byte, error)
func (f *T) ReadFileCtx(_ context.Context, name string) ([]byte, error)
func (f *T) Readlink(_ context.Context, path string) (string, error)
func (f *T) Scheme() string
func (f *T) Stat(_ context.Context, path string) (file.Info, error)
func (f *T) SysXAttr(existing any, merge file.XAttr) any
func (f *T) WriteFile(name string, data []byte, perm fs.FileMode) error
func (f *T) WriteFileCtx(_ context.Context, name string, data []byte, perm fs.FileMode) error
func (f *T) XAttr(_ context.Context, name string, info file.Info) (file.XAttr, error)

Documentation

Index

Constants

View Source
const DefaultLargeFileBlockSize = 1024 * 1024 * 16 // Default block size is 16 MiB.

Variables

This section is empty.

Functions

func NewLevelScanner

func NewLevelScanner(path string, openwait time.Duration) filewalk.LevelScanner

Types

type LargeFile

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

LargeFile is a wrapper around a file that supports reading large files in blocks. It implements the largefile.Reader interface.

func NewLargeFile

func NewLargeFile(file *os.File, blockSize int, digest digests.Hash) (*LargeFile, error)

NewLargeFile creates a new LargeFile instance that wraps the provided file and uses the specified block size for reading. The supplied digest is simply returned by the Digest() method and is not used to validate the file's contents directly.

func (*LargeFile) ContentLengthAndBlockSize

func (lf *LargeFile) ContentLengthAndBlockSize() (int64, int)

ContentLengthAndBlockSize implements largefile.Reader.

func (*LargeFile) Digest

func (lf *LargeFile) Digest() digests.Hash

Digest implements largefile.Reader.

func (*LargeFile) GetReader

func (lf *LargeFile) GetReader(_ context.Context, from, _ int64) (io.ReadCloser, largefile.RetryResponse, error)

GetReader implements largefile.Reader.

func (*LargeFile) Name

func (lf *LargeFile) Name() string

Name implements largefile.Reader.

type Option

type Option func(o *options)

func WithScannerOpenWait

func WithScannerOpenWait(d time.Duration) Option

WithScannerOpenWait configures the amount of time to wait for the scanner to open a file before timing out. If zero then no timeout is applied and open is called directly.

type R

type R struct {
	*T
	// contains filtered or unexported fields
}

R represents a local filesystem tree that is rooted at a specified directory.

func NewRoot

func NewRoot(root string, opts ...Option) *R

NewRoot returns an instance of file.FS that provides access to the local filesystem tree rooted at the specified directory.

func (*R) Base

func (f *R) Base(path string) string

func (*R) Delete

func (f *R) Delete(ctx context.Context, path string) error

func (*R) DeleteAll

func (f *R) DeleteAll(ctx context.Context, path string) error

func (*R) EnsurePrefix

func (f *R) EnsurePrefix(ctx context.Context, path string, perm fs.FileMode) error

func (*R) Get

func (f *R) Get(ctx context.Context, path string) ([]byte, error)

func (*R) IsNotExist

func (f *R) IsNotExist(err error) bool

func (*R) IsPermissionError

func (f *R) IsPermissionError(err error) bool

func (*R) Join

func (f *R) Join(components ...string) string

func (*R) LevelScanner

func (f *R) LevelScanner(prefix string) filewalk.LevelScanner

func (*R) Lstat

func (f *R) Lstat(ctx context.Context, path string) (file.Info, error)

func (*R) Open

func (f *R) Open(name string) (fs.File, error)

func (*R) OpenCtx

func (f *R) OpenCtx(ctx context.Context, name string) (fs.File, error)

func (*R) Put

func (f *R) Put(ctx context.Context, path string, perm fs.FileMode, data []byte) error

func (*R) ReadFile

func (f *R) ReadFile(name string) ([]byte, error)

func (*R) ReadFileCtx

func (f *R) ReadFileCtx(ctx context.Context, name string) ([]byte, error)
func (f *R) Readlink(ctx context.Context, path string) (string, error)

func (*R) Scheme

func (f *R) Scheme() string

func (*R) Stat

func (f *R) Stat(ctx context.Context, path string) (file.Info, error)

func (*R) SysXAttr

func (f *R) SysXAttr(existing any, merge file.XAttr) any

func (*R) WriteFile

func (f *R) WriteFile(name string, data []byte, perm fs.FileMode) error

func (*R) WriteFileCtx

func (f *R) WriteFileCtx(ctx context.Context, name string, data []byte, perm fs.FileMode) error

func (*R) XAttr

func (f *R) XAttr(ctx context.Context, name string, info file.Info) (file.XAttr, error)

type T

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

T represents the local filesystem. It implements FS, ObjectFS and filewalk.FS

func New

func New(opts ...Option) *T

New returns an instance of file.FS that provides access to the local filesystem.

func (*T) Base

func (f *T) Base(path string) string

func (*T) Delete

func (f *T) Delete(_ context.Context, path string) error

func (*T) DeleteAll

func (f *T) DeleteAll(_ context.Context, path string) error

func (*T) EnsurePrefix

func (f *T) EnsurePrefix(_ context.Context, path string, perm fs.FileMode) error

func (*T) Get

func (f *T) Get(_ context.Context, path string) ([]byte, error)

func (*T) IsNotExist

func (f *T) IsNotExist(err error) bool

func (*T) IsPermissionError

func (f *T) IsPermissionError(err error) bool

func (*T) Join

func (f *T) Join(components ...string) string

func (*T) LevelScanner

func (f *T) LevelScanner(prefix string) filewalk.LevelScanner

func (*T) Lstat

func (f *T) Lstat(_ context.Context, path string) (file.Info, error)

func (*T) Open

func (f *T) Open(name string) (fs.File, error)

func (*T) OpenCtx

func (f *T) OpenCtx(_ context.Context, name string) (fs.File, error)

func (*T) Put

func (f *T) Put(_ context.Context, path string, perm fs.FileMode, data []byte) error

func (*T) ReadFile

func (f *T) ReadFile(name string) ([]byte, error)

func (*T) ReadFileCtx

func (f *T) ReadFileCtx(_ context.Context, name string) ([]byte, error)
func (f *T) Readlink(_ context.Context, path string) (string, error)

func (*T) Scheme

func (f *T) Scheme() string

func (*T) Stat

func (f *T) Stat(_ context.Context, path string) (file.Info, error)

func (*T) SysXAttr

func (f *T) SysXAttr(existing any, merge file.XAttr) any

func (*T) WriteFile

func (f *T) WriteFile(name string, data []byte, perm fs.FileMode) error

func (*T) WriteFileCtx

func (f *T) WriteFileCtx(_ context.Context, name string, data []byte, perm fs.FileMode) error

func (*T) XAttr

func (f *T) XAttr(_ context.Context, name string, info file.Info) (file.XAttr, error)

Jump to

Keyboard shortcuts

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