Fix error handling for file not found
This commit is contained in:
parent
48121c279f
commit
035d20033e
4
main.go
4
main.go
|
@ -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") {
|
||||||
|
|
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue