aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.Native/CabinetCompressFile.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.Native/CabinetCompressFile.cs')
-rw-r--r--src/WixToolset.Core.Native/CabinetCompressFile.cs65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/WixToolset.Core.Native/CabinetCompressFile.cs b/src/WixToolset.Core.Native/CabinetCompressFile.cs
new file mode 100644
index 00000000..6778f4a1
--- /dev/null
+++ b/src/WixToolset.Core.Native/CabinetCompressFile.cs
@@ -0,0 +1,65 @@
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.Core.Native
4{
5 /// <summary>
6 /// Information to compress file into a cabinet.
7 /// </summary>
8 public sealed class CabinetCompressFile
9 {
10 /// <summary>
11 /// Cabinet compress file.
12 /// </summary>
13 /// <param name="path">Path to file to add.</param>
14 /// <param name="token">The token for the file.</param>
15 public CabinetCompressFile(string path, string token)
16 {
17 this.Path = path;
18 this.Token = token;
19 this.Hash = null;
20 }
21
22 /// <summary>
23 /// Cabinet compress file.
24 /// </summary>
25 /// <param name="path">Path to file to add.</param>
26 /// <param name="token">The token for the file.</param>
27 /// <param name="hash1">Hash 1</param>
28 /// <param name="hash2">Hash 2</param>
29 /// <param name="hash3">Hash 3</param>
30 /// <param name="hash4">Hash 4</param>
31 public CabinetCompressFile(string path, string token, int hash1, int hash2, int hash3, int hash4)
32 {
33 this.Path = path;
34 this.Token = token;
35 this.Hash = new[] { hash1, hash2, hash3, hash4 };
36 }
37
38 /// <summary>
39 /// Gets the path to the file to compress.
40 /// </summary>
41 public string Path { get; }
42
43 /// <summary>
44 /// Gets the token for the file to compress.
45 /// </summary>
46 public string Token { get; }
47
48 /// <summary>
49 /// Gets the hash of the file to compress.
50 /// </summary>
51 public int[] Hash { get; }
52
53 internal string ToWixNativeStdinLine()
54 {
55 if (this.Hash == null)
56 {
57 return $"{this.Path}\t{this.Token}";
58 }
59 else
60 {
61 return $"{this.Path}\t{this.Token}\t{this.Hash[0]}\t{this.Hash[1]}\t{this.Hash[2]}\t{this.Hash[3]}";
62 }
63 }
64 }
65}