示例#1
0
 /// <summary>
 // Try to parse file containing game meta-information.
 /// </summary>
 internal string TryParseMeta(string meta_arc_name)
 {
     if (!VFS.FileExists(meta_arc_name))
     {
         return(null);
     }
     using (var unpacker = new TocUnpacker(meta_arc_name))
     {
         if (unpacker.Length > 0x1000)
         {
             return(null);
         }
         var data = unpacker.Unpack(8);
         if (null == data)
         {
             return(null);
         }
         using (var content = new BinMemoryStream(data))
         {
             int title_length = content.ReadInt32();
             if (title_length <= 0 || title_length > content.Length)
             {
                 return(null);
             }
             var title = content.ReadBytes(title_length);
             if (title.Length != title_length)
             {
                 return(null);
             }
             return(Encodings.cp932.GetString(title));
         }
     }
 }
示例#2
0
        public override ArcFile TryOpen(ArcView file)
        {
            long index_offset = 4 + (long)file.View.ReadInt32(0) * 2;

            if (index_offset <= 4 || index_offset >= file.MaxOffset)
            {
                return(null);
            }
            using (var toc_unpacker = new TocUnpacker(file))
            {
                var toc = toc_unpacker.Unpack(index_offset, 8);
                if (null == toc)
                {
                    return(null);
                }
                var data_offset = index_offset + 0x10 + toc_unpacker.PackedSize;
                using (var index = new AppendixReader(toc, file, data_offset))
                {
                    if (!index.Read())
                    {
                        return(null);
                    }
                    return(new BellArchive(file, this, index.Dir, null));
                }
            }
        }
示例#3
0
 internal byte[] ReadToc(string toc_name, int num_length)
 {
     if (!VFS.FileExists(toc_name))
     {
         return(null);
     }
     using (var toc_unpacker = new TocUnpacker(toc_name))
         return(toc_unpacker.Unpack(num_length));
 }