MCPcopy Index your code
hub / github.com/dnote/dnote / EnsureDir

Function EnsureDir

pkg/cli/utils/files.go:57–71  ·  view source on GitHub ↗

EnsureDir creates a directory if it doesn't exist. Returns nil if the directory already exists or was successfully created.

(path string)

Source from the content-addressed store, hash-verified

55// EnsureDir creates a directory if it doesn't exist.
56// Returns nil if the directory already exists or was successfully created.
57func EnsureDir(path string) error {
58 ok, err := FileExists(path)
59 if err != nil {
60 return errors.Wrapf(err, "checking if dir exists at %s", path)
61 }
62 if ok {
63 return nil
64 }
65
66 if err := os.MkdirAll(path, 0755); err != nil {
67 return errors.Wrapf(err, "creating directory at %s", path)
68 }
69
70 return nil
71}
72
73// CopyDir copies a directory from src to dest, recursively copying nested
74// directories

Callers 2

InitDnoteDirsFunction · 0.92
TestEnsureDirFunction · 0.85

Calls 1

FileExistsFunction · 0.85

Tested by 1

TestEnsureDirFunction · 0.68