vfat

package
v0.1.1-0...-42241d0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package vfat provides functions for working with the VFAT filesystem.

Index

Constants

View Source
const (
	// Magic is the VFAT magic signature.
	Magic = "FAT32"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File represents a VFAT backed file.

func (*File) Read

func (f *File) Read(p []byte) (n int, err error)

func (*File) Seek

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

Seek sets the offset for the next Read or Write on file to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.

type FileSystem

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

FileSystem provides simple way to read files from FAT32 filesystems.

This code is far from being production quality, it might break if filesystem is corrupted or is not actually FAT32.

func NewFileSystem

func NewFileSystem(f io.ReaderAt, sb *SuperBlock) (*FileSystem, error)

NewFileSystem initializes Filesystem, reads FAT.

func (*FileSystem) Open

func (fs *FileSystem) Open(path string) (*File, error)

Open the file as read-only stream on the filesystem.

type Option

type Option func(*Options)

Option is the functional option func.

func WithLabel

func WithLabel(o string) Option

WithLabel sets the filesystem label.

type Options

type Options struct {
	Label string
}

Options is the functional options struct.

func NewDefaultOptions

func NewDefaultOptions(setters ...Option) *Options

NewDefaultOptions initializes a Options struct with default values.

type SuperBlock

type SuperBlock struct {
	Ignored      [3]uint8
	Sysid        [8]uint8
	SectorSize   [2]uint8
	ClusterSize  uint8
	Reserved     [2]uint8
	Fats         uint8
	DirEntries   [2]uint8
	Sectors      [2]uint8
	Media        uint8
	FatLength    uint16
	SecsTrack    uint16
	Heads        uint16
	Hidden       uint32
	TotalSect    uint32
	Fat32Length  [4]uint8
	Flags        uint16
	Version      [2]uint8
	RootCluster  [4]uint8
	FsinfoSector uint16
	BackupBoot   uint16
	Reserved2    [6]uint16
	Unknown      [3]uint8
	Serno        [4]uint8
	Label        [11]uint8
	Magic        [8]uint8
	Dummy2       [0x1fe - 0x5a]uint8
	Pmagic       [2]uint8
}

SuperBlock represents the vfat super block.

func (*SuperBlock) Is

func (sb *SuperBlock) Is() bool

Is implements the SuperBlocker interface.

func (*SuperBlock) Offset

func (sb *SuperBlock) Offset() int64

Offset implements the SuperBlocker interface.

func (*SuperBlock) Type

func (sb *SuperBlock) Type() string

Type implements the SuperBlocker interface.

Jump to

Keyboard shortcuts

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