Skip to content

Commit

Permalink
Merge pull request #6 from Damon3000s/create-pid-directory
Browse files Browse the repository at this point in the history
Create the directory the Pid will be stored in
  • Loading branch information
matt-edmondson authored Feb 3, 2025
2 parents ff97a13 + d4834a5 commit 4b70455
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions SingleAppInstance/SingleAppInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace ktsu.SingleAppInstance;
/// </summary>
public static class SingleAppInstance
{
internal static AbsoluteFilePath PidFilePath { get; } = AppData.Path / $".{nameof(SingleAppInstance)}.pid".As<FileName>();
internal static AbsoluteDirectoryPath PidDirectoryPath { get; } = AppData.Path;
internal static AbsoluteFilePath PidFilePath { get; } = PidDirectoryPath / $".{nameof(SingleAppInstance)}.pid".As<FileName>();

/// <summary>
/// Exits the application if another instance is already running.
Expand Down Expand Up @@ -107,5 +108,9 @@ internal static bool IsAlreadyRunning()
/// <remarks>
/// This method writes the current process ID to the PID file in the application data path.
/// </remarks>
internal static void WritePidFile() => File.WriteAllText(PidFilePath, Environment.ProcessId.ToString(CultureInfo.InvariantCulture));
internal static void WritePidFile()
{
Directory.CreateDirectory(PidDirectoryPath);
File.WriteAllText(PidFilePath, Environment.ProcessId.ToString(CultureInfo.InvariantCulture));
}
}

0 comments on commit 4b70455

Please sign in to comment.