コード例 #1
0
        internal static ShuffleARC AnalyzeShuffle(string path)
        {
            ShuffleARC sharc = new ShuffleARC
            {
                FileName  = Path.GetFileNameWithoutExtension(path),
                FilePath  = Path.GetDirectoryName(path),
                Extension = Path.GetExtension(path)
            };
            BinaryReader br = new BinaryReader(File.OpenRead(path));

            if (br.ReadUInt32() != 0xB)
            {
                br.BaseStream.Seek(0x100, SeekOrigin.Begin);
                if (br.ReadUInt32() != 0xB)
                {
                    sharc.valid = false;
                    return(sharc);
                }
                sharc.add100 = true;
            }
            uint magic = br.ReadUInt32();

            if (magic.ToString("X8") != sharc.FileName)
            {
                Console.WriteLine("Sharc mismatch - " + magic.ToString("X8") + "," + sharc.FileName);
                sharc.valid = false;
                return(sharc);
            }
            sharc.valid = true;
            br.ReadUInt32();
            br.ReadUInt32();
            sharc.FileCount = br.ReadUInt32();
            br.ReadUInt32();
            sharc.Files = new List <ShuffleFile>();
            for (int i = 0; i < sharc.FileCount; i++)
            {
                br.BaseStream.Seek(0x8, SeekOrigin.Current);
                ShuffleFile sf = new ShuffleFile
                {
                    Length = br.ReadUInt32(),
                    Offset = br.ReadUInt32() + (uint)(sharc.add100 ? 0x100 : 0)
                };
                br.BaseStream.Seek(0x10, SeekOrigin.Current);
                sharc.Files.Add(sf);
            }
            return(sharc);
        }
コード例 #2
0
ファイル: ARCUtil.cs プロジェクト: WilliamO7/pk3DS
 internal static ShuffleARC AnalyzeShuffle(string path)
 {
     ShuffleARC sharc = new ShuffleARC
     {
         FileName = Path.GetFileNameWithoutExtension(path),
         FilePath = Path.GetDirectoryName(path),
         Extension = Path.GetExtension(path)
     };
     BinaryReader br = new BinaryReader(File.OpenRead(path));
     if (br.ReadUInt32() != 0xB)
     {
         br.BaseStream.Seek(0x100, SeekOrigin.Begin);
         if (br.ReadUInt32() != 0xB)
         {
             sharc.valid = false;
             return sharc;
         }
         sharc.add100 = true;
     }
     uint magic = br.ReadUInt32();
     if (magic.ToString("X8") != sharc.FileName)
     {
         Console.WriteLine("Sharc mismatch - " + magic.ToString("X8") + "," + sharc.FileName);
         sharc.valid = false;
         return sharc;
     }
     sharc.valid = true;
     br.ReadUInt32();
     br.ReadUInt32();
     sharc.FileCount = br.ReadUInt32();
     br.ReadUInt32();
     sharc.Files = new List<ShuffleFile>();
     for (int i = 0; i < sharc.FileCount; i++)
     {
         br.BaseStream.Seek(0x8, SeekOrigin.Current);
         ShuffleFile sf = new ShuffleFile
         {
             Length = br.ReadUInt32(),
             Offset = br.ReadUInt32() + (uint)(sharc.add100 ? 0x100 : 0)
         };
         br.BaseStream.Seek(0x10, SeekOrigin.Current);
         sharc.Files.Add(sf);
     }
     return sharc;
 }