public void SetDropDownOptions(BF.BigFileTypeCollection options)
 {
     for (int i = 0; i < options.BigFileTypeNames.Length; i++)
     {
         BF.BigFileType bft = options.GetTypeByName(options.BigFileTypeNames[i]);
         cbxTypes.Items.Add(bft.Description);
     }
     if (cbxTypes.Items.Count > 0)
     {
         cbxTypes.SelectedIndex = 0;
     }
 }
Beispiel #2
0
        public static BigFileTypeCollection GetAllTypes()
        {
            BigFileTypeCollection result   = new BigFileTypeCollection();
            ArrayList             nameList = new ArrayList();

            BF.BigFileTypeAkuji bftAkuji = new BigFileTypeAkuji();
            result.BigFileTypeHash.Add(bftAkuji.Name, bftAkuji);
            nameList.Add(bftAkuji.Name);

            BF.BigFileTypeBloodOmen bftBloodOmen = new BigFileTypeBloodOmen();
            result.BigFileTypeHash.Add(bftBloodOmen.Name, bftBloodOmen);
            nameList.Add(bftBloodOmen.Name);

            BF.BigFileTypeMadDashRacingBigFile bftMadDashRacingBigFile = new BigFileTypeMadDashRacingBigFile();
            result.BigFileTypeHash.Add(bftMadDashRacingBigFile.Name, bftMadDashRacingBigFile);
            nameList.Add(bftMadDashRacingBigFile.Name);

            BF.BigFileTypeDefiancePC bftDefiancePC = new BigFileTypeDefiancePC();
            result.BigFileTypeHash.Add(bftDefiancePC.Name, bftDefiancePC);
            nameList.Add(bftDefiancePC.Name);

            BF.BigFileTypeDefiancePlayStation2 bftDefiancePlayStation2 = new BigFileTypeDefiancePlayStation2();
            result.BigFileTypeHash.Add(bftDefiancePlayStation2.Name, bftDefiancePlayStation2);
            nameList.Add(bftDefiancePlayStation2.Name);

            BF.BigFileTypeGex1PlayStation bftGex1PlayStation = new BigFileTypeGex1PlayStation();
            result.BigFileTypeHash.Add(bftGex1PlayStation.Name, bftGex1PlayStation);
            nameList.Add(bftGex1PlayStation.Name);

            BF.BigFileTypeGex1Saturn bftGex1Saturn = new BigFileTypeGex1Saturn();
            result.BigFileTypeHash.Add(bftGex1Saturn.Name, bftGex1Saturn);
            nameList.Add(bftGex1Saturn.Name);

            BF.BigFileTypeGex2 bftGex2 = new BigFileTypeGex2();
            result.BigFileTypeHash.Add(bftGex2.Name, bftGex2);
            nameList.Add(bftGex2.Name);

            BF.BigFileTypeGex3 bftGex3 = new BigFileTypeGex3();
            result.BigFileTypeHash.Add(bftGex3.Name, bftGex3);
            nameList.Add(bftGex3.Name);

            /* BF.BigFileTypePandemonium bftPandemonium = new BigFileTypePandemonium();
             * result.BigFileTypeHash.Add(bftPandemonium.Name, bftPandemonium);
             * nameList.Add(bftPandemonium.Name); */

            BF.BigFileTypeSoulReaverProto1Demo bftSoulReaverProto1Demo = new BigFileTypeSoulReaverProto1Demo();
            result.BigFileTypeHash.Add(bftSoulReaverProto1Demo.Name, bftSoulReaverProto1Demo);
            nameList.Add(bftSoulReaverProto1Demo.Name);

            BF.BigFileTypeSoulReaverPlayStation bftSoulReaverPlayStation = new BigFileTypeSoulReaverPlayStation();
            result.BigFileTypeHash.Add(bftSoulReaverPlayStation.Name, bftSoulReaverPlayStation);
            nameList.Add(bftSoulReaverPlayStation.Name);

            BF.BigFileTypeSoulReaverPlayStationPALPrereleaseJuly1999 bftSoulReaverPlayStationPALPrereleaseJuly1999 = new BigFileTypeSoulReaverPlayStationPALPrereleaseJuly1999();
            result.BigFileTypeHash.Add(bftSoulReaverPlayStationPALPrereleaseJuly1999.Name, bftSoulReaverPlayStationPALPrereleaseJuly1999);
            nameList.Add(bftSoulReaverPlayStationPALPrereleaseJuly1999.Name);

            BF.BigFileTypeSoulReaverPlayStationPALRetail bftSoulReaverPlayStationPALRetail = new BigFileTypeSoulReaverPlayStationPALRetail();
            result.BigFileTypeHash.Add(bftSoulReaverPlayStationPALRetail.Name, bftSoulReaverPlayStationPALRetail);
            nameList.Add(bftSoulReaverPlayStationPALRetail.Name);

            BF.BigFileTypeSoulReaverPC bftSoulReaverPC = new BigFileTypeSoulReaverPC();
            result.BigFileTypeHash.Add(bftSoulReaverPC.Name, bftSoulReaverPC);
            nameList.Add(bftSoulReaverPC.Name);

            BF.BigFileTypeSoulReaverDreamcast bftSoulReaverDreamcast = new BigFileTypeSoulReaverDreamcast();
            result.BigFileTypeHash.Add(bftSoulReaverDreamcast.Name, bftSoulReaverDreamcast);
            nameList.Add(bftSoulReaverDreamcast.Name);

            BF.BigFileTypeSoulReaver2AirForgeDemo bftSoulReaver2AirForgeDemo = new BigFileTypeSoulReaver2AirForgeDemo();
            result.BigFileTypeHash.Add(bftSoulReaver2AirForgeDemo.Name, bftSoulReaver2AirForgeDemo);
            nameList.Add(bftSoulReaver2AirForgeDemo.Name);

            BF.BigFileTypeSoulReaver2PlayStation2 bftSoulReaver2PlayStation2 = new BigFileTypeSoulReaver2PlayStation2();
            result.BigFileTypeHash.Add(bftSoulReaver2PlayStation2.Name, bftSoulReaver2PlayStation2);
            nameList.Add(bftSoulReaver2PlayStation2.Name);

            BF.BigFileTypeSoulReaver2PC bftSoulReaver2PC = new BigFileTypeSoulReaver2PC();
            result.BigFileTypeHash.Add(bftSoulReaver2PC.Name, bftSoulReaver2PC);
            nameList.Add(bftSoulReaver2PC.Name);

            BF.BigFileTypeTombRaiderLegendPlayStation2Demo bftTombRaiderLegendPlayStation2Demo = new BigFileTypeTombRaiderLegendPlayStation2Demo();
            result.BigFileTypeHash.Add(bftTombRaiderLegendPlayStation2Demo.Name, bftTombRaiderLegendPlayStation2Demo);
            nameList.Add(bftTombRaiderLegendPlayStation2Demo.Name);

            BF.BigFileTypeTombRaiderLegendPlayStation2 bftTombRaiderLegendPlayStation2 = new BigFileTypeTombRaiderLegendPlayStation2();
            result.BigFileTypeHash.Add(bftTombRaiderLegendPlayStation2.Name, bftTombRaiderLegendPlayStation2);
            nameList.Add(bftTombRaiderLegendPlayStation2.Name);

            /* BF.BigFileTypeWhiplashBigFile bftWhiplashBigFile = new BigFileTypeWhiplashBigFile();
             * result.BigFileTypeHash.Add(bftWhiplashBigFile.Name, bftWhiplashBigFile);
             * nameList.Add(bftWhiplashBigFile.Name); */

            BF.BigFileTypeWaltDisneyMagicalRacingTour bftDisneyRacing = new BigFileTypeWaltDisneyMagicalRacingTour();
            result.BigFileTypeHash.Add(bftDisneyRacing.Name, bftDisneyRacing);
            nameList.Add(bftDisneyRacing.Name);

            result.BigFileTypeNames = (string[])nameList.ToArray("".GetType());

            return(result);
        }
        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;
        }