iso9660

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package iso9660 provides parsing for ISO9660 disc images.

Index

Constants

View Source
const DefaultReadFileSizeLimit uint32 = 16 * 1024 * 1024

DefaultReadFileSizeLimit caps ReadFile allocations. Directory records store sizes as uint32, so corrupt images can claim up to 4GB for a file.

Variables

View Source
var (
	ErrInvalidISO   = errors.New("invalid ISO9660 image")
	ErrPVDNotFound  = errors.New("primary volume descriptor not found")
	ErrInvalidBlock = errors.New("invalid block size")
	ErrFileNotFound = errors.New("file not found")
)

Common errors

Functions

func IsCueFile

func IsCueFile(path string) bool

IsCueFile checks if the given path is a CUE file.

Types

type CueSheet

type CueSheet struct {
	Path     string   // Path to the CUE file
	BinFiles []string // Paths to BIN files (absolute)
}

CueSheet represents a parsed CUE sheet file.

func ParseCue

func ParseCue(cuePath string) (*CueSheet, error)

ParseCue parses a CUE sheet file and returns the BIN file paths.

type FileInfo

type FileInfo struct {
	Path string
	LBA  uint32 // Logical Block Address
	Size uint32
}

FileInfo contains information about a file in the ISO filesystem.

type ISO9660

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

ISO9660 represents a parsed ISO9660 disc image.

func Open

func Open(path string) (*ISO9660, error)

Open opens an ISO9660 disc image from a file.

func OpenCHD

func OpenCHD(path string) (*ISO9660, error)

OpenCHD opens an ISO9660 filesystem from a CHD disc image file. The CHD file's DataTrackSectorReader provides 2048-byte logical sectors starting at the first data track, suitable for ISO9660 parsing. This handles multi-track CDs like Neo Geo CD that have audio tracks first.

func OpenCue

func OpenCue(cuePath string) (*ISO9660, error)

OpenCue opens an ISO9660 disc image from a CUE sheet. It uses the first BIN file referenced in the CUE sheet.

func OpenReader

func OpenReader(reader io.ReaderAt, size int64) (*ISO9660, error)

OpenReader creates an ISO9660 from an io.ReaderAt. The caller is responsible for closing the underlying reader if needed.

func OpenReaderWithCloser

func OpenReaderWithCloser(reader io.ReaderAt, size int64, closer io.Closer) (*ISO9660, error)

OpenReaderWithCloser creates an ISO9660 from an io.ReaderAt with an optional closer. The closer will be called when Close() is called on the ISO9660.

func (*ISO9660) BlockSize

func (iso *ISO9660) BlockSize() int

BlockSize returns the block size of the disc image.

func (*ISO9660) Close

func (iso *ISO9660) Close() error

Close closes the ISO9660 file.

func (*ISO9660) FileExists

func (iso *ISO9660) FileExists(path string) bool

FileExists checks if a file exists at the given path.

func (*ISO9660) GetDataPreparerID

func (iso *ISO9660) GetDataPreparerID() string

GetDataPreparerID returns the data preparer identifier from the PVD.

func (*ISO9660) GetPublisherID

func (iso *ISO9660) GetPublisherID() string

GetPublisherID returns the publisher identifier from the PVD.

func (*ISO9660) GetSystemID

func (iso *ISO9660) GetSystemID() string

GetSystemID returns the system identifier from the PVD.

func (*ISO9660) GetUUID

func (iso *ISO9660) GetUUID() string

GetUUID returns a unique identifier derived from disc metadata.

func (*ISO9660) GetVolumeID

func (iso *ISO9660) GetVolumeID() string

GetVolumeID returns the volume identifier from the PVD.

func (*ISO9660) IterFiles

func (iso *ISO9660) IterFiles(onlyRootDir bool) ([]FileInfo, error)

IterFiles returns a list of files in the filesystem. If onlyRootDir is true, only files in the root directory are returned.

func (*ISO9660) ReadFile

func (iso *ISO9660) ReadFile(info FileInfo) ([]byte, error)

ReadFile reads the contents of a file by its FileInfo.

func (*ISO9660) ReadFileByPath

func (iso *ISO9660) ReadFileByPath(path string) ([]byte, error)

ReadFileByPath reads a file by its path.

func (*ISO9660) ReadFileWithLimit

func (iso *ISO9660) ReadFileWithLimit(info FileInfo, maxSize uint32) ([]byte, error)

ReadFileWithLimit reads the contents of a file with a caller-provided size limit. A limit of 0 disables the guard.

func (*ISO9660) Size

func (iso *ISO9660) Size() int64

Size returns the total size of the disc image.

func (*ISO9660) WalkFiles added in v0.2.0

func (iso *ISO9660) WalkFiles(onlyRootDir bool, fn func(FileInfo) bool) error

WalkFiles visits files in the ISO filesystem. Returning false from fn stops iteration early. If onlyRootDir is true, only files in the root directory are visited.

type MountedDisc

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

MountedDisc represents a mounted disc directory. This allows treating a directory as if it were an ISO9660 filesystem.

func OpenMounted

func OpenMounted(path, uuid, volumeID string) (*MountedDisc, error)

OpenMounted creates a MountedDisc from a directory path.

func (*MountedDisc) Close

func (*MountedDisc) Close() error

Close is a no-op for mounted discs.

func (*MountedDisc) FileExists

func (m *MountedDisc) FileExists(path string) bool

FileExists checks if a file exists at the given path.

func (*MountedDisc) GetDataPreparerID

func (*MountedDisc) GetDataPreparerID() string

GetDataPreparerID returns empty string for mounted discs.

func (*MountedDisc) GetPublisherID

func (*MountedDisc) GetPublisherID() string

GetPublisherID returns empty string for mounted discs.

func (*MountedDisc) GetSystemID

func (*MountedDisc) GetSystemID() string

GetSystemID returns empty string for mounted discs.

func (*MountedDisc) GetUUID

func (m *MountedDisc) GetUUID() string

GetUUID returns the UUID if set.

func (*MountedDisc) GetVolumeID

func (m *MountedDisc) GetVolumeID() string

GetVolumeID returns the volume ID.

func (*MountedDisc) IterFiles

func (m *MountedDisc) IterFiles(onlyRootDir bool) ([]FileInfo, error)

IterFiles returns a list of files in the mounted directory.

func (*MountedDisc) ReadFile

func (m *MountedDisc) ReadFile(info FileInfo) ([]byte, error)

ReadFile reads a file from the mounted directory.

func (*MountedDisc) ReadFileByPath

func (m *MountedDisc) ReadFileByPath(path string) ([]byte, error)

ReadFileByPath reads a file by its path.

Jump to

Keyboard shortcuts

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