From 46cfc454c5ccfbad472926fdd47be75055ac232e Mon Sep 17 00:00:00 2001 From: Terence Boldt Date: Tue, 12 Mar 2024 20:53:48 -0500 Subject: [PATCH] Fix warnings --- main.go | 13 ++++++++++++- prodos/basic_test.go | 2 +- prodos/directory.go | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 5937717..14cbd38 100644 --- a/main.go +++ b/main.go @@ -89,6 +89,10 @@ func dumpFile(fileName string, pathName string) { } defer file.Close() 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) } @@ -101,6 +105,10 @@ func dumpDirectory(fileName string, pathName string) { } defer file.Close() _, 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) } @@ -200,6 +208,9 @@ func put(fileName string, pathName string, fileType uint8, auxType uint16, inFil } defer file.Close() 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) if err != nil { @@ -229,7 +240,7 @@ func get(fileName string, pathName string, outFileName string) { os.Exit(1) } if strings.HasSuffix(strings.ToLower(outFileName), ".bas") { - fmt.Fprintf(outFile, prodos.ConvertBasicToText(getFile)) + fmt.Fprint(outFile, prodos.ConvertBasicToText(getFile)) } else { outFile.Write(getFile) } diff --git a/prodos/basic_test.go b/prodos/basic_test.go index 168f6fa..0b60acc 100644 --- a/prodos/basic_test.go +++ b/prodos/basic_test.go @@ -74,7 +74,7 @@ func TestConvertTextToBasic(t *testing.T) { testname := tt.name t.Run(testname, func(t *testing.T) { 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) } }) diff --git a/prodos/directory.go b/prodos/directory.go index 0a379ea..ea574b6 100644 --- a/prodos/directory.go +++ b/prodos/directory.go @@ -277,7 +277,7 @@ func expandDirectory(readerWriter ReaderWriterAt, buffer []byte, blockNumber uin nextBlockNumber := blockList[0] buffer[0x02] = byte(nextBlockNumber & 0x00FF) buffer[0x03] = byte(nextBlockNumber >> 8) - WriteBlock(readerWriter, blockNumber, buffer) + err = WriteBlock(readerWriter, blockNumber, buffer) if err != nil { errString := fmt.Sprintf("failed to write block to expand directory: %s", err) return 0, errors.New(errString)