generated from justjavac/deno_starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.ts
29 lines (26 loc) · 933 Bytes
/
mod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/** Returns the path to the user's picture directory.
*
* The returned value depends on the operating system and is either a string,
* containing a value from the following table, or `null`.
*
* |Platform | Value | Example |
* | ------- | --------------------- | --------------------------- |
* | Linux | `XDG_PICTURES_DIR` | /home/justjavac/Pictures |
* | macOS | `$HOME`/Pictures | /Users/justjavac/Pictures |
* | Windows | `{FOLDERID_Pictures}` | C:\Users\justjavac\Pictures |
*/
export default function pictureDir(): string | null {
switch (Deno.build.os) {
case "linux": {
return Deno.env.get("XDG_PICTURES_DIR") ?? null;
}
case "darwin": {
const home = Deno.env.get("HOME");
if (home) return `${home}/Pictures`;
break;
}
case "windows":
return Deno.env.get("FOLDERID_Pictures") ?? null;
}
return null;
}