Exemplo n.º 1
0
        private bool DumpAppPackage(CR2WFile cr2w, Stream appStream, string outfile)
        {
            if (cr2w == null || !cr2w.Chunks.Select(_ => _.Data).OfType <appearanceAppearanceDefinition>().Any())
            {
                return(false);
            }
            var blobs = cr2w.Chunks.Select(_ => _.Data).OfType <appearanceAppearanceDefinition>().ToList();
            List <RedFileDto> datas = new List <RedFileDto>();

            foreach (var blob in blobs)
            {
                if (blob.CompiledData.IsSerialized)
                {
                    var bufferIdx = blob.CompiledData.Buffer.Value;
                    var buffer    = cr2w.Buffers[bufferIdx - 1];
                    appStream.Seek(buffer.Offset, SeekOrigin.Begin);
                    var packageStream = new MemoryStream();
                    appStream.DecompressAndCopySegment(packageStream, buffer.DiskSize, buffer.MemSize);

                    CompiledPackage package = new CompiledPackage(_hashService);
                    packageStream.Seek(0, SeekOrigin.Begin);
                    package.Read(new BinaryReader(packageStream));
                    datas.Add(new RedFileDto(package));
                }
            }
            if (datas.Count > 1)
            {
                var data = JsonConvert.SerializeObject(datas, Formatting.Indented);
                File.WriteAllText(outfile, data);
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        private bool DumpAppPackage(CR2WFile cr2w, Stream appStream, string outfile)
        {
            var blob = cr2w.RootChunk as appearanceAppearanceResource;

            var datas = new List <RedFileDto>();

            foreach (var appearance in blob.Appearances)
            {
                if (appearance.Chunk.CompiledData.Buffer.MemSize > 0)
                {
                    var packageStream = new MemoryStream();
                    packageStream.Write(appearance.Chunk.CompiledData.Buffer.GetBytes());

                    var package = new CompiledPackage(_hashService);
                    packageStream.Seek(0, SeekOrigin.Begin);
                    package.Read(new BinaryReader(packageStream));
                    datas.Add(new RedFileDto(cr2w));
                }
            }
            if (datas.Count > 1)
            {
                var data = RedJsonSerializer.Serialize(datas);
                File.WriteAllText(outfile, data);
                return(true);
            }
            return(false);
        }
Exemplo n.º 3
0
        private bool DumpEntPackage(CR2WFile cr2w, Stream entStream, string outfile)
        {
            if (cr2w == null || !cr2w.Chunks.Select(_ => _.Data).OfType <entEntityTemplate>().Any())
            {
                return(false);
            }
            var blob = cr2w.Chunks.Select(_ => _.Data).OfType <entEntityTemplate>().First();

            if (blob.CompiledData.IsSerialized)
            {
                var bufferIdx = blob.CompiledData.Buffer.Value;
                var buffer    = cr2w.Buffers[bufferIdx - 1];
                entStream.Seek(buffer.Offset, SeekOrigin.Begin);
                var packageStream = new MemoryStream();
                entStream.DecompressAndCopySegment(packageStream, buffer.DiskSize, buffer.MemSize);

                CompiledPackage package = new CompiledPackage(_hashService);
                packageStream.Seek(0, SeekOrigin.Begin);
                package.Read(new BinaryReader(packageStream));
                string data = JsonConvert.SerializeObject(new RedFileDto(package), Formatting.Indented);
                File.WriteAllText(outfile, data);
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
        private bool DumpEntPackage(CR2WFile cr2w, Stream entStream, string outfile)
        {
            var blob = cr2w.RootChunk as entEntityTemplate;

            if (blob.CompiledData.Buffer.MemSize > 0)
            {
                var packageStream = new MemoryStream();
                packageStream.Write(blob.CompiledData.Buffer.GetBytes());

                var package = new CompiledPackage(_hashService);
                packageStream.Seek(0, SeekOrigin.Begin);
                package.Read(new BinaryReader(packageStream));
                var data = RedJsonSerializer.Serialize(new RedFileDto(cr2w));
                File.WriteAllText(outfile, data);
                return(true);
            }
            return(false);
        }