Skip to content

Commit

Permalink
Fixes #497
Browse files Browse the repository at this point in the history
  • Loading branch information
bcssov committed Mar 20, 2024
1 parent 38091f5 commit ebab952
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Created : 02-10-2024
//
// Last Modified By : Mario
// Last Modified On : 03-11-2024
// Last Modified On : 03-20-2024
// ***********************************************************************
// <copyright file="SingleInstance.cs" company="Mario">
// Mario
Expand All @@ -14,8 +14,10 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -188,6 +190,22 @@ private static string GetMutexName()
sb.Append($"{item:X2}");
}

if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Trim if not windows, so limit of 104 or 108 characters? net will create a file with the following Path.GetTempPath() + "CoreFXPipe_" prefix. Check length and trim if necessary
var tempFile = Path.GetTempPath();
var path = Path.Combine(tempFile, $"CoreFXPipe_{sb}");
while (path.Length > 100)
{
path = Path.Combine(tempFile, $"CoreFXPipe_{sb}");
sb.Remove(sb.Length - 1, 1);
if (sb.Length < 0)
{
throw new ArgumentException("Temp Path is too long. Cannot generate SingleInstance.");
}
}
}

mutexName = sb.ToString();
}

Expand Down

0 comments on commit ebab952

Please sign in to comment.