Add AuxType and FileType

This commit is contained in:
Terence Boldt 2021-06-27 07:53:50 -04:00
parent aa6fb993ee
commit 77f8ee59a0
2 changed files with 8 additions and 4 deletions

View File

@ -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 {

View File

@ -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)