当前位置: 首页>>代码示例>>C#>>正文


C# Entry.CheckPlacement方法代码示例

本文整理汇总了C#中Entry.CheckPlacement方法的典型用法代码示例。如果您正苦于以下问题:C# Entry.CheckPlacement方法的具体用法?C# Entry.CheckPlacement怎么用?C# Entry.CheckPlacement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entry的用法示例。


在下文中一共展示了Entry.CheckPlacement方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryOpen

        public override ArcFile TryOpen(ArcView file)
        {
            if (0 != file.View.ReadUInt32 (4) || 0xCCAE01FF != file.View.ReadUInt32 (0xA))
                return null;
            uint first_offset = file.View.ReadUInt32 (0x12);
            int count = (int)(first_offset - 0x12) / 6;
            if (!IsSaneCount (count))
                return null;
            var base_name = Path.GetFileNameWithoutExtension (file.Name);

            uint next_offset = first_offset;
            uint index_offset = 0x12;
            var dir = new List<Entry> (count);
            for (int i = 0; i < count; ++i)
            {
                var entry = new Entry {
                    Name = string.Format ("{0}#{1:D4}.ogg", base_name, i),
                    Type = "audio",
                    Offset = next_offset,
                };
                index_offset += 6;
                next_offset = i+1 == count ? (uint)file.MaxOffset : file.View.ReadUInt32 (index_offset);
                entry.Size = (uint)(next_offset - entry.Offset);
                if (!entry.CheckPlacement (file.MaxOffset))
                    return null;
                dir.Add (entry);
            }
            return new ArcFile (file, this, dir);
        }
开发者ID:Casidi,项目名称:GARbro,代码行数:29,代码来源:ArcODIO.cs

示例2: TryOpen

        public override ArcFile TryOpen(ArcView file)
        {
            int version = file.View.ReadByte (4) * 10 + file.View.ReadByte (5) - '0' * 11;
            if (file.View.ReadByte (6) != 0 || version < 10 || version > 12)
                return null;
            string base_name = Path.GetFileNameWithoutExtension (file.Name);
            uint offset = 0x10;
            var dir = new List<Entry>();
            int n = 0;
            var type_buf = new byte[0x10];
            while (offset < file.MaxOffset)
            {
                if (0x10 != file.View.Read (offset, type_buf, 0, 0x10))
                    break;
                offset += 0x10;
                if (Binary.AsciiEqual (type_buf, "abdata"))
                {
                    var entry = new Entry {
                        Name = string.Format ("{0}#{1}.dat", base_name, n++),
                        Offset = offset + 4,
                        Size = file.View.ReadUInt32 (offset),
                    };
                    dir.Add (entry);
                    offset += 4 + entry.Size;
                }
                else if (Binary.AsciiEqual (type_buf, "abimage10\0")
                         || Binary.AsciiEqual (type_buf, "absound10\0"))
                {
                    int count = file.View.ReadByte (offset++);
                    for (int i = 0; i < count && offset < file.MaxOffset; ++i)
                    {
                        file.View.Read (offset, type_buf, 0, 0x10);
                        var tag = Binary.GetCString (type_buf, 0, 0x10, Encoding.ASCII);
                        uint name_length = file.View.ReadUInt16 (offset+0x10);
                        var name = file.View.ReadString (offset+0x12, name_length);
                        offset += 0x12 + name_length;

                        if (tag != "abimgdat10" && tag != "absnddat10")
                        {
                            offset += 2u + file.View.ReadUInt16 (offset);
                            if ("abimgdat13" == tag)
                                offset += 0x0C;
                            else if ("abimgdat14" == tag)
                                offset += 0x4C;
                        }
                        ++offset;
                        var size = file.View.ReadUInt32 (offset);
                        offset += 4;
                        if (0 != size)
                        {
                            if (string.IsNullOrEmpty (name))
                                name = string.Format ("{0}#{1}", base_name, n++);
                            else
                                name = s_InvalidChars.Replace (name, "_");
                            var entry = new Entry {
                                Name = name,
                                Type = tag.StartsWith ("abimg") ? "image" : tag.StartsWith ("absnd") ? "audio" : "",
                                Offset = offset,
                                Size = size,
                            };
                            if (entry.CheckPlacement (file.MaxOffset))
                            {
                                DetectFileType (file, entry);
                                dir.Add (entry);
                            }
                        }
                        offset += size;
                    }
                }
                else
                {
                    var entry = new Entry {
                        Name = string.Format ("{0}#{1}#{2}", base_name, n++, GetTypeName (type_buf)),
                        Offset = offset,
                        Size = (uint)(file.MaxOffset - offset),
                    };
                    dir.Add (entry);
                    offset += entry.Size;
                }
            }
            if (0 == dir.Count)
                return null;
            return new ArcFile (file, this, dir);
        }
