OS: Add FreeBSD support inside ASF code

#2129
This commit is contained in:
Archi
2021-06-21 11:47:20 +02:00
parent a355c1a4ba
commit d01a26e48a
3 changed files with 21 additions and 5 deletions

View File

@@ -377,7 +377,11 @@ namespace ArchiSteamFarm.Core {
return null;
}
#if NETFRAMEWORK
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
#else
if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
#endif
string executable = Path.Combine(SharedInfo.HomeDirectory, SharedInfo.AssemblyName);
if (File.Exists(executable)) {

View File

@@ -141,8 +141,12 @@ namespace ArchiSteamFarm.Core {
throw new ArgumentNullException(nameof(path));
}
#if NETFRAMEWORK
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
return;
#else
if (!RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD) && !RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
#endif
throw new PlatformNotSupportedException();
}
if (!File.Exists(path) && !Directory.Exists(path)) {
@@ -201,7 +205,7 @@ namespace ArchiSteamFarm.Core {
private static void WindowsDisableQuickEditMode() {
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
return;
throw new PlatformNotSupportedException();
}
IntPtr consoleHandle = NativeMethods.GetStdHandle(NativeMethods.StandardInputHandle);
@@ -221,7 +225,7 @@ namespace ArchiSteamFarm.Core {
private static void WindowsKeepSystemActive() {
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
return;
throw new PlatformNotSupportedException();
}
// This function calls unmanaged API in order to tell Windows OS that it should not enter sleep state while the program is running

View File

@@ -174,7 +174,11 @@ namespace ArchiSteamFarm.Helpers {
// Non-critical, user might have no rights to manage the resource
ASF.ArchiLogger.LogGenericDebuggingException(e);
}
} else {
#if NETFRAMEWORK
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
#else
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
#endif
OS.UnixSetFileAccess(directoryPath!, OS.EUnixPermission.Combined777);
}
}
@@ -195,7 +199,11 @@ namespace ArchiSteamFarm.Helpers {
// Non-critical, user might have no rights to manage the resource
ASF.ArchiLogger.LogGenericDebuggingException(e);
}
} else {
#if NETFRAMEWORK
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
#else
} else if (RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
#endif
OS.UnixSetFileAccess(FilePath, OS.EUnixPermission.Combined777);
}
} catch (IOException) {