lightweight variant (#1)
Reviewed-on: #1 Co-authored-by: Aleksandr Neychev <alexnejchev73@gmail.com>
This commit was merged in pull request #1.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
namespace CursorLang.Core.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Where the background half of the application lives on disk.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Two processes now share one folder, and each of them at some point needs the path
|
||||
/// of the other: the settings window registers the agent for startup and must not
|
||||
/// register itself, and the agent starts the settings window from the tray menu.
|
||||
/// <c>Environment.ProcessPath</c> answers the wrong question for both, so the paths
|
||||
/// are worked out from the folder the assemblies were loaded from.
|
||||
/// </remarks>
|
||||
internal static class AgentExecutable
|
||||
{
|
||||
/// <summary>The background process — the one Windows starts at sign-in.</summary>
|
||||
internal const string AgentFileName = "CursorLang.exe";
|
||||
|
||||
/// <summary>The settings window, started on demand and gone when closed.</summary>
|
||||
internal const string SettingsFileName = "CursorLang.Settings.exe";
|
||||
|
||||
/// <summary>
|
||||
/// The full path of the agent, or <c>null</c> when it is not next to us — which
|
||||
/// happens in the tests and would happen to a half-copied installation.
|
||||
/// </summary>
|
||||
internal static string? AgentPath => Beside(AgentFileName);
|
||||
|
||||
/// <summary>The full path of the settings window, on the same terms.</summary>
|
||||
internal static string? SettingsPath => Beside(SettingsFileName);
|
||||
|
||||
private static string? Beside(string fileName)
|
||||
{
|
||||
string path = Path.Combine(AppContext.BaseDirectory, fileName);
|
||||
return File.Exists(path) ? path : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user