vfs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReadOnly    = errors.New("hfsgo/vfs: file system is read-only")
	ErrNotExist    = fs.ErrNotExist
	ErrExist       = fs.ErrExist
	ErrNotDir      = errors.New("hfsgo/vfs: not a directory")
	ErrIsDir       = errors.New("hfsgo/vfs: is a directory")
	ErrJournaled   = errors.New("hfsgo/vfs: refusing to write a journaled HFS+ volume")
	ErrUnsupported = errors.New("hfsgo/vfs: unsupported operation")
)

Functions

func Join

func Join(parts ...string) string

func Register

func Register(f Factory)

func Split

func Split(path string) []string

Types

type ContentFile

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

ContentFile is the shared File implementation over disk.Content. Classic HFS and HFS+ both mount through vfs.FS; forks should be Content windows on the volume, not a separate I/O stack.

func NewContentFile

func NewContentFile(c disk.Content, writable bool) *ContentFile

NewContentFile wraps c as a seekable fork. writable controls Write/WriteAt.

func (*ContentFile) Close

func (f *ContentFile) Close() error

func (*ContentFile) OnClose

func (f *ContentFile) OnClose(fn func() error) *ContentFile

OnClose sets an optional flush invoked from Close. Returns f for chaining.

func (*ContentFile) Read

func (f *ContentFile) Read(p []byte) (int, error)

func (*ContentFile) ReadAt

func (f *ContentFile) ReadAt(p []byte, off int64) (int, error)

func (*ContentFile) Seek

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

func (*ContentFile) Write

func (f *ContentFile) Write(p []byte) (int, error)

func (*ContentFile) WriteAt

func (f *ContentFile) WriteAt(p []byte, off int64) (int, error)

type FS

type FS interface {
	io.Closer
	Name() string
	VolumeLabel() string
	CanWrite() bool
	Stat(path string) (FileInfo, error)
	ReadDir(path string) ([]FileInfo, error)
	OpenFile(path string, fork Fork, flag int) (File, error)
	CreateFile(path string) error
	CreateDir(path string) error
	Remove(path string) error
	Rename(oldpath, newpath string) error
	MkdirAll(path string) error
	SetInfo(path string, info FileInfo) error
}

FS is the Mac-aware file system interface (DiscUtils IFileSystem + forks).

func Mount

func Mount(c disk.Content, writable bool) (FS, error)

Mount probes registered file systems on the volume content.

func MountVolume

func MountVolume(v *volume.Volume, writable bool) (FS, error)

MountVolume mounts the first detected FS on a volume.

type Factory

type Factory interface {
	Name() string
	Detect(c disk.Content) bool
	Mount(c disk.Content, writable bool) (FS, error)
}

Factory detects and mounts a file system on a volume.

type File

type File interface {
	io.Reader
	io.Writer
	io.Seeker
	io.Closer
	io.ReaderAt
	io.WriterAt
}

File is an open fork.

type FileInfo

type FileInfo struct {
	Name     string
	IsDir    bool
	Size     int64
	RsrcSize int64
	CNID     uint32
	Type     FourCC
	Creator  FourCC
	Created  time.Time
	Modified time.Time
	Accessed time.Time
	Flags    uint16
}

FileInfo is Mac-native metadata.

func (FileInfo) Mode

func (fi FileInfo) Mode() fs.FileMode

type Fork

type Fork int

Fork identifies which fork to open.

const (
	DataFork Fork = iota
	RsrcFork
)

type FourCC

type FourCC [4]byte

FourCC is a Mac OS type or creator code.

func ParseFourCC

func ParseFourCC(s string) FourCC

func (FourCC) String

func (f FourCC) String() string

type IOFS

type IOFS struct{ Inner FS }

IOFS adapts FS to io/fs.FS for read-only stdlib use.

func (IOFS) Open

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

Jump to

Keyboard shortcuts

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