Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d7d556d2f2 | ||
![]() |
850b313269 | ||
![]() |
fe985e1a9c |
@@ -3,11 +3,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Diagnostics.Runtime;
|
using Microsoft.Diagnostics.Runtime;
|
||||||
using NLog;
|
using NLog;
|
||||||
using PropertyChanged;
|
using PropertyChanged;
|
||||||
@@ -21,8 +20,6 @@ using Torch.API.Session;
|
|||||||
using Torch.Commands;
|
using Torch.Commands;
|
||||||
using Torch.Managers.PatchManager;
|
using Torch.Managers.PatchManager;
|
||||||
using Torch.Mod;
|
using Torch.Mod;
|
||||||
using Torch.Mod.Messages;
|
|
||||||
using Torch.Patches;
|
|
||||||
using Torch.Server.Commands;
|
using Torch.Server.Commands;
|
||||||
using Torch.Server.Managers;
|
using Torch.Server.Managers;
|
||||||
using Torch.Utils;
|
using Torch.Utils;
|
||||||
@@ -211,7 +208,7 @@ namespace Torch.Server
|
|||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
var exe = Assembly.GetExecutingAssembly().Location.Replace("dll", "exe");
|
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
||||||
|
|
||||||
var args = Environment.GetCommandLineArgs();
|
var args = Environment.GetCommandLineArgs();
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using NLog;
|
using NLog;
|
||||||
using VRage;
|
using VRage;
|
||||||
@@ -31,7 +32,7 @@ internal class UnhandledExceptionHandler
|
|||||||
{
|
{
|
||||||
Console.WriteLine("Restarting in 5 seconds.");
|
Console.WriteLine("Restarting in 5 seconds.");
|
||||||
Thread.Sleep(5000);
|
Thread.Sleep(5000);
|
||||||
var exe = typeof(Program).Assembly.Location;
|
var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe");
|
||||||
|
|
||||||
Process.Start(exe, $"-waitForPid {Environment.ProcessId} {_config}");
|
Process.Start(exe, $"-waitForPid {Environment.ProcessId} {_config}");
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NLog;
|
using NLog;
|
||||||
@@ -9,7 +10,7 @@ using Torch.API;
|
|||||||
|
|
||||||
namespace Torch.Managers
|
namespace Torch.Managers
|
||||||
{
|
{
|
||||||
public class FilesystemManager : Manager
|
public partial class FilesystemManager : Manager
|
||||||
{
|
{
|
||||||
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
|
private static readonly Logger _log = LogManager.GetCurrentClassLogger();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -51,19 +52,27 @@ namespace Torch.Managers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Move the given file (if it exists) to a temporary directory that will be cleared the next time the application starts.
|
|
||||||
/// </summary>
|
|
||||||
public void SoftDelete(string path, string file)
|
public void SoftDelete(string path, string file)
|
||||||
{
|
{
|
||||||
string source = Path.Combine(path, file);
|
var source = Path.Combine(path, file);
|
||||||
if (!File.Exists(source))
|
if (!File.Exists(source))
|
||||||
return;
|
return;
|
||||||
var rand = Path.GetRandomFileName();
|
|
||||||
var dest = Path.Combine(TempDirectory, rand);
|
var tempFilePath = Path.Combine(path, file + ".old");
|
||||||
File.Move(source, rand);
|
if (File.Exists(tempFilePath))
|
||||||
string rsource = Path.Combine(path, rand);
|
File.Delete(tempFilePath);
|
||||||
File.Move(rsource, dest);
|
|
||||||
}
|
var errorCode = Rename(source, tempFilePath);
|
||||||
|
if (Marshal.GetExceptionForHR(errorCode) is { } exception)
|
||||||
|
throw exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
[LibraryImport("msvcrt", SetLastError = true, EntryPoint = "rename")]
|
||||||
|
[UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
|
||||||
|
private static partial int Rename(
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)]
|
||||||
|
string oldpath,
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)]
|
||||||
|
string newpath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user