diff options
| author | Rob Mensching <rob@firegiant.com> | 2018-07-23 13:44:01 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2018-07-23 13:44:01 -0700 |
| commit | 7f846324105e14c84f1ad1bad2fe2c10c22f6e4b (patch) | |
| tree | 0e3dcb0e06bb789ca886c8a0c1517ff21d5a3718 /src | |
| parent | 80e6fdeb013c96dbde1a74e5f2973688fa1018d6 (diff) | |
| download | wix-7f846324105e14c84f1ad1bad2fe2c10c22f6e4b.tar.gz wix-7f846324105e14c84f1ad1bad2fe2c10c22f6e4b.tar.bz2 wix-7f846324105e14c84f1ad1bad2fe2c10c22f6e4b.zip | |
Move data only used by extension to Extensiblity repo
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.Data/Bind/BindPath.cs | 60 | ||||
| -rw-r--r-- | src/WixToolset.Data/Bind/BindResult.cs | 13 | ||||
| -rw-r--r-- | src/WixToolset.Data/Bind/BindStage.cs | 22 | ||||
| -rw-r--r-- | src/WixToolset.Data/Bind/FileTransfer.cs | 112 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.Data/WixToolsetTest.Data.csproj | 8 |
5 files changed, 4 insertions, 211 deletions
diff --git a/src/WixToolset.Data/Bind/BindPath.cs b/src/WixToolset.Data/Bind/BindPath.cs deleted file mode 100644 index 823a57c9..00000000 --- a/src/WixToolset.Data/Bind/BindPath.cs +++ /dev/null | |||
| @@ -1,60 +0,0 @@ | |||
| 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 | |||
| 3 | namespace WixToolset.Data | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using WixToolset.Data.Bind; | ||
| 7 | |||
| 8 | /// <summary> | ||
| 9 | /// Bind path representation. | ||
| 10 | /// </summary> | ||
| 11 | public class BindPath | ||
| 12 | { | ||
| 13 | /// <summary> | ||
| 14 | /// Creates an unnamed bind path. | ||
| 15 | /// </summary> | ||
| 16 | /// <param name="path">Path for the bind path.</param> | ||
| 17 | public BindPath(string path) : this(String.Empty, path, BindStage.Normal) | ||
| 18 | { | ||
| 19 | } | ||
| 20 | |||
| 21 | /// <summary> | ||
| 22 | /// Creates a named bind path. | ||
| 23 | /// </summary> | ||
| 24 | /// <param name="name">Name of the bind path.</param> | ||
| 25 | /// <param name="path">Path for the bind path.</param> | ||
| 26 | /// <param name="stage">Stage for the bind path.</param> | ||
| 27 | public BindPath(string name, string path, BindStage stage = BindStage.Normal) | ||
| 28 | { | ||
| 29 | this.Name = name; | ||
| 30 | this.Path = path; | ||
| 31 | this.Stage = stage; | ||
| 32 | } | ||
| 33 | |||
| 34 | /// <summary> | ||
| 35 | /// Name of the bind path or String.Empty if the path is unnamed. | ||
| 36 | /// </summary> | ||
| 37 | public string Name { get; set; } | ||
| 38 | |||
| 39 | /// <summary> | ||
| 40 | /// Path for the bind path. | ||
| 41 | /// </summary> | ||
| 42 | public string Path { get; set; } | ||
| 43 | |||
| 44 | /// <summary> | ||
| 45 | /// Stage for the bind path. | ||
| 46 | /// </summary> | ||
| 47 | public BindStage Stage { get; set; } | ||
| 48 | |||
| 49 | /// <summary> | ||
| 50 | /// Parses a normal bind path from its string representation | ||
| 51 | /// </summary> | ||
| 52 | /// <param name="bindPath">String representation of bind path that looks like: [name=]path</param> | ||
| 53 | /// <returns>Parsed normal bind path.</returns> | ||
| 54 | public static BindPath Parse(string bindPath) | ||
| 55 | { | ||
| 56 | string[] namedPath = bindPath.Split(new char[] { '=' }, 2); | ||
| 57 | return (1 == namedPath.Length) ? new BindPath(namedPath[0]) : new BindPath(namedPath[0], namedPath[1]); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | } | ||
diff --git a/src/WixToolset.Data/Bind/BindResult.cs b/src/WixToolset.Data/Bind/BindResult.cs deleted file mode 100644 index 1b81ab78..00000000 --- a/src/WixToolset.Data/Bind/BindResult.cs +++ /dev/null | |||
| @@ -1,13 +0,0 @@ | |||
| 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 | |||
| 3 | namespace WixToolset.Data.Bind | ||
| 4 | { | ||
| 5 | using System.Collections.Generic; | ||
| 6 | |||
| 7 | public class BindResult | ||
| 8 | { | ||
| 9 | public IEnumerable<FileTransfer> FileTransfers { get; set; } | ||
| 10 | |||
| 11 | public IEnumerable<string> ContentFilePaths { get; set; } | ||
| 12 | } | ||
| 13 | } | ||
diff --git a/src/WixToolset.Data/Bind/BindStage.cs b/src/WixToolset.Data/Bind/BindStage.cs deleted file mode 100644 index c567cde0..00000000 --- a/src/WixToolset.Data/Bind/BindStage.cs +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 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 | |||
| 3 | namespace WixToolset.Data.Bind | ||
| 4 | { | ||
| 5 | public enum BindStage | ||
| 6 | { | ||
| 7 | /// <summary> | ||
| 8 | /// Normal binding | ||
| 9 | /// </summary> | ||
| 10 | Normal, | ||
| 11 | |||
| 12 | /// <summary> | ||
| 13 | /// Bind the file path of the target build file | ||
| 14 | /// </summary> | ||
| 15 | Target, | ||
| 16 | |||
| 17 | /// <summary> | ||
| 18 | /// Bind the file path of the updated build file | ||
| 19 | /// </summary> | ||
| 20 | Updated, | ||
| 21 | } | ||
| 22 | } | ||
diff --git a/src/WixToolset.Data/Bind/FileTransfer.cs b/src/WixToolset.Data/Bind/FileTransfer.cs deleted file mode 100644 index 046883d8..00000000 --- a/src/WixToolset.Data/Bind/FileTransfer.cs +++ /dev/null | |||
| @@ -1,112 +0,0 @@ | |||
| 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 | |||
| 3 | namespace WixToolset.Data.Bind | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | |||
| 8 | /// <summary> | ||
| 9 | /// Structure used for all file transfer information. | ||
| 10 | /// </summary> | ||
| 11 | public class FileTransfer | ||
| 12 | { | ||
| 13 | /// <summary>Source path to file.</summary> | ||
| 14 | public string Source { get; set; } | ||
| 15 | |||
| 16 | /// <summary>Destination path for file.</summary> | ||
| 17 | public string Destination { get; set; } | ||
| 18 | |||
| 19 | /// <summary>Flag if file should be moved (optimal).</summary> | ||
| 20 | public bool Move { get; set; } | ||
| 21 | |||
| 22 | /// <summary>Optional source line numbers where this file transfer orginated.</summary> | ||
| 23 | public SourceLineNumber SourceLineNumbers { get; set; } | ||
| 24 | |||
| 25 | /// <summary>Optional type of file this transfer is moving or copying.</summary> | ||
| 26 | public string Type { get; set; } | ||
| 27 | |||
| 28 | /// <summary>Indicates whether the file transer was a built by this build or copied from other some build.</summary> | ||
| 29 | public bool Built { get; set; } | ||
| 30 | |||
| 31 | /// <summary>Set during layout of media when the file transfer when the source and target resolve to the same path.</summary> | ||
| 32 | public bool Redundant { get; set; } | ||
| 33 | |||
| 34 | /// <summary> | ||
| 35 | /// Prefer the TryCreate() method to create FileTransfer objects. | ||
| 36 | /// </summary> | ||
| 37 | /// <param name="source">Source path to file.</param> | ||
| 38 | /// <param name="destination">Destination path for file.</param> | ||
| 39 | /// <param name="move">File if file should be moved (optimal).</param> | ||
| 40 | /// <param name="type">Optional type of file this transfer is transferring.</param> | ||
| 41 | /// <param name="sourceLineNumbers">Optional source line numbers wher this transfer originated.</param> | ||
| 42 | public FileTransfer(string source, string destination, bool move, string type = null, SourceLineNumber sourceLineNumbers = null) | ||
| 43 | { | ||
| 44 | this.Source = source; | ||
| 45 | this.Destination = destination; | ||
| 46 | this.Move = move; | ||
| 47 | |||
| 48 | this.Type = type; | ||
| 49 | this.SourceLineNumbers = sourceLineNumbers; | ||
| 50 | } | ||
| 51 | |||
| 52 | /// <summary> | ||
| 53 | /// Creates a file transfer if the source and destination are different. | ||
| 54 | /// </summary> | ||
| 55 | /// <param name="source">Source path to file.</param> | ||
| 56 | /// <param name="destination">Destination path for file.</param> | ||
| 57 | /// <param name="move">File if file should be moved (optimal).</param> | ||
| 58 | /// <param name="type">Optional type of file this transfer is transferring.</param> | ||
| 59 | /// <param name="sourceLineNumbers">Optional source line numbers where this transfer originated.</param> | ||
| 60 | /// <returns>true if the source and destination are the different, false if no file transfer is created.</returns> | ||
| 61 | public static bool TryCreate(string source, string destination, bool move, string type, SourceLineNumber sourceLineNumbers, out FileTransfer transfer) | ||
| 62 | { | ||
| 63 | string sourceFullPath = GetValidatedFullPath(sourceLineNumbers, source); | ||
| 64 | |||
| 65 | string fileLayoutFullPath = GetValidatedFullPath(sourceLineNumbers, destination); | ||
| 66 | |||
| 67 | //// if the current source path (where we know that the file already exists) and the resolved | ||
| 68 | //// path as dictated by the Directory table are not the same, then propagate the file. The | ||
| 69 | //// image that we create may have already been done by some other process other than the linker, so | ||
| 70 | //// there is no reason to copy the files to the resolved source if they are already there. | ||
| 71 | //if (String.Equals(sourceFullPath, fileLayoutFullPath, StringComparison.OrdinalIgnoreCase)) | ||
| 72 | //{ | ||
| 73 | // transfer = null; | ||
| 74 | // return false; | ||
| 75 | //} | ||
| 76 | |||
| 77 | transfer = new FileTransfer(source, destination, move, type, sourceLineNumbers); | ||
| 78 | transfer.Redundant = String.Equals(sourceFullPath, fileLayoutFullPath, StringComparison.OrdinalIgnoreCase); | ||
| 79 | return true; | ||
| 80 | } | ||
| 81 | |||
| 82 | private static string GetValidatedFullPath(SourceLineNumber sourceLineNumbers, string path) | ||
| 83 | { | ||
| 84 | string result; | ||
| 85 | |||
| 86 | try | ||
| 87 | { | ||
| 88 | result = Path.GetFullPath(path); | ||
| 89 | |||
| 90 | var filename = Path.GetFileName(result); | ||
| 91 | |||
| 92 | foreach (var reservedName in Common.ReservedFileNames) | ||
| 93 | { | ||
| 94 | if (reservedName.Equals(filename, StringComparison.OrdinalIgnoreCase)) | ||
| 95 | { | ||
| 96 | throw new WixException(ErrorMessages.InvalidFileName(sourceLineNumbers, path)); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | catch (ArgumentException) | ||
| 101 | { | ||
| 102 | throw new WixException(ErrorMessages.InvalidFileName(sourceLineNumbers, path)); | ||
| 103 | } | ||
| 104 | catch (PathTooLongException) | ||
| 105 | { | ||
| 106 | throw new WixException(ErrorMessages.PathTooLong(sourceLineNumbers, path)); | ||
| 107 | } | ||
| 108 | |||
| 109 | return result; | ||
| 110 | } | ||
| 111 | } | ||
| 112 | } | ||
diff --git a/src/test/WixToolsetTest.Data/WixToolsetTest.Data.csproj b/src/test/WixToolsetTest.Data/WixToolsetTest.Data.csproj index a4ba7cb1..e81b4f6f 100644 --- a/src/test/WixToolsetTest.Data/WixToolsetTest.Data.csproj +++ b/src/test/WixToolsetTest.Data/WixToolsetTest.Data.csproj | |||
| @@ -7,13 +7,13 @@ | |||
| 7 | </PropertyGroup> | 7 | </PropertyGroup> |
| 8 | 8 | ||
| 9 | <ItemGroup> | 9 | <ItemGroup> |
| 10 | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0-preview-20180610-02" /> | 10 | <ProjectReference Include="..\..\WixToolset.Data\WixToolset.Data.csproj" /> |
| 11 | <PackageReference Include="xunit" Version="2.3.1" /> | ||
| 12 | <PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" /> | ||
| 13 | </ItemGroup> | 11 | </ItemGroup> |
| 14 | 12 | ||
| 15 | <ItemGroup> | 13 | <ItemGroup> |
| 16 | <ProjectReference Include="..\..\WixToolset.Data\WixToolset.Data.csproj" /> | 14 | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" /> |
| 15 | <PackageReference Include="xunit" Version="2.4.0" /> | ||
| 16 | <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | ||
| 17 | </ItemGroup> | 17 | </ItemGroup> |
| 18 | 18 | ||
| 19 | </Project> | 19 | </Project> |
