prodos

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// StorageDeleted signifies file is deleted
	StorageDeleted = 0
	// StorageSeedling signifies file is <= 512 bytes
	StorageSeedling = 1
	// StorageSapling signifies file is > 512 bytes and <= 128 KB
	StorageSapling = 2
	// StorageTree signifies file is > 128 KB and <= 16 MB
	StorageTree = 3
	// StoragePascal signifies pascal storage area
	StoragePascal = 4
	// StorageDirectory signifies directory
	StorageDirectory = 13
)

Variables

This section is empty.

Functions

func AddFilesFromHostDirectory added in v0.4.0

func AddFilesFromHostDirectory(
	readerWriter ReaderWriterAt,
	directory string,
	path string,
	recursive bool,
) error

AddFilesFromHostDirectory fills the root volume with files from the specified host directory

func ConvertBasicToText

func ConvertBasicToText(basic []byte) string

ConvertBasicToText converts AppleSoft BASIC to text

func ConvertImageToHiResColour added in v0.4.3

func ConvertImageToHiResColour(imageBytes []byte) []byte

ConvertImageToHiResColour converts jpeg and png images to Apple II hi-res colour

func ConvertImageToHiResMonochrome added in v0.4.3

func ConvertImageToHiResMonochrome(imageBytes []byte) []byte

ConvertImageToHiResMonochrome converts jpeg and png images to Apple II hi-res monochrome

func ConvertTextToBasic added in v0.3.2

func ConvertTextToBasic(text string) ([]byte, error)

ConvertTextToBasic converts text to AppleSoft BASIC

func CreateDirectory added in v0.4.4

func CreateDirectory(readerWriter ReaderWriterAt, path string) error

CreateDirectory creates a directory information of a specified path on a ProDOS image

func CreateVolume

func CreateVolume(readerWriter ReaderWriterAt, volumeName string, numberOfBlocks uint16)

CreateVolume formats a new ProDOS volume including boot block, volume bitmap and empty directory

func DateTimeFromProDOS

func DateTimeFromProDOS(buffer []byte) time.Time

DateTimeFromProDOS converts Time from ProDOS date time

func DateTimeToProDOS

func DateTimeToProDOS(dateTime time.Time) []byte

DateTimeToProDOS converts Time to ProDOS date time

       49041 ($BF91)     49040 ($BF90)

        7 6 5 4 3 2 1 0   7 6 5 4 3 2 1 0
       +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
DATE:  |    year     |  month  |   day   |
       +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+

       49043 ($BF93)     49042 ($BF92)

        7 6 5 4 3 2 1 0   7 6 5 4 3 2 1 0
       +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+
TIME:  |    hour       | |    minute     |
       +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+

func DeleteFile

func DeleteFile(readerWriter ReaderWriterAt, path string) error

DeleteFile deletes a file from a ProDOS volume

func DumpBlock

func DumpBlock(buffer []byte)

DumpBlock dumps the block as hexadecimal and text

func DumpDirectory

func DumpDirectory(blocksFree uint16, totalBlocks uint16, path string, fileEntries []FileEntry)

DumpDirectory displays the directory similar to ProDOS catalog

func DumpDirectoryHeader

func DumpDirectoryHeader(directoryHeader DirectoryHeader)

DumpDirectoryHeader dumps the directory header as text

func DumpFileEntry

func DumpFileEntry(fileEntry FileEntry)

DumpFileEntry dumps the file entry values as text

func DumpVolumeHeader

func DumpVolumeHeader(volumeHeader VolumeHeader)

DumpVolumeHeader dumps the volume header values as text

func FileExists added in v0.4.4

func FileExists(reader io.ReaderAt, path string) (bool, error)

FileExists return true if the file exists

func FileTypeToString

func FileTypeToString(fileType uint8) string

FileTypeToString display the file type as a string

func GetDirectoryAndFileNameFromPath

func GetDirectoryAndFileNameFromPath(path string) (string, string)

GetDirectoryAndFileNameFromPath gets the directory and filename from a path

func GetFreeBlockCount

func GetFreeBlockCount(volumeBitmap []byte, totalBlocks uint16) uint16

GetFreeBlockCount gets the number of free blocks on a ProDOS image

