Fix warnings

This commit is contained in:
Terence Boldt 2024-03-12 20:53:48 -05:00
parent d9930ff85a
commit 46cfc454c5
3 changed files with 14 additions and 3 deletions

13
main.go
View File

@ -89,6 +89,10 @@ func dumpFile(fileName string, pathName string) {
} }
defer file.Close() defer file.Close()
fileEntry, err := prodos.GetFileEntry(file, pathName) fileEntry, err := prodos.GetFileEntry(file, pathName)
if err != nil {
fmt.Printf("Failed to path %s:\n %s", pathName, err)
os.Exit(1)
}
prodos.DumpFileEntry(fileEntry) prodos.DumpFileEntry(fileEntry)
} }
@ -101,6 +105,10 @@ func dumpDirectory(fileName string, pathName string) {
} }
defer file.Close() defer file.Close()
_, directoryheader, _, err := prodos.ReadDirectory(file, pathName) _, directoryheader, _, err := prodos.ReadDirectory(file, pathName)
if err != nil {
fmt.Printf("Failed to read directory %s:\n %s", pathName, err)
os.Exit(1)
}
prodos.DumpDirectoryHeader(directoryheader) prodos.DumpDirectoryHeader(directoryheader)
} }
@ -200,6 +208,9 @@ func put(fileName string, pathName string, fileType uint8, auxType uint16, inFil
} }
defer file.Close() defer file.Close()
fileInfo, err := os.Stat(fileName) fileInfo, err := os.Stat(fileName)
if err != nil {
fmt.Printf("Failed get fileInfo for %s - %s", fileName, err)
}
err = prodos.WriteFileFromFile(file, pathName, fileType, auxType, fileInfo.ModTime(), inFileName, false) err = prodos.WriteFileFromFile(file, pathName, fileType, auxType, fileInfo.ModTime(), inFileName, false)
if err != nil { if err != nil {
@ -229,7 +240,7 @@ func get(fileName string, pathName string, outFileName string) {
os.Exit(1) os.Exit(1)
} }
if strings.HasSuffix(strings.ToLower(outFileName), ".bas") { if strings.HasSuffix(strings.ToLower(outFileName), ".bas") {
fmt.Fprintf(outFile, prodos.ConvertBasicToText(getFile)) fmt.Fprint(outFile, prodos.ConvertBasicToText(getFile))
} else { } else {
outFile.Write(getFile) outFile.Write(getFile)
} }

View File

@ -74,7 +74,7 @@ func TestConvertTextToBasic(t *testing.T) {
testname := tt.name testname := tt.name
t.Run(testname, func(t *testing.T) { t.Run(testname, func(t *testing.T) {
basic, _ := ConvertTextToBasic(tt.basicText) basic, _ := ConvertTextToBasic(tt.basicText)
if bytes.Compare(basic, tt.want) != 0 { if !bytes.Equal(basic, tt.want) {
t.Errorf("%s\ngot '%#v'\nwant '%#v'\n", testname, basic, tt.want) t.Errorf("%s\ngot '%#v'\nwant '%#v'\n", testname, basic, tt.want)
} }
}) })

View File

@ -277,7 +277,7 @@ func expandDirectory(readerWriter ReaderWriterAt, buffer []byte, blockNumber uin
nextBlockNumber := blockList[0] nextBlockNumber := blockList[0]
buffer[0x02] = byte(nextBlockNumber & 0x00FF) buffer[0x02] = byte(nextBlockNumber & 0x00FF)
buffer[0x03] = byte(nextBlockNumber >> 8) buffer[0x03] = byte(nextBlockNumber >> 8)
WriteBlock(readerWriter, blockNumber, buffer) err = WriteBlock(readerWriter, blockNumber, buffer)
if err != nil { if err != nil {
errString := fmt.Sprintf("failed to write block to expand directory: %s", err) errString := fmt.Sprintf("failed to write block to expand directory: %s", err)
return 0, errors.New(errString) return 0, errors.New(errString)