Files
RobustToolbox/Robust.Client/Utility/UserDataDir.cs
T
Pieter-Jan BriersandGitHub f40ccb7558 New HWID system prep (#5446)
* New HWID system prep

* Allow HWID to be disabled.

Both client and server can now request HWID to be disabled.

On the server via CVar, if disabled the client won't send it.

On the client via env var, if disabled it won't be sent to the client.

This involved moving legacy HWID to be sent in MsgEncryptionResponse instead of MsgLoginStart. This means the legacy HWID won't be available anymore if the connection isn't authenticated.

* Fix tests

* Fix another test

* Review

* Thanks Rider
2024-09-29 00:29:02 +02:00

42 lines
1.3 KiB
C#

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);
}
}
}