Fix error handling for file not found

This commit is contained in:
Terence Boldt 2021-07-02 07:58:06 -04:00
parent 48121c279f
commit 035d20033e
2 changed files with 6 additions and 1 deletions

View File

@ -63,13 +63,15 @@ func main() {
} }
getFile, err := prodos.LoadFile(file, pathName) getFile, err := prodos.LoadFile(file, pathName)
if err != nil { 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 { if len(outFileName) == 0 {
_, outFileName = prodos.GetDirectoryAndFileNameFromPath(pathName) _, outFileName = prodos.GetDirectoryAndFileNameFromPath(pathName)
} }
outFile, err := os.Create(outFileName) outFile, err := os.Create(outFileName)
if err != nil { if err != nil {
fmt.Printf("Failed to create output file %s: %s\n", outFileName, err)
os.Exit(1) os.Exit(1)
} }
if strings.HasSuffix(strings.ToLower(outFileName), ".bas") { if strings.HasSuffix(strings.ToLower(outFileName), ".bas") {

View File

@ -139,6 +139,9 @@ func DeleteFile(file *os.File, path string) error {
if fileEntry.StorageType == StorageDeleted { if fileEntry.StorageType == StorageDeleted {
return errors.New("File already deleted") return errors.New("File already deleted")
} }
if fileEntry.StorageType == StorageDirectory {
return errors.New("Directory deletion not supported")
}
// free the blocks // free the blocks
blocks, err := getBlocklist(file, fileEntry) blocks, err := getBlocklist(file, fileEntry)