mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-17 06:50:29 +00:00
Always navigate to executable location first
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,6 +7,9 @@ ArchiSteamFarm/config/*
|
|||||||
!ArchiSteamFarm/config/example.xml
|
!ArchiSteamFarm/config/example.xml
|
||||||
!ArchiSteamFarm/config/minimal.xml
|
!ArchiSteamFarm/config/minimal.xml
|
||||||
|
|
||||||
|
# Ignore local debugging log file
|
||||||
|
ArchiSteamFarm/log.txt
|
||||||
|
|
||||||
#################
|
#################
|
||||||
## Eclipse
|
## Eclipse
|
||||||
#################
|
#################
|
||||||
|
|||||||
@@ -117,10 +117,10 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
BotName = botName;
|
BotName = botName;
|
||||||
|
|
||||||
ConfigFile = Path.Combine(Program.ConfigDirectoryPath, BotName + ".xml");
|
ConfigFile = Path.Combine(Program.ConfigDirectory, BotName + ".xml");
|
||||||
LoginKeyFile = Path.Combine(Program.ConfigDirectoryPath, BotName + ".key");
|
LoginKeyFile = Path.Combine(Program.ConfigDirectory, BotName + ".key");
|
||||||
MobileAuthenticatorFile = Path.Combine(Program.ConfigDirectoryPath, BotName + ".auth");
|
MobileAuthenticatorFile = Path.Combine(Program.ConfigDirectory, BotName + ".auth");
|
||||||
SentryFile = Path.Combine(Program.ConfigDirectoryPath, BotName + ".bin");
|
SentryFile = Path.Combine(Program.ConfigDirectory, BotName + ".bin");
|
||||||
|
|
||||||
if (!ReadConfig()) {
|
if (!ReadConfig()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -43,18 +43,17 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private const string LatestGithubReleaseURL = "https://api.github.com/repos/JustArchi/ArchiSteamFarm/releases/latest";
|
private const string LatestGithubReleaseURL = "https://api.github.com/repos/JustArchi/ArchiSteamFarm/releases/latest";
|
||||||
internal const string ConfigDirectoryPath = "config";
|
internal const string ConfigDirectory = "config";
|
||||||
|
internal const string LogFile = "log.txt";
|
||||||
|
|
||||||
|
private static readonly object ConsoleLock = new object();
|
||||||
private static readonly SemaphoreSlim SteamSemaphore = new SemaphoreSlim(1);
|
private static readonly SemaphoreSlim SteamSemaphore = new SemaphoreSlim(1);
|
||||||
private static readonly ManualResetEvent ShutdownResetEvent = new ManualResetEvent(false);
|
private static readonly ManualResetEvent ShutdownResetEvent = new ManualResetEvent(false);
|
||||||
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
|
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
|
||||||
private static readonly string ExecutablePath = Assembly.Location;
|
private static readonly string ExecutableFile = Assembly.Location;
|
||||||
private static readonly AssemblyName AssemblyName = Assembly.GetName();
|
private static readonly string ExecutableDirectory = Path.GetDirectoryName(ExecutableFile);
|
||||||
private static readonly object ConsoleLock = new object();
|
|
||||||
//private static readonly string ExeName = AssemblyName.Name + ".exe";
|
|
||||||
|
|
||||||
internal static readonly string LogFile = Path.Combine(Path.GetDirectoryName(ExecutablePath), "log.txt");
|
internal static readonly string Version = Assembly.GetName().Version.ToString();
|
||||||
internal static readonly string Version = AssemblyName.Version.ToString();
|
|
||||||
|
|
||||||
internal static bool ConsoleIsBusy { get; private set; } = false;
|
internal static bool ConsoleIsBusy { get; private set; } = false;
|
||||||
|
|
||||||
@@ -92,7 +91,7 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal static async Task Restart() {
|
internal static async Task Restart() {
|
||||||
await Bot.ShutdownAllBots().ConfigureAwait(false);
|
await Bot.ShutdownAllBots().ConfigureAwait(false);
|
||||||
System.Diagnostics.Process.Start(ExecutablePath);
|
System.Diagnostics.Process.Start(ExecutableFile);
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,29 +155,36 @@ namespace ArchiSteamFarm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void Main(string[] args) {
|
private static void Main(string[] args) {
|
||||||
|
Directory.SetCurrentDirectory(ExecutableDirectory);
|
||||||
InitServices();
|
InitServices();
|
||||||
|
|
||||||
Logging.LogGenericInfo("Main", "Archi's Steam Farm, version " + Version);
|
|
||||||
|
|
||||||
Task.Run(async () => await CheckForUpdate().ConfigureAwait(false)).Wait();
|
|
||||||
|
|
||||||
// Allow loading configs from source tree if it's a debug build
|
// Allow loading configs from source tree if it's a debug build
|
||||||
if (Debugging.IsDebugBuild) {
|
if (Debugging.IsDebugBuild) {
|
||||||
|
|
||||||
|
// Common structure is bin/(x64/)Debug/ArchiSteamFarm.exe, so we allow up to 4 directories up
|
||||||
for (var i = 0; i < 4; i++) {
|
for (var i = 0; i < 4; i++) {
|
||||||
Directory.SetCurrentDirectory("..");
|
Directory.SetCurrentDirectory("..");
|
||||||
if (Directory.Exists(ConfigDirectoryPath)) {
|
if (Directory.Exists(ConfigDirectory)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If config directory doesn't exist after our adjustment, abort all of that
|
||||||
|
if (!Directory.Exists(ConfigDirectory)) {
|
||||||
|
Directory.SetCurrentDirectory(ExecutableDirectory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists(ConfigDirectoryPath)) {
|
Logging.LogGenericInfo("Main", "Archi's Steam Farm, version " + Version);
|
||||||
|
Task.Run(async () => await CheckForUpdate().ConfigureAwait(false)).Wait();
|
||||||
|
|
||||||
|
if (!Directory.Exists(ConfigDirectory)) {
|
||||||
Logging.LogGenericError("Main", "Config directory doesn't exist!");
|
Logging.LogGenericError("Main", "Config directory doesn't exist!");
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
Task.Run(async () => await Exit(1).ConfigureAwait(false)).Wait();
|
Task.Run(async () => await Exit(1).ConfigureAwait(false)).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var configFile in Directory.EnumerateFiles(ConfigDirectoryPath, "*.xml")) {
|
foreach (var configFile in Directory.EnumerateFiles(ConfigDirectory, "*.xml")) {
|
||||||
string botName = Path.GetFileNameWithoutExtension(configFile);
|
string botName = Path.GetFileNameWithoutExtension(configFile);
|
||||||
Bot bot = new Bot(botName);
|
Bot bot = new Bot(botName);
|
||||||
if (!bot.Enabled) {
|
if (!bot.Enabled) {
|
||||||
|
|||||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.2.4.0")]
|
[assembly: AssemblyVersion("1.3.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.2.4.0")]
|
[assembly: AssemblyFileVersion("1.3.0.0")]
|
||||||
|
|||||||
Reference in New Issue
Block a user