-
Notifications
You must be signed in to change notification settings - Fork 455
/
Copy pathUserDataDir.cs
41 lines (37 loc) · 1.25 KB
/
UserDataDir.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
using System;
using System.IO;
using JetBrains.Annotations;
namespace Robust.Client.Utility
{
internal static class UserDataDir
{
[Pure]
public static string GetUserDataDir(IGameControllerInternal gameController)
{
return Path.Combine(GetRootUserDataDir(gameController), "data");
}
[Pure]
public static string GetRootUserDataDir(IGameControllerInternal gameController)
{
string appDataDir;
#if LINUX
var xdgDataHome = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
if (xdgDataHome == null)
{
appDataDir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local", "share");
}
else
{
appDataDir = xdgDataHome;
}
#elif MACOS
appDataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"Library", "Application Support");
#else
appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
#endif
return Path.Combine(appDataDir, gameController.Options.UserDataDirectoryName);
}
}
}