public frmMain() { InitializeComponent(); //these options will be replaced by registry key reads mnuDirectoryNames.Checked = true; mDirectoryMode = BigFile.DirectoryModes.Normal; mnuParseNames.Checked = true; mParseNamesFromKnownFileTypes = true; mnuAlwaysUseHash.Checked = false; //figure out if there is an ohrainBOWS file to work with BF.Fingerprint test = new BF.Fingerprint(); string dllPath = test.GetType().Assembly.Location; int lastSlash = dllPath.LastIndexOf('\\') + 1; dllPath = dllPath.Substring(0, lastSlash); //if (System.IO.File.Exists(dllPath + "ohrainBOWS.mdb")) //{ // mHashLookupFileIsPresent = true; //} //else //{ // mHashLookupFileIsPresent = false; // //UI.NotificationDialogue noDBFileDialogue = new BenLincoln.UI.NotificationDialogue(); // //noDBFileDialogue.SetTitle("No Rainbows"); // //noDBFileDialogue.SetMessage("Soul Spiral was unable to find the file 'ohrainBOWS.mdb' in the " + // // "application folder\r\n" + dllPath + "\r\nReverse hash name lookups will be disabled."); // //noDBFileDialogue.SetIcon(UI.Dialogue.ICON_X); // //noDBFileDialogue.ShowDialog(); // MessageBox.Show("Soul Spiral was unable to find the file 'ohrainBOWS.mdb' in the " + // "application folder\r\n" + dllPath + "\r\nReverse hash name lookups will be disabled.", // "No Rainbows", // MessageBoxButtons.OK, // MessageBoxIcon.Exclamation); //} //set up the tooltips CreateToolTip(this.btnOpen, "Open a BigFile"); CreateToolTip(this.btnExport, "Export the currently-selected file"); CreateToolTip(this.btnExportAll, "Export all files"); CreateToolTip(this.btnReplace, "Replace the current file"); CreateToolTip(this.btnHexEdit, "Hex edit the current file"); //disable controls if necessary DisableMainIOControls(); }
public void InitializeSpecificTypes() { //file types BF.FileType ftUnknown = new FileType(); //mBigFileTypes = new BigFileType[] //{ // bftGex1PlayStation, bftGex1Saturn, bftBloodOmen, bftGex2, bftGex3, bftAkuji, bftSoulReaverProto1Demo, bftSoulReaverPlayStation, // bftSoulReaverPlayStationPALPrereleaseJuly1999, bftSoulReaverPlayStationPALRetail, bftSoulReaverPC, bftSoulReaverDreamcast, // bftSoulReaver2AirForgeDemo, bftSoulReaver2PlayStation2, // bftSoulReaver2PC, bftDefiancePlayStation2, bftDefiancePC, bftTombRaiderLegendPlayStation2Demo, bftTombRaiderLegendPlayStation2, bftBloodOmen2 //}; mBigFileTypes = BigFileType.GetAllTypes(); //BigFile fingerprints string dllPath = this.GetType().Assembly.Location; dllPath = System.IO.Path.GetDirectoryName(dllPath); string fpPath = System.IO.Path.Combine(dllPath, "Fingerprints.txt"); string[] fingerprintLines = new string[] { }; int contentLineCount = 0; if (System.IO.File.Exists(fpPath)) { try { FileStream inStream = new FileStream(fpPath, FileMode.Open, FileAccess.Read); StreamReader inReader = new StreamReader(inStream); string inData = inReader.ReadToEnd().Replace("\r\n", "\n"); fingerprintLines = inData.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); inReader.Close(); inStream.Close(); foreach (string fpl in fingerprintLines) { bool isValid = true; if (fpl.StartsWith("#")) { isValid = false; } if (fpl.Trim() == "") { isValid = false; } if (isValid) { contentLineCount++; } } } catch (Exception ex) { // do something with this later? } } ArrayList fingerprintList = new ArrayList(); int fingerprintNum = 0; foreach (string fpl in fingerprintLines) { bool isValid = true; string fpTitle = ""; string fpPlatform = ""; string fpFormat = ""; string fpLanguage = ""; string fpReleaseID = ""; string fpReleaseType = ""; string fpFileName = ""; string fpBuildDate = ""; long fpFileSize = -1; string fpBigFileTypeString = ""; string fpSHA256Hash = ""; if (fpl.StartsWith("#")) { isValid = false; } if (fpl.Trim() == "") { isValid = false; } if (isValid) { string[] lineSplit = fpl.Split(new string[] { "\t" }, StringSplitOptions.None); if (lineSplit.Length >= 11) { fpTitle = lineSplit[0]; fpPlatform = lineSplit[1]; fpFormat = lineSplit[2]; fpLanguage = lineSplit[3]; fpReleaseID = lineSplit[4]; fpReleaseType = lineSplit[5]; fpFileName = lineSplit[6]; fpBuildDate = lineSplit[7]; fpFileSize = long.Parse(lineSplit[8]); fpBigFileTypeString = lineSplit[9]; fpSHA256Hash = lineSplit[10]; } else { isValid = false; } } if (isValid) { BF.Fingerprint newFingerprint = new BF.Fingerprint(); if (BigFileTypes.BigFileTypeHash.ContainsKey(fpBigFileTypeString)) { newFingerprint.Type = (BigFileType)BigFileTypes.BigFileTypeHash[fpBigFileTypeString]; } else { isValid = false; } if (isValid) { newFingerprint.Title = fpTitle; newFingerprint.Platform = fpPlatform; newFingerprint.Format = fpFormat; newFingerprint.Language = fpLanguage; newFingerprint.ReleaseID = fpReleaseID; newFingerprint.ReleaseType = fpReleaseType; newFingerprint.FileName = fpFileName; newFingerprint.BuildDate = fpBuildDate; newFingerprint.FileSize = fpFileSize; if (fpSHA256Hash.Trim() != "") { newFingerprint.SHA256Hash = BLD.HexConverter.HexStringToBytes(fpSHA256Hash); } fingerprintList.Add(newFingerprint); fingerprintNum++; } } } BF.Fingerprint dummy = new BF.Fingerprint(); mFingerprints = (BF.Fingerprint[])fingerprintList.ToArray(dummy.GetType()); //mFingerprints = new BF.Fingerprint[] //{ // fpGexPlaystationNTSC, fpGexSaturnNTSC, fpGex2PlaystationNTSC, // fpBloodOmenPlaystationNTSC, fpBloodOmenPlaystationPAL, fpBloodOmenKTV, fpBloodOmenPC, // fpAkujiDemoNTSC, // fpAkujiNTSC, fpGex3NTSC, fpSRPSLighthouseNTSC, fpSRPSLighthousePAL, // fpSRPSBetaNTSC, fpSRPSFireDemoNTSC, fpSRPSFireDemoPAL, fpSRPSNTSC, fpSRPSPAL, fpSRPCFireDemo, fpSRPCQFM, // fpSRPC, fpSRDCNTSC, fpSRDCDemo, fpSR2AirforgePS2NTSC, fpSR2AirforgePS2PAL, fpSR2PS2NTSC, // fpSR2PS2PAL, fpSR2PS2Japan, fpSR2PC, fpSR2PCDeutsch, // fpDefiancePS2NTSC, fpDefiancePS2PAL, fpDefiancePS2PALPR20031010, fpDefiancePC, fpDefiancePCDeutsch, // fpTRLPS2DemoPAL, fpTRLPS2NTSC, fpTRLPS2PAL, fpTRLPSPPAL, // fpBloodOmen2PC, // fpUnknown //}; int d2 = 7; }