mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-10-27 13:29:58 -04:00
Initial read shortcut support (target status checking)
This commit is contained in:
1 parent
ba89fbeab6
commit
adcc05f3f4
2 files changed
+38
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package offline
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
// TargetIsFile TargetStatusCheck checks if the targetLocation is a file, directory, or is inaccessible
|
||||
// returns: isFile, isAccessible
|
||||
func TargetIsFile(targetLocation string, errorOnFail bool) (bool, bool) {
|
||||
targetInfo, err := os.Stat(targetLocation)
|
||||
if err != nil {
|
||||
if errorOnFail {
|
||||
fmt.Println(AnsiError + "Failed to access " + targetLocation + " - ensure it exists and has the correct permissions" + AnsiReset)
|
||||
os.Exit(1)
|
||||
} else {
|
||||
return false, false
|
||||
}
|
||||
}
|
||||
if targetInfo.IsDir() {
|
||||
return false, true
|
||||
} else {
|
||||
return true, true
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user