Skip to content

Commit 763ffde

Browse files
committed
Move HasRunFlag to Abstractions.Utils
1 parent 079f5ba commit 763ffde

File tree

3 files changed

+45
-41
lines changed

3 files changed

+45
-41
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace DevProxy.Abstractions.Utils;
6+
7+
public static class HasRunFlag
8+
{
9+
private static readonly string filename = Path.Combine(ProxyUtils.AppFolder!, ".hasrun");
10+
11+
public static bool CreateIfMissing()
12+
{
13+
if (File.Exists(filename))
14+
{
15+
return false;
16+
}
17+
18+
return Create();
19+
}
20+
21+
private static bool Create()
22+
{
23+
try
24+
{
25+
File.WriteAllText(filename, "");
26+
}
27+
catch
28+
{
29+
return false;
30+
}
31+
return true;
32+
}
33+
34+
public static void Remove()
35+
{
36+
try
37+
{
38+
if (File.Exists(filename))
39+
{
40+
File.Delete(filename);
41+
}
42+
}
43+
catch { }
44+
}
45+
}

DevProxy/Commands/CertCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.CommandLine.Parsing;
1010
using System.Diagnostics;
1111
using Titanium.Web.Proxy.Helpers;
12-
using static DevProxy.Proxy.ProxyEngine;
1312

1413
namespace DevProxy.Commands;
1514

DevProxy/Proxy/ProxyEngine.cs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -615,46 +615,6 @@ private static void ToggleSystemProxy(ToggleSystemProxyAction toggle, string? ip
615615
process.WaitForExit();
616616
}
617617

618-
internal static class HasRunFlag
619-
{
620-
private static readonly string filename = Path.Combine(ProxyUtils.AppFolder!, ".hasrun");
621-
622-
public static bool CreateIfMissing()
623-
{
624-
if (File.Exists(filename))
625-
{
626-
return false;
627-
}
628-
629-
return Create();
630-
}
631-
632-
private static bool Create()
633-
{
634-
try
635-
{
636-
File.WriteAllText(filename, "");
637-
}
638-
catch
639-
{
640-
return false;
641-
}
642-
return true;
643-
}
644-
645-
public static void Remove()
646-
{
647-
try
648-
{
649-
if (File.Exists(filename))
650-
{
651-
File.Delete(filename);
652-
}
653-
}
654-
catch { }
655-
}
656-
}
657-
658618
private static int GetProcessId(TunnelConnectSessionEventArgs e)
659619
{
660620
if (RunTime.IsWindows)

0 commit comments

Comments
 (0)