utils

package
v0.4.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotDir   = vfs.ErrNotDir
	ErrReadOnly = vfs.ErrReadOnly

	ErrFileClosed = errors.New("file is closed")
	ErrOutOfRange = errors.New("out of range")
	ErrTooLarge   = errors.New("too large")
	ErrNotEmpty   = vfs.ErrNotEmpty
)

Functions

func NewFSSupport

func NewFSSupport(name string, root FileData, adapter SupportAdapter) vfs.FileSystem

func NewFileInfo

func NewFileInfo(name string, file FileData) os.FileInfo

func NewRenamedFile

func NewRenamedFile(name string, file vfs.File) vfs.File

Types

type File

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

func (*File) Close

func (f *File) Close() error

func (*File) Name

func (f *File) Name() string

func (*File) Open

func (f *File) Open() error

func (*File) Read

func (f *File) Read(buf []byte) (int, error)

func (*File) ReadAt

func (f *File) ReadAt(b []byte, off int64) (n int, err error)

func (*File) ReadDir

func (f *File) ReadDir(count int) (files []fs.DirEntry, err error)

func (*File) Readdir

func (f *File) Readdir(count int) (files []os.FileInfo, err error)

func (*File) Readdirnames

func (f *File) Readdirnames(n int) (names []string, err error)

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

func (*File) Stat

func (f *File) Stat() (os.FileInfo, error)

func (*File) Sync

func (f *File) Sync() error

func (*File) Truncate

func (f *File) Truncate(size int64) error

func (*File) Write

func (f *File) Write(buf []byte) (int, error)

func (*File) WriteAt

func (f *File) WriteAt(buf []byte, off int64) (n int, err error)

func (*File) WriteString

func (f *File) WriteString(s string) (ret int, err error)

type FileData

type FileData interface {
	FileDataDirAccess
	Data() []byte
	Files() []os.FileInfo
	SetData([]byte)
	Mode() os.FileMode
	SetMode(mode os.FileMode)
	ModTime() time.Time
	SetModTime(time.Time)
	Add(name string, f FileData) error
	Del(name string) error
}

type FileDataDirAccess

type FileDataDirAccess interface {
	Lock()
	Unlock()
	IsDir() bool
	IsSymlink() bool
	GetEntry(name string) (FileDataDirAccess, error)
	GetSymlink() string
}

type FileSystemBase

type FileSystemBase struct{}

func (FileSystemBase) Cleanup

func (FileSystemBase) Cleanup() error

func (FileSystemBase) FSTempDir

func (FileSystemBase) FSTempDir() string

func (FileSystemBase) Getwd

func (FileSystemBase) Getwd() (string, error)

func (FileSystemBase) Normalize

func (FileSystemBase) Normalize(path string) string

func (FileSystemBase) VolumeName

func (FileSystemBase) VolumeName(name string) string

type FileSystemSupport

type FileSystemSupport struct {
	FileSystemBase
	// contains filtered or unexported fields
}

func (*FileSystemSupport) Chmod

func (m *FileSystemSupport) Chmod(name string, mode os.FileMode) error

func (*FileSystemSupport) Chtimes

func (m *FileSystemSupport) Chtimes(name string, atime time.Time, mtime time.Time) error

func (*FileSystemSupport) Create

func (m *FileSystemSupport) Create(name string) (vfs.File, error)

func (*FileSystemSupport) Lstat

func (m *FileSystemSupport) Lstat(name string) (os.FileInfo, error)

func (*FileSystemSupport) Mkdir

func (m *FileSystemSupport) Mkdir(name string, perm os.FileMode) error

func (*FileSystemSupport) MkdirAll

func (m *FileSystemSupport) MkdirAll(path string, perm os.FileMode) error

func (*FileSystemSupport) Name

func (m *FileSystemSupport) Name() string

func (*FileSystemSupport) Open

func (m *FileSystemSupport) Open(name string) (vfs.File, error)

func (*FileSystemSupport) OpenFile

