Documentation
¶
Index ¶
- Constants
- Variables
- func ReadExactly(c Content, off int64, p []byte) error
- func Register(f Factory)
- func WriteExactly(c Content, off int64, p []byte) error
- type Access
- type BasicDisk
- type Content
- type Disk
- type Extent
- type Factory
- type FileContent
- type Geometry
- type MemoryContent
- type ReadOnly
- type SubContent
Constants ¶
const DefaultSectorSize = 512
Variables ¶
var ErrReadOnly = errors.New("hfsgo/disk: content is read-only")
ErrReadOnly is returned when writing to a read-only Content.
Functions ¶
func ReadExactly ¶
ReadExactly reads len(p) bytes at off, or returns an error.
Types ¶
type Content ¶
Content is a sparse, random-access byte view of a disk or volume. It is the Go equivalent of DiscUtils SparseStream.
type Disk ¶
type Disk interface {
io.Closer
Content() Content
Capacity() int64
SectorSize() int
Geometry() Geometry
CanWrite() bool
}
Disk is a virtual disk. Equivalent to DiscUtils VirtualDisk.
func CreateMemory ¶
CreateMemory creates an in-memory disk of the given type.
func Open ¶
Open opens a disk image by path. Extension selects a factory; remaining factories are probed; raw is the fallback.
func OpenContent ¶
OpenContent selects a factory by extension then probe.
type Factory ¶
type Factory interface {
Type() string
Extensions() []string
Detect(c Content) bool
Open(c Content, writable bool) (Disk, error)
Create(c Content, capacity int64) (Disk, error)
}
Factory opens or creates a disk format. Equivalent to DiscUtils VirtualDiskFactory.
type FileContent ¶
type FileContent struct {
// contains filtered or unexported fields
}
FileContent wraps an os.File as Content.
func CreateFile ¶
func CreateFile(path string, size int64) (*FileContent, error)
func (*FileContent) Close ¶
func (c *FileContent) Close() error
func (*FileContent) Extents ¶
func (c *FileContent) Extents() []Extent
func (*FileContent) Size ¶
func (c *FileContent) Size() int64
type Geometry ¶
Geometry is CHS disk geometry (DiscUtils Geometry).
func FromCapacity ¶
FromCapacity guesses a BIOS-safe geometry for a given capacity.
type MemoryContent ¶
type MemoryContent struct {
// contains filtered or unexported fields
}
MemoryContent is an in-memory sparse Content.
func MemoryFromBytes ¶
func MemoryFromBytes(b []byte) *MemoryContent
func NewMemory ¶
func NewMemory(size int64) *MemoryContent
func (*MemoryContent) Bytes ¶
func (c *MemoryContent) Bytes() []byte
func (*MemoryContent) Close ¶
func (c *MemoryContent) Close() error
func (*MemoryContent) Extents ¶
func (c *MemoryContent) Extents() []Extent
func (*MemoryContent) Size ¶
func (c *MemoryContent) Size() int64
type SubContent ¶
type SubContent struct {
// contains filtered or unexported fields
}
SubContent is a window into parent, equivalent to DiscUtils SubStream.
func NewSub ¶
func NewSub(parent Content, off, length int64) *SubContent
func (*SubContent) Close ¶
func (c *SubContent) Close() error
func (*SubContent) Extents ¶
func (c *SubContent) Extents() []Extent
func (*SubContent) Size ¶
func (c *SubContent) Size() int64