aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Extensibility/Data/FileTransfer.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/WixToolset.Extensibility/Data/FileTransfer.cs114
1 files changed, 114 insertions, 0 deletions
diff --git a/src/WixToolset.Extensibility/Data/FileTransfer.cs b/src/WixToolset.Extensibility/Data/FileTransfer.cs
new file mode 100644
index 00000000..0356ac4c
--- /dev/null
+++ b/src/WixToolset.Extensibility/Data/FileTransfer.cs
@@ -0,0 +1,114 @@
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
3namespace WixToolset.Extensibility.Data
4{
5 using System;
6 using System.IO;
7 using WixToolset.Data;
8
9 /// <summary>
10 /// Structure used for all file transfer information.
11 /// </summary>
12 public class FileTransfer
13 {
14 /// <summary>Source path to file.</summary>
15 public string Source { get; set; }
16
17 /// <summary>Destination path for file.</summary>
18 public string Destination { get; set; }
19
20 /// <summary>Flag if file should be moved (optimal).</summary>
21 public bool Move { get; set; }
22
23 /// <summary>Optional source line numbers where this file transfer orginated.</summary>
24 public SourceLineNumber SourceLineNumbers { get; set; }
25
26 /// <summary>Optional type of file this transfer is moving or copying.</summary>
27 public string Type { get; set; }
28
29 /// <summary>Indicates whether the file transer was a built by this build or copied from other some build.</summary>
30 public bool Built { get; set; }
31
32 /// <summary>Set during layout of media when the file transfer when the source and target resolve to the same path.</summary>
33 public bool Redundant { get; set; }
34
35 /// <summary>
36 /// Prefer the TryCreate() method to create FileTransfer objects.
37 /// </summary>
38 /// <param name="source">Source path to file.</param>
39 /// <param name="destination">Destination path for file.</param>
40 /// <param name="move">File if file should be moved (optimal).</param>
41 /// <param name="type">Optional type of file this transfer is transferring.</param>
42 /// <param name="sourceLineNumbers">Optional source line numbers wher this transfer originated.</param>
43 public FileTransfer(string source, string destination, bool move, string type = null, SourceLineNumber sourceLineNumbers = null)
44 {
45 this.Source = source;
46 this.Destination = destination;
47 this.Move = move;
48
49 this.Type = type;
50 this.SourceLineNumbers = sourceLineNumbers;
51 }
52
53 /// <summary>
54 /// Creates a file transfer if the source and destination are different.
55 /// </summary>
56 /// <param name="source">Source path to file.</param>
57 /// <param name="destination">Destination path for file.</param>
58 /// <param name="move">File if file should be moved (optimal).</param>
59 /// <param name="type">Optional type of file this transfer is transferring.</param>
60 /// <param name="sourceLineNumbers">Optional source line numbers where this transfer originated.</param>
61 /// <returns>true if the source and destination are the different, false if no file transfer is created.</returns>
62 public static bool TryCreate(string source, string destination, bool move, string type, SourceLineNumber sourceLineNumbers, out FileTransfer transfer)
63 {
64 //string sourceFullPath = GetValidatedFullPath(sourceLineNumbers, source);
65
66 //string fileLayoutFullPath = GetValidatedFullPath(sourceLineNumbers, destination);
67
68 ////// if the current source path (where we know that the file already exists) and the resolved
69 ////// path as dictated by the Directory table are not the same, then propagate the file. The
70 ////// image that we create may have already been done by some other process other than the linker, so
71 ////// there is no reason to copy the files to the resolved source if they are already there.
72 ////if (String.Equals(sourceFullPath, fileLayoutFullPath, StringComparison.OrdinalIgnoreCase))
73 ////{
74 //// transfer = null;
75 //// return false;
76 ////}
77
78 //transfer = new FileTransfer(source, destination, move, type, sourceLineNumbers);
79 //transfer.Redundant = String.Equals(sourceFullPath, fileLayoutFullPath, StringComparison.OrdinalIgnoreCase);
80 //return true;
81 throw new NotImplementedException();
82 }
83
84 //private static string GetValidatedFullPath(SourceLineNumber sourceLineNumbers, string path)
85 //{
86 // string result;
87
88 // try
89 // {
90 // result = Path.GetFullPath(path);
91
92 // var filename = Path.GetFileName(result);
93
94 // foreach (var reservedName in Common.ReservedFileNames)
95 // {
96 // if (reservedName.Equals(filename, StringComparison.OrdinalIgnoreCase))
97 // {
98 // throw new WixException(ErrorMessages.InvalidFileName(sourceLineNumbers, path));
99 // }
100 // }
101 // }
102 // catch (ArgumentException)
103 // {
104 // throw new WixException(ErrorMessages.InvalidFileName(sourceLineNumbers, path));
105 // }
106 // catch (PathTooLongException)
107 // {
108 // throw new WixException(ErrorMessages.PathTooLong(sourceLineNumbers, path));
109 // }
110
111 // return result;
112 //}
113 }
114}