Skip to content

Commit 6de5a52

Browse files
committed
Refactor code
Renamed FileManager to FileUtils and updated all references accordingly. Moved SemanticVersion to the Models namespace. Replaced WindowsJob with WindowsJobService, relocating and updating the implementation. Updated usages in CoreManager and related classes to use the new service and utility names. These changes improve code organization and naming consistency.
1 parent 8d86aa2 commit 6de5a52

11 files changed

Lines changed: 190 additions & 196 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace ServiceLib.Common;
55

6-
public static class FileManager
6+
public static class FileUtils
77
{
88
private static readonly string _tag = "FileManager";
99

v2rayN/ServiceLib/Common/WindowsJob.cs

Lines changed: 0 additions & 177 deletions
This file was deleted.

v2rayN/ServiceLib/Handler/SysProxy/ProxySettingLinux.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static async Task UnsetProxy()
1818

1919
private static async Task ExecCmd(List<string> args)
2020
{
21-
var fileName = await FileManager.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetLinuxShellFileName), false);
21+
var fileName = await FileUtils.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetLinuxShellFileName), false);
2222

2323
await Utils.GetCliWrapOutput(fileName, args);
2424
}

v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static async Task UnsetProxy()
2323

2424
private static async Task ExecCmd(List<string> args)
2525
{
26-
var fileName = await FileManager.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetOSXShellFileName), false);
26+
var fileName = await FileUtils.CreateLinuxShellFile(_proxySetFileName, EmbedUtils.GetEmbedText(Global.ProxySetOSXShellFileName), false);
2727

2828
await Utils.GetCliWrapOutput(fileName, args);
2929
}

v2rayN/ServiceLib/Manager/CoreAdminManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private async Task UpdateFunc(bool notify, string msg)
3535
sb.AppendLine("#!/bin/bash");
3636
var cmdLine = $"{fileName.AppendQuotes()} {string.Format(coreInfo.Arguments, Utils.GetBinConfigPath(configPath).AppendQuotes())}";
3737
sb.AppendLine($"exec sudo -S -- {cmdLine}");
38-
var shFilePath = await FileManager.CreateLinuxShellFile("run_as_sudo.sh", sb.ToString(), true);
38+
var shFilePath = await FileUtils.CreateLinuxShellFile("run_as_sudo.sh", sb.ToString(), true);
3939

4040
var procService = new ProcessService(
4141
fileName: shFilePath,
@@ -68,7 +68,7 @@ public async Task KillProcessAsLinuxSudo()
6868
try
6969
{
7070
var shellFileName = Utils.IsOSX() ? Global.KillAsSudoOSXShellFileName : Global.KillAsSudoLinuxShellFileName;
71-
var shFilePath = await FileManager.CreateLinuxShellFile("kill_as_sudo.sh", EmbedUtils.GetEmbedText(shellFileName), true);
71+
var shFilePath = await FileUtils.CreateLinuxShellFile("kill_as_sudo.sh", EmbedUtils.GetEmbedText(shellFileName), true);
7272
if (shFilePath.Contains(' '))
7373
{
7474
shFilePath = shFilePath.AppendQuotes();

v2rayN/ServiceLib/Manager/CoreManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class CoreManager
88
private static readonly Lazy<CoreManager> _instance = new(() => new());
99
public static CoreManager Instance => _instance.Value;
1010
private Config _config;
11-
private WindowsJob? _processJob;
11+
private WindowsJobService? _processJob;
1212
private ProcessService? _processService;
1313
private ProcessService? _processPreService;
1414
private bool _linuxSudo = false;
@@ -27,7 +27,7 @@ public async Task Init(Config config, Func<bool, string, Task> updateFunc)
2727
var toPath = Utils.GetBinPath("");
2828
if (fromPath != toPath)
2929
{
30-
FileManager.CopyDirectory(fromPath, toPath, true, false);
30+
FileUtils.CopyDirectory(fromPath, toPath, true, false);
3131
}
3232
}
3333

v2rayN/ServiceLib/Manager/TaskManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ private async Task ScheduledTasks()
5656
{
5757
//Logging.SaveLog("Execute delete expired files");
5858

59-
FileManager.DeleteExpiredFiles(Utils.GetBinConfigPath(), DateTime.Now.AddHours(-1));
60-
FileManager.DeleteExpiredFiles(Utils.GetLogPath(), DateTime.Now.AddMonths(-1));
61-
FileManager.DeleteExpiredFiles(Utils.GetTempPath(), DateTime.Now.AddMonths(-1));
59+
FileUtils.DeleteExpiredFiles(Utils.GetBinConfigPath(), DateTime.Now.AddHours(-1));
60+
FileUtils.DeleteExpiredFiles(Utils.GetLogPath(), DateTime.Now.AddMonths(-1));
61+
FileUtils.DeleteExpiredFiles(Utils.GetTempPath(), DateTime.Now.AddMonths(-1));
6262

6363
try
6464
{

v2rayN/ServiceLib/Common/SemanticVersion.cs renamed to v2rayN/ServiceLib/Models/SemanticVersion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace ServiceLib.Common;
1+
namespace ServiceLib.Models;
22

33
public class SemanticVersion
44
{

0 commit comments

Comments
 (0)