From dbde9e7104b907bbbaea17e21247d8cafc8b3a4c Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 14 Oct 2017 16:12:07 -0700 Subject: Massive refactoring to introduce the concept of IBackend --- src/WixToolset.Core/Bind/TransferFilesCommand.cs | 61 ++++++++---------------- 1 file changed, 21 insertions(+), 40 deletions(-) (limited to 'src/WixToolset.Core/Bind/TransferFilesCommand.cs') 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 @@ // 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. -namespace WixToolset.Bind +namespace WixToolset.Core.Bind { using System; using System.Collections.Generic; using System.IO; using System.Security.AccessControl; using WixToolset.Data; + using WixToolset.Data.Bind; using WixToolset.Extensibility; - internal class TransferFilesCommand : ICommand + internal class TransferFilesCommand { - public IEnumerable FileManagers { private get; set; } + public TransferFilesCommand(IEnumerable bindPaths, IEnumerable extensions, IEnumerable fileTransfers, bool suppressAclReset) + { + this.FileResolver = new FileResolver(bindPaths, extensions); + this.FileTransfers = fileTransfers; + this.SuppressAclReset = suppressAclReset; + } + + private FileResolver FileResolver { get; } - public IEnumerable FileTransfers { private get; set; } + private IEnumerable FileTransfers { get; } - public bool SuppressAclReset { private get; set; } + private bool SuppressAclReset { get; } public void Execute() { List destinationFiles = new List(); - foreach (FileTransfer fileTransfer in this.FileTransfers) + foreach (var fileTransfer in this.FileTransfers) { - string fileSource = this.ResolveFile(fileTransfer.Source, fileTransfer.Type, fileTransfer.SourceLineNumbers, BindStage.Normal); + string fileSource = this.FileResolver.ResolveFile(fileTransfer.Source, fileTransfer.Type, fileTransfer.SourceLineNumbers, BindStage.Normal); // If the source and destination are identical, then there's nothing to do here if (0 == String.Compare(fileSource, fileTransfer.Destination, StringComparison.OrdinalIgnoreCase)) @@ -165,44 +173,17 @@ namespace WixToolset.Bind } } - private string ResolveFile(string source, string type, SourceLineNumber sourceLineNumbers, BindStage bindStage) + private void TransferFile(bool move, string source, string destination) { - string path = null; - foreach (IBinderFileManager fileManager in this.FileManagers) - { - path = fileManager.ResolveFile(source, type, sourceLineNumbers, bindStage); - if (null != path) - { - break; - } - } + bool complete = false; - if (null == path) + if (move) { - throw new WixFileNotFoundException(sourceLineNumbers, source, type); + complete = this.FileResolver.MoveFile(source, destination, true); } - - return path; - } - - private void TransferFile(bool move, string source, string destination) - { - bool complete = false; - foreach (IBinderFileManager fileManager in this.FileManagers) + else { - if (move) - { - complete = fileManager.MoveFile(source, destination, true); - } - else - { - complete = fileManager.CopyFile(source, destination, true); - } - - if (complete) - { - break; - } + complete = this.FileResolver.CopyFile(source, destination, true); } if (!complete) -- cgit v1.2.3-55-g6feb