MCPcopy
hub / github.com/wavetermdev/waveterm / TryMkdirs

Function TryMkdirs

pkg/wavebase/wavebase.go:270–286  ·  view source on GitHub ↗
(dirName string, perm os.FileMode, dirDesc string)

Source from the content-addressed store, hash-verified

268}
269
270func TryMkdirs(dirName string, perm os.FileMode, dirDesc string) error {
271 info, err := os.Stat(dirName)
272 if errors.Is(err, fs.ErrNotExist) {
273 err = os.MkdirAll(dirName, perm)
274 if err != nil {
275 return fmt.Errorf("cannot make %s %q: %w", dirDesc, dirName, err)
276 }
277 info, err = os.Stat(dirName)
278 }
279 if err != nil {
280 return fmt.Errorf("error trying to stat %s: %w", dirDesc, err)
281 }
282 if !info.IsDir() {
283 return fmt.Errorf("%s %q must be a directory", dirDesc, dirName)
284 }
285 return nil
286}
287
288func listValidLangs(ctx context.Context) []string {
289 out, err := exec.CommandContext(ctx, "locale", "-a").CombinedOutput()

Callers 3

GetTsunamiAppCachePathFunction · 0.92
CacheEnsureDirFunction · 0.85

Calls 2

StatMethod · 0.80
IsDirMethod · 0.45

Tested by

no test coverage detected