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 virtual string GetInfo()
        {
            string fileInfo;

            try
            {
                fileInfo =
                    "BigFile Information" + Environment.NewLine + "---" + Environment.NewLine +
                    "Name: " + Name + Environment.NewLine +
                    "Path: " + Path + Environment.NewLine +
                    "Size: " + FileSize.ToString() + " bytes" + Environment.NewLine +
                    "SHA256 Hash: 0x" + BLD.HexConverter.ByteArrayToHexString(mSHA256Hash) + Environment.NewLine +
                    "Fingerprint: " + Fingerprint.GetDisplayName() + Environment.NewLine;
                if (Fingerprint.Title != "Unrecognized File")
                {
                    fileInfo += "Title: " + Fingerprint.Title + Environment.NewLine;
                    if (Fingerprint.Platform != "")
                    {
                        fileInfo += "Platform: " + Fingerprint.Platform + Environment.NewLine;
                    }
                    if (Fingerprint.Format != "")
                    {
                        fileInfo += "Format/Region: " + Fingerprint.Format + Environment.NewLine;
                    }
                    if (Fingerprint.Language != "")
                    {
                        fileInfo += "Language: " + Fingerprint.Language + Environment.NewLine;
                    }
                    if (Fingerprint.ReleaseID != "")
                    {
                        fileInfo += "Release ID: " + Fingerprint.ReleaseID + Environment.NewLine;
                    }
                    if (Fingerprint.ReleaseType != "")
                    {
                        fileInfo += "Release Type: " + Fingerprint.ReleaseType + Environment.NewLine;
                    }
                    if (Fingerprint.FileName != "")
                    {
                        fileInfo += "FileName: " + Fingerprint.FileName + Environment.NewLine;
                    }
                    if (Fingerprint.BuildDate != "")
                    {
                        fileInfo += "Build Date: " + Fingerprint.BuildDate + Environment.NewLine;
                    }
                }
                if (mType == null)
                {
                    fileInfo += "Reading As: unknown filetype" + Environment.NewLine;
                }
                else
                {
                    fileInfo += "Reading As: " + mType.Description + Environment.NewLine;
                }

                if (mHashLookupTable != null)
                {
                    fileInfo += "Hash Lookup Table: " + HashLookupTable.Name + Environment.NewLine;
                }

                if (mMasterIndex != null)
                {
                    fileInfo += "Files Contained: " + mMasterIndex.FileCount;
                }
            }
            catch (Exception ex)
            {
                fileInfo = "BigFile is not open yet";
            }

            return(fileInfo);
        }
        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;
        }
        public BigFile(string filePath)
        {
            SetParameters();
            Path = filePath;
            int lastBackSlash = filePath.LastIndexOf('\\') + 1;

            Name     = filePath.Substring(lastBackSlash, filePath.Length - lastBackSlash);
            FileSize = 0;
            try
            {
                FileInfo fInfo = new FileInfo(Path);
                FileSize = fInfo.Length;
            }
            catch (Exception ex)
            {
                throw new BigFileOpenException
                          ("Unable to open the file " + Path + " to determine its size.\r\n" +
                          "The specific error message is: \r\n" +
                          ex.Message
                          );
            }
            try
            {
                FileStream hStream = new FileStream(Path, FileMode.Open, FileAccess.Read);
                hStream.Position = 0;
                SHA256 s256 = SHA256Managed.Create();
                mSHA256Hash = s256.ComputeHash(hStream);
                hStream.Close();
            }
            catch (Exception ex)
            {
                throw new BigFileOpenException
                          ("Unable to open the file " + Path + " to determine its hash." + Environment.NewLine +
                          "The specific error message is:" + Environment.NewLine +
                          ex.Message
                          );
            }

            InitializeTypes();
            bool foundMatch = false;

            Fingerprint = new BF.Fingerprint();

            for (int i = 0; i < mFingerprints.GetUpperBound(0); i++)
            {
                if ((!foundMatch) && (mFingerprints[i].CheckBigFileForMatch(this, true)))
                {
                    Fingerprint = mFingerprints[i];
                    foundMatch  = true;
                }
            }
            // check for matches twice - once based just on file size, and then using the SHA256 hash if there are
            // multiple matches for the file size
            // this is to avoid lengthy hash calculations for large files if there is only one (or no) match
            // based on file size alone
            //ArrayList matchList = new ArrayList();
            //for (int i = 0; i < mFingerprints.GetUpperBound(0); i++)
            //{
            //    if (mFingerprints[i].CheckBigFileForMatch(this, false))
            //    {
            //        matchList.Add(i);
            //    }
            //}
            //if (matchList.Count > 0)
            //{
            //    if (matchList.Count == 1)
            //    {
            //        Fingerprint = mFingerprints[(int)matchList[0]];
            //    }
            //    else
            //    {
            //        foreach (int i in matchList)
            //        {
            //            if ((!foundMatch) && (mFingerprints[i].CheckBigFileForMatch(this, false)))
            //            {
            //                Fingerprint = mFingerprints[i];
            //                foundMatch = true;
            //            }
            //        }
            //    }
            //}
        }