MCPcopy
hub / github.com/redspread/spread / findPath

Function findPath

cli/cli.go:90–104  ·  view source on GitHub ↗
(leafDir, targetFile string, dir bool)

Source from the content-addressed store, hash-verified

88}
89
90func findPath(leafDir, targetFile string, dir bool) (string, bool) {
91 if len(leafDir) == 0 {
92 return "", false
93 }
94 spread := filepath.Join(leafDir, targetFile)
95 if exists, err := pathExists(spread, dir); err == nil && exists {
96 return spread, true
97 } else {
98 if leafDir == "/" {
99 return "", false
100 }
101 parent := filepath.Dir(leafDir)
102 return findPath(parent, targetFile, dir)
103 }
104}
105
106func pathExists(path string, dir bool) (bool, error) {
107 info, err := os.Stat(path)

Callers 1

projectMethod · 0.85

Calls 1

pathExistsFunction · 0.85

Tested by

no test coverage detected