udf

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

README

Udf filesystem golang library

  • Non-optimized
  • Some functioal is broken
  • recovery() style error handling interface
  • Work only with certain iso's

It's all because I has reached requried functional for me.

Example

package main

import (
	"fmt"
	"os"
	"github.com/mogaika/udf"
)

func main() {
	r, _ := os.Open("example.iso")
	u := udf.NewUdfFromReader(r)
	for _, f := range u.ReadDir(nil) {
		fmt.Printf("%s %-10d %-20s %v\n", f.Mode().String(), f.Size(), f.Name(), f.ModTime())
	}
}

Output:

-r-xr-xr-x 57         system.cnf           2006-02-11 00:00:00 +0000 UTC
-r-xr-xr-x 1911580    SCUS_973.99          2006-03-15 00:00:00 +0000 UTC
-r-xr-xr-x 278305     ioprp300.img         2005-11-14 00:00:00 +0000 UTC
-r-xr-xr-x 6641       sio2man.irx          2005-10-18 00:00:00 +0000 UTC
-r-xr-xr-x 15653      dbcman.irx           2005-10-18 00:00:00 +0000 UTC

Documentation

Index

Constants

View Source
const (
	DESCRIPTOR_PRIMARY_VOLUME            = 0x1
	DESCRIPTOR_ANCHOR_VOLUME_POINTER     = 0x2
	DESCRIPTOR_VOLUME_POINTER            = 0x3
	DESCRIPTOR_IMPLEMENTATION_USE_VOLUME = 0x4
	DESCRIPTOR_PARTITION                 = 0x5
	DESCRIPTOR_LOGICAL_VOLUME            = 0x6
	DESCRIPTOR_UNALLOCATED               = 0x7
	DESCRIPTOR_TERMINATING               = 0x8
	DESCRIPTOR_FILE_SET                  = 0x100
	DESCRIPTOR_IDENTIFIER                = 0x101
	DESCRIPTOR_ALLOCATION_EXTENT         = 0x102
	DESCRIPTOR_INDIRECT_ENTRY            = 0x103
	DESCRIPTOR_TERMINAL_ENTRY            = 0x104
	DESCRIPTOR_FILE_ENTRY                = 0x105
)
View Source
const SECTOR_SIZE = 2048

Variables

This section is empty.

Functions

This section is empty.

Types

type AnchorVolumeDescriptorPointer

type AnchorVolumeDescriptorPointer struct {
	Descriptor                 Descriptor
	MainVolumeDescriptorSeq    Extent
	ReserveVolumeDescriptorSeq Extent
}

func NewAnchorVolumeDescriptorPointer

func NewAnchorVolumeDescriptorPointer(b []byte) *AnchorVolumeDescriptorPointer

func (*AnchorVolumeDescriptorPointer) FromBytes

type Descriptor

type Descriptor struct {
	TagIdentifier       uint16
	DescriptorVersion   uint16
	TagChecksum         uint8
	TagSerialNumber     uint16
	DescriptorCRC       uint16
	DescriptorCRCLength uint16
	TagLocation         uint32
	// contains filtered or unexported fields
}

func NewDescriptor

func NewDescriptor(b []byte) *Descriptor

func (*Descriptor) AnchorVolumeDescriptorPointer

func (d *Descriptor) AnchorVolumeDescriptorPointer() *AnchorVolumeDescriptorPointer

func (*Descriptor) Data

func (d *Descriptor) Data() []byte

func (*Descriptor) FileEntry

func (d *Descriptor) FileEntry() *FileEntry

func (*Descriptor) FileIdentifierDescriptor

func (d *Descriptor) FileIdentifierDescriptor() *FileIdentifierDescriptor

func (*Descriptor) FileSetDescriptor

func (d *Descriptor) FileSetDescriptor() *FileSetDescriptor

func (*Descriptor) FromBytes

func (d *Descriptor) FromBytes(b []byte) *Descriptor

func (*Descriptor) LogicalVolumeDescriptor

func (d *Descriptor) LogicalVolumeDescriptor() *LogicalVolumeDescriptor

func (*Descriptor) PartitionDescriptor

func (d *Descriptor) PartitionDescriptor() *PartitionDescriptor

func (*Descriptor) PrimaryVolumeDescriptor

func (d *Descriptor) PrimaryVolumeDescriptor() *PrimaryVolumeDescriptor

type EntityID

type EntityID struct {
	Flags            uint8
	Identifier       [23]byte
	IdentifierSuffix [8]byte
}

func NewEntityID

func NewEntityID(b []byte) EntityID

type Extent

type Extent struct {
	Length   uint32
	Location uint32
}

func NewExtent

func NewExtent(b []byte) Extent

type ExtentLong

type ExtentLong struct {
	Length   uint32
	Location uint64
}

func NewExtentLong

func NewExtentLong(b []byte) ExtentLong

type ExtentSmall

type ExtentSmall struct {
	Length   uint16
	Location uint64
}

func NewExtentSmall

func NewExtentSmall(b []byte) ExtentSmall

type File

type File struct {
	Udf *Udf
	Fid *FileIdentifierDescriptor
	// contains filtered or unexported fields
}

func (*File) FileEntry

func (f *File) FileEntry() *FileEntry

func (*File) GetFileEntryPosition

func (f *File) GetFileEntryPosition() int64

func (*File) GetFileOffset

func (f *File) GetFileOffset() int64

func (*File) IsDir

func (f *File) IsDir() bool

func (*File) ModTime

func (f *File) ModTime() time.Time

func (*File) Mode

func (f *File) Mode() os.FileMode

func (*File) Name

func (f *File) Name() string

func (*File) NewReader

func (f *File) NewReader() *io.SectionReader

func (*File) ReadDir

func (f *File) ReadDir() []File

func (*File) Size

func (f *File) Size() int64

func (*File) Sys

func (f *File) Sys() interface{}

type FileEntry

type FileEntry struct {
	Descriptor                    Descriptor
	ICBTag                        *ICBTag
	Uid                           uint32
	Gid                           uint32
	Permissions                   uint32
	FileLinkCount                 uint16
	RecordFormat                  uint8
	RecordDisplayAttributes       uint8
	RecordLength                  uint32
	InformationLength             uint64
	LogicalBlocksRecorded         uint64
	AccessTime                    time.Time
	ModificationTime              time.Time
	AttributeTime                 time.Time
	Checkpoint                    uint32
	ExtendedAttributeICB          ExtentLong
	ImplementationIdentifier      EntityID
	UniqueId                      uint64
	LengthOfExtendedAttributes    uint32
	LengthOfAllocationDescriptors uint32
	ExtendedAttributes            []byte
	AllocationDescriptors         []Extent
}

func NewFileEntry

func NewFileEntry(b []byte) *FileEntry

func (*FileEntry) FromBytes

func (fe *FileEntry) FromBytes(b []byte) *FileEntry

type FileIdentifierDescriptor

type FileIdentifierDescriptor struct {
	Descriptor                Descriptor
	FileVersionNumber         uint16
	FileCharacteristics       uint8
	LengthOfFileIdentifier    uint8
	ICB                       ExtentLong
	LengthOfImplementationUse uint16
	ImplementationUse         EntityID
	FileIdentifier            string
}

func NewFileIdentifierDescriptor

func NewFileIdentifierDescriptor(b []byte) *FileIdentifierDescriptor

func (*FileIdentifierDescriptor) FromBytes

func (*FileIdentifierDescriptor) Len

func (fid *FileIdentifierDescriptor) Len() uint64

type FileSetDescriptor

type FileSetDescriptor struct {
	Descriptor              Descriptor
	RecordingDateTime       time.Time
	InterchangeLevel        uint16
	MaximumInterchangeLevel uint16
	CharacterSetList        uint32
	MaximumCharacterSetList uint32
	FileSetNumber           uint32
	FileSetDescriptorNumber uint32
	LogicalVolumeIdentifier string
	FileSetIdentifier       string
	CopyrightFileIdentifier string
	AbstractFileIdentifier  string
	RootDirectoryICB        ExtentLong
	DomainIdentifier        EntityID
	NexExtent               ExtentLong
}

func NewFileSetDescriptor

func NewFileSetDescriptor(b []byte) *FileSetDescriptor

func (*FileSetDescriptor) FromBytes

