aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Bind/TransferFilesCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/Bind/TransferFilesCommand.cs')
-rw-r--r--src/WixToolset.Core/Bind/TransferFilesCommand.cs61
1 files changed, 21 insertions, 40 deletions
diff --git a/src/WixToolset.Core/Bind/TransferFilesCommand.cs b/src/WixToolset.Core/Bind/TransferFilesCommand.cs
index 719b8b20..f116569c 100644
--- a/src/WixToolset.Core/Bind/TransferFilesCommand.cs
+++ b/src/WixToolset.Core/Bind/TransferFilesCommand.cs
@@ -1,29 +1,37 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. 1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 2
3namespace WixToolset.Bind 3namespace WixToolset.Core.Bind
4{ 4{
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.IO; 7 using System.IO;
8 using System.Security.AccessControl; 8 using System.Security.AccessControl;
9 using WixToolset.Data; 9 using WixToolset.Data;
10 using WixToolset.Data.Bind;
10 using WixToolset.Extensibility; 11 using WixToolset.Extensibility;
11 12
12 internal class TransferFilesCommand : ICommand 13 internal class TransferFilesCommand
13 { 14 {
14 public IEnumerable<IBinderFileManager> FileManagers { private get; set; } 15 public TransferFilesCommand(IEnumerable<BindPath> bindPaths, IEnumerable<IBinderExtension> extensions, IEnumerable<FileTransfer> fileTransfers, bool suppressAclReset)
16 {
17 this.FileResolver = new FileResolver(bindPaths, extensions);
18 this.FileTransfers = fileTransfers;
19 this.SuppressAclReset = suppressAclReset;
20 }
21
22 private FileResolver FileResolver { get; }
15 23
16 public IEnumerable<FileTransfer> FileTransfers { private get; set; } 24 private IEnumerable<FileTransfer> FileTransfers { get; }
17 25
18 public bool SuppressAclReset { private get; set; } 26 private bool SuppressAclReset { get; }
19 27
20 public void Execute() 28 public void Execute()
21 { 29 {
22 List<string> destinationFiles = new List<string>(); 30 List<string> destinationFiles = new List<string>();
23 31
24 foreach (FileTransfer fileTransfer in this.FileTransfers) 32 foreach (var fileTransfer in this.FileTransfers)
25 { 33 {
26 string fileSource = this.ResolveFile(fileTransfer.Source, fileTransfer.Type, fileTransfer.SourceLineNumbers, BindStage.Normal); 34 string fileSource = this.FileResolver.ResolveFile(fileTransfer.Source, fileTransfer.Type, fileTransfer.SourceLineNumbers, BindStage.Normal);
27 35
28 // If the source and destination are identical, then there's nothing to do here 36 // If the source and destination are identical, then there's nothing to do here
29 if (0 == String.Compare(fileSource, fileTransfer.Destination, StringComparison.OrdinalIgnoreCase)) 37 if (0 == String.Compare(fileSource, fileTransfer.Destination, StringComparison.OrdinalIgnoreCase))
@@ -165,44 +173,17 @@ namespace WixToolset.Bind
165 } 173 }
166 } 174 }
167 175
168 private string ResolveFile(string source, string type, SourceLineNumber sourceLineNumbers, BindStage bindStage) 176 private void TransferFile(bool move, string source, string destination)
169 { 177 {
170 string path = null; 178 bool complete = false;
171 foreach (IBinderFileManager fileManager in this.FileManagers)
172 {
173 path = fileManager.ResolveFile(source, type, sourceLineNumbers, bindStage);
174 if (null != path)
175 {
176 break;
177 }
178 }
179 179
180 if (null == path) 180 if (move)
181 { 181 {
182 throw new WixFileNotFoundException(sourceLineNumbers, source, type); 182 complete = this.FileResolver.MoveFile(source, destination, true);
183 } 183 }
184 184 else
185 return path;
186 }
187
188 private void TransferFile(bool move, string source, string destination)
189 {
190 bool complete = false;
191 foreach (IBinderFileManager fileManager in this.FileManagers)
192 { 185 {
193 if (move) 186 complete = this.FileResolver.CopyFile(source, destination, true);
194 {
195 complete = fileManager.MoveFile(source, destination, true);
196 }
197 else
198 {
199 complete = fileManager.CopyFile(source, destination, true);
200 }
201
202 if (complete)
203 {
204 break;
205 }
206 } 187 }
207 188
208 if (!complete) 189 if (!complete)