MCPcopy Index your code
hub / github.com/expr-lang/expr / FileExists

Function FileExists

internal/testify/assert/assertions.go:1690–1705  ·  view source on GitHub ↗

FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.

(t TestingT, path string, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1688// FileExists checks whether a file exists in the given path. It also fails if
1689// the path points to a directory or there is an error when trying to check the file.
1690func FileExists(t TestingT, path string, msgAndArgs ...interface{}) bool {
1691 if h, ok := t.(tHelper); ok {
1692 h.Helper()
1693 }
1694 info, err := os.Lstat(path)
1695 if err != nil {
1696 if os.IsNotExist(err) {
1697 return Fail(t, fmt.Sprintf("unable to find file %q", path), msgAndArgs...)
1698 }
1699 return Fail(t, fmt.Sprintf("error when running os.Lstat(%q): %s", path, err), msgAndArgs...)
1700 }
1701 if info.IsDir() {
1702 return Fail(t, fmt.Sprintf("%q is a directory", path), msgAndArgs...)
1703 }
1704 return true
1705}
1706
1707// NoFileExists checks whether a file does not exist in a given path. It fails
1708// if the path points to an existing _file_ only.

Callers 4

FileExistsFunction · 0.92
FileExistsfFunction · 0.70
TestFileExistsFunction · 0.70
FileExistsMethod · 0.70

Calls 3

SprintfMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45

Tested by 1

TestFileExistsFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…