func (fsd *FileSetDescriptor) FromBytes(b []byte) *FileSetDescriptor

type ICBTag

type ICBTag struct {
	PriorRecordedNumberOfDirectEntries uint32
	StrategyType                       uint16
	StrategyParameter                  uint16
	MaximumNumberOfEntries             uint16
	FileType                           uint8
	ParentICBLocation                  uint64
	Flags                              uint16
}

func NewICBTag

func NewICBTag(b []byte) *ICBTag

func (*ICBTag) FromBytes

func (itag *ICBTag) FromBytes(b []byte) *ICBTag

type LogicalVolumeDescriptor

type LogicalVolumeDescriptor struct {
	Descriptor                     Descriptor
	VolumeDescriptorSequenceNumber uint32
	LogicalVolumeIdentifier        string
	LogicalBlockSize               uint32
	DomainIdentifier               EntityID
	LogicalVolumeContentsUse       ExtentLong
	MapTableLength                 uint32
	NumberOfPartitionMaps          uint32
	ImplementationIdentifier       EntityID
	ImplementationUse              []byte
	IntegritySequenceExtent        Extent
	PartitionMaps                  []PartitionMap
}

func NewLogicalVolumeDescriptor

func NewLogicalVolumeDescriptor(b []byte) *LogicalVolumeDescriptor

func (*LogicalVolumeDescriptor) FromBytes

type PartitionDescriptor

type PartitionDescriptor struct {
	Descriptor                     Descriptor
	VolumeDescriptorSequenceNumber uint32
	PartitionFlags                 uint16
	PartitionNumber                uint16
	PartitionContents              EntityID
	PartitionContentsUse           []byte
	AccessType                     uint32
	PartitionStartingLocation      uint32
	PartitionLength                uint32
	ImplementationIdentifier       EntityID
	ImplementationUse              []byte
}

func NewPartitionDescriptor

func NewPartitionDescriptor(b []byte) *PartitionDescriptor

func (*PartitionDescriptor) FromBytes

func (pd *PartitionDescriptor) FromBytes(b []byte) *PartitionDescriptor

type PartitionMap

type PartitionMap struct {
	PartitionMapType     uint8
	PartitionMapLength   uint8
	VolumeSequenceNumber uint16
	PartitionNumber      uint16
}

func (*PartitionMap) FromBytes

func (pm *PartitionMap) FromBytes(b []byte) *PartitionMap

type PrimaryVolumeDescriptor

type PrimaryVolumeDescriptor struct {
	Descriptor                                  Descriptor
	VolumeDescriptorSequenceNumber              uint32
	PrimaryVolumeDescriptorNumber               uint32
	VolumeIdentifier                            string
	VolumeSequenceNumber                        uint16
	MaximumVolumeSequenceNumber                 uint16
	InterchangeLevel                            uint16
	MaximumInterchangeLevel                     uint16
	CharacterSetList                            uint32
	MaximumCharacterSetList                     uint32
	VolumeSetIdentifier                         string
	VolumeAbstract                              Extent
	VolumeCopyrightNoticeExtent                 Extent
	ApplicationIdentifier                       EntityID
	RecordingDateTime                           time.Time
	ImplementationIdentifier                    EntityID
	ImplementationUse                           []byte
	PredecessorVolumeDescriptorSequenceLocation uint32
	Flags                                       uint16
}

func NewPrimaryVolumeDescriptor

func NewPrimaryVolumeDescriptor(b []byte) *PrimaryVolumeDescriptor

func (*PrimaryVolumeDescriptor) FromBytes

type Udf

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

func NewUdfFromReader

func NewUdfFromReader(r io.ReaderAt) *Udf

func (*Udf) GetReader

func (udf *Udf) GetReader() io.ReaderAt

func (*Udf) PartitionStart

func (udf *Udf) PartitionStart() uint64

func (*Udf) ReadDir

func (udf *Udf) ReadDir(fe *FileEntry) []File

func (*Udf) ReadSector

func (udf *Udf) ReadSector(sectorNumber uint64) []byte

func (*Udf) ReadSectors

func (udf *Udf) ReadSectors(sectorNumber uint64, sectorsCount uint64) []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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