示例#1
0
        public static Stream EnsurePacked(Stream s)
        {
            s.Position = 0;
            StructReader reader = new StructReader(s);
            MemoryStream ms     = new MemoryStream();
            StructWriter writer = new StructWriter(ms, System.Text.Encoding.ASCII, true);

            var header = reader.ReadStruct <FTS_IO_UNIQUE_HEADER>();

            writer.WriteStruct(header);

            for (int i = 0; i < header.count; i++)
            {
                writer.WriteStruct(reader.ReadStruct <FTS_IO_UNIQUE_HEADER2>());
            }

            byte[] restOfFile = reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position));
            byte[] packed     = ArxIO.Pack(restOfFile);

            ms.Write(packed, 0, packed.Length);
            ms.Position = 0;

            s.Dispose();
            return(ms);
        }
示例#2
0
        public static Stream EnsurePacked(Stream s)
        {
            byte[] unpacked = new byte[s.Length];
            s.Read(unpacked, 0, unpacked.Length);
            byte[] packed = ArxIO.Pack(unpacked);

            MemoryStream ms = new MemoryStream();

            ms.Write(packed, 0, packed.Length);
            ms.Position = 0;
            s.Dispose(); //close old stream
            return(ms);
        }
示例#3
0
        public static Stream EnsurePacked(Stream s)
        {
            s.Position = 0;
            MemoryStream ms = new MemoryStream();

            BinaryReader reader = new BinaryReader(s);

            byte[] header     = reader.ReadBytes(Marshal.SizeOf(typeof(DLF_IO_HEADER)));
            byte[] restOfFile = reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position));

            byte[] packed = ArxIO.Pack(restOfFile);

            ms.Write(header, 0, header.Length);
            ms.Write(packed, 0, packed.Length);
            ms.Position = 0;

            s.Dispose();
            return(ms);
        }
示例#4
0
        public static Stream EnsurePacked(Stream s)
        {
            //TODO: i should pack stuff depending on version, but for now ill just assume version 1.44 by default

            MemoryStream ms = new MemoryStream();

            BinaryReader reader = new BinaryReader(s);

            byte[] header     = reader.ReadBytes(Marshal.SizeOf(typeof(DLF_IO_HEADER)));
            byte[] restOfFile = reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position));

            byte[] packed = ArxIO.Pack(restOfFile);

            ms.Write(header, 0, header.Length);
            ms.Write(packed, 0, packed.Length);
            ms.Position = 0;

            s.Dispose();
            return(ms);
        }