diff options
Diffstat (limited to 'src/WixToolset.Core/Bind/TransferFilesCommand.cs')
| -rw-r--r-- | src/WixToolset.Core/Bind/TransferFilesCommand.cs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/WixToolset.Core/Bind/TransferFilesCommand.cs b/src/WixToolset.Core/Bind/TransferFilesCommand.cs index f116569c..68d8b129 100644 --- a/src/WixToolset.Core/Bind/TransferFilesCommand.cs +++ b/src/WixToolset.Core/Bind/TransferFilesCommand.cs | |||
| @@ -9,18 +9,22 @@ namespace WixToolset.Core.Bind | |||
| 9 | using WixToolset.Data; | 9 | using WixToolset.Data; |
| 10 | using WixToolset.Data.Bind; | 10 | using WixToolset.Data.Bind; |
| 11 | using WixToolset.Extensibility; | 11 | using WixToolset.Extensibility; |
| 12 | using WixToolset.Extensibility.Services; | ||
| 12 | 13 | ||
| 13 | internal class TransferFilesCommand | 14 | internal class TransferFilesCommand |
| 14 | { | 15 | { |
| 15 | public TransferFilesCommand(IEnumerable<BindPath> bindPaths, IEnumerable<IBinderExtension> extensions, IEnumerable<FileTransfer> fileTransfers, bool suppressAclReset) | 16 | public TransferFilesCommand(IMessaging messaging, IEnumerable<BindPath> bindPaths, IEnumerable<IBinderExtension> extensions, IEnumerable<FileTransfer> fileTransfers, bool suppressAclReset) |
| 16 | { | 17 | { |
| 17 | this.FileResolver = new FileResolver(bindPaths, extensions); | 18 | this.FileResolver = new FileResolver(bindPaths, extensions); |
| 19 | this.Messaging = messaging; | ||
| 18 | this.FileTransfers = fileTransfers; | 20 | this.FileTransfers = fileTransfers; |
| 19 | this.SuppressAclReset = suppressAclReset; | 21 | this.SuppressAclReset = suppressAclReset; |
| 20 | } | 22 | } |
| 21 | 23 | ||
| 22 | private FileResolver FileResolver { get; } | 24 | private FileResolver FileResolver { get; } |
| 23 | 25 | ||
| 26 | private IMessaging Messaging { get; } | ||
| 27 | |||
| 24 | private IEnumerable<FileTransfer> FileTransfers { get; } | 28 | private IEnumerable<FileTransfer> FileTransfers { get; } |
| 25 | 29 | ||
| 26 | private bool SuppressAclReset { get; } | 30 | private bool SuppressAclReset { get; } |
| @@ -47,12 +51,12 @@ namespace WixToolset.Core.Bind | |||
| 47 | { | 51 | { |
| 48 | if (fileTransfer.Move) | 52 | if (fileTransfer.Move) |
| 49 | { | 53 | { |
| 50 | Messaging.Instance.OnMessage(WixVerboses.MoveFile(fileSource, fileTransfer.Destination)); | 54 | this.Messaging.Write(VerboseMessages.MoveFile(fileSource, fileTransfer.Destination)); |
| 51 | this.TransferFile(true, fileSource, fileTransfer.Destination); | 55 | this.TransferFile(true, fileSource, fileTransfer.Destination); |
| 52 | } | 56 | } |
| 53 | else | 57 | else |
| 54 | { | 58 | { |
| 55 | Messaging.Instance.OnMessage(WixVerboses.CopyFile(fileSource, fileTransfer.Destination)); | 59 | this.Messaging.Write(VerboseMessages.CopyFile(fileSource, fileTransfer.Destination)); |
| 56 | this.TransferFile(false, fileSource, fileTransfer.Destination); | 60 | this.TransferFile(false, fileSource, fileTransfer.Destination); |
| 57 | } | 61 | } |
| 58 | 62 | ||
| @@ -61,7 +65,7 @@ namespace WixToolset.Core.Bind | |||
| 61 | } | 65 | } |
| 62 | catch (FileNotFoundException e) | 66 | catch (FileNotFoundException e) |
| 63 | { | 67 | { |
| 64 | throw new WixFileNotFoundException(e.FileName); | 68 | throw new WixFileNotFoundException(fileTransfer.SourceLineNumbers, e.FileName); |
| 65 | } | 69 | } |
| 66 | catch (DirectoryNotFoundException) | 70 | catch (DirectoryNotFoundException) |
| 67 | { | 71 | { |
| @@ -72,7 +76,7 @@ namespace WixToolset.Core.Bind | |||
| 72 | } | 76 | } |
| 73 | 77 | ||
| 74 | string directory = Path.GetDirectoryName(fileTransfer.Destination); | 78 | string directory = Path.GetDirectoryName(fileTransfer.Destination); |
| 75 | Messaging.Instance.OnMessage(WixVerboses.CreateDirectory(directory)); | 79 | this.Messaging.Write(VerboseMessages.CreateDirectory(directory)); |
| 76 | Directory.CreateDirectory(directory); | 80 | Directory.CreateDirectory(directory); |
| 77 | retry = true; | 81 | retry = true; |
| 78 | } | 82 | } |
| @@ -86,7 +90,7 @@ namespace WixToolset.Core.Bind | |||
| 86 | 90 | ||
| 87 | if (File.Exists(fileTransfer.Destination)) | 91 | if (File.Exists(fileTransfer.Destination)) |
| 88 | { | 92 | { |
| 89 | Messaging.Instance.OnMessage(WixVerboses.RemoveDestinationFile(fileTransfer.Destination)); | 93 | this.Messaging.Write(VerboseMessages.RemoveDestinationFile(fileTransfer.Destination)); |
| 90 | 94 | ||
| 91 | // try to ensure the file is not read-only | 95 | // try to ensure the file is not read-only |
| 92 | FileAttributes attributes = File.GetAttributes(fileTransfer.Destination); | 96 | FileAttributes attributes = File.GetAttributes(fileTransfer.Destination); |
| @@ -96,7 +100,7 @@ namespace WixToolset.Core.Bind | |||
| 96 | } | 100 | } |
| 97 | catch (ArgumentException) // thrown for unauthorized access errors | 101 | catch (ArgumentException) // thrown for unauthorized access errors |
| 98 | { | 102 | { |
| 99 | throw new WixException(WixErrors.UnauthorizedAccess(fileTransfer.Destination)); | 103 | throw new WixException(ErrorMessages.UnauthorizedAccess(fileTransfer.Destination)); |
| 100 | } | 104 | } |
| 101 | 105 | ||
| 102 | // try to delete the file | 106 | // try to delete the file |
| @@ -106,7 +110,7 @@ namespace WixToolset.Core.Bind | |||
| 106 | } | 110 | } |
| 107 | catch (IOException) | 111 | catch (IOException) |
| 108 | { | 112 | { |
| 109 | throw new WixException(WixErrors.FileInUse(null, fileTransfer.Destination)); | 113 | throw new WixException(ErrorMessages.FileInUse(null, fileTransfer.Destination)); |
| 110 | } | 114 | } |
| 111 | 115 | ||
| 112 | retry = true; | 116 | retry = true; |
| @@ -126,7 +130,7 @@ namespace WixToolset.Core.Bind | |||
| 126 | 130 | ||
| 127 | if (File.Exists(fileTransfer.Destination)) | 131 | if (File.Exists(fileTransfer.Destination)) |
| 128 | { | 132 | { |
| 129 | Messaging.Instance.OnMessage(WixVerboses.RemoveDestinationFile(fileTransfer.Destination)); | 133 | this.Messaging.Write(VerboseMessages.RemoveDestinationFile(fileTransfer.Destination)); |
| 130 | 134 | ||
| 131 | // ensure the file is not read-only, then delete it | 135 | // ensure the file is not read-only, then delete it |
| 132 | FileAttributes attributes = File.GetAttributes(fileTransfer.Destination); | 136 | FileAttributes attributes = File.GetAttributes(fileTransfer.Destination); |
| @@ -137,7 +141,7 @@ namespace WixToolset.Core.Bind | |||
| 137 | } | 141 | } |
| 138 | catch (IOException) | 142 | catch (IOException) |
| 139 | { | 143 | { |
| 140 | throw new WixException(WixErrors.FileInUse(null, fileTransfer.Destination)); | 144 | throw new WixException(ErrorMessages.FileInUse(null, fileTransfer.Destination)); |
| 141 | } | 145 | } |
| 142 | 146 | ||
| 143 | retry = true; | 147 | retry = true; |
| @@ -168,7 +172,7 @@ namespace WixToolset.Core.Bind | |||
| 168 | } | 172 | } |
| 169 | catch | 173 | catch |
| 170 | { | 174 | { |
| 171 | Messaging.Instance.OnMessage(WixWarnings.UnableToResetAcls()); | 175 | this.Messaging.Write(WarningMessages.UnableToResetAcls()); |
| 172 | } | 176 | } |
| 173 | } | 177 | } |
| 174 | } | 178 | } |
