Наследование: IFormatDetector
Пример #1
0
        public static GameEntry HandleIso(string IsoFile)
        {
            var IsoFileInfo = new FileInfo(IsoFile);
            Psf ParamSfo;
            var Entry = new GameEntry();
            byte[] Icon0Png;
            string UmdData = string.Empty;

            if (DefaultIcon == null)
            {
                var TempMemoryStream = new MemoryStream();
                Properties.Resources.icon0.Save(TempMemoryStream, ImageFormat.Png);
                DefaultIcon = TempMemoryStream.ToArray();
            }

            using (var IsoStream = File.OpenRead(IsoFile))
            {
                switch (new FormatDetector().DetectSubType(IsoStream))
                {
                    case FormatDetector.SubType.Pbp:
                        var PBP = new Pbp().Load(File.OpenRead(IsoFile));
                        ParamSfo = new Psf(PBP[Pbp.Types.ParamSfo]);

                        Icon0Png = PBP.ContainsKey(Pbp.Types.Icon0Png) ? PBP[Pbp.Types.Icon0Png].ReadAll() : DefaultIcon;
                        UmdData = "---";

                        break;
                    case FormatDetector.SubType.Iso:
                    case FormatDetector.SubType.Cso:
                    case FormatDetector.SubType.Dax:
                        using (var Iso = IsoLoader.GetIso(IsoFile))
                        {
                            var FileSystem = new HleIoDriverIso(Iso);

                            if (!FileSystem.FileExists("/PSP_GAME/PARAM.SFO"))
                            {
                                throw (new Exception(String.Format("Not a PSP ISO '{0}'", IsoFile)));
                            }

                            ParamSfo = new Psf(new MemoryStream(FileSystem.OpenRead("/PSP_GAME/PARAM.SFO").ReadAll()));

                            if (FileSystem.FileExists("/UMD_DATA.BIN")) UmdData = FileSystem.OpenRead("/UMD_DATA.BIN").ReadAllContentsAsString();
                            Icon0Png = FileSystem.FileExists("/PSP_GAME/ICON0.PNG") ? FileSystem.OpenRead("/PSP_GAME/ICON0.PNG").ReadAll() : DefaultIcon;
                            Entry.PatchedWithPrometheus = FileSystem.FileExists("/PSP_GAME/SYSDIR/prometheus.prx") || FileSystem.FileExists("/PSP_GAME/SYSDIR/EBOOT.OLD");
                        }
                        break;
                    default: return null;
                }
            }

            FillGameEntryFromSfo(Entry, ParamSfo);
            Entry.IsoSize = IsoFileInfo.Length;
            Entry.Hash = GetHash(IsoFile);
            Entry.IsoFile = IsoFile;
            Entry.DiscId0 = UmdData.Split('|')[0];
            Entry.Icon0Png = Icon0Png;
            return Entry;
        }
Пример #2
0
 public void LoadTest()
 {
     var Pbp = new Pbp();
     Pbp.Load(File.OpenRead("../../../TestInput/HelloJpcsp.pbp"));
 }