From 77f8ee59a0eb74a7b5f89d913e77a3bbcbf62fc0 Mon Sep 17 00:00:00 2001 From: Terence Boldt Date: Sun, 27 Jun 2021 07:53:50 -0400 Subject: [PATCH] Add AuxType and FileType --- main.go | 6 +++++- prodos/file.go | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 7e2074b..2fa2816 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,8 @@ func main() { var blockNumber int var volumeSize int var volumeName string + var fileType int + var auxType int flag.StringVar(&fileName, "driveimage", "", "A ProDOS format drive image") flag.StringVar(&pathName, "path", "", "Path name in ProDOS drive image") flag.StringVar(&command, "command", "ls", "Command to execute: ls, get, put, volumebitmap, readblock, writeblock, createvolume, delete") @@ -25,6 +27,8 @@ func main() { flag.IntVar(&volumeSize, "volumesize", 65535, "Number of blocks to create the volume with") flag.StringVar(&volumeName, "volumename", "NO.NAME", "Specifiy a name for the volume from 1 to 15 characters") flag.IntVar(&blockNumber, "block", 0, "A block number to read/write from 0 to 65535") + flag.IntVar(&fileType, "type", 6, "ProDOS FileType: 4=txt, 6=bin, 252=bas, 255=sys etc.") + flag.IntVar(&auxType, "aux", 0x2000, "ProDOS AuxType from 0 to 65535 (usually load address)") flag.Parse() if len(fileName) == 0 { @@ -78,7 +82,7 @@ func main() { if err != nil { os.Exit(1) } - prodos.WriteFile(file, pathName, inFile) + prodos.WriteFile(file, pathName, fileType, auxType, inFile) case "readblock": file, err := os.OpenFile(fileName, os.O_RDWR, 0755) if err != nil { diff --git a/prodos/file.go b/prodos/file.go index 52e7424..f00afc3 100644 --- a/prodos/file.go +++ b/prodos/file.go @@ -23,7 +23,7 @@ func LoadFile(file *os.File, path string) []byte { return buffer } -func WriteFile(file *os.File, path string, buffer []byte) { +func WriteFile(file *os.File, path string, fileType int, auxType int, buffer []byte) { directory, fileName := GetDirectoryAndFileNameFromPath(path) DeleteFile(file, path) @@ -80,9 +80,9 @@ func WriteFile(file *os.File, path string, buffer []byte) { fileEntry.BlocksUsed = len(blockList) fileEntry.CreationTime = time.Now() fileEntry.ModifiedTime = time.Now() - fileEntry.AuxType = 0x2000 + fileEntry.AuxType = auxType fileEntry.EndOfFile = len(buffer) - fileEntry.FileType = 0x06 + fileEntry.FileType = fileType fileEntry.KeyPointer = blockList[0] writeFileEntry(file, fileEntry)