Beispiel #1
0
 private void ReadScheme()
 {
     using (PartialStream stream = new PartialStream(m_stream, m_offset, m_size))
     {
         using (EndianReader reader = new EndianReader(stream, EndianType.LittleEndian))
         {
             Header.Read(reader);
             Metadata.Read(reader);
         }
     }
 }
        public SerializedFile ReadFile(IFileCollection collection, IAssemblyManager manager)
        {
            SerializedFile file = new SerializedFile(collection, manager, this);

            using (PartialStream stream = new PartialStream(m_stream, m_offset, m_size))
            {
                EndianType endianess = Header.SwapEndianess ? EndianType.BigEndian : EndianType.LittleEndian;
                using (EndianReader reader = new EndianReader(stream, endianess, stream.Position))
                {
                    file.Read(reader);
                }
            }
            return(file);
        }
Beispiel #3
0
 public void ReadResourcesFile(FileCollection collection)
 {
     if (m_stream.StreamType == SmartStreamType.Memory && m_stream.Length > m_size)
     {
         // create separate stream so resouce file don't refer to huge memory blob and this blob will be released
         using (SmartStream resStream = SmartStream.CreateMemory(new byte[m_size]))
         {
             using (PartialStream partStream = new PartialStream(m_stream, m_offset, m_size))
             {
                 partStream.CopyTo(resStream);
             }
             collection.ReadResourceFile(resStream, FilePath, Name, 0, m_size);
         }
     }
     else
     {
         collection.ReadResourceFile(m_stream, FilePath, Name, m_offset, m_size);
     }
 }
        private void ReadScheme()
        {
            using (PartialStream stream = new PartialStream(m_stream, m_offset, m_size))
            {
                using (EndianReader reader = new EndianReader(stream, EndianType.BigEndian))
                {
                    Header.Read(reader);
                }

                EndianType endianess = EndianType.LittleEndian;
                if (SerializedFileHeader.HasEndian(Header.Generation))
                {
                    endianess = Header.SwapEndianess ? EndianType.BigEndian : EndianType.LittleEndian;
                }
                using (SerializedReader reader = new SerializedReader(stream, endianess, Name, Header.Generation))
                {
                    if (SerializedFileMetadata.IsMetadataAtTheEnd(reader.Generation))
                    {
                        reader.BaseStream.Position = Header.FileSize - Header.MetadataSize;
                        reader.BaseStream.Position++;
                    }

                    Metadata.Read(reader);
                }
            }

            SerializedFileMetadataConverter.CombineFormats(Header.Generation, Metadata);
            RTTIClassHierarchyDescriptorConverter.FixResourceVersion(Name, ref Metadata.Hierarchy);

#warning TEMP HACK
            if (Metadata.Hierarchy.Platform == Platform.NoTarget)
            {
                Flags = TransferInstructionFlags.NoTransferInstructionFlags;
            }
            if (FilenameUtils.IsEngineResource(Name) || Header.Generation < FileGeneration.FG_500a1 && FilenameUtils.IsBuiltinExtra(Name))
            {
                Flags |= TransferInstructionFlags.IsBuiltinResourcesFile;
            }
            if (Header.SwapEndianess)
            {
                Flags |= TransferInstructionFlags.SwapEndianess;
            }
        }
        private void OnRequestAssembly(string assembly)
        {
            string assemblyName = $"{assembly}{MonoManager.AssemblyExtension}";

            foreach (ResourcesFile file in m_resources)
            {
                if (file.Name == assemblyName)
                {
                    using (PartialStream stream = new PartialStream(file.Stream, file.Offset, file.Size))
                    {
                        ReadAssembly(stream, assemblyName);
                    }
                    Logger.Log(LogType.Info, LogCategory.Import, $"Assembly '{assembly}' has been loaded");
                    return;
                }
            }

            m_assemblyCallback?.Invoke(assembly);
        }
Beispiel #6
0
        private void ReadScheme()
        {
            using (PartialStream stream = new PartialStream(m_stream, m_offset, m_size))
            {
                using (EndianReader reader = new EndianReader(stream, EndianType.BigEndian))
                {
                    Header.Read(reader);

                    switch (Header.Type)
                    {
                    case ArchiveType.GZip:
                        m_dataStream = ReadGZip(reader);
                        break;

                    case ArchiveType.Brotli:
                        m_dataStream = ReadBrotli(reader);
                        break;

                    default:
                        throw new NotSupportedException(Header.Type.ToString());
                    }
                }
            }
        }