Beispiel #1
0
        public void TestSfoWriteRead()
        {
            var sfo = new ParamSfo();

            sfo.SetValue("KEY1", SfoEntryType.Integer, "1234");
            sfo.SetValue("KEY2", SfoEntryType.Utf8, "This is the title", 32);
            sfo.SetValue("KEY3", SfoEntryType.Utf8Special, "This is a special string", 32);
            sfo.SetValue("KEY4", SfoEntryType.Integer, "0x1234");

            using (var ms = new MemoryStream())
            {
                sfo.Write(ms);
                ms.Seek(0, SeekOrigin.Begin);
                var sfo2 = ParamSfo.FromStream(ms);
                Assert.AreEqual((sfo2["KEY1"] as IntegerValue).Value, 1234);
                Assert.AreEqual((sfo2["KEY2"] as Utf8Value).Value, "This is the title");
                Assert.AreEqual((sfo2["KEY3"] as Utf8SpecialValue).Value, "This is a special string");
                Assert.AreEqual((sfo2["KEY4"] as IntegerValue).Value, 0x1234);
            }
        }
Beispiel #2
0
        public static List <ValidateResult> ValidateProject(Gp4Project proj, string projDir)
        {
            var ret = new List <ValidateResult>();

            foreach (var check in commonChecks)
            {
                var result = check(proj, projDir);
                if (result != null)
                {
                    ret.Add(result);
                }
            }
            // Checks with project and SFO file
            if (proj.files.Items.Where(f => f.TargetPath == "sce_sys/param.sfo").FirstOrDefault() is Gp4File sfoFile &&
                Path.Combine(projDir, sfoFile.OrigPath) is string sfoPath &&
                File.Exists(sfoPath))
            {
                ParamSfo sfoObject = null;
                try
                {
                    using (var f = File.OpenRead(sfoPath))
                    {
                        sfoObject = ParamSfo.FromStream(f);
                    }
                }
                catch (Exception e)
                {
                    ret.Add(ValidateResult.Fatal("Could not load param.sfo file: " + e.Message));
                }
                if (sfoObject != null)
                {
                    foreach (var check in sfoChecks)
                    {
                        var result = check(proj, projDir, sfoObject);
                        if (result != null)
                        {
                            ret.Add(result);
                        }
                    }
                }
            }