// - BaseOffset is the current offset of the program binary. File table must start right after binary public byte[] Build(int baseOffset) { if (_objConfig == null) { Globals.Throw("Installer config was null for build(). Please use the constructor tp pass the installer config into the InstallerFIleTable."); } //Construct table entries foreach (InstallerFile file in _objConfig.GetFiles()) { System.IO.FileInfo inf = new System.IO.FileInfo(file.LocalPath); inf.Refresh(); _lstEntries.Add(new FileTableEntry(0, inf.Length, file.InstallerPath)); } //Now serialize the class and add the length of this table to all file offsets. //Offsets will be invalid long tablen = Serialize().Length; long runningTotal = baseOffset; // Size of binary //runningTotal += toklen; // the "token" string length (bytes) runningTotal += tablen; // Length of the file table. foreach (FileTableEntry ent in _lstEntries) { ent.Offset = runningTotal; runningTotal += ent.Size; } //Serialize again returning the the correct offsets return(Serialize()); }
private void LoadConfiguration(BuildForm bf) { _objConfig = new InstallerConfig(SparkGlobals.BuildConfigPath); _objConfig.Load(); _objConfig.BuildFileList(); if (_objConfig.Options.GetOption(InstallOption.AppGuid) == null) { Globals.Throw("The install option 'AppGuid' is required. Please add this option to the input configuration file."); } //Attempt to parse GUID - if it is invalid an exception will throw. ProgramInfo.TryParseGuidToUninstallGuid(_objConfig.Options.GetOption(InstallOption.AppGuid).Value); if (_objConfig.Options.GetOption(InstallOption.DisplayName) == null) { Globals.Throw("The install option 'DisplayName' is required. Please add this option to the input configuration file."); } Globals.Logger.LogInfo("Excluded " + _objConfig.NumExcludedFiles + " files."); Globals.Logger.LogInfo("Excluded " + _objConfig.NumExcludedDirectories + " directories."); Globals.Logger.LogInfo("Packaging " + _objConfig.GetFiles().Count + " total files."); _objFileTable = new InstallerFileTable(_objConfig); bf.Progress(0.01); }