github.com/haraldrudell/parl@v0.4.176/pfs/result-reason.go (about) 1 /* 2 © 2023–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) 3 ISC License 4 */ 5 6 package pfs 7 8 import "fmt" 9 10 const ( 11 // the filesystem traversal completed all entries 12 REnd ResultReason = iota 13 // a non-symlink non-directory non-error entry 14 REntry 15 // a directory or symlink about to be traversed 16 RSkippable 17 // a directory whose listing failed [os.Open] [os.File.ReadDir] 18 RDirBad 19 // a broken symlink [os.Stat] 20 RSymlinkBad 21 // failure in [os.Lstat] [os.Readlink] [os.Getwd] 22 RError 23 ) 24 25 // Why a directory entry was provided by Traverser 26 // - REnd REntry RSkippable RDirBad RSymlinkBad RError 27 type ResultReason uint8 28 29 var reasonMap = map[ResultReason]string{ 30 REnd: "filesystem traversal completed all entries", 31 REntry: "non-symlink non-directory non-error entry", 32 RSkippable: "a directory or symlink about to be traversed", 33 RDirBad: "a directory whose listing failed", 34 RSymlinkBad: "a broken symlink", 35 RError: "error while examining entry", 36 } 37 38 func (r ResultReason) String() (s string) { 39 if s = reasonMap[r]; s != "" { 40 return 41 } 42 s = fmt.Sprintf("?entryReason%d", r) 43 44 return 45 }