MCPcopy
hub / github.com/expr-lang/expr / DirExists

Function DirExists

internal/testify/assert/assertions.go:1725–1740  ·  view source on GitHub ↗

DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.

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

Source from the content-addressed store, hash-verified

1723// DirExists checks whether a directory exists in the given path. It also fails
1724// if the path is a file rather a directory or there is an error checking whether it exists.
1725func DirExists(t TestingT, path string, msgAndArgs ...interface{}) bool {
1726 if h, ok := t.(tHelper); ok {
1727 h.Helper()
1728 }
1729 info, err := os.Lstat(path)
1730 if err != nil {
1731 if os.IsNotExist(err) {
1732 return Fail(t, fmt.Sprintf("unable to find file %q", path), msgAndArgs...)
1733 }
1734 return Fail(t, fmt.Sprintf("error when running os.Lstat(%q): %s", path, err), msgAndArgs...)
1735 }
1736 if !info.IsDir() {
1737 return Fail(t, fmt.Sprintf("%q is a file", path), msgAndArgs...)
1738 }
1739 return true
1740}
1741
1742// NoDirExists checks whether a directory does not exist in the given path.
1743// It fails if the path points to an existing _directory_ only.

Callers 4

DirExistsFunction · 0.92
DirExistsfFunction · 0.70
TestDirExistsFunction · 0.70
DirExistsMethod · 0.70

Calls 3

SprintfMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45

Tested by 1

TestDirExistsFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…