diff options
Diffstat (limited to '')
-rw-r--r-- | src/dtf/WixToolset.Dtf.Compression/ArchiveProgressEventArgs.cs | 307 |
1 files changed, 307 insertions, 0 deletions
diff --git a/src/dtf/WixToolset.Dtf.Compression/ArchiveProgressEventArgs.cs b/src/dtf/WixToolset.Dtf.Compression/ArchiveProgressEventArgs.cs new file mode 100644 index 00000000..5d96d714 --- /dev/null +++ b/src/dtf/WixToolset.Dtf.Compression/ArchiveProgressEventArgs.cs | |||
@@ -0,0 +1,307 @@ | |||
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.Dtf.Compression | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using System.Text; | ||
8 | |||
9 | /// <summary> | ||
10 | /// Contains the data reported in an archive progress event. | ||
11 | /// </summary> | ||
12 | public class ArchiveProgressEventArgs : EventArgs | ||
13 | { | ||
14 | private ArchiveProgressType progressType; | ||
15 | |||
16 | private string currentFileName; | ||
17 | private int currentFileNumber; | ||
18 | private int totalFiles; | ||
19 | private long currentFileBytesProcessed; | ||
20 | private long currentFileTotalBytes; | ||
21 | |||
22 | private string currentArchiveName; | ||
23 | private short currentArchiveNumber; | ||
24 | private short totalArchives; | ||
25 | private long currentArchiveBytesProcessed; | ||
26 | private long currentArchiveTotalBytes; | ||
27 | |||
28 | private long fileBytesProcessed; | ||
29 | private long totalFileBytes; | ||
30 | |||
31 | /// <summary> | ||
32 | /// Creates a new ArchiveProgressEventArgs object from specified event parameters. | ||
33 | /// </summary> | ||
34 | /// <param name="progressType">type of status message</param> | ||
35 | /// <param name="currentFileName">name of the file being processed</param> | ||
36 | /// <param name="currentFileNumber">number of the current file being processed</param> | ||
37 | /// <param name="totalFiles">total number of files to be processed</param> | ||
38 | /// <param name="currentFileBytesProcessed">number of bytes processed so far when compressing or extracting a file</param> | ||
39 | /// <param name="currentFileTotalBytes">total number of bytes in the current file</param> | ||
40 | /// <param name="currentArchiveName">name of the current Archive</param> | ||
41 | /// <param name="currentArchiveNumber">current Archive number, when processing a chained set of Archives</param> | ||
42 | /// <param name="totalArchives">total number of Archives in a chained set</param> | ||
43 | /// <param name="currentArchiveBytesProcessed">number of compressed bytes processed so far during an extraction</param> | ||
44 | /// <param name="currentArchiveTotalBytes">total number of compressed bytes to be processed during an extraction</param> | ||
45 | /// <param name="fileBytesProcessed">number of uncompressed file bytes processed so far</param> | ||
46 | /// <param name="totalFileBytes">total number of uncompressed file bytes to be processed</param> | ||
47 | public ArchiveProgressEventArgs( | ||
48 | ArchiveProgressType progressType, | ||
49 | string currentFileName, | ||
50 | int currentFileNumber, | ||
51 | int totalFiles, | ||
52 | long currentFileBytesProcessed, | ||
53 | long currentFileTotalBytes, | ||
54 | string currentArchiveName, | ||
55 | int currentArchiveNumber, | ||
56 | int totalArchives, | ||
57 | long currentArchiveBytesProcessed, | ||
58 | long currentArchiveTotalBytes, | ||
59 | long fileBytesProcessed, | ||
60 | long totalFileBytes) | ||
61 | { | ||
62 | this.progressType = progressType; | ||
63 | this.currentFileName = currentFileName; | ||
64 | this.currentFileNumber = currentFileNumber; | ||
65 | this.totalFiles = totalFiles; | ||
66 | this.currentFileBytesProcessed = currentFileBytesProcessed; | ||
67 | this.currentFileTotalBytes = currentFileTotalBytes; | ||
68 | this.currentArchiveName = currentArchiveName; | ||
69 | this.currentArchiveNumber = (short) currentArchiveNumber; | ||
70 | this.totalArchives = (short) totalArchives; | ||
71 | this.currentArchiveBytesProcessed = currentArchiveBytesProcessed; | ||
72 | this.currentArchiveTotalBytes = currentArchiveTotalBytes; | ||
73 | this.fileBytesProcessed = fileBytesProcessed; | ||
74 | this.totalFileBytes = totalFileBytes; | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// Gets the type of status message. | ||
79 | /// </summary> | ||
80 | /// <value>A <see cref="ArchiveProgressType"/> value indicating what type of progress event occurred.</value> | ||
81 | /// <remarks> | ||
82 | /// The handler may choose to ignore some types of progress events. | ||
83 | /// For example, if the handler will only list each file as it is | ||
84 | /// compressed/extracted, it can ignore events that | ||
85 | /// are not of type <see cref="ArchiveProgressType.FinishFile"/>. | ||
86 | /// </remarks> | ||
87 | public ArchiveProgressType ProgressType | ||
88 | { | ||
89 | get | ||
90 | { | ||
91 | return this.progressType; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | /// <summary> | ||
96 | /// Gets the name of the file being processed. (The name of the file within the Archive; not the external | ||
97 | /// file path.) Also includes the internal path of the file, if any. Valid for | ||
98 | /// <see cref="ArchiveProgressType.StartFile"/>, <see cref="ArchiveProgressType.PartialFile"/>, | ||
99 | /// and <see cref="ArchiveProgressType.FinishFile"/> messages. | ||
100 | /// </summary> | ||
101 | /// <value>The name of the file currently being processed, or null if processing | ||
102 | /// is currently at the stream or archive level.</value> | ||
103 | public string CurrentFileName | ||
104 | { | ||
105 | get | ||
106 | { | ||
107 | return this.currentFileName; | ||
108 | } | ||
109 | } | ||
110 | |||
111 | /// <summary> | ||
112 | /// Gets the number of the current file being processed. The first file is number 0, and the last file | ||
113 | /// is <see cref="TotalFiles"/>-1. Valid for <see cref="ArchiveProgressType.StartFile"/>, | ||
114 | /// <see cref="ArchiveProgressType.PartialFile"/>, and <see cref="ArchiveProgressType.FinishFile"/> messages. | ||
115 | /// </summary> | ||
116 | /// <value>The number of the file currently being processed, or the most recent | ||
117 | /// file processed if processing is currently at the stream or archive level.</value> | ||
118 | public int CurrentFileNumber | ||
119 | { | ||
120 | get | ||
121 | { | ||
122 | return this.currentFileNumber; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | /// <summary> | ||
127 | /// Gets the total number of files to be processed. Valid for all message types. | ||
128 | /// </summary> | ||
129 | /// <value>The total number of files to be processed that are known so far.</value> | ||
130 | public int TotalFiles | ||
131 | { | ||
132 | get | ||
133 | { | ||
134 | return this.totalFiles; | ||
135 | } | ||
136 | } | ||
137 | |||
138 | /// <summary> | ||
139 | /// Gets the number of bytes processed so far when compressing or extracting a file. Valid for | ||
140 | /// <see cref="ArchiveProgressType.StartFile"/>, <see cref="ArchiveProgressType.PartialFile"/>, | ||
141 | /// and <see cref="ArchiveProgressType.FinishFile"/> messages. | ||
142 | /// </summary> | ||
143 | /// <value>The number of uncompressed bytes processed so far for the current file, | ||
144 | /// or 0 if processing is currently at the stream or archive level.</value> | ||
145 | public long CurrentFileBytesProcessed | ||
146 | { | ||
147 | get | ||
148 | { | ||
149 | return this.currentFileBytesProcessed; | ||
150 | } | ||
151 | } | ||
152 | |||
153 | /// <summary> | ||
154 | /// Gets the total number of bytes in the current file. Valid for <see cref="ArchiveProgressType.StartFile"/>, | ||
155 | /// <see cref="ArchiveProgressType.PartialFile"/>, and <see cref="ArchiveProgressType.FinishFile"/> messages. | ||
156 | /// </summary> | ||
157 | /// <value>The uncompressed size of the current file being processed, | ||
158 | /// or 0 if processing is currently at the stream or archive level.</value> | ||
159 | public long CurrentFileTotalBytes | ||
160 | { | ||
161 | get | ||
162 | { | ||
163 | return this.currentFileTotalBytes; | ||
164 | } | ||
165 | } | ||
166 | |||
167 | /// <summary> | ||
168 | /// Gets the name of the current archive. Not necessarily the name of the archive on disk. | ||
169 | /// Valid for all message types. | ||
170 | /// </summary> | ||
171 | /// <value>The name of the current archive, or an empty string if no name was specified.</value> | ||
172 | public string CurrentArchiveName | ||
173 | { | ||
174 | get | ||
175 | { | ||
176 | return this.currentArchiveName; | ||
177 | } | ||
178 | } | ||
179 | |||
180 | /// <summary> | ||
181 | /// Gets the current archive number, when processing a chained set of archives. Valid for all message types. | ||
182 | /// </summary> | ||
183 | /// <value>The number of the current archive.</value> | ||
184 | /// <remarks>The first archive is number 0, and the last archive is | ||
185 | /// <see cref="TotalArchives"/>-1.</remarks> | ||
186 | public int CurrentArchiveNumber | ||
187 | { | ||
188 | get | ||
189 | { | ||
190 | return this.currentArchiveNumber; | ||
191 | } | ||
192 | } | ||
193 | |||
194 | /// <summary> | ||
195 | /// Gets the total number of known archives in a chained set. Valid for all message types. | ||
196 | /// </summary> | ||
197 | /// <value>The total number of known archives in a chained set.</value> | ||
198 | /// <remarks> | ||
199 | /// When using the compression option to auto-split into multiple archives based on data size, | ||
200 | /// this value will not be accurate until the end. | ||
201 | /// </remarks> | ||
202 | public int TotalArchives | ||
203 | { | ||
204 | get | ||
205 | { | ||
206 | return this.totalArchives; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// Gets the number of compressed bytes processed so far during extraction | ||
212 | /// of the current archive. Valid for all extraction messages. | ||
213 | /// </summary> | ||
214 | /// <value>The number of compressed bytes processed so far during extraction | ||
215 | /// of the current archive.</value> | ||
216 | public long CurrentArchiveBytesProcessed | ||
217 | { | ||
218 | get | ||
219 | { | ||
220 | return this.currentArchiveBytesProcessed; | ||
221 | } | ||
222 | } | ||
223 | |||
224 | /// <summary> | ||
225 | /// Gets the total number of compressed bytes to be processed during extraction | ||
226 | /// of the current archive. Valid for all extraction messages. | ||
227 | /// </summary> | ||
228 | /// <value>The total number of compressed bytes to be processed during extraction | ||
229 | /// of the current archive.</value> | ||
230 | public long CurrentArchiveTotalBytes | ||
231 | { | ||
232 | get | ||
233 | { | ||
234 | return this.currentArchiveTotalBytes; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | /// <summary> | ||
239 | /// Gets the number of uncompressed bytes processed so far among all files. Valid for all message types. | ||
240 | /// </summary> | ||
241 | /// <value>The number of uncompressed file bytes processed so far among all files.</value> | ||
242 | /// <remarks> | ||
243 | /// When compared to <see cref="TotalFileBytes"/>, this can be used as a measure of overall progress. | ||
244 | /// </remarks> | ||
245 | public long FileBytesProcessed | ||
246 | { | ||
247 | get | ||
248 | { | ||
249 | return this.fileBytesProcessed; | ||
250 | } | ||
251 | } | ||
252 | |||
253 | /// <summary> | ||
254 | /// Gets the total number of uncompressed file bytes to be processed. Valid for all message types. | ||
255 | /// </summary> | ||
256 | /// <value>The total number of uncompressed bytes to be processed among all files.</value> | ||
257 | public long TotalFileBytes | ||
258 | { | ||
259 | get | ||
260 | { | ||
261 | return this.totalFileBytes; | ||
262 | } | ||
263 | } | ||
264 | |||
265 | #if DEBUG | ||
266 | |||
267 | /// <summary> | ||
268 | /// Creates a string representation of the progress event. | ||
269 | /// </summary> | ||
270 | /// <returns>a listing of all event parameters and values</returns> | ||
271 | public override string ToString() | ||
272 | { | ||
273 | string formatString = | ||
274 | "{0}\n" + | ||
275 | "\t CurrentFileName = {1}\n" + | ||
276 | "\t CurrentFileNumber = {2}\n" + | ||
277 | "\t TotalFiles = {3}\n" + | ||
278 | "\t CurrentFileBytesProcessed = {4}\n" + | ||
279 | "\t CurrentFileTotalBytes = {5}\n" + | ||
280 | "\t CurrentArchiveName = {6}\n" + | ||
281 | "\t CurrentArchiveNumber = {7}\n" + | ||
282 | "\t TotalArchives = {8}\n" + | ||
283 | "\t CurrentArchiveBytesProcessed = {9}\n" + | ||
284 | "\t CurrentArchiveTotalBytes = {10}\n" + | ||
285 | "\t FileBytesProcessed = {11}\n" + | ||
286 | "\t TotalFileBytes = {12}\n"; | ||
287 | return String.Format( | ||
288 | System.Globalization.CultureInfo.InvariantCulture, | ||
289 | formatString, | ||
290 | this.ProgressType, | ||
291 | this.CurrentFileName, | ||
292 | this.CurrentFileNumber, | ||
293 | this.TotalFiles, | ||
294 | this.CurrentFileBytesProcessed, | ||
295 | this.CurrentFileTotalBytes, | ||
296 | this.CurrentArchiveName, | ||
297 | this.CurrentArchiveNumber, | ||
298 | this.TotalArchives, | ||
299 | this.CurrentArchiveBytesProcessed, | ||
300 | this.CurrentArchiveTotalBytes, | ||
301 | this.FileBytesProcessed, | ||
302 | this.TotalFileBytes); | ||
303 | } | ||
304 | |||
305 | #endif | ||
306 | } | ||
307 | } | ||