diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-12-26 15:12:48 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-12-26 15:12:48 -0800 |
| commit | eee0773fc35c4c2d37c95186f4bf686dcb1c8d8b (patch) | |
| tree | 471dd54ac9b302c0443a242858a01b59e491c947 | |
| parent | 1d6ff8af3c423ee4622185edc986ae5caad6b122 (diff) | |
| download | wix-eee0773fc35c4c2d37c95186f4bf686dcb1c8d8b.tar.gz wix-eee0773fc35c4c2d37c95186f4bf686dcb1c8d8b.tar.bz2 wix-eee0773fc35c4c2d37c95186f4bf686dcb1c8d8b.zip | |
Move copy/move file operations to ILayoutExtension
| -rw-r--r-- | src/WixToolset.Core/Bind/FileSystem.cs | 21 | ||||
| -rw-r--r-- | src/WixToolset.Core/Bind/TransferFilesCommand.cs | 6 | ||||
| -rw-r--r-- | src/WixToolset.Core/Layout.cs | 3 |
3 files changed, 14 insertions, 16 deletions
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 | |||
| 10 | 10 | ||
| 11 | internal class FileSystem | 11 | internal class FileSystem |
| 12 | { | 12 | { |
| 13 | public FileSystem(IEnumerable<IFileSystemExtension> extensions) | 13 | public FileSystem(IEnumerable<ILayoutExtension> extensions) |
| 14 | { | 14 | { |
| 15 | this.Extensions = extensions ?? Array.Empty<IFileSystemExtension>(); | 15 | this.Extensions = extensions ?? Array.Empty<ILayoutExtension>(); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | private IEnumerable<IFileSystemExtension> Extensions { get; } | 18 | private IEnumerable<ILayoutExtension> Extensions { get; } |
| 19 | 19 | ||
| 20 | /// <summary> | 20 | /// <summary> |
| 21 | /// Copies a file. | 21 | /// Copies a file. |
| 22 | /// </summary> | 22 | /// </summary> |
| 23 | /// <param name="source">The file to copy.</param> | 23 | /// <param name="source">The file to copy.</param> |
| 24 | /// <param name="destination">The destination file.</param> | 24 | /// <param name="destination">The destination file.</param> |
| 25 | /// <param name="overwrite">true if the destination file can be overwritten; otherwise, false.</param> | 25 | public bool CopyFile(string source, string destination) |
| 26 | public bool CopyFile(string source, string destination, bool overwrite) | ||
| 27 | { | 26 | { |
| 28 | foreach (var extension in this.Extensions) | 27 | foreach (var extension in this.Extensions) |
| 29 | { | 28 | { |
| 30 | if (extension.CopyFile(source, destination, overwrite)) | 29 | if (extension.CopyFile(source, destination)) |
| 31 | { | 30 | { |
| 32 | return true; | 31 | return true; |
| 33 | } | 32 | } |
| 34 | } | 33 | } |
| 35 | 34 | ||
| 36 | if (overwrite && File.Exists(destination)) | 35 | if (File.Exists(destination)) |
| 37 | { | 36 | { |
| 38 | File.Delete(destination); | 37 | File.Delete(destination); |
| 39 | } | 38 | } |
| @@ -44,7 +43,7 @@ namespace WixToolset.Core.Bind | |||
| 44 | int er = Marshal.GetLastWin32Error(); | 43 | int er = Marshal.GetLastWin32Error(); |
| 45 | #endif | 44 | #endif |
| 46 | 45 | ||
| 47 | File.Copy(source, destination, overwrite); | 46 | File.Copy(source, destination, true); |
| 48 | } | 47 | } |
| 49 | 48 | ||
| 50 | return true; | 49 | return true; |
| @@ -55,17 +54,17 @@ namespace WixToolset.Core.Bind | |||
| 55 | /// </summary> | 54 | /// </summary> |
| 56 | /// <param name="source">The file to move.</param> | 55 | /// <param name="source">The file to move.</param> |
| 57 | /// <param name="destination">The destination file.</param> | 56 | /// <param name="destination">The destination file.</param> |
| 58 | public bool MoveFile(string source, string destination, bool overwrite) | 57 | public bool MoveFile(string source, string destination) |
| 59 | { | 58 | { |
| 60 | foreach (var extension in this.Extensions) | 59 | foreach (var extension in this.Extensions) |
| 61 | { | 60 | { |
| 62 | if (extension.MoveFile(source, destination, overwrite)) | 61 | if (extension.MoveFile(source, destination)) |
| 63 | { | 62 | { |
| 64 | return true; | 63 | return true; |
| 65 | } | 64 | } |
| 66 | } | 65 | } |
| 67 | 66 | ||
| 68 | if (overwrite && File.Exists(destination)) | 67 | if (File.Exists(destination)) |
| 69 | { | 68 | { |
| 70 | File.Delete(destination); | 69 | File.Delete(destination); |
| 71 | } | 70 | } |
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 | |||
| 13 | 13 | ||
| 14 | internal class TransferFilesCommand | 14 | internal class TransferFilesCommand |
| 15 | { | 15 | { |
| 16 | public TransferFilesCommand(IMessaging messaging, IEnumerable<IFileSystemExtension> extensions, IEnumerable<FileTransfer> fileTransfers, bool suppressAclReset) | 16 | public TransferFilesCommand(IMessaging messaging, IEnumerable<ILayoutExtension> extensions, IEnumerable<FileTransfer> fileTransfers, bool suppressAclReset) |
| 17 | { | 17 | { |
| 18 | this.FileSystem = new FileSystem(extensions); | 18 | this.FileSystem = new FileSystem(extensions); |
| 19 | this.Messaging = messaging; | 19 | this.Messaging = messaging; |
| @@ -181,11 +181,11 @@ namespace WixToolset.Core.Bind | |||
| 181 | 181 | ||
| 182 | if (move) | 182 | if (move) |
| 183 | { | 183 | { |
| 184 | complete = this.FileSystem.MoveFile(source, destination, true); | 184 | complete = this.FileSystem.MoveFile(source, destination); |
| 185 | } | 185 | } |
| 186 | else | 186 | else |
| 187 | { | 187 | { |
| 188 | complete = this.FileSystem.CopyFile(source, destination, true); | 188 | complete = this.FileSystem.CopyFile(source, destination); |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | if (!complete) | 191 | 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 | |||
| 47 | var context = this.ServiceProvider.GetService<ILayoutContext>(); | 47 | var context = this.ServiceProvider.GetService<ILayoutContext>(); |
| 48 | context.Messaging = this.Messaging; | 48 | context.Messaging = this.Messaging; |
| 49 | context.Extensions = extensionManager.Create<ILayoutExtension>(); | 49 | context.Extensions = extensionManager.Create<ILayoutExtension>(); |
| 50 | context.FileSystemExtensions = extensionManager.Create<IFileSystemExtension>(); | ||
| 51 | context.FileTransfers = this.FileTransfers; | 50 | context.FileTransfers = this.FileTransfers; |
| 52 | context.ContentFilePaths = this.ContentFilePaths; | 51 | context.ContentFilePaths = this.ContentFilePaths; |
| 53 | context.ContentsFile = this.ContentsFile; | 52 | context.ContentsFile = this.ContentsFile; |
| @@ -70,7 +69,7 @@ namespace WixToolset.Core | |||
| 70 | { | 69 | { |
| 71 | this.Messaging.Write(VerboseMessages.LayingOutMedia()); | 70 | this.Messaging.Write(VerboseMessages.LayingOutMedia()); |
| 72 | 71 | ||
| 73 | var command = new TransferFilesCommand(context.Messaging, context.FileSystemExtensions, context.FileTransfers, context.SuppressAclReset); | 72 | var command = new TransferFilesCommand(context.Messaging, context.Extensions, context.FileTransfers, context.SuppressAclReset); |
| 74 | command.Execute(); | 73 | command.Execute(); |
| 75 | } | 74 | } |
| 76 | } | 75 | } |
