diff options
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs b/src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs deleted file mode 100644 index 6dc18271..00000000 --- a/src/WixToolset.Core.WindowsInstaller/Bind/PathResolver.cs +++ /dev/null | |||
| @@ -1,106 +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.Core.WindowsInstaller.Bind | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.IO; | ||
| 8 | using WixToolset.Data; | ||
| 9 | using WixToolset.Data.WindowsInstaller; | ||
| 10 | |||
| 11 | internal static class PathResolver | ||
| 12 | { | ||
| 13 | /// <summary> | ||
| 14 | /// Get the source path of a directory. | ||
| 15 | /// </summary> | ||
| 16 | /// <param name="directories">All cached directories.</param> | ||
| 17 | /// <param name="componentIdGenSeeds">Hash table of Component GUID generation seeds indexed by directory id.</param> | ||
| 18 | /// <param name="directory">Directory identifier.</param> | ||
| 19 | /// <param name="canonicalize">Canonicalize the path for standard directories.</param> | ||
| 20 | /// <returns>Source path of a directory.</returns> | ||
| 21 | public static string GetDirectoryPath(Dictionary<string, ResolvedDirectory> directories, Dictionary<string, string> componentIdGenSeeds, string directory, bool canonicalize) | ||
| 22 | { | ||
| 23 | if (!directories.TryGetValue(directory, out var resolvedDirectory)) | ||
| 24 | { | ||
| 25 | throw new WixException(ErrorMessages.ExpectedDirectory(directory)); | ||
| 26 | } | ||
| 27 | |||
| 28 | if (null == resolvedDirectory.Path) | ||
| 29 | { | ||
| 30 | if (null != componentIdGenSeeds && componentIdGenSeeds.ContainsKey(directory)) | ||
| 31 | { | ||
| 32 | resolvedDirectory.Path = componentIdGenSeeds[directory]; | ||
| 33 | } | ||
| 34 | else if (canonicalize && WindowsInstallerStandard.IsStandardDirectory(directory)) | ||
| 35 | { | ||
| 36 | // when canonicalization is on, standard directories are treated equally | ||
| 37 | resolvedDirectory.Path = directory; | ||
| 38 | } | ||
| 39 | else | ||
| 40 | { | ||
| 41 | string name = resolvedDirectory.Name; | ||
| 42 | |||
| 43 | if (canonicalize) | ||
| 44 | { | ||
| 45 | name = name?.ToLowerInvariant(); | ||
| 46 | } | ||
| 47 | |||
| 48 | if (String.IsNullOrEmpty(resolvedDirectory.DirectoryParent)) | ||
| 49 | { | ||
| 50 | resolvedDirectory.Path = name; | ||
| 51 | } | ||
| 52 | else | ||
| 53 | { | ||
| 54 | string parentPath = GetDirectoryPath(directories, componentIdGenSeeds, resolvedDirectory.DirectoryParent, canonicalize); | ||
| 55 | |||
| 56 | if (null != resolvedDirectory.Name) | ||
| 57 | { | ||
| 58 | resolvedDirectory.Path = Path.Combine(parentPath, name); | ||
| 59 | } | ||
| 60 | else | ||
| 61 | { | ||
| 62 | resolvedDirectory.Path = parentPath; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | return resolvedDirectory.Path; | ||
| 69 | } | ||
| 70 | |||
| 71 | /// <summary> | ||
| 72 | /// Gets the source path of a file. | ||
| 73 | /// </summary> | ||
| 74 | /// <param name="directories">All cached directories in <see cref="ResolvedDirectory"/>.</param> | ||
| 75 | /// <param name="directoryId">Parent directory identifier.</param> | ||
| 76 | /// <param name="fileName">File name (in long|source format).</param> | ||
| 77 | /// <param name="compressed">Specifies the package is compressed.</param> | ||
| 78 | /// <param name="useLongName">Specifies the package uses long file names.</param> | ||
| 79 | /// <returns>Source path of file relative to package directory.</returns> | ||
| 80 | public static string GetFileSourcePath(Dictionary<string, ResolvedDirectory> directories, string directoryId, string fileName, bool compressed, bool useLongName) | ||
| 81 | { | ||
| 82 | string fileSourcePath = Common.GetName(fileName, true, useLongName); | ||
| 83 | |||
| 84 | if (compressed) | ||
| 85 | { | ||
| 86 | // Use just the file name of the file since all uncompressed files must appear | ||
| 87 | // in the root of the image in a compressed package. | ||
| 88 | } | ||
| 89 | else | ||
| 90 | { | ||
| 91 | // Get the relative path of where we want the file to be layed out as specified | ||
| 92 | // in the Directory table. | ||
| 93 | string directoryPath = PathResolver.GetDirectoryPath(directories, null, directoryId, false); | ||
| 94 | fileSourcePath = Path.Combine(directoryPath, fileSourcePath); | ||
| 95 | } | ||
| 96 | |||
| 97 | // Strip off "SourceDir" if it's still on there. | ||
| 98 | if (fileSourcePath.StartsWith("SourceDir\\", StringComparison.Ordinal)) | ||
| 99 | { | ||
| 100 | fileSourcePath = fileSourcePath.Substring(10); | ||
| 101 | } | ||
| 102 | |||
| 103 | return fileSourcePath; | ||
| 104 | } | ||
| 105 | } | ||
| 106 | } | ||
