From eee0773fc35c4c2d37c95186f4bf686dcb1c8d8b Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 26 Dec 2017 15:12:48 -0800 Subject: Move copy/move file operations to ILayoutExtension --- src/WixToolset.Core/Bind/FileSystem.cs | 21 ++++++++++----------- src/WixToolset.Core/Bind/TransferFilesCommand.cs | 6 +++--- src/WixToolset.Core/Layout.cs | 3 +-- 3 files changed, 14 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Core/Bind/FileSystem.cs b/src/WixToolset.Core/Bind/FileSystem.cs index 7d1b223e..bdd65503 100644 --- a/src/WixToolset.Core/Bind/FileSystem.cs +++ b/src/WixToolset.Core/Bind/FileSystem.cs @@ -10,30 +10,29 @@ namespace WixToolset.Core.Bind internal class FileSystem { - public FileSystem(IEnumerable extensions) + public FileSystem(IEnumerable extensions) { - this.Extensions = extensions ?? Array.Empty(); + this.Extensions = extensions ?? Array.Empty(); } - private IEnumerable Extensions { get; } + private IEnumerable Extensions { get; } /// /// Copies a file. /// /// The file to copy. /// The destination file. - /// true if the destination file can be overwritten; otherwise, false. - public bool CopyFile(string source, string destination, bool overwrite) + public bool CopyFile(string source, string destination) { foreach (var extension in this.Extensions) { - if (extension.CopyFile(source, destination, overwrite)) + if (extension.CopyFile(source, destination)) { return true; } } - if (overwrite && File.Exists(destination)) + if (File.Exists(destination)) { File.Delete(destination); } @@ -44,7 +43,7 @@ namespace WixToolset.Core.Bind int er = Marshal.GetLastWin32Error(); #endif - File.Copy(source, destination, overwrite); + File.Copy(source, destination, true); } return true; @@ -55,17 +54,17 @@ namespace WixToolset.Core.Bind /// /// The file to move. /// The destination file. - public bool MoveFile(string source, string destination, bool overwrite) + public bool MoveFile(string source, string destination) { foreach (var extension in this.Extensions) { - if (extension.MoveFile(source, destination, overwrite)) + if (extension.MoveFile(source, destination)) { return true; } } - if (overwrite && File.Exists(destination)) + if (File.Exists(destination)) { File.Delete(destination); } diff --git a/src/WixToolset.Core/Bind/TransferFilesCommand.cs b/src/WixToolset.Core/Bind/TransferFilesCommand.cs index d4e143c3..6230a4f5 100644 --- a/src/WixToolset.Core/Bind/TransferFilesCommand.cs +++ b/src/WixToolset.Core/Bind/TransferFilesCommand.cs @@ -13,7 +13,7 @@ namespace WixToolset.Core.Bind internal class TransferFilesCommand { - public TransferFilesCommand(IMessaging messaging, IEnumerable extensions, IEnumerable fileTransfers, bool suppressAclReset) + public TransferFilesCommand(IMessaging messaging, IEnumerable extensions, IEnumerable fileTransfers, bool suppressAclReset) { this.FileSystem = new FileSystem(extensions); this.Messaging = messaging; @@ -181,11 +181,11 @@ namespace WixToolset.Core.Bind if (move) { - complete = this.FileSystem.MoveFile(source, destination, true); + complete = this.FileSystem.MoveFile(source, destination); } else { - complete = this.FileSystem.CopyFile(source, destination, true); + complete = this.FileSystem.CopyFile(source, destination); } if (!complete) diff --git a/src/WixToolset.Core/Layout.cs b/src/WixToolset.Core/Layout.cs index b2957fb9..d62335fb 100644 --- a/src/WixToolset.Core/Layout.cs +++ b/src/WixToolset.Core/Layout.cs @@ -47,7 +47,6 @@ namespace WixToolset.Core var context = this.ServiceProvider.GetService(); context.Messaging = this.Messaging; context.Extensions = extensionManager.Create(); - context.FileSystemExtensions = extensionManager.Create(); context.FileTransfers = this.FileTransfers; context.ContentFilePaths = this.ContentFilePaths; context.ContentsFile = this.ContentsFile; @@ -70,7 +69,7 @@ namespace WixToolset.Core { this.Messaging.Write(VerboseMessages.LayingOutMedia()); - var command = new TransferFilesCommand(context.Messaging, context.FileSystemExtensions, context.FileTransfers, context.SuppressAclReset); + var command = new TransferFilesCommand(context.Messaging, context.Extensions, context.FileTransfers, context.SuppressAclReset); command.Execute(); } } -- cgit v1.2.3-55-g6feb