Skip to content

Commit

Permalink
Imaging: Further fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gus33000 committed Oct 7, 2023
1 parent 9e1222f commit ec705fc
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/UnifiedUpdatePlatform.Imaging.NET/WimLibImaging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,19 @@ namespace UnifiedUpdatePlatform.Imaging.NET
{
public class WimLibImaging : IImaging
{
public delegate void ProgressCallback(string Operation, int ProgressPercentage, bool IsIndeterminate);

public WimImaging()
{
InitNativeLibrary();
}

public bool AddFileToImage(string wimFile, int imageIndex, string fileToAdd, string destination, ProgressCallback progressCallback = null)
public bool AddFileToImage(string wimFile, int imageIndex, string fileToAdd, string destination, IImaging.ProgressCallback progressCallback = null)
{
return UpdateFilesInImage(wimFile, imageIndex,
new[] { (fileToAdd, destination) },
progressCallback);
}

public bool UpdateFilesInImage(string wimFile, int imageIndex, IEnumerable<(string fileToAdd, string destination)> fileList, ProgressCallback progressCallback = null)
public bool UpdateFilesInImage(string wimFile, int imageIndex, IEnumerable<(string fileToAdd, string destination)> fileList, IImaging.ProgressCallback progressCallback = null)
{
// Early false returns because calling update with no operations sounds unintentional
if (fileList == null)
Expand Down Expand Up @@ -95,12 +93,12 @@ public bool UpdateFilesInImage(string wimFile, int imageIndex, IEnumerable<(stri
return ReformatWindowsImageFileXML(wimFile);
}

public bool DeleteFileFromImage(string wimFile, int imageIndex, string fileToRemove, ProgressCallback progressCallback = null)
public bool DeleteFileFromImage(string wimFile, int imageIndex, string fileToRemove, IImaging.ProgressCallback progressCallback = null)
{
return UpdateFilesInImage(wimFile, imageIndex, new[] { ((string)null, fileToRemove) }, progressCallback);
}

public bool ExportImage(string wimFile, string destinationWimFile, int imageIndex, IEnumerable<string> referenceWIMs = null, WimCompressionType compressionType = WimCompressionType.Lzx, ProgressCallback progressCallback = null, ExportFlags exportFlags = ExportFlags.None)
public bool ExportImage(string wimFile, string destinationWimFile, int imageIndex, IEnumerable<string> referenceWIMs = null, WimCompressionType compressionType = WimCompressionType.Lzx, IImaging.ProgressCallback progressCallback = null, ExportFlags exportFlags = ExportFlags.None)
{
string title = $"Exporting {wimFile.Split(Path.DirectorySeparatorChar).Last()} - Index {imageIndex}";
try
Expand Down Expand Up @@ -168,7 +166,7 @@ public bool ExtractFileFromImage(string wimFile, int imageIndex, string fileToEx
return true;
}

public bool RenameFileInImage(string wimFile, int imageIndex, string sourceFilePath, string destinationFilePath, ProgressCallback progressCallback = null)
public bool RenameFileInImage(string wimFile, int imageIndex, string sourceFilePath, string destinationFilePath, IImaging.ProgressCallback progressCallback = null)
{
sourceFilePath = sourceFilePath.Replace(Path.DirectorySeparatorChar, '\\');
destinationFilePath = destinationFilePath.Replace(Path.DirectorySeparatorChar, '\\');
Expand All @@ -193,7 +191,7 @@ public bool RenameFileInImage(string wimFile, int imageIndex, string sourceFileP
return ReformatWindowsImageFileXML(wimFile);
}

public bool ApplyImage(string wimFile, int imageIndex, string OutputDirectory, IEnumerable<string> referenceWIMs = null, bool PreserveACL = true, ProgressCallback progressCallback = null)
public bool ApplyImage(string wimFile, int imageIndex, string OutputDirectory, IEnumerable<string> referenceWIMs = null, bool PreserveACL = true, IImaging.ProgressCallback progressCallback = null)
{
string title = $"Applying {wimFile.Split(Path.DirectorySeparatorChar).Last()} - Index {imageIndex}";
try
Expand Down Expand Up @@ -225,7 +223,7 @@ public bool CaptureImage(
string imageDisplayName = null,
string imageDisplayDescription = null,
WimCompressionType compressionType = WimCompressionType.Lzx,
ProgressCallback progressCallback = null,
IImaging.ProgressCallback progressCallback = null,
int UpdateFrom = -1,
bool PreserveACL = true)
{
Expand Down Expand Up @@ -564,7 +562,7 @@ private static bool ReformatWindowsImageFileXMLUsingWimgApi(string wimFile)
return true;
}

private ManagedWimLib.ProgressCallback GetCallbackStatus(String title, ProgressCallback progressCallback = null)
private ManagedWimLib.ProgressCallback GetCallbackStatus(String title, IImaging.ProgressCallback progressCallback = null)
{
CallbackStatus ProgressCallback(ProgressMsg msg, object info, object progctx)
{
Expand Down

0 comments on commit ec705fc

Please sign in to comment.