mirror of
https://github.com/copyrighttxt/watrbx-game-engine.git
synced 2026-09-04 20:57:49 +00:00
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System;
|
|
using System.IO;
|
|
|
|
namespace Roblox.Configuration
|
|
{
|
|
public class ConfigurationCopier
|
|
{
|
|
public enum Result
|
|
{
|
|
UpdatedFiles,
|
|
NoUpdatesNeeded
|
|
}
|
|
|
|
public static Result CopyConfiguration(string source, DirectoryInfo destination)
|
|
{
|
|
var result = Result.NoUpdatesNeeded;
|
|
|
|
if (string.IsNullOrEmpty(source))
|
|
throw new InvalidOperationException("SharedConfigSource isn't specified.");
|
|
|
|
var files = new DirectoryInfo(source).GetFiles("*.config");
|
|
for (int i = 0; i < files.Length; i++)
|
|
{
|
|
var file = files[i];
|
|
var destinationFile = new FileInfo(destination.FullName + file.Name);
|
|
if (!destinationFile.Exists)
|
|
{
|
|
file.CopyTo(destinationFile.FullName, true);
|
|
result = Result.UpdatedFiles;
|
|
continue;
|
|
}
|
|
|
|
if (destinationFile.LastWriteTimeUtc != file.LastWriteTimeUtc)
|
|
{
|
|
file.CopyTo(destinationFile.FullName, true);
|
|
result = Result.UpdatedFiles;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|