func LoadFile

func LoadFile(reader io.ReaderAt, path string) ([]byte, error)

LoadFile loads in a file from a ProDOS volume into a byte array

func ReadBlock

func ReadBlock(reader io.ReaderAt, block uint16) ([]byte, error)

ReadBlock reads a block from a ProDOS volume into a byte array

func ReadDirectory

func ReadDirectory(reader io.ReaderAt, path string) (VolumeHeader, DirectoryHeader, []FileEntry, error)

ReadDirectory reads the directory information from a specified path on a ProDOS image

func ReadVolumeBitmap

func ReadVolumeBitmap(reader io.ReaderAt) ([]byte, error)

ReadVolumeBitmap reads the volume bitmap from a ProDOS image

func TimeToString

func TimeToString(printTime time.Time) string

TimeToString displays the date and time in ProDOS format

func WriteBlock

func WriteBlock(writer io.WriterAt, block uint16, buffer []byte) error

WriteBlock writes a block to a ProDOS volume from a byte array

func WriteFile

func WriteFile(readerWriter ReaderWriterAt, path string, fileType uint8, auxType uint16, createdTime time.Time, modifiedTime time.Time, buffer []byte) error

WriteFile writes a file to a ProDOS volume from a byte array

func WriteFileFromFile added in v0.4.0

func WriteFileFromFile(
	readerWriter ReaderWriterAt,
	pathName string,
	fileType uint8,
	auxType uint16,
	modifiedTime time.Time,
	inFileName string,
	cacheDir fs.DirEntry,
	ignoreDuplicates bool,
) error

WriteFileFromFile writes a file to a ProDOS volume from a host file

Types

type DirectoryHeader

type DirectoryHeader struct {
	PreviousBlock     uint16
	NextBlock         uint16
	IsSubDirectory    bool
	Name              string
	CreationTime      time.Time
	Version           uint8
	MinVersion        uint8
	Access            uint8
	EntryLength       uint8
	EntriesPerBlock   uint8
	ActiveFileCount   uint16
	StartingBlock     uint16
	ParentBlock       uint16
	ParentEntry       uint16
	ParentEntryLength uint8
}

DirectoryHeader from ProDOS

type FileEntry

type FileEntry struct {
	StorageType   uint8
	FileName      string
	FileType      uint8
	CreationTime  time.Time
	KeyPointer    uint16
	Version       uint8
	MinVersion    uint8
	BlocksUsed    uint16
	EndOfFile     uint32
	Access        uint8
	AuxType       uint16
	ModifiedTime  time.Time
	HeaderPointer uint16

	DirectoryBlock  uint16
	DirectoryOffset uint16
}

FileEntry from ProDOS

func GetFileEntry added in v0.3.1

func GetFileEntry(reader io.ReaderAt, path string) (FileEntry, error)

GetFileEntry returns a file entry for the given path

type MemoryFile added in v0.2.0

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

MemoryFile containts file data and size

func NewMemoryFile added in v0.2.0

func NewMemoryFile(size int) *MemoryFile

NewMemoryFile creates an in-memory file of the specified size in bytes

func (*MemoryFile) ReadAt added in v0.2.0

func (memoryFile *MemoryFile) ReadAt(data []byte, offset int64) (int, error)

ReadAt reads data from the specified offset in the file

func (*MemoryFile) WriteAt added in v0.2.0

func (memoryFile *MemoryFile) WriteAt(data []byte, offset int64) (int, error)

WriteAt writes data to the specified offset in the file

type ReaderWriterAt added in v0.3.0

type ReaderWriterAt interface {
	ReadAt(data []byte, offset int64) (int, error)
	WriteAt(data []byte, offset int64) (int, error)
}

ReaderWriterAt is an interface for both ReaderAt and WriterAt combined

type VolumeHeader

type VolumeHeader struct {
	VolumeName       string
	CreationTime     time.Time
	ActiveFileCount  uint16
	BitmapStartBlock uint16
	TotalBlocks      uint16
	NextBlock        uint16
	EntryLength      uint8
	EntriesPerBlock  uint8
	MinVersion       uint8
	Version          uint8
}

VolumeHeader from ProDOS

Jump to

Keyboard shortcuts

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