2019-02-16 17:34:17 +01:00
// _ _ _ ____ _ _____
2017-11-18 17:27:06 +01:00
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
2019-01-14 19:11:17 +01:00
// |
2023-01-25 15:43:12 +01:00
// Copyright 2015-2023 Łukasz "JustArchi" Domeradzki
2018-07-27 04:52:14 +02:00
// Contact: JustArchi@JustArchi.net
2019-01-14 19:11:17 +01:00
// |
2018-07-27 04:52:14 +02:00
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
2019-01-14 19:11:17 +01:00
// |
2018-07-27 04:52:14 +02:00
// http://www.apache.org/licenses/LICENSE-2.0
2019-01-14 19:11:17 +01:00
// |
2018-07-27 04:52:14 +02:00
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2016-06-27 02:07:27 +02:00
2016-08-02 06:04:44 +02:00
using System ;
2021-05-06 20:28:25 +02:00
using System.IO ;
2016-08-02 06:04:44 +02:00
using System.Reflection ;
2021-05-08 01:37:22 +02:00
using ArchiSteamFarm.Core ;
2019-06-25 12:26:55 +02:00
using ArchiSteamFarm.Plugins ;
2019-01-10 23:44:32 +01:00
using JetBrains.Annotations ;
2016-08-02 06:04:44 +02:00
2021-11-10 21:23:24 +01:00
namespace ArchiSteamFarm ;
2020-06-13 12:08:21 +02:00
2021-11-10 21:23:24 +01:00
public static class SharedInfo {
[PublicAPI]
public const string ConfigDirectory = "config" ;
2016-08-02 06:04:44 +02:00
2021-11-10 21:23:24 +01:00
internal const string ArchivalLogFile = "log.{#}.txt" ;
internal const string ArchivalLogsDirectory = "logs" ;
internal const string ASF = nameof ( ASF ) ;
internal const ulong ASFGroupSteamID = 103582791440160998 ;
2021-11-11 01:53:34 +01:00
internal const string AssemblyDocumentation = $"{AssemblyName}.xml" ;
2021-11-10 21:23:24 +01:00
internal const string AssemblyName = nameof ( ArchiSteamFarm ) ;
internal const string DatabaseExtension = ".db" ;
internal const string DebugDirectory = "debug" ;
2023-02-26 10:59:48 +01:00
internal const string EnvironmentVariableArguments = $"{ASF}_ARGS" ;
2021-11-11 01:53:34 +01:00
internal const string EnvironmentVariableCryptKey = $"{ASF}_CRYPTKEY" ;
2022-09-08 19:53:36 +02:00
internal const string EnvironmentVariableCryptKeyFile = $"{EnvironmentVariableCryptKey}_FILE" ;
2021-11-11 01:53:34 +01:00
internal const string EnvironmentVariableNetworkGroup = $"{ASF}_NETWORK_GROUP" ;
internal const string EnvironmentVariablePath = $"{ASF}_PATH" ;
internal const string GithubReleaseURL = $"https://api.github.com/repos/{GithubRepo}/releases" ;
internal const string GithubRepo = $"JustArchiNET/{AssemblyName}" ;
internal const string GlobalConfigFileName = $"{ASF}{JsonConfigExtension}" ;
internal const string GlobalDatabaseFileName = $"{ASF}{DatabaseExtension}" ;
2021-11-10 21:23:24 +01:00
internal const ushort InformationDelay = 10000 ;
internal const string IPCConfigExtension = ".config" ;
2021-11-11 01:53:34 +01:00
internal const string IPCConfigFile = $"{nameof(IPC)}{IPCConfigExtension}" ;
2021-11-10 21:23:24 +01:00
internal const string JsonConfigExtension = ".json" ;
internal const string KeysExtension = ".keys" ;
internal const string KeysUnusedExtension = ".unused" ;
internal const string KeysUsedExtension = ".used" ;
internal const string LicenseName = "Apache 2.0" ;
internal const string LicenseURL = "https://www.apache.org/licenses/LICENSE-2.0" ;
internal const string LogFile = "log.txt" ;
internal const string LolcatCultureName = "qps-Ploc" ;
internal const string MobileAuthenticatorExtension = ".maFile" ;
internal const string PluginsDirectory = "plugins" ;
2021-11-11 01:53:34 +01:00
internal const string ProjectURL = $"https://github.com/{GithubRepo}" ;
2021-11-10 21:23:24 +01:00
internal const ushort ShortInformationDelay = InformationDelay / 2 ;
internal const string UlongCompatibilityStringPrefix = "s_" ;
internal const string UpdateDirectory = "_old" ;
internal const string WebsiteDirectory = "www" ;
2019-12-08 00:13:18 +01:00
2023-11-14 19:12:33 +01:00
[PublicAPI]
public static readonly char [ ] ListElementSeparators = { ',' } ;
[PublicAPI]
public static readonly string [ ] NewLineIndicators = { "\r\n" , "\r" , "\n" } ;
[PublicAPI]
public static readonly string [ ] RangeIndicators = { ".." } ;
2021-11-10 21:23:24 +01:00
internal static string HomeDirectory {
get {
if ( ! string . IsNullOrEmpty ( CachedHomeDirectory ) ) {
2023-11-14 20:01:29 +01:00
return CachedHomeDirectory ;
2019-12-05 21:34:40 +01:00
}
2021-11-10 21:23:24 +01:00
// We're aiming to handle two possible cases here, classic publish and single-file publish which is possible with OS-specific builds
// In order to achieve that, we have to guess the case above from the binary's name
// We can't just return our base directory since it could lead to the (wrong) temporary directory of extracted files in a single-publish scenario
// If the path goes to our own binary, the user is using OS-specific build, single-file or not, we'll use path to location of that binary then
// Otherwise, this path goes to some third-party binary, likely dotnet/mono, the user is using our generic build or other custom binary, we need to trust our base directory then
CachedHomeDirectory = Path . GetFileNameWithoutExtension ( OS . ProcessFileName ) = = AssemblyName ? Path . GetDirectoryName ( OS . ProcessFileName ) ? ? AppContext . BaseDirectory : AppContext . BaseDirectory ;
return CachedHomeDirectory ;
2019-12-05 21:34:40 +01:00
}
2021-11-10 21:23:24 +01:00
}
2019-01-10 23:44:32 +01:00
2021-11-10 21:23:24 +01:00
internal static string ProgramIdentifier = > $"{PublicIdentifier} V{Version} ({BuildInfo.Variant}/{ModuleVersion} | {OS.Version})" ;
2021-11-11 01:53:34 +01:00
internal static string PublicIdentifier = > $"{AssemblyName}{(BuildInfo.IsCustomBuild ? " - custom " : PluginsCore.HasCustomPluginsLoaded ? " - modded " : " ")}" ;
2021-11-10 21:23:24 +01:00
internal static Version Version = > Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version ? ? throw new InvalidOperationException ( nameof ( Version ) ) ;
2018-05-11 23:20:25 +02:00
2021-11-10 21:23:24 +01:00
private static Guid ModuleVersion = > Assembly . GetExecutingAssembly ( ) . ManifestModule . ModuleVersionId ;
2019-06-25 12:26:55 +02:00
2021-11-10 21:23:24 +01:00
private static string? CachedHomeDirectory ;
2019-12-08 00:13:18 +01:00
2021-11-10 21:23:24 +01:00
internal static class BuildInfo {
2018-05-11 23:20:25 +02:00
#if ASF_VARIANT_DOCKER
2021-11-10 21:47:42 +01:00
internal static bool CanUpdate = > false ;
internal static string Variant = > "docker" ;
2018-05-11 23:20:25 +02:00
#elif ASF_VARIANT_GENERIC
2021-11-10 21:47:42 +01:00
internal static bool CanUpdate = > true ;
internal static string Variant = > "generic" ;
2018-05-11 23:20:25 +02:00
#elif ASF_VARIANT_LINUX_ARM
2021-11-10 21:47:42 +01:00
internal static bool CanUpdate = > true ;
internal static string Variant = > "linux-arm" ;
2020-04-08 19:32:53 +02:00
#elif ASF_VARIANT_LINUX_ARM64
2021-11-10 21:47:42 +01:00
internal static bool CanUpdate = > true ;
internal static string Variant = > "linux-arm64" ;
2018-05-11 23:20:25 +02:00
#elif ASF_VARIANT_LINUX_X64
2021-11-10 21:47:42 +01:00
internal static bool CanUpdate = > true ;
internal static string Variant = > "linux-x64" ;
2021-11-10 20:36:09 +01:00
#elif ASF_VARIANT_OSX_ARM64
2021-11-10 21:47:42 +01:00
internal static bool CanUpdate = > true ;
internal static string Variant = > "osx-arm64" ;
2018-05-11 23:20:25 +02:00
#elif ASF_VARIANT_OSX_X64
2021-11-10 21:47:42 +01:00
internal static bool CanUpdate = > true ;
internal static string Variant = > "osx-x64" ;
2023-02-09 14:08:39 +01:00
#elif ASF_VARIANT_WIN_ARM64
internal static bool CanUpdate = > true ;
internal static string Variant = > "win-arm64" ;
2018-05-11 23:20:25 +02:00
#elif ASF_VARIANT_WIN_X64
2021-11-10 21:47:42 +01:00
internal static bool CanUpdate = > true ;
internal static string Variant = > "win-x64" ;
2018-05-11 23:20:25 +02:00
#else
2021-11-10 21:23:24 +01:00
internal static bool CanUpdate = > false ;
internal static string Variant = > SourceVariant ;
2018-05-11 23:20:25 +02:00
#endif
2021-11-10 21:23:24 +01:00
private const string SourceVariant = "source" ;
2018-05-11 23:20:25 +02:00
2021-11-10 21:23:24 +01:00
internal static bool IsCustomBuild = > Variant = = SourceVariant ;
2016-06-27 02:07:27 +02:00
}
2018-07-28 05:17:52 +02:00
}