aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Data.WindowsInstaller/Rows/FileRow.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Data.WindowsInstaller/Rows/FileRow.cs')
-rw-r--r--src/WixToolset.Data.WindowsInstaller/Rows/FileRow.cs640
1 files changed, 640 insertions, 0 deletions
diff --git a/src/WixToolset.Data.WindowsInstaller/Rows/FileRow.cs b/src/WixToolset.Data.WindowsInstaller/Rows/FileRow.cs
new file mode 100644
index 00000000..de5d5652
--- /dev/null
+++ b/src/WixToolset.Data.WindowsInstaller/Rows/FileRow.cs
@@ -0,0 +1,640 @@
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.Data.Rows
4{
5 using System;
6 using System.Diagnostics;
7 using System.Globalization;
8 using WixToolset.Data.Msi;
9
10 /// <summary>
11 /// Specialization of a row for the file table.
12 /// </summary>
13 public sealed class FileRow : Row //, IComparable
14 {
15 //private string assemblyApplication;
16 //private string assemblyManifest;
17 //private FileAssemblyType assemblyType;
18 //private string directory;
19 //private int diskId;
20 //private bool fromModule;
21 //private bool isGeneratedShortFileName;
22 //private int patchGroup;
23 //private string processorArchitecture;
24 //private string source;
25 //private Row hashRow;
26 //private List<Row> assemblyNameRows;
27 //private string[] previousSource;
28 //private string symbols;
29 //private string[] previousSymbols;
30 //private PatchAttributeType patchAttributes;
31 //private string retainOffsets;
32 //private string retainLengths;
33 //private string ignoreOffsets;
34 //private string ignoreLengths;
35 //private string[] previousRetainOffsets;
36 //private string[] previousRetainLengths;
37 //private string[] previousIgnoreOffsets;
38 //private string[] previousIgnoreLengths;
39 //private string patch;
40
41 /// <summary>
42 /// Creates a File row that belongs to a table.
43 /// </summary>
44 /// <param name="sourceLineNumbers">Original source lines for this row.</param>
45 /// <param name="table">Table this File row belongs to and should get its column definitions from.</param>
46 public FileRow(SourceLineNumber sourceLineNumbers, Table table)
47 : base(sourceLineNumbers, table)
48 {
49 //this.assemblyType = FileAssemblyType.NotAnAssembly;
50 //this.previousSource = new string[1];
51 //this.previousSymbols = new string[1];
52 //this.previousRetainOffsets = new string[1];
53 //this.previousRetainLengths = new string[1];
54 //this.previousIgnoreOffsets = new string[1];
55 //this.previousIgnoreLengths = new string[1];
56 }
57
58 /// <summary>
59 /// Creates a File row that does not belong to a table.
60 /// </summary>
61 /// <param name="sourceLineNumbers">Original source lines for this row.</param>
62 /// <param name="tableDefinition">TableDefinition this Media row belongs to and should get its column definitions from.</param>
63 public FileRow(SourceLineNumber sourceLineNumbers, TableDefinition tableDefinition)
64 : base(sourceLineNumbers, tableDefinition)
65 {
66 //this.assemblyType = FileAssemblyType.NotAnAssembly;
67 //this.previousSource = new string[1];
68 //this.previousSymbols = new string[1];
69 //this.previousRetainOffsets = new string[1];
70 //this.previousRetainLengths = new string[1];
71 //this.previousIgnoreOffsets = new string[1];
72 //this.previousIgnoreLengths = new string[1];
73 }
74
75 /// <summary>
76 /// Gets or sets the primary key of the file row.
77 /// </summary>
78 /// <value>Primary key of the file row.</value>
79 public string File
80 {
81 get { return (string)this.Fields[0].Data; }
82 set { this.Fields[0].Data = value; }
83 }
84
85 /// <summary>
86 /// Gets or sets the component this file row belongs to.
87 /// </summary>
88 /// <value>Component this file row belongs to.</value>
89 public string Component
90 {
91 get { return (string)this.Fields[1].Data; }
92 set { this.Fields[1].Data = value; }
93 }
94
95 /// <summary>
96 /// Gets or sets the name of the file.
97 /// </summary>
98 /// <value>Name of the file.</value>
99 public string FileName
100 {
101 get { return (string)this.Fields[2].Data; }
102 set { this.Fields[2].Data = value; }
103 }
104
105 /// <summary>
106 /// Gets or sets the real filesystem name of the file (without a pipe). This is typically the long name of the file.
107 /// However, if no long name is available, falls back to the short name.
108 /// </summary>
109 /// <value>Long Name of the file - or if no long name is available, falls back to the short name.</value>
110 public string LongFileName
111 {
112 get
113 {
114 string fileName = this.FileName;
115 int index = fileName.IndexOf('|');
116
117 // If it doesn't contain a pipe, just return the whole string
118 if (-1 == index)
119 {
120 return fileName;
121 }
122 else // otherwise, extract the part of the string after the pipe
123 {
124 return fileName.Substring(index + 1);
125 }
126 }
127 }
128
129 /// <summary>
130 /// Gets or sets the size of the file.
131 /// </summary>
132 /// <value>Size of the file.</value>
133 public int FileSize
134 {
135 get { return (int)this.Fields[3].Data; }
136 set { this.Fields[3].Data = value; }
137 }
138
139 /// <summary>
140 /// Gets or sets the version of the file.
141 /// </summary>
142 /// <value>Version of the file.</value>
143 public string Version
144 {
145 get { return (string)this.Fields[4].Data; }
146 set { this.Fields[4].Data = value; }
147 }
148
149 /// <summary>
150 /// Gets or sets the LCID of the file.
151 /// </summary>
152 /// <value>LCID of the file.</value>
153 public string Language
154 {
155 get { return (string)this.Fields[5].Data; }
156 set { this.Fields[5].Data = value; }
157 }
158
159 /// <summary>
160 /// Gets or sets the attributes on a file.
161 /// </summary>
162 /// <value>Attributes on a file.</value>
163 public int Attributes
164 {
165 get { return Convert.ToInt32(this.Fields[6].Data, CultureInfo.InvariantCulture); }
166 set { this.Fields[6].Data = value; }
167 }
168
169 /// <summary>
170 /// Gets or sets whether this file should be compressed.
171 /// </summary>
172 /// <value>Whether this file should be compressed.</value>
173 public YesNoType Compressed
174 {
175 get
176 {
177 bool compressedFlag = (0 < (this.Attributes & MsiInterop.MsidbFileAttributesCompressed));
178 bool noncompressedFlag = (0 < (this.Attributes & MsiInterop.MsidbFileAttributesNoncompressed));
179
180 if (compressedFlag && noncompressedFlag)
181 {
182 throw new WixException(WixDataErrors.IllegalFileCompressionAttributes(this.SourceLineNumbers));
183 }
184 else if (compressedFlag)
185 {
186 return YesNoType.Yes;
187 }
188 else if (noncompressedFlag)
189 {
190 return YesNoType.No;
191 }
192 else
193 {
194 return YesNoType.NotSet;
195 }
196 }
197
198 set
199 {
200 if (YesNoType.Yes == value)
201 {
202 // these are mutually exclusive
203 this.Attributes |= MsiInterop.MsidbFileAttributesCompressed;
204 this.Attributes &= ~MsiInterop.MsidbFileAttributesNoncompressed;
205 }
206 else if (YesNoType.No == value)
207 {
208 // these are mutually exclusive
209 this.Attributes |= MsiInterop.MsidbFileAttributesNoncompressed;
210 this.Attributes &= ~MsiInterop.MsidbFileAttributesCompressed;
211 }
212 else // not specified
213 {
214 Debug.Assert(YesNoType.NotSet == value);
215
216 // clear any compression bits
217 this.Attributes &= ~MsiInterop.MsidbFileAttributesCompressed;
218 this.Attributes &= ~MsiInterop.MsidbFileAttributesNoncompressed;
219 }
220 }
221 }
222
223 /// <summary>
224 /// Gets or sets the sequence of the file row.
225 /// </summary>
226 /// <value>Sequence of the file row.</value>
227 public int Sequence
228 {
229 get { return (int)this.Fields[7].Data; }
230 set { this.Fields[7].Data = value; }
231 }
232
233 /////// <summary>
234 /////// Gets or sets the type of assembly of file row.
235 /////// </summary>
236 /////// <value>Assembly type for file row.</value>
237 ////public FileAssemblyType AssemblyType
238 ////{
239 //// get { return this.assemblyType; }
240 //// set { this.assemblyType = value; }
241 ////}
242
243 /////// <summary>
244 /////// Gets or sets the identifier for the assembly application.
245 /////// </summary>
246 /////// <value>Identifier for the assembly application.</value>
247 ////public string AssemblyApplication
248 ////{
249 //// get { return this.assemblyApplication; }
250 //// set { this.assemblyApplication = value; }
251 ////}
252
253 /////// <summary>
254 /////// Gets or sets the identifier for the assembly manifest.
255 /////// </summary>
256 /////// <value>Identifier for the assembly manifest.</value>
257 ////public string AssemblyManifest
258 ////{
259 //// get { return this.assemblyManifest; }
260 //// set { this.assemblyManifest = value; }
261 ////}
262
263 /////// <summary>
264 /////// Gets or sets the directory of the file.
265 /////// </summary>
266 /////// <value>Directory of the file.</value>
267 ////public string Directory
268 ////{
269 //// get { return this.directory; }
270 //// set { this.directory = value; }
271 ////}
272
273 /////// <summary>
274 /////// Gets or sets the disk id for this file.
275 /////// </summary>
276 /////// <value>Disk id for the file.</value>
277 ////public int DiskId
278 ////{
279 //// get { return this.diskId; }
280 //// set { this.diskId = value; }
281 ////}
282
283 /////// <summary>
284 /////// Gets or sets the source location to the file.
285 /////// </summary>
286 /////// <value>Source location to the file.</value>
287 ////public string Source
288 ////{
289 //// get { return this.source; }
290 //// set { this.source = value; }
291 ////}
292
293 /////// <summary>
294 /////// Gets or sets the source location to the previous file.
295 /////// </summary>
296 /////// <value>Source location to the previous file.</value>
297 ////public string PreviousSource
298 ////{
299 //// get { return this.previousSource[0]; }
300 //// set { this.previousSource[0] = value; }
301 ////}
302
303 /////// <summary>
304 /////// Gets the source location to the previous files.
305 /////// </summary>
306 /////// <value>Source location to the previous files.</value>
307 ////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
308 ////public string[] PreviousSourceArray
309 ////{
310 //// get { return this.previousSource; }
311 ////}
312
313 /////// <summary>
314 /////// Gets or sets the architecture the file executes on.
315 /////// </summary>
316 /////// <value>Architecture the file executes on.</value>
317 ////public string ProcessorArchitecture
318 ////{
319 //// get { return this.processorArchitecture; }
320 //// set { this.processorArchitecture = value; }
321 ////}
322
323 /////// <summary>
324 /////// Gets of sets the patch group of a patch-added file.
325 /////// </summary>
326 /////// <value>The patch group of a patch-added file.</value>
327 ////public int PatchGroup
328 ////{
329 //// get { return this.patchGroup; }
330 //// set { this.patchGroup = value; }
331 ////}
332
333 /////// <summary>
334 /////// Gets or sets the patch header of the file.
335 /////// </summary>
336 /////// <value>Patch header of the file.</value>
337 ////public string Patch
338 ////{
339 //// get { return this.patch; }
340 //// set { this.patch = value; }
341 ////}
342
343 /////// <summary>
344 /////// Gets or sets the locations to find the file's symbols.
345 /////// </summary>
346 /////// <value>Symbol paths for the file.</value>
347 ////public string Symbols
348 ////{
349 //// get { return this.symbols; }
350 //// set { this.symbols = value; }
351 ////}
352
353 /////// <summary>
354 /////// Gets or sets the locations to find the file's previous symbols.
355 /////// </summary>
356 /////// <value>Symbol paths for the previous file.</value>
357 ////public string PreviousSymbols
358 ////{
359 //// get { return this.previousSymbols[0]; }
360 //// set { this.previousSymbols[0] = value; }
361 ////}
362
363 /////// <summary>
364 /////// Gets the locations to find the files' previous symbols.
365 /////// </summary>
366 /////// <value>Symbol paths for the previous files.</value>
367 ////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
368 ////public string[] PreviousSymbolsArray
369 ////{
370 //// get { return this.previousSymbols; }
371 ////}
372
373 /////// <summary>
374 /////// Gets or sets the generated short file name attribute.
375 /////// </summary>
376 /////// <value>The generated short file name attribute.</value>
377 ////public bool IsGeneratedShortFileName
378 ////{
379 //// get { return this.isGeneratedShortFileName; }
380
381 //// set { this.isGeneratedShortFileName = value; }
382 ////}
383
384 /////// <summary>
385 /////// Gets or sets whether this row came from a merge module.
386 /////// </summary>
387 /////// <value>Whether this row came from a merge module.</value>
388 ////public bool FromModule
389 ////{
390 //// get { return this.fromModule; }
391 //// set { this.fromModule = value; }
392 ////}
393
394 /////// <summary>
395 /////// Gets or sets the MsiFileHash row created for this FileRow.
396 /////// </summary>
397 /////// <value>Row for MsiFileHash table.</value>
398 ////public Row HashRow
399 ////{
400 //// get { return this.hashRow; }
401 //// set { this.hashRow = value; }
402 ////}
403
404 /////// <summary>
405 /////// Gets or sets the set of MsiAssemblyName rows created for this FileRow.
406 /////// </summary>
407 /////// <value>RowCollection of MsiAssemblyName table.</value>
408 ////[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
409 ////public List<Row> AssemblyNameRows
410 ////{
411 //// get { return this.assemblyNameRows; }
412 //// set { this.assemblyNameRows = value; }
413 ////}
414
415 /////// <summary>
416 /////// Gets or sets the patching attributes to the file.
417 /////// </summary>
418 /////// <value>Patching attributes of the file.</value>
419 ////public PatchAttributeType PatchAttributes
420 ////{
421 //// get { return this.patchAttributes; }
422 //// set { this.patchAttributes = value; }
423 ////}
424
425 /////// <summary>
426 /////// Gets or sets the delta patch retain-length list for the file.
427 /////// </summary>
428 /////// <value>RetainLength list for the file.</value>
429 ////public string RetainLengths
430 ////{
431 //// get { return this.retainLengths; }
432 //// set { this.retainLengths = value; }
433 ////}
434
435 /////// <summary>
436 /////// Gets or sets the delta patch ignore-offset list for the file.
437 /////// </summary>
438 /////// <value>IgnoreOffset list for the file.</value>
439 ////public string IgnoreOffsets
440 ////{
441 //// get { return this.ignoreOffsets; }
442 //// set { this.ignoreOffsets = value; }
443 ////}
444
445 /////// <summary>
446 /////// Gets or sets the delta patch ignore-length list for the file.
447 /////// </summary>
448 /////// <value>IgnoreLength list for the file.</value>
449 ////public string IgnoreLengths
450 ////{
451 //// get { return this.ignoreLengths; }
452 //// set { this.ignoreLengths = value; }
453 ////}
454
455 /////// <summary>
456 /////// Gets or sets the delta patch retain-offset list for the file.
457 /////// </summary>
458 /////// <value>RetainOffset list for the file.</value>
459 ////public string RetainOffsets
460 ////{
461 //// get { return this.retainOffsets; }
462 //// set { this.retainOffsets = value; }
463 ////}
464
465 /////// <summary>
466 /////// Gets or sets the delta patch retain-length list for the previous file.
467 /////// </summary>
468 /////// <value>RetainLength list for the previous file.</value>
469 ////public string PreviousRetainLengths
470 ////{
471 //// get { return this.previousRetainLengths[0]; }
472 //// set { this.previousRetainLengths[0] = value; }
473 ////}
474
475 /////// <summary>
476 /////// Gets the delta patch retain-length list for the previous files.
477 /////// </summary>
478 /////// <value>RetainLength list for the previous files.</value>
479 ////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
480 ////public string[] PreviousRetainLengthsArray
481 ////{
482 //// get { return this.previousRetainLengths; }
483 ////}
484
485 /////// <summary>
486 /////// Gets or sets the delta patch ignore-offset list for the previous file.
487 /////// </summary>
488 /////// <value>IgnoreOffset list for the previous file.</value>
489 ////public string PreviousIgnoreOffsets
490 ////{
491 //// get { return this.previousIgnoreOffsets[0]; }
492 //// set { this.previousIgnoreOffsets[0] = value; }
493 ////}
494
495 /////// <summary>
496 /////// Gets the delta patch ignore-offset list for the previous files.
497 /////// </summary>
498 /////// <value>IgnoreOffset list for the previous files.</value>
499 ////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
500 ////public string[] PreviousIgnoreOffsetsArray
501 ////{
502 //// get { return this.previousIgnoreOffsets; }
503 ////}
504
505 /////// <summary>
506 /////// Gets or sets the delta patch ignore-length list for the previous file.
507 /////// </summary>
508 /////// <value>IgnoreLength list for the previous file.</value>
509 ////public string PreviousIgnoreLengths
510 ////{
511 //// get { return this.previousIgnoreLengths[0]; }
512 //// set { this.previousIgnoreLengths[0] = value; }
513 ////}
514
515 /////// <summary>
516 /////// Gets the delta patch ignore-length list for the previous files.
517 /////// </summary>
518 /////// <value>IgnoreLength list for the previous files.</value>
519 ////[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
520 ////public string[] PreviousIgnoreLengthsArray
521 ////{
522 //// get { return this.previousIgnoreLengths; }
523 ////}
524
525 /////// <summary>
526 /////// Gets or sets the delta patch retain-offset list for the previous file.
527 /////// </summary>
528 /////// <value>RetainOffset list for the previous file.</value>
529 ////public string PreviousRetainOffsets
530 ////{
531 //// get { return this.previousRetainOffsets[0]; }
532 //// set { this.previousRetainOffsets[0] = value; }
533 ////}
534
535 /////// <summary>
536 /////// Gets the delta patch retain-offset list for the previous files.
537 /////// </summary>
538 /////// <value>RetainOffset list for the previous files.</value>
539 ////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
540 ////public string[] PreviousRetainOffsetsArray
541 ////{
542 //// get { return this.previousRetainOffsets; }
543 ////}
544
545 /////// <summary>
546 /////// Compares the current FileRow with another object of the same type.
547 /////// </summary>
548 /////// <param name="obj">An object to compare with this instance.</param>
549 /////// <returns>An integer that indicates the relative order of the comparands.</returns>
550 ////[SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentException.#ctor(System.String)")]
551 ////[SuppressMessage("Microsoft.Globalization", "CA1309:UseOrdinalStringComparison")]
552 ////public int CompareTo(object obj)
553 ////{
554 //// if (this == obj)
555 //// {
556 //// return 0;
557 //// }
558
559 //// FileRow fileRow = obj as FileRow;
560 //// if (null == fileRow)
561 //// {
562 //// throw new ArgumentException(WixDataStrings.EXP_OtherObjectIsNotFileRow);
563 //// }
564
565 //// int compared = this.DiskId - fileRow.DiskId;
566 //// if (0 == compared)
567 //// {
568 //// compared = this.patchGroup - fileRow.patchGroup;
569
570 //// if (0 == compared)
571 //// {
572 //// compared = String.Compare(this.File, fileRow.File, StringComparison.InvariantCulture);
573 //// }
574 //// }
575
576 //// return compared;
577 ////}
578
579 /////// <summary>
580 /////// Copies data from another FileRow object.
581 /////// </summary>
582 /////// <param name="src">An row to get data from.</param>
583 ////public void CopyFrom(FileRow src)
584 ////{
585 //// for (int i = 0; i < src.Fields.Length; i++)
586 //// {
587 //// this[i] = src[i];
588 //// }
589 //// this.assemblyManifest = src.assemblyManifest;
590 //// this.assemblyType = src.assemblyType;
591 //// this.directory = src.directory;
592 //// this.diskId = src.diskId;
593 //// this.fromModule = src.fromModule;
594 //// this.isGeneratedShortFileName = src.isGeneratedShortFileName;
595 //// this.patchGroup = src.patchGroup;
596 //// this.processorArchitecture = src.processorArchitecture;
597 //// this.source = src.source;
598 //// this.PreviousSource = src.PreviousSource;
599 //// this.Operation = src.Operation;
600 //// this.symbols = src.symbols;
601 //// this.PreviousSymbols = src.PreviousSymbols;
602 //// this.patchAttributes = src.patchAttributes;
603 //// this.retainOffsets = src.retainOffsets;
604 //// this.retainLengths = src.retainLengths;
605 //// this.ignoreOffsets = src.ignoreOffsets;
606 //// this.ignoreLengths = src.ignoreLengths;
607 //// this.PreviousRetainOffsets = src.PreviousRetainOffsets;
608 //// this.PreviousRetainLengths = src.PreviousRetainLengths;
609 //// this.PreviousIgnoreOffsets = src.PreviousIgnoreOffsets;
610 //// this.PreviousIgnoreLengths = src.PreviousIgnoreLengths;
611 ////}
612
613 /////// <summary>
614 /////// Appends previous data from another FileRow object.
615 /////// </summary>
616 /////// <param name="src">An row to get data from.</param>
617 ////public void AppendPreviousDataFrom(FileRow src)
618 ////{
619 //// AppendStringToArray(ref this.previousSource, src.previousSource[0]);
620 //// AppendStringToArray(ref this.previousSymbols, src.previousSymbols[0]);
621 //// AppendStringToArray(ref this.previousRetainOffsets, src.previousRetainOffsets[0]);
622 //// AppendStringToArray(ref this.previousRetainLengths, src.previousRetainLengths[0]);
623 //// AppendStringToArray(ref this.previousIgnoreOffsets, src.previousIgnoreOffsets[0]);
624 //// AppendStringToArray(ref this.previousIgnoreLengths, src.previousIgnoreLengths[0]);
625 ////}
626
627 /////// <summary>
628 /////// Helper method for AppendPreviousDataFrom.
629 /////// </summary>
630 /////// <param name="source">Destination array.</param>
631 /////// <param name="destination">Source string.</param>
632 ////private static void AppendStringToArray(ref string[] destination, string source)
633 ////{
634 //// string[] result = new string[destination.Length + 1];
635 //// destination.CopyTo(result, 0);
636 //// result[destination.Length] = source;
637 //// destination = result;
638 ////}
639 }
640}