prodos

package
v0.4.9 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 15 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 int)

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 int, totalBlocks int, 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 int) 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 int) int

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 int) ([]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 int, buffer []byte) error

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

func WriteFile

func WriteFile(readerWriter ReaderWriterAt, path string, fileType int, auxType int, 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 int,
	auxType int,
	modifiedTime time.Time,
	inFileName string,
	ignoreDuplicates bool,
) error

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

Types

type DirectoryHeader

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

DirectoryHeader from ProDOS

type FileEntry

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

	DirectoryBlock  int
	DirectoryOffset int
}

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  int
	BitmapStartBlock int
	TotalBlocks      int
	NextBlock        int
	EntryLength      int
	EntriesPerBlock  int
	MinVersion       int
	Version          int
}

VolumeHeader from ProDOS

Jump to

Keyboard shortcuts

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