Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move laargs.txt to more suitable location. #83

Merged
merged 15 commits into from
Dec 12, 2023
26 changes: 25 additions & 1 deletion Core/StartupArgManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class StartupArgManager
/// <summary>
/// Path to startup arguments file.
/// </summary>
private const string StartupArgsPath = "laargs.txt";
private static readonly string StartupArgsPath = Path.Combine(PathManager.ConfigPath, "laargs.txt");
iamalexrouse marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Merges Command-line arguments and arguments in <paramref name="cmdArgs"/>
Expand All @@ -20,6 +20,8 @@ public static class StartupArgManager
/// <returns>Merged Arguments</returns>
public static string[] MergeStartupArgs(IEnumerable<string> cmdArgs)
{
MigrateArgsFile();

List<string> startupArgs = new List<string>();
startupArgs.AddRange(cmdArgs);

Expand All @@ -37,5 +39,27 @@ public static string[] MergeStartupArgs(IEnumerable<string> cmdArgs)
return startupArgs.ToArray();
}
}

private static void MigrateArgsFile()
{
try
{
const string OldFileLocation = "laargs.txt";

if (!File.Exists(StartupArgsPath))
{
if (!File.Exists(OldFileLocation))
return;
else
File.Move(OldFileLocation, StartupArgsPath);
}
else
File.Delete(OldFileLocation);
}
catch (Exception ex)
{
ConsoleUtil.WriteLine($"An error occured while trying to migrate 'laargs.txt': {ex}");
}
}
}
}
Loading