开发者ID:Casidi,项目名称:GARbro,代码行数:84,代码来源:ArcABMP.cs

示例3: TryOpen

        public override ArcFile TryOpen(ArcView file)
        {
            if (!file.View.AsciiEqual (0, "BSS-Composition\0"))
                return null;
            int count = file.View.ReadByte (0x11);
            if (0 == count)
                return null;

            string base_name = Path.GetFileNameWithoutExtension (file.Name);
            var dir = new List<Entry> (count);
            uint current_offset = 0x20;
            for (int i = 0; i < count; ++i)
            {
                var entry = new Entry {
                    Name    = string.Format ("{0}#{1:D3}.bsg", base_name, i),
                    Type    = "image",
                    Offset  = current_offset,
                    Size    = 0x40 + file.View.ReadUInt32 (current_offset+0x36),
                };
                if (!entry.CheckPlacement (file.MaxOffset))
                    return null;
                dir.Add (entry);
                current_offset += entry.Size;
            }
            return new ArcFile (file, this, dir);
        }
开发者ID:Casidi,项目名称:GARbro,代码行数:26,代码来源:ArcBSC.cs

示例4: TryOpen

 public override ArcFile TryOpen(ArcView file)
 {
     int count = file.View.ReadInt32 (0);
     if (count <= 0 || count > 0xfffff)
         return null;
     long index_offset = 4;
     uint index_size = (uint)(0xc * count);
     if (index_size > file.View.Reserve (index_offset, index_size))
         return null;
     var dir = new List<Entry>();
     for (int i = 0; i < count; ++i)
     {
         var entry = new Entry {
             Offset = file.View.ReadUInt32 (index_offset+4),
             Size   = file.View.ReadUInt32 (index_offset+8)
         };
         if (entry.Offset < index_size || !entry.CheckPlacement (file.MaxOffset))
             return null;
         dir.Add (entry);
         index_offset += 12;
     }
     byte[] name_buf = new byte[260];
     foreach (var entry in dir)
     {
         uint max_len = Math.Min (260u, file.View.Reserve (index_offset, 260));
         uint n;
         for (n = 0; n < max_len; ++n)
         {
             byte b = file.View.ReadByte (index_offset+n);
             if (0 == b)
                 break;
             name_buf[n] = b;
         }
         if (0 == n || max_len == n)
             return null;
         entry.Name = Encodings.cp932.GetString (name_buf, 0, (int)n);
         entry.Type = FormatCatalog.Instance.GetTypeFromName (entry.Name);
         index_offset += n+1;
     }
     return new ArcFile (file, this, dir);
 }
开发者ID:Casidi,项目名称:GARbro,代码行数:41,代码来源:ArcPCK.cs

