示例#1
0
 public BndContentsEntry(string sourceFile, int fileId, string name, Binder.FileFlags flags, DCX.Type compressionType, string paramType)
 {
     this.SourceFile      = sourceFile;
     this.FileId          = fileId;
     this.Name            = name;
     this.Flags           = flags;
     this.CompressionType = compressionType;
     this.ParamType       = paramType;
 }
示例#2
0
        private static BinderFile ReadFile(BinaryReaderEx br, Binder.Format format)
        {
            Binder.FileFlags flags = br.ReadEnum8 <Binder.FileFlags>();
            br.AssertByte(0);
            br.AssertByte(0);
            br.AssertByte(0);

            int  compressedSize = br.ReadInt32();
            uint fileOffset     = br.ReadUInt32();

            int id = -1;

            if (Binder.HasID(format))
            {
                id = br.ReadInt32();
            }

            string name = null;

            if (Binder.HasName(format))
            {
                uint fileNameOffset = br.ReadUInt32();
                name = br.GetShiftJIS(fileNameOffset);
            }

            if (Binder.HasUncompressedSize(format))
            {
                int uncompressedSize = br.ReadInt32();
            }

            byte[] bytes;
            if (Binder.IsCompressed(flags))
            {
                br.StepIn(fileOffset);
                bytes = SFUtil.ReadZlib(br, compressedSize);
                br.StepOut();
            }
            else
            {
                bytes = br.GetBytes(fileOffset, compressedSize);
            }

            return(new BinderFile(flags, id, name, bytes));
        }
示例#3
0
                public FileHeader(BinaryReaderEx br, bool unicode, Binder.Format format)
                {
                    Flags = br.ReadEnum8 <Binder.FileFlags>();
                    br.AssertByte(0);
                    br.AssertByte(0);
                    br.AssertByte(0);

                    br.AssertInt32(-1);
                    CompressedSize = br.ReadInt64();
                    if (Binder.HasUncompressedSize(format))
                    {
                        UncompressedSize = br.ReadInt64();
                    }

                    if (Binder.HasLongOffsets(format))
                    {
                        Offset = br.ReadInt64();
                    }
                    else
                    {
                        Offset = br.ReadUInt32();
                    }

                    if (Binder.HasID(format))
                    {
                        ID = br.ReadInt32();
                    }
                    else
                    {
                        ID = -1;
                    }

                    uint nameOffset = br.ReadUInt32();

                    if (unicode)
                    {
                        Name = br.GetUTF16(nameOffset);
                    }
                    else
                    {
                        Name = br.GetShiftJIS(nameOffset);
                    }
                }
示例#4
0
        private static BinderFile ReadFile(BinaryReaderEx br, bool unicode, Binder.Format format)
        {
            Binder.FileFlags flags = br.ReadEnum8 <Binder.FileFlags>();
            br.AssertByte(0);
            br.AssertByte(0);
            br.AssertByte(0);

            br.AssertInt32(-1);
            long compressedSize = br.ReadInt64();

            if (Binder.HasUncompressedSize(format))
            {
                long uncompressedSize = br.ReadInt64();
            }

            uint fileOffset = br.ReadUInt32();

            int id = -1;

            if (Binder.HasID(format))
            {
                id = br.ReadInt32();
            }

            string name = null;

            if (Binder.HasName(format))
            {
                uint nameOffset = br.ReadUInt32();
                if (unicode)
                {
                    name = br.GetUTF16(nameOffset);
                }
                else
                {
                    name = br.GetShiftJIS(nameOffset);
                }
            }

            if (format == Binder.Format.x20)
            {
                br.AssertInt64(0);
            }

            byte[] bytes;
            if (Binder.IsCompressed(flags))
            {
                if (format == Binder.Format.x2E)
                {
                    bytes = br.GetBytes(fileOffset, (int)compressedSize);
                    bytes = DCX.Decompress(bytes, out DCX.Type type);
                    if (type != DCX.Type.DemonsSoulsEDGE)
                    {
                        throw null;
                    }
                }
                else
                {
                    br.StepIn(fileOffset);
                    bytes = SFUtil.ReadZlib(br, (int)compressedSize);
                    br.StepOut();
                }
            }
            else
            {
                bytes = br.GetBytes(fileOffset, (int)compressedSize);
            }

            return(new BinderFile(flags, id, name, bytes));
        }