mirror of
https://github.com/patchzyy/wiicompiled
synced 2026-09-13 09:59:47 -04:00
refactor WiiCompiled.Setup into WiiCompiled.Setup.Windows and add WiiCompiled.Setup.Common
the idea behind this is C# code that is OS agnostic can go in WiiCompiled.Setup.Common to be shared by any OS specific code (eg: WiiCompiled.Setup.Windows and WiiCompiled.Setup.Linux).
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
using WiiCompiled.Setup.Common;
|
||||
|
||||
namespace WiiCompiled.Setup.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// The one path by which a product receives its copied runtime assets, shared by install and repair.
|
||||
/// Each product gets its own moved (not copied) entry, re-verified against the authoritative identity
|
||||
/// in case the source changed mid-preparation.
|
||||
/// </summary>
|
||||
internal static class RuntimeAssetPublication
|
||||
{
|
||||
public static void AddEntries(List<InstallTransactionEntry> entries, string sourceAssets,
|
||||
string preparedRoot, IEnumerable<(string Name, string Destination)> products,
|
||||
string expectedFingerprint, string operationDescription, Action<string> diagnostic,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var (name, destination) in products)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
var preparedProduct = Path.Combine(preparedRoot, name);
|
||||
Directory.CreateDirectory(preparedProduct);
|
||||
FileSystemUtilities.CopyDirectory(
|
||||
Path.Combine(sourceAssets, ProductRuntimeAssets.SourceBootstrapDirectoryName),
|
||||
Path.Combine(preparedProduct, ProductRuntimeAssets.ProductBootstrapDirectoryName),
|
||||
cancellationToken);
|
||||
foreach (var (relativePath, fileName) in ProductRuntimeAssets.Files)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
File.Copy(ProductRuntimeAssets.SourceFile(sourceAssets, relativePath),
|
||||
Path.Combine(preparedProduct, fileName));
|
||||
}
|
||||
|
||||
if (!ToolkitFingerprint.ProductRuntimeAssetsMatch(preparedProduct, expectedFingerprint,
|
||||
cancellationToken, diagnostic))
|
||||
{
|
||||
throw new IOException(
|
||||
$"A copied product runtime asset changed while {operationDescription} was being prepared.");
|
||||
}
|
||||
|
||||
entries.Add(InstallTransactionEntry.Directory(
|
||||
Path.Combine(preparedProduct, ProductRuntimeAssets.ProductBootstrapDirectoryName),
|
||||
Path.Combine(destination, ProductRuntimeAssets.ProductBootstrapDirectoryName)));
|
||||
foreach (var (_, fileName) in ProductRuntimeAssets.Files)
|
||||
entries.Add(InstallTransactionEntry.File(Path.Combine(preparedProduct, fileName),
|
||||
Path.Combine(destination, fileName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user