Esempio n. 1
0
        /// <summary>
        /// Extract binary data from tables with a Name and Data column in them.
        /// </summary>
        /// <param name="inputPdb">A reference to a <see cref="Pdb"/> as output.  Paths (Data properties) will be modified in this object.</param>
        /// <param name="package">The installer database to rip from.</param>
        /// <param name="exportPath">The full path where files will be exported to.</param>
        /// <param name="tableName">The name of the table to export.</param>
        private static void MeltBinaryTable(Pdb inputPdb, InstallPackage package, string exportPath, string tableName)
        {
            if (string.IsNullOrEmpty(tableName))
            {
                throw new ArgumentNullException("tableName");
            }
            if (string.IsNullOrEmpty(exportPath))
            {
                throw new ArgumentNullException("exportPath");
            }
            if (null == package)
            {
                throw new ArgumentNullException("package");
            }
            if (null == inputPdb)
            {
                throw new ArgumentNullException("inputPdb");
            }

            Table pdbTable = inputPdb.Output.Tables[tableName];

            if (null == pdbTable)
            {
                Console.WriteLine("Table {0} does not exist.", tableName);
                return;
            }

            try
            {
                Directory.CreateDirectory(exportPath);
                Melt.ExtractFilesInBinaryTable(package, null, tableName, exportPath);
                IDictionary <string, string> paths = package.GetFilePaths(exportPath);

                if (null != paths)
                {
                    foreach (Row row in pdbTable.Rows)
                    {
                        string filename = (string)row.Fields[0].Data;
                        row.Fields[1].Data = paths[filename];
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occured extracting the {0} binary table from the install package.", tableName);
                Console.WriteLine(ex.Message);
            }
        }