From 035d20033efa9d8d45d2efb679ce99758bb5471c Mon Sep 17 00:00:00 2001 From: Terence Boldt Date: Fri, 2 Jul 2021 07:58:06 -0400 Subject: [PATCH] Fix error handling for file not found --- main.go | 4 +++- prodos/file.go | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 311247e..eb94e0f 100644 --- a/main.go +++ b/main.go @@ -63,13 +63,15 @@ func main() { } getFile, err := prodos.LoadFile(file, pathName) if err != nil { - fmt.Printf("Failed to read file %s: %s", pathName, err) + fmt.Printf("Failed to read file %s: %s\n", pathName, err) + os.Exit(1) } if len(outFileName) == 0 { _, outFileName = prodos.GetDirectoryAndFileNameFromPath(pathName) } outFile, err := os.Create(outFileName) if err != nil { + fmt.Printf("Failed to create output file %s: %s\n", outFileName, err) os.Exit(1) } if strings.HasSuffix(strings.ToLower(outFileName), ".bas") { diff --git a/prodos/file.go b/prodos/file.go index 37e148c..af2c623 100644 --- a/prodos/file.go +++ b/prodos/file.go @@ -139,6 +139,9 @@ func DeleteFile(file *os.File, path string) error { if fileEntry.StorageType == StorageDeleted { return errors.New("File already deleted") } + if fileEntry.StorageType == StorageDirectory { + return errors.New("Directory deletion not supported") + } // free the blocks blocks, err := getBlocklist(file, fileEntry)