Skip to content

Commit 23998bf

Browse files
authored
Merge pull request #1662 from cogentcore/direxists
direxists: add fsx helper for DirExists
2 parents 4b0a8cc + ac8a90c commit 23998bf

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

base/fsx/fsx.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ func FileExists(filePath string) (bool, error) {
184184
return false, err
185185
}
186186

187+
// DirExists checks whether given directory exists, returning true if so,
188+
// false if not, and error if there is an error in accessing the file.
189+
func DirExists(filePath string) (bool, error) {
190+
fileInfo, err := os.Stat(filePath)
191+
if err == nil {
192+
return fileInfo.IsDir(), nil
193+
}
194+
return false, err
195+
}
196+
187197
// DirAndFile returns the final dir and file name.
188198
func DirAndFile(file string) string {
189199
dir, fnm := filepath.Split(file)

yaegicore/basesymbols/cogentcore_org-core-base-fsx.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)