Fix initial entry reader shortcut on Windows

This commit is contained in:
2024-03-01 13:47:28 -05:00
parent adcc05f3f4
commit 7d5bd76489
3 changed files with 6 additions and 4 deletions
+4 -2
View File
@@ -22,10 +22,12 @@ func main() {
// initial entry reader shortcut
// TODO Do not use file extensions for entries! This will allow doing this check more efficiently than otherwise possible.
if strings.HasPrefix(args[0], "/") {
if isFile, _ := offline.TargetIsFile(offline.EntryRoot+args[0], true); isFile {
targetLocation := offline.EntryRoot + offline.PathSeparator + args[0][1:]
if isFile, _ := offline.TargetIsFile(targetLocation, true); isFile {
// TODO decrypt and display the entry
fmt.Println("It's a file!")
} else {
fmt.Println("It's a directory!")
fmt.Println(offline.AnsiError + "Failed to read \"" + targetLocation + "\" - it is a directory" + offline.AnsiReset)
}
os.Exit(0)
}
+1 -1
View File
@@ -95,7 +95,7 @@ func EntryListGen() {
dirList = append(dirList, "")
} else {
// otherwise, print the source of the error
fmt.Print("\n\n" + offline.AnsiError + "An unexpected error occurred while generating the entry list: " + err.Error() + offline.AnsiReset)
fmt.Println(offline.AnsiError + "An unexpected error occurred while generating the entry list: " + err.Error() + offline.AnsiReset)
}
// quit walking EntryRoot and return nil to allow the program to continue
return nil
+1 -1
View File
@@ -11,7 +11,7 @@ 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)
fmt.Println(AnsiError + "Failed to access \"" + targetLocation + "\" - ensure it exists and has the correct permissions" + AnsiReset)
os.Exit(1)
} else {
return false, false