예제 #1
0
파일: YLS.cs 프로젝트: javilapiedra/3DNUS
        public void Entry(char region, YLS_Title wat)
        {
            if (!regions.ContainsKey(region))
            {
                regions[region] = new List <YLS_Title>();
            }

            regions[region].Add(wat);
        }
예제 #2
0
파일: YLS.cs 프로젝트: javilapiedra/3DNUS
        public static YLS Import(String wat)
        {
            if (!File.Exists(wat))
            {
                return(null);
            }
            YLS       yls  = new YLS();
            YLS_Title titl = null;

            String[] line = null;
            using (StreamReader str = File.OpenText(wat))
            {
                str.ReadLine();

                while (!str.EndOfStream)
                {
                    line = str.ReadLine().Split(',');
                    if (line.Length != 4)
                    {
                        continue;
                    }

                    titl = new YLS_Title();

                    titl.id = Convert.ToUInt64(line[0], 16);

                    if (titl.id == 0x4013000001B02)
                    {
                        line[3] = line[3].Replace("02-11-15 GPIO", "9.5.0-22");
                    }
                    if (titl.id == 0x400102002CA00)
                    {
                        line[3] = line[3].Replace("10-02-14 JPN", "9.1.0-20J");
                    }

                    Match mat = Regex.Match(line[3], @"(\d+)\.(\d+)\.(\d+)-(\d+)");

                    foreach (String ver in line[2].Split(' '))
                    {
                        while (mat.Success && String.IsNullOrEmpty(mat.ToString()))
                        {
                            mat = mat.NextMatch();                                                        //stupid dotNOT Regex engine ¬_¬
                        }
                        if (!mat.Success)
                        {
                            throw new InvalidDataException("Invalid report file!");
                        }

                        titl.ver.Add(new YLS_Titlever()
                        {
                            version = int.Parse(ver.Substring(1)), sysver = new YLS_Sysver()
                            {
                                label = mat.ToString()
                            }
                        });

                        mat = mat.NextMatch();
                    }

                    if (mat != null && mat.Success)
                    {
                        throw new InvalidDataException("Invalid report file!");
                    }
                    else
                    {
                        yls.Entry(line[1][0], titl);
                    }
                }
            }
            return(yls);
        }