aboutsummaryrefslogtreecommitdiff
path: root/src/WixBuildTools.TestSupport/Query.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixBuildTools.TestSupport/Query.cs')
-rw-r--r--src/WixBuildTools.TestSupport/Query.cs68
1 files changed, 67 insertions, 1 deletions
diff --git a/src/WixBuildTools.TestSupport/Query.cs b/src/WixBuildTools.TestSupport/Query.cs
index a5883067..bbd9f89a 100644
--- a/src/WixBuildTools.TestSupport/Query.cs
+++ b/src/WixBuildTools.TestSupport/Query.cs
@@ -4,7 +4,10 @@ namespace WixBuildTools.TestSupport
4{ 4{
5 using System; 5 using System;
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.IO;
8 using System.Linq;
7 using System.Text; 9 using System.Text;
10 using WixToolset.Dtf.Compression.Cab;
8 using WixToolset.Dtf.WindowsInstaller; 11 using WixToolset.Dtf.WindowsInstaller;
9 12
10 public class Query 13 public class Query
@@ -25,7 +28,7 @@ namespace WixBuildTools.TestSupport
25 continue; 28 continue;
26 } 29 }
27 30
28 using (var view = db.OpenView($"SELECT * FROM `{table}`")) 31 using (var view = db.OpenView("SELECT * FROM `{0}`", table))
29 { 32 {
30 view.Execute(); 33 view.Execute();
31 34
@@ -58,5 +61,68 @@ namespace WixBuildTools.TestSupport
58 results.Sort(); 61 results.Sort();
59 return results.ToArray(); 62 return results.ToArray();
60 } 63 }
64
65 public static CabFileInfo[] GetCabinetFiles(string path)
66 {
67 var cab = new CabInfo(path);
68
69 var result = cab.GetFiles();
70
71 return result.Select(c => c).ToArray();
72 }
73
74 public static void ExtractStream(string path, string streamName, string outputPath)
75 {
76 Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
77
78 using (var db = new Database(path))
79 using (var view = db.OpenView("SELECT `Data` FROM `_Streams` WHERE `Name` = '{0}'", streamName))
80 {
81 view.Execute();
82
83 using (var record = view.Fetch())
84 {
85 record.GetStream(1, outputPath);
86 }
87 }
88 }
89
90 public static void ExtractSubStorage(string path, string subStorageName, string outputPath)
91 {
92 Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
93
94 using (var db = new Database(path))
95 using (var view = db.OpenView("SELECT `Name`, `Data` FROM `_Storages` WHERE `Name` = '{0}'", subStorageName))
96 {
97 view.Execute();
98
99 using (var record = view.Fetch())
100 {
101 var name = record.GetString(1);
102 record.GetStream(2, outputPath);
103 }
104 }
105 }
106
107 public static string[] GetSubStorageNames(string path)
108 {
109 var result = new List<string>();
110
111 using (var db = new Database(path))
112 using (var view = db.OpenView("SELECT `Name` FROM `_Storages`"))
113 {
114 view.Execute();
115
116 Record record;
117 while ((record = view.Fetch()) != null)
118 {
119 var name = record.GetString(1);
120 result.Add(name);
121 }
122 }
123
124 result.Sort();
125 return result.ToArray();
126 }
61 } 127 }
62} 128}