返回 DeepSeek-Reasonix
protected_dirs_darwin.go
根目录 / internal / tool / builtin / protected_dirs_darwin.go
1 package builtin
2
3 import (
4 "os"
5 "path/filepath"
6 )
7
8 // macOS TCC-protected user dirs: an opendir trips a privacy consent prompt
9 // ("wants to access Apple Music / media library"), so recursive glob/grep prune
10 // them. Matched by absolute path, not basename, so a project's own dir is safe.
11 var protectedDirs = func() map[string]bool {
12 home, err := os.UserHomeDir()
13 if err != nil || home == "" {
14 return nil
15 }
16 m := make(map[string]bool, 4)
17 for _, d := range []string{"Music", "Pictures", "Movies", "Library"} {
18 m[filepath.Clean(filepath.Join(home, d))] = true
19 }
20 return m
21 }()
22
23 func isProtectedDir(abs string) bool { return protectedDirs[abs] }
24
24 lines GO