-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserDirectory.cs
118 lines (110 loc) · 4.42 KB
/
UserDirectory.cs
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
namespace Xdg.Directories;
/// <include file='docs/UserDirectory.xml' path='docs/UserDirectory/*'/>
public static class UserDirectory
{
/// <include file='docs/UserDirectory.xml' path='docs/DesktopDir/*'/>
public static string DesktopDir
{
get =>
GetEnvironmentVariable("XDG_DESKTOP_DIR")
?? Helpers.GetCurrentOperatingSystem() switch
{
Helpers.OS.Windows => GetFolderPath(SpecialFolder.Desktop),
Helpers.OS.MacOS => Path.Combine(Other.Home, "Desktop"),
Helpers.OS.UnixLike => Path.Combine(Other.Home, "Desktop"),
_ => string.Empty
};
}
/// <include file='docs/UserDirectory.xml' path='docs/DownloadDir/*'/>
public static string DownloadDir
{
get =>
GetEnvironmentVariable("XDG_DOWNLOAD_DIR")
?? Helpers.GetCurrentOperatingSystem() switch
{
// TODO: Implement this ourselves because Microsoft doesn't.
Helpers.OS.Windows => string.Empty,
Helpers.OS.MacOS => Path.Combine(Other.Home, "Downloads"),
Helpers.OS.UnixLike => Path.Combine(Other.Home, "Downloads"),
_ => string.Empty
};
}
/// <include file='docs/UserDirectory.xml' path='docs/DocumentsDir/*'/>
public static string DocumentsDir
{
get =>
GetEnvironmentVariable("XDG_DOCUMENTS_DIR")
?? Helpers.GetCurrentOperatingSystem() switch
{
Helpers.OS.Windows => GetFolderPath(SpecialFolder.MyDocuments),
Helpers.OS.MacOS => Path.Combine(Other.Home, "Documents"),
Helpers.OS.UnixLike => Path.Combine(Other.Home, "Documents"),
_ => string.Empty
};
}
/// <include file='docs/UserDirectory.xml' path='docs/MusicDir/*'/>
public static string MusicDir
{
get =>
GetEnvironmentVariable("XDG_MUSIC_DIR")
?? Helpers.GetCurrentOperatingSystem() switch
{
Helpers.OS.Windows => GetFolderPath(SpecialFolder.MyMusic),
Helpers.OS.MacOS => Path.Combine(Other.Home, "Music"),
Helpers.OS.UnixLike => Path.Combine(Other.Home, "Music"),
_ => string.Empty
};
}
/// <include file='docs/UserDirectory.xml' path='docs/PicturesDir/*'/>
public static string PicturesDir
{
get =>
GetEnvironmentVariable("XDG_PICTURES_DIR")
?? Helpers.GetCurrentOperatingSystem() switch
{
Helpers.OS.Windows => GetFolderPath(SpecialFolder.MyPictures),
Helpers.OS.MacOS => Path.Combine(Other.Home, "Pictures"),
Helpers.OS.UnixLike => Path.Combine(Other.Home, "Pictures"),
_ => string.Empty
};
}
/// <include file='docs/UserDirectory.xml' path='docs/VideosDir/*'/>
public static string VideosDir
{
get =>
GetEnvironmentVariable("XDG_VIDEOS_DIR")
?? Helpers.GetCurrentOperatingSystem() switch
{
Helpers.OS.Windows => GetFolderPath(SpecialFolder.MyVideos),
Helpers.OS.MacOS => Path.Combine(Other.Home, "Movies"),
Helpers.OS.UnixLike => Path.Combine(Other.Home, "Videos"),
_ => string.Empty
};
}
/// <include file='docs/UserDirectory.xml' path='docs/TemplatesDir/*'/>
public static string TemplatesDir
{
get =>
GetEnvironmentVariable("XDG_TEMPLATES_DIR")
?? Helpers.GetCurrentOperatingSystem() switch
{
Helpers.OS.Windows => GetFolderPath(SpecialFolder.Templates),
Helpers.OS.MacOS => Path.Combine(Other.Home, "Templates"),
Helpers.OS.UnixLike => Path.Combine(Other.Home, "Templates"),
_ => string.Empty
};
}
/// <include file='docs/UserDirectory.xml' path='docs/PublicDir/*'/>
public static string PublicDir
{
get =>
GetEnvironmentVariable("XDG_PUBLICSHARE_DIR")
?? Helpers.GetCurrentOperatingSystem() switch
{
Helpers.OS.Windows => GetEnvironmentVariable("PUBLIC") ?? string.Empty,
Helpers.OS.MacOS => Path.Combine(Other.Home, "Public"),
Helpers.OS.UnixLike => $"{Other.Home}/Public",
_ => string.Empty
};
}
}