it was needed, but with some checks
This commit is contained in:
@@ -92,29 +92,49 @@ namespace Torch.Server
|
|||||||
|
|
||||||
private static void CopyNative(string binPath)
|
private static void CopyNative(string binPath)
|
||||||
{
|
{
|
||||||
var apiSource = Path.Combine(binPath, "steam_api64.dll");
|
var log = LogManager.GetLogger("TorchLauncher");
|
||||||
var apiTarget = Path.Combine(AppContext.BaseDirectory, "steam_api64.dll");
|
|
||||||
if (!File.Exists(apiTarget))
|
|
||||||
{
|
|
||||||
File.Copy(apiSource, apiTarget);
|
|
||||||
}
|
|
||||||
else if (File.GetLastWriteTime(apiTarget) < File.GetLastWriteTime(binPath))
|
|
||||||
{
|
|
||||||
File.Delete(apiTarget);
|
|
||||||
File.Copy(apiSource, apiTarget);
|
|
||||||
}
|
|
||||||
|
|
||||||
var havokSource = Path.Combine(binPath, "Havok.dll");
|
var workingDir = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||||
var havokTarget = Path.Combine(AppContext.BaseDirectory, "Havok.dll");
|
if (workingDir.Attributes.HasFlag(FileAttributes.ReadOnly))
|
||||||
|
|
||||||
if (!File.Exists(havokTarget))
|
|
||||||
{
|
{
|
||||||
File.Copy(havokSource, havokTarget);
|
log.Warn("Game directory is readonly. You should copy steam_api64.dll, Havok.dll from bin manually");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (File.GetLastWriteTime(havokTarget) < File.GetLastWriteTime(havokSource))
|
|
||||||
{
|
try
|
||||||
File.Delete(havokTarget);
|
{
|
||||||
File.Copy(havokSource, havokTarget);
|
var apiSource = Path.Combine(binPath, "steam_api64.dll");
|
||||||
|
var apiTarget = Path.Combine(workingDir.FullName, "steam_api64.dll");
|
||||||
|
if (!File.Exists(apiTarget))
|
||||||
|
{
|
||||||
|
File.Copy(apiSource, apiTarget);
|
||||||
|
}
|
||||||
|
else if (File.GetLastWriteTime(apiTarget) < File.GetLastWriteTime(binPath))
|
||||||
|
{
|
||||||
|
File.Delete(apiTarget);
|
||||||
|
File.Copy(apiSource, apiTarget);
|
||||||
|
}
|
||||||
|
|
||||||
|
var havokSource = Path.Combine(binPath, "Havok.dll");
|
||||||
|
var havokTarget = Path.Combine(workingDir.FullName, "Havok.dll");
|
||||||
|
|
||||||
|
if (!File.Exists(havokTarget))
|
||||||
|
{
|
||||||
|
File.Copy(havokSource, havokTarget);
|
||||||
|
}
|
||||||
|
else if (File.GetLastWriteTime(havokTarget) < File.GetLastWriteTime(havokSource))
|
||||||
|
{
|
||||||
|
File.Delete(havokTarget);
|
||||||
|
File.Copy(havokSource, havokTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
// file is being used by another process, probably previous torch has not been closed yet
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.Error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user