protected.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import os from "os"
  2. import path from "path"
  3. const home = os.homedir()
  4. const DARWIN_HOME = [
  5. "Music",
  6. "Pictures",
  7. "Movies",
  8. "Downloads",
  9. "Desktop",
  10. "Documents",
  11. "Public",
  12. "Applications",
  13. "Library",
  14. ]
  15. const DARWIN_LIBRARY = [
  16. "Application Support/AddressBook",
  17. "Calendars",
  18. "Mail",
  19. "Messages",
  20. "Safari",
  21. "Cookies",
  22. "Application Support/com.apple.TCC",
  23. "PersonalizationPortrait",
  24. "Metadata/CoreSpotlight",
  25. "Suggestions",
  26. ]
  27. const DARWIN_ROOT = ["/.DocumentRevisions-V100", "/.Spotlight-V100", "/.Trashes", "/.fseventsd"]
  28. const WIN32_HOME = ["AppData", "Downloads", "Desktop", "Documents", "Pictures", "Music", "Videos", "OneDrive"]
  29. /** Directory basenames to skip when scanning the home directory. */
  30. export function names(): ReadonlySet<string> {
  31. if (process.platform === "darwin") return new Set(DARWIN_HOME)
  32. if (process.platform === "win32") return new Set(WIN32_HOME)
  33. return new Set()
  34. }
  35. /** Absolute paths that should never be watched, stated, or scanned. */
  36. export function paths(): string[] {
  37. if (process.platform === "darwin")
  38. return [
  39. ...DARWIN_HOME.map((name) => path.join(home, name)),
  40. ...DARWIN_LIBRARY.map((name) => path.join(home, "Library", name)),
  41. ...DARWIN_ROOT,
  42. ]
  43. if (process.platform === "win32") return WIN32_HOME.map((name) => path.join(home, name))
  44. return []
  45. }
  46. export * as Protected from "./protected"