mirror of
https://github.com/tjboldt/ProDOS-Utilities.git
synced 2025-01-15 21:31:48 +00:00
Add AuxType and FileType
This commit is contained in:
parent
aa6fb993ee
commit
77f8ee59a0
6
main.go
6
main.go
@ -17,6 +17,8 @@ func main() {
|
|||||||
var blockNumber int
|
var blockNumber int
|
||||||
var volumeSize int
|
var volumeSize int
|
||||||
var volumeName string
|
var volumeName string
|
||||||
|
var fileType int
|
||||||
|
var auxType int
|
||||||
flag.StringVar(&fileName, "driveimage", "", "A ProDOS format drive image")
|
flag.StringVar(&fileName, "driveimage", "", "A ProDOS format drive image")
|
||||||
flag.StringVar(&pathName, "path", "", "Path name in ProDOS 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")
|
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.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.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(&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()
|
flag.Parse()
|
||||||
|
|
||||||
if len(fileName) == 0 {
|
if len(fileName) == 0 {
|
||||||
@ -78,7 +82,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
prodos.WriteFile(file, pathName, inFile)
|
prodos.WriteFile(file, pathName, fileType, auxType, inFile)
|
||||||
case "readblock":
|
case "readblock":
|
||||||
file, err := os.OpenFile(fileName, os.O_RDWR, 0755)
|
file, err := os.OpenFile(fileName, os.O_RDWR, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -23,7 +23,7 @@ func LoadFile(file *os.File, path string) []byte {
|
|||||||
return buffer
|
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)
|
directory, fileName := GetDirectoryAndFileNameFromPath(path)
|
||||||
|
|
||||||
DeleteFile(file, path)
|
DeleteFile(file, path)
|
||||||
@ -80,9 +80,9 @@ func WriteFile(file *os.File, path string, buffer []byte) {
|
|||||||
fileEntry.BlocksUsed = len(blockList)
|
fileEntry.BlocksUsed = len(blockList)
|
||||||
fileEntry.CreationTime = time.Now()
|
fileEntry.CreationTime = time.Now()
|
||||||
fileEntry.ModifiedTime = time.Now()
|
fileEntry.ModifiedTime = time.Now()
|
||||||
fileEntry.AuxType = 0x2000
|
fileEntry.AuxType = auxType
|
||||||
fileEntry.EndOfFile = len(buffer)
|
fileEntry.EndOfFile = len(buffer)
|
||||||
fileEntry.FileType = 0x06
|
fileEntry.FileType = fileType
|
||||||
fileEntry.KeyPointer = blockList[0]
|
fileEntry.KeyPointer = blockList[0]
|
||||||
|
|
||||||
writeFileEntry(file, fileEntry)
|
writeFileEntry(file, fileEntry)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user