MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / parseExistingFilePath

Function parseExistingFilePath

env/parsers.go:307–322  ·  view source on GitHub ↗

parseExistingFilePath checks if the provided path points to an existing file and returns the path if valid.

(env string)

Source from the content-addressed store, hash-verified

305
306// parseExistingFilePath checks if the provided path points to an existing file and returns the path if valid.
307func parseExistingFilePath(env string) (string, error) {
308 if env == "" {
309 return "", nil
310 }
311
312 info, err := os.Stat(env)
313 if err != nil {
314 return "", fmt.Errorf("cannot access file %s: %w", env, err)
315 }
316
317 if info.IsDir() {
318 return "", fmt.Errorf("%s is a directory, expected a file", env)
319 }
320
321 return env, nil
322}

Callers

nothing calls this directly

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected