AutomationTool changes to support game projects overriding how to copy files during staging. InternalUtils.SafeCopyFile now takes an optional delegate to call when copying files. A CustomStageCopyHandler can be implemented to supply the copy operation. This is useful for transforming files during staging.

#rb Josh.Adams

[CL 30192577 by will brown in ue5-main branch]
This commit is contained in:
will brown
2023-12-07 16:35:45 -05:00
parent 969d787e3d
commit 3a3e27c70e
6 changed files with 110 additions and 4 deletions
@@ -69,6 +69,12 @@ namespace AutomationTool
Local
}
/// <summary>
/// Delegate to override the copy operation.
/// <returns>Return true if the copy was handled. Otherwise false to fallback on the built in copy operation</returns>
/// </summary>
public delegate bool OverrideCopyDelegate(ILogger Logger, string SourceName, string TargetName);
/// <summary>
/// Base utility function for script commands.
/// </summary>
@@ -1415,7 +1421,7 @@ namespace AutomationTool
/// <param name="Dest">The full path to the destination file</param>
/// <param name="bAllowDifferingTimestamps">If true, will always skip a file if the destination exists, even if timestamp differs; defaults to false</param>
/// <returns>True if the operation was successful, false otherwise.</returns>
public static void CopyFileIncremental(FileReference Source, FileReference Dest, bool bAllowDifferingTimestamps = false, List<string> IniKeyDenyList = null, List<string> IniSectionDenyList = null)
public static void CopyFileIncremental(FileReference Source, FileReference Dest, OverrideCopyDelegate OverrideCopyHandler = null, bool bAllowDifferingTimestamps = false, List<string> IniKeyDenyList = null, List<string> IniSectionDenyList = null)
{
if (InternalUtils.SafeFileExists(Dest.FullName, true))
{
@@ -1443,7 +1449,7 @@ namespace AutomationTool
{
throw new AutomationException("Failed to delete {0} for copy", Dest);
}
if (!InternalUtils.SafeCopyFile(Source.FullName, Dest.FullName, IniKeyDenyList: IniKeyDenyList, IniSectionDenyList: IniSectionDenyList))
if (!InternalUtils.SafeCopyFile(Source.FullName, Dest.FullName, OverrideCopyHandler: OverrideCopyHandler, IniKeyDenyList: IniKeyDenyList, IniSectionDenyList: IniSectionDenyList))
{
throw new AutomationException("Failed to copy {0} to {1}", Source, Dest);
}