示例5: TryOpen

        public override ArcFile TryOpen(ArcView file)
        {
            int index_offset = file.View.ReadByte (0);
            if (index_offset <= 2 || index_offset >= file.MaxOffset)
                return null;
            int key = file.View.ReadByte (1);
            int count = 0xfff & file.View.ReadUInt16 (index_offset);
            if (0 == count)
                return null;
            index_offset += 16;

            byte[] index = new byte[count*8];
            if (index.Length != file.View.Read (index_offset, index, 0, (uint)(index.Length)))
                return null;
            DecryptIndex (index, key);

            var dir = new List<Entry> (count);
            int data_offset = index_offset + index.Length;
            index_offset = 0;
            for (int i = 0; i < count; ++i)
            {
                uint offset = LittleEndian.ToUInt32 (index, index_offset);
                uint size   = LittleEndian.ToUInt32 (index, index_offset+4);
                if (offset < data_offset || offset >= file.MaxOffset)
                    return null;
                var entry = new Entry {
                    Name = string.Format ("{0:D4}.pic", i),
                    Type = "image",
                    Offset = offset,
                    Size = size,
                };
                if (!entry.CheckPlacement (file.MaxOffset))
                    return null;
                dir.Add (entry);
                index_offset += 8;
            }
            return new ArcFile (file, this, dir);
        }
开发者ID:Casidi,项目名称:GARbro,代码行数:38,代码来源:ArcKAAS.cs

示例6: TryOpen

        public override ArcFile TryOpen(ArcView file)
        {
            if (!file.View.AsciiEqual (4, "PACK"))
                return null;

            uint init_key = file.View.ReadUInt32 (0xC);
            var xdec = new NekoXCode (init_key);
            uint key = file.View.ReadUInt32 (0x10);
            var buffer = file.View.ReadBytes (0x14, 8);
            xdec.Decrypt (key, buffer, 0, 8);

            uint index_size = LittleEndian.ToUInt32 (buffer, 0);
            if (index_size != LittleEndian.ToUInt32 (buffer, 4))
                return null;
            var index = new byte[(index_size + 7u) & ~7u];
            if (file.View.Read (0x1C, index, 0, index_size) < index_size)
                return null;
            xdec.Decrypt (key, index, 0, index.Length);

            var names_map = GetNamesMap (init_key, KnownDirNames);
            var files_map = GetNamesMap (init_key, KnownFileNames.Value);

            int index_pos = 0;
            var dir = new List<Entry>();
            long current_offset = 0x1C + index.Length;
            while (index_pos < (int)index_size)
            {
                uint dir_hash = LittleEndian.ToUInt32 (index, index_pos);
                int count = LittleEndian.ToInt32 (index, index_pos+4);
                if (count != LittleEndian.ToInt32 (index, index_pos+8))
                    break;
                index_pos += 12;
                string dir_name;
                if (!names_map.TryGetValue (dir_hash, out dir_name))
                    dir_name = dir_hash.ToString ("X8");
                dir.Capacity = dir.Count + count;
                for (int i = 0; i < count; ++i)
                {
                    uint name_hash = LittleEndian.ToUInt32 (index, index_pos);
                    uint size = LittleEndian.ToUInt32 (index, index_pos+4);
                    string file_name;
                    string type = "";
                    if (!files_map.TryGetValue(name_hash, out file_name))
                        file_name = name_hash.ToString("X8");
                    else
                        type = FormatCatalog.Instance.GetTypeFromName (file_name);
                    var entry = new Entry
                    {
                        Name = string.Format ("{0}/{1}", dir_name, file_name),
                        Type = type,
                        Offset = current_offset,
                        Size = size,
                    };
                    if (!entry.CheckPlacement (file.MaxOffset))
                        return null;
                    dir.Add (entry);
                    index_pos += 8;
                    current_offset += entry.Size;
                }
            }
            if (0 == dir.Count)
                return null;
            DetectTypes (file, dir, xdec);
            return new NekoArchive (file, this, dir, xdec);
        }
开发者ID:Casidi,项目名称:GARbro,代码行数:65,代码来源:ArcNEKO.cs


注:本文中的Entry.CheckPlacement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。