// 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.
namespace WixToolset.Data.Rows
{
using System;
using System.Diagnostics;
using System.Globalization;
using WixToolset.Data.Msi;
///
/// Specialization of a row for the file table.
///
public sealed class FileRow : Row //, IComparable
{
//private string assemblyApplication;
//private string assemblyManifest;
//private FileAssemblyType assemblyType;
//private string directory;
//private int diskId;
//private bool fromModule;
//private bool isGeneratedShortFileName;
//private int patchGroup;
//private string processorArchitecture;
//private string source;
//private Row hashRow;
//private List assemblyNameRows;
//private string[] previousSource;
//private string symbols;
//private string[] previousSymbols;
//private PatchAttributeType patchAttributes;
//private string retainOffsets;
//private string retainLengths;
//private string ignoreOffsets;
//private string ignoreLengths;
//private string[] previousRetainOffsets;
//private string[] previousRetainLengths;
//private string[] previousIgnoreOffsets;
//private string[] previousIgnoreLengths;
//private string patch;
///
/// Creates a File row that belongs to a table.
///
/// Original source lines for this row.
/// Table this File row belongs to and should get its column definitions from.
public FileRow(SourceLineNumber sourceLineNumbers, Table table)
: base(sourceLineNumbers, table)
{
//this.assemblyType = FileAssemblyType.NotAnAssembly;
//this.previousSource = new string[1];
//this.previousSymbols = new string[1];
//this.previousRetainOffsets = new string[1];
//this.previousRetainLengths = new string[1];
//this.previousIgnoreOffsets = new string[1];
//this.previousIgnoreLengths = new string[1];
}
///
/// Creates a File row that does not belong to a table.
///
/// Original source lines for this row.
/// TableDefinition this Media row belongs to and should get its column definitions from.
public FileRow(SourceLineNumber sourceLineNumbers, TableDefinition tableDefinition)
: base(sourceLineNumbers, tableDefinition)
{
//this.assemblyType = FileAssemblyType.NotAnAssembly;
//this.previousSource = new string[1];
//this.previousSymbols = new string[1];
//this.previousRetainOffsets = new string[1];
//this.previousRetainLengths = new string[1];
//this.previousIgnoreOffsets = new string[1];
//this.previousIgnoreLengths = new string[1];
}
///
/// Gets or sets the primary key of the file row.
///
/// Primary key of the file row.
public string File
{
get { return (string)this.Fields[0].Data; }
set { this.Fields[0].Data = value; }
}
///
/// Gets or sets the component this file row belongs to.
///
/// Component this file row belongs to.
public string Component
{
get { return (string)this.Fields[1].Data; }
set { this.Fields[1].Data = value; }
}
///
/// Gets or sets the name of the file.
///
/// Name of the file.
public string FileName
{
get { return (string)this.Fields[2].Data; }
set { this.Fields[2].Data = value; }
}
///
/// Gets or sets the real filesystem name of the file (without a pipe). This is typically the long name of the file.
/// However, if no long name is available, falls back to the short name.
///
/// Long Name of the file - or if no long name is available, falls back to the short name.
public string LongFileName
{
get
{
string fileName = this.FileName;
int index = fileName.IndexOf('|');
// If it doesn't contain a pipe, just return the whole string
if (-1 == index)
{
return fileName;
}
else // otherwise, extract the part of the string after the pipe
{
return fileName.Substring(index + 1);
}
}
}
///
/// Gets or sets the size of the file.
///
/// Size of the file.
public int FileSize
{
get { return (int)this.Fields[3].Data; }
set { this.Fields[3].Data = value; }
}
///
/// Gets or sets the version of the file.
///
/// Version of the file.
public string Version
{
get { return (string)this.Fields[4].Data; }
set { this.Fields[4].Data = value; }
}
///
/// Gets or sets the LCID of the file.
///
/// LCID of the file.
public string Language
{
get { return (string)this.Fields[5].Data; }
set { this.Fields[5].Data = value; }
}
///
/// Gets or sets the attributes on a file.
///
/// Attributes on a file.
public int Attributes
{
get { return Convert.ToInt32(this.Fields[6].Data, CultureInfo.InvariantCulture); }
set { this.Fields[6].Data = value; }
}
///
/// Gets or sets whether this file should be compressed.
///
/// Whether this file should be compressed.
public YesNoType Compressed
{
get
{
bool compressedFlag = (0 < (this.Attributes & MsiInterop.MsidbFileAttributesCompressed));
bool noncompressedFlag = (0 < (this.Attributes & MsiInterop.MsidbFileAttributesNoncompressed));
if (compressedFlag && noncompressedFlag)
{
throw new WixException(WixDataErrors.IllegalFileCompressionAttributes(this.SourceLineNumbers));
}
else if (compressedFlag)
{
return YesNoType.Yes;
}
else if (noncompressedFlag)
{
return YesNoType.No;
}
else
{
return YesNoType.NotSet;
}
}
set
{
if (YesNoType.Yes == value)
{
// these are mutually exclusive
this.Attributes |= MsiInterop.MsidbFileAttributesCompressed;
this.Attributes &= ~MsiInterop.MsidbFileAttributesNoncompressed;
}
else if (YesNoType.No == value)
{
// these are mutually exclusive
this.Attributes |= MsiInterop.MsidbFileAttributesNoncompressed;
this.Attributes &= ~MsiInterop.MsidbFileAttributesCompressed;
}
else // not specified
{
Debug.Assert(YesNoType.NotSet == value);
// clear any compression bits
this.Attributes &= ~MsiInterop.MsidbFileAttributesCompressed;
this.Attributes &= ~MsiInterop.MsidbFileAttributesNoncompressed;
}
}
}
///
/// Gets or sets the sequence of the file row.
///
/// Sequence of the file row.
public int Sequence
{
get { return (int)this.Fields[7].Data; }
set { this.Fields[7].Data = value; }
}
///////
/////// Gets or sets the type of assembly of file row.
///////
/////// Assembly type for file row.
////public FileAssemblyType AssemblyType
////{
//// get { return this.assemblyType; }
//// set { this.assemblyType = value; }
////}
///////
/////// Gets or sets the identifier for the assembly application.
///////
/////// Identifier for the assembly application.
////public string AssemblyApplication
////{
//// get { return this.assemblyApplication; }
//// set { this.assemblyApplication = value; }
////}
///////
/////// Gets or sets the identifier for the assembly manifest.
///////
/////// Identifier for the assembly manifest.
////public string AssemblyManifest
////{
//// get { return this.assemblyManifest; }
//// set { this.assemblyManifest = value; }
////}
///////
/////// Gets or sets the directory of the file.
///////
/////// Directory of the file.
////public string Directory
////{
//// get { return this.directory; }
//// set { this.directory = value; }
////}
///////
/////// Gets or sets the disk id for this file.
///////
/////// Disk id for the file.
////public int DiskId
////{
//// get { return this.diskId; }
//// set { this.diskId = value; }
////}
///////
/////// Gets or sets the source location to the file.
///////
/////// Source location to the file.
////public string Source
////{
//// get { return this.source; }
//// set { this.source = value; }
////}
///////
/////// Gets or sets the source location to the previous file.
///////
/////// Source location to the previous file.
////public string PreviousSource
////{
//// get { return this.previousSource[0]; }
//// set { this.previousSource[0] = value; }
////}
///////
/////// Gets the source location to the previous files.
///////
/////// Source location to the previous files.
////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
////public string[] PreviousSourceArray
////{
//// get { return this.previousSource; }
////}
///////
/////// Gets or sets the architecture the file executes on.
///////
/////// Architecture the file executes on.
////public string ProcessorArchitecture
////{
//// get { return this.processorArchitecture; }
//// set { this.processorArchitecture = value; }
////}
///////
/////// Gets of sets the patch group of a patch-added file.
///////
/////// The patch group of a patch-added file.
////public int PatchGroup
////{
//// get { return this.patchGroup; }
//// set { this.patchGroup = value; }
////}
///////
/////// Gets or sets the patch header of the file.
///////
/////// Patch header of the file.
////public string Patch
////{
//// get { return this.patch; }
//// set { this.patch = value; }
////}
///////
/////// Gets or sets the locations to find the file's symbols.
///////
/////// Symbol paths for the file.
////public string Symbols
////{
//// get { return this.symbols; }
//// set { this.symbols = value; }
////}
///////
/////// Gets or sets the locations to find the file's previous symbols.
///////
/////// Symbol paths for the previous file.
////public string PreviousSymbols
////{
//// get { return this.previousSymbols[0]; }
//// set { this.previousSymbols[0] = value; }
////}
///////
/////// Gets the locations to find the files' previous symbols.
///////
/////// Symbol paths for the previous files.
////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
////public string[] PreviousSymbolsArray
////{
//// get { return this.previousSymbols; }
////}
///////
/////// Gets or sets the generated short file name attribute.
///////
/////// The generated short file name attribute.
////public bool IsGeneratedShortFileName
////{
//// get { return this.isGeneratedShortFileName; }
//// set { this.isGeneratedShortFileName = value; }
////}
///////
/////// Gets or sets whether this row came from a merge module.
///////
/////// Whether this row came from a merge module.
////public bool FromModule
////{
//// get { return this.fromModule; }
//// set { this.fromModule = value; }
////}
///////
/////// Gets or sets the MsiFileHash row created for this FileRow.
///////
/////// Row for MsiFileHash table.
////public Row HashRow
////{
//// get { return this.hashRow; }
//// set { this.hashRow = value; }
////}
///////
/////// Gets or sets the set of MsiAssemblyName rows created for this FileRow.
///////
/////// RowCollection of MsiAssemblyName table.
////[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
////public List AssemblyNameRows
////{
//// get { return this.assemblyNameRows; }
//// set { this.assemblyNameRows = value; }
////}
///////
/////// Gets or sets the patching attributes to the file.
///////
/////// Patching attributes of the file.
////public PatchAttributeType PatchAttributes
////{
//// get { return this.patchAttributes; }
//// set { this.patchAttributes = value; }
////}
///////
/////// Gets or sets the delta patch retain-length list for the file.
///////
/////// RetainLength list for the file.
////public string RetainLengths
////{
//// get { return this.retainLengths; }
//// set { this.retainLengths = value; }
////}
///////
/////// Gets or sets the delta patch ignore-offset list for the file.
///////
/////// IgnoreOffset list for the file.
////public string IgnoreOffsets
////{
//// get { return this.ignoreOffsets; }
//// set { this.ignoreOffsets = value; }
////}
///////
/////// Gets or sets the delta patch ignore-length list for the file.
///////
/////// IgnoreLength list for the file.
////public string IgnoreLengths
////{
//// get { return this.ignoreLengths; }
//// set { this.ignoreLengths = value; }
////}
///////
/////// Gets or sets the delta patch retain-offset list for the file.
///////
/////// RetainOffset list for the file.
////public string RetainOffsets
////{
//// get { return this.retainOffsets; }
//// set { this.retainOffsets = value; }
////}
///////
/////// Gets or sets the delta patch retain-length list for the previous file.
///////
/////// RetainLength list for the previous file.
////public string PreviousRetainLengths
////{
//// get { return this.previousRetainLengths[0]; }
//// set { this.previousRetainLengths[0] = value; }
////}
///////
/////// Gets the delta patch retain-length list for the previous files.
///////
/////// RetainLength list for the previous files.
////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
////public string[] PreviousRetainLengthsArray
////{
//// get { return this.previousRetainLengths; }
////}
///////
/////// Gets or sets the delta patch ignore-offset list for the previous file.
///////
/////// IgnoreOffset list for the previous file.
////public string PreviousIgnoreOffsets
////{
//// get { return this.previousIgnoreOffsets[0]; }
//// set { this.previousIgnoreOffsets[0] = value; }
////}
///////
/////// Gets the delta patch ignore-offset list for the previous files.
///////
/////// IgnoreOffset list for the previous files.
////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
////public string[] PreviousIgnoreOffsetsArray
////{
//// get { return this.previousIgnoreOffsets; }
////}
///////
/////// Gets or sets the delta patch ignore-length list for the previous file.
///////
/////// IgnoreLength list for the previous file.
////public string PreviousIgnoreLengths
////{
//// get { return this.previousIgnoreLengths[0]; }
//// set { this.previousIgnoreLengths[0] = value; }
////}
///////
/////// Gets the delta patch ignore-length list for the previous files.
///////
/////// IgnoreLength list for the previous files.
////[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
////public string[] PreviousIgnoreLengthsArray
////{
//// get { return this.previousIgnoreLengths; }
////}
///////
/////// Gets or sets the delta patch retain-offset list for the previous file.
///////
/////// RetainOffset list for the previous file.
////public string PreviousRetainOffsets
////{
//// get { return this.previousRetainOffsets[0]; }
//// set { this.previousRetainOffsets[0] = value; }
////}
///////
/////// Gets the delta patch retain-offset list for the previous files.
///////
/////// RetainOffset list for the previous files.
////[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
////public string[] PreviousRetainOffsetsArray
////{
//// get { return this.previousRetainOffsets; }
////}
///////
/////// Compares the current FileRow with another object of the same type.
///////
/////// An object to compare with this instance.
/////// An integer that indicates the relative order of the comparands.
////[SuppressMessage("Microsoft.Globalization", "CA1303:DoNotPassLiteralsAsLocalizedParameters", MessageId = "System.ArgumentException.#ctor(System.String)")]
////[SuppressMessage("Microsoft.Globalization", "CA1309:UseOrdinalStringComparison")]
////public int CompareTo(object obj)
////{
//// if (this == obj)
//// {
//// return 0;
//// }
//// FileRow fileRow = obj as FileRow;
//// if (null == fileRow)
//// {
//// throw new ArgumentException(WixDataStrings.EXP_OtherObjectIsNotFileRow);
//// }
//// int compared = this.DiskId - fileRow.DiskId;
//// if (0 == compared)
//// {
//// compared = this.patchGroup - fileRow.patchGroup;
//// if (0 == compared)
//// {
//// compared = String.Compare(this.File, fileRow.File, StringComparison.InvariantCulture);
//// }
//// }
//// return compared;
////}
///////
/////// Copies data from another FileRow object.
///////
/////// An row to get data from.
////public void CopyFrom(FileRow src)
////{
//// for (int i = 0; i < src.Fields.Length; i++)
//// {
//// this[i] = src[i];
//// }
//// this.assemblyManifest = src.assemblyManifest;
//// this.assemblyType = src.assemblyType;
//// this.directory = src.directory;
//// this.diskId = src.diskId;
//// this.fromModule = src.fromModule;
//// this.isGeneratedShortFileName = src.isGeneratedShortFileName;
//// this.patchGroup = src.patchGroup;
//// this.processorArchitecture = src.processorArchitecture;
//// this.source = src.source;
//// this.PreviousSource = src.PreviousSource;
//// this.Operation = src.Operation;
//// this.symbols = src.symbols;
//// this.PreviousSymbols = src.PreviousSymbols;
//// this.patchAttributes = src.patchAttributes;
//// this.retainOffsets = src.retainOffsets;
//// this.retainLengths = src.retainLengths;
//// this.ignoreOffsets = src.ignoreOffsets;
//// this.ignoreLengths = src.ignoreLengths;
//// this.PreviousRetainOffsets = src.PreviousRetainOffsets;
//// this.PreviousRetainLengths = src.PreviousRetainLengths;
//// this.PreviousIgnoreOffsets = src.PreviousIgnoreOffsets;
//// this.PreviousIgnoreLengths = src.PreviousIgnoreLengths;
////}
///////
/////// Appends previous data from another FileRow object.
///////
/////// An row to get data from.
////public void AppendPreviousDataFrom(FileRow src)
////{
//// AppendStringToArray(ref this.previousSource, src.previousSource[0]);
//// AppendStringToArray(ref this.previousSymbols, src.previousSymbols[0]);
//// AppendStringToArray(ref this.previousRetainOffsets, src.previousRetainOffsets[0]);
//// AppendStringToArray(ref this.previousRetainLengths, src.previousRetainLengths[0]);
//// AppendStringToArray(ref this.previousIgnoreOffsets, src.previousIgnoreOffsets[0]);
//// AppendStringToArray(ref this.previousIgnoreLengths, src.previousIgnoreLengths[0]);
////}
///////
/////// Helper method for AppendPreviousDataFrom.
///////
/////// Destination array.
/////// Source string.
////private static void AppendStringToArray(ref string[] destination, string source)
////{
//// string[] result = new string[destination.Length + 1];
//// destination.CopyTo(result, 0);
//// result[destination.Length] = source;
//// destination = result;
////}
}
}