import { join } from "@std/path"; function getHomeDir(): string { if (Deno.build.os === "windows") { const home = Deno.env.get("USERPROFILE"); if (home == null) throw new Error("%USERPROFILE% missing"); return home; } else { const home = Deno.env.get("HOME"); if (home == null) throw new Error("$HOME missing"); return home; } } export function getDataDir(): string { let base = Deno.env.get("HSH_DATA_DIR"); if (base == null) { switch (Deno.build.os) { case "windows": base = Deno.env.get("APPDATA")!; break; case "darwin": // As far as I can tell, unlike Linux and Windows, this is just fixed base = join(getHomeDir(), "Library", "Application Support"); break; default: base = Deno.env.get("XDG_DATA_HOME") ?? join(getHomeDir(), ".local", "share"); } } return join(base, "hsh"); } export function getConfigDir(): string { let base: string; switch (Deno.build.os) { case "windows": base = Deno.env.get("APPDATA")!; break; default: base = Deno.env.get("XDG_CONFIG_HOME") ?? join(getHomeDir(), ".config"); } return join(base, "hsh"); } export function likelyPath(path: string): boolean { return !path.includes(" ") && (path.includes("/") || path.includes(":")); }