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 /src/WixToolset.Core/Bind/FileSystem.cs | |
| parent | 1d6ff8af3c423ee4622185edc986ae5caad6b122 (diff) | |
| download | wix-eee0773fc35c4c2d37c95186f4bf686dcb1c8d8b.tar.gz wix-eee0773fc35c4c2d37c95186f4bf686dcb1c8d8b.tar.bz2 wix-eee0773fc35c4c2d37c95186f4bf686dcb1c8d8b.zip | |
Move copy/move file operations to ILayoutExtension
Diffstat (limited to 'src/WixToolset.Core/Bind/FileSystem.cs')
| -rw-r--r-- | src/WixToolset.Core/Bind/FileSystem.cs | 21 |
1 files changed, 10 insertions, 11 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 | } |