func (m *FileSystemSupport) OpenFile(name string, flags int, perm os.FileMode) (vfs.File, error)
func (m *FileSystemSupport) Readlink(name string) (string, error)

func (*FileSystemSupport) Remove

func (m *FileSystemSupport) Remove(name string) error

func (*FileSystemSupport) RemoveAll

func (m *FileSystemSupport) RemoveAll(name string) error

func (*FileSystemSupport) Rename

func (m *FileSystemSupport) Rename(oldname, newname string) error

func (*FileSystemSupport) Stat

func (m *FileSystemSupport) Stat(name string) (os.FileInfo, error)
func (m *FileSystemSupport) Symlink(oldname, newname string) error

type FilesSorter

type FilesSorter []os.FileInfo

func (FilesSorter) Len

func (s FilesSorter) Len() int

func (FilesSorter) Less

func (s FilesSorter) Less(i, j int) bool

func (FilesSorter) Swap

func (s FilesSorter) Swap(i, j int)

type MappedFileSystem

type MappedFileSystem struct {
	FileSystemBase
	// contains filtered or unexported fields
}

func NewMappedFileSystem

func NewMappedFileSystem(root vfs.FileSystem, mapper PathMapper) *MappedFileSystem

func (*MappedFileSystem) Base

func (m *MappedFileSystem) Base() vfs.FileSystem

func (*MappedFileSystem) Chmod

func (m *MappedFileSystem) Chmod(name string, mode os.FileMode) (err error)

func (*MappedFileSystem) Chtimes

func (m *MappedFileSystem) Chtimes(name string, atime, mtime time.Time) (err error)

func (*MappedFileSystem) Cleanup

func (m *MappedFileSystem) Cleanup() error

func (*MappedFileSystem) Create

func (m *MappedFileSystem) Create(name string) (f vfs.File, err error)

func (*MappedFileSystem) FSTempDir

func (m *MappedFileSystem) FSTempDir() string

func (*MappedFileSystem) Getwd

func (*MappedFileSystem) Getwd() (string, error)

func (*MappedFileSystem) Lstat

func (m *MappedFileSystem) Lstat(name string) (os.FileInfo, error)

func (*MappedFileSystem) Mkdir

func (m *MappedFileSystem) Mkdir(name string, mode os.FileMode) (err error)

func (*MappedFileSystem) MkdirAll

func (m *MappedFileSystem) MkdirAll(name string, mode os.FileMode) (err error)

func (*MappedFileSystem) Normalize

func (m *MappedFileSystem) Normalize(path string) string

func (*MappedFileSystem) Open

func (m *MappedFileSystem) Open(name string) (f vfs.File, err error)

func (*MappedFileSystem) OpenFile

func (m *MappedFileSystem) OpenFile(name string, flag int, mode os.FileMode) (f vfs.File, err error)
func (m *MappedFileSystem) Readlink(name string) (string, error)

func (*MappedFileSystem) Remove

func (m *MappedFileSystem) Remove(name string) (err error)

func (*MappedFileSystem) RemoveAll

func (m *MappedFileSystem) RemoveAll(name string) (err error)

func (*MappedFileSystem) Rename

func (m *MappedFileSystem) Rename(oldname, newname string) (err error)

func (*MappedFileSystem) Stat

func (m *MappedFileSystem) Stat(name string) (fi os.FileInfo, err error)
func (m *MappedFileSystem) Symlink(oldname, newname string) error

type PathMapper

type PathMapper interface {
	MapPath(path string) (vfs.FileSystem, string)
}

type RenamedFile

type RenamedFile struct {
	vfs.File
	// contains filtered or unexported fields
}

func (*RenamedFile) Name

func (r *RenamedFile) Name() string

type SupportAdapter

type SupportAdapter interface {
	CreateFile(perm os.FileMode) FileData
	CreateDir(perm os.FileMode) FileData
	CreateSymlink(oldname string, perm os.FileMode) FileData
}

Jump to

Keyboard shortcuts

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