コード例 #1
0
        /// <summary>
        /// Deserializes the filesystem portion (directory and files) of a release manifest file.
        /// </summary>
        private void DeserializeFileSystemBody(
            BinaryReader reader,
            ReleaseManifest manifest,
            DeserializationContext context)
        {
            // - First load the directory block and treeify it ---------------------------------------
            reader.BaseStream.Position   = context.DirectoryTableDataOffset;
            context.DirectoryDescriptors = new ReleaseManifestDirectoryDescriptor[context.DirectoryTableCount];
            context.FileParentTable      = new ReleaseManifestDirectoryEntry[context.FileTableCount];
            context.directoryTable       = new ReleaseManifestDirectoryEntry[context.DirectoryTableCount];

            for (var i = 0; i < context.DirectoryTableCount; i++)
            {
                context.DirectoryDescriptors[i] = reader.ReadRMDirectoryDescriptor();
            }

            DeserializeTreeifyDirectoryDescriptor(0, context);
            manifest.Directories = new ReadOnlyCollection <ReleaseManifestDirectoryEntry>(context.directoryTable);
            manifest.Root        = context.directoryTable[0];

            // - Place the File Descriptors into our tree---------------------------------------------
            reader.BaseStream.Position = context.FileTableDataOffset;
            var files = new ReleaseManifestFileEntry[context.FileTableCount];

            for (var fileId = 0U; fileId < context.FileTableCount; fileId++)
            {
                var fileDescriptor = reader.ReadRMFileEntryDescriptor();
                files[fileId] = new ReleaseManifestFileEntry(fileId, manifest, fileDescriptor, context.FileParentTable[fileId]);
            }

            manifest.Files = new ReadOnlyCollection <ReleaseManifestFileEntry>(files);
        }
コード例 #2
0
 /// <summary>
 /// Loads the header block of a release manifest file
 /// </summary>
 private void DeserializeHeader(
     BinaryReader reader,
     ReleaseManifest manifest,
     DeserializationContext context)
 {
     manifest.Header.magic         = reader.ReadUInt32();
     manifest.Header.formatVersion = reader.ReadUInt32();
     manifest.Header.unknownCount  = reader.ReadUInt32();
     manifest.Header.entityVersion = reader.ReadUInt32();
 }
コード例 #3
0
 internal ReleaseManifestFileEntry(
     uint fileId,
     ReleaseManifest releaseManifest,
     ReleaseManifestFileEntryDescriptor fileDescriptor,
     ReleaseManifestDirectoryEntry parent
     )
 {
     m_id = fileId;
     m_releaseManifest = releaseManifest;
     m_descriptor      = fileDescriptor;
     m_parent          = parent;
     parent.m_files.Add(this);
 }
コード例 #4
0
        /// <summary>
        /// Skips over the filesystem body portion of a release manifest file.
        ///
        /// Offsets to the directory and file tables' contents are stored in the deserialization
        /// context object.
        /// </summary>
        private void DeserializeSkipFileSystemBody(
            BinaryReader reader,
            ReleaseManifest manifest,
            DeserializationContext context)
        {
            context.DirectoryTableCount      = reader.ReadUInt32();
            context.DirectoryTableDataOffset = reader.BaseStream.Position;
            reader.BaseStream.Position      += kDirectoryEntrySize * context.DirectoryTableCount;

            context.FileTableCount      = reader.ReadUInt32();
            context.FileTableDataOffset = reader.BaseStream.Position;
            reader.BaseStream.Position += kFileEntrySize * context.FileTableCount;
        }
コード例 #5
0
        /// <summary>
        /// Deserializes the string table of a release manifest file
        /// </summary>
        private void DeserializeStringTable(
            BinaryReader reader,
            ReleaseManifest manifest,
            DeserializationContext context)
        {
            var stringTable = new ReleaseManifestStringTable();

            stringTable.Count     = reader.ReadUInt32();
            stringTable.BlockSize = reader.ReadUInt32();
            stringTable.Strings   = new string[stringTable.Count];
            for (var i = 0; i < stringTable.Count; i++)
            {
                stringTable.Strings[i] = reader.ReadNullTerminatedString();
            }
            manifest.StringTable = stringTable;
        }
コード例 #6
0
        // - deserialization ------------------------------------------------------------------------
        /// <summary>
        /// Loads a Riot Application Distribution System Release Manifest file from the given path.
        /// </summary>
        public ReleaseManifest LoadFile(string path)
        {
            using (var ms = new MemoryStream(File.ReadAllBytes(path)))
                using (var reader = new BinaryReader(ms)) {
                    var rmFile  = new ReleaseManifest(path);
                    var context = new DeserializationContext()
                    {
                        ReleaseManifest = rmFile
                    };

                    DeserializeHeader(reader, rmFile, context);
                    DeserializeSkipFileSystemBody(reader, rmFile, context);
                    DeserializeStringTable(reader, rmFile, context);
                    DeserializeFileSystemBody(reader, rmFile, context);

                    return(rmFile);
                }// using
        }
コード例 #7
0
        internal ReleaseManifestDirectoryEntry(
            uint directoryId,
            ReleaseManifest releaseManifest,
            ReleaseManifestDirectoryDescriptor descriptor,
            ReleaseManifestDirectoryEntry parent
            )
        {
            m_id = directoryId;
            m_releaseManifest = releaseManifest;
            m_descriptor      = descriptor;

            m_parent = parent;
            if (parent != null)
            {
                parent.m_directories.Add(this);
            }

            m_directories = new List <ReleaseManifestDirectoryEntry>((int)descriptor.SubdirectoryCount);
            m_files       = new List <ReleaseManifestFileEntry>((int)descriptor.FileCount);
        }
コード例 #8
0
 public ReleaseManifestWriter(ReleaseManifest manifest)
 {
     this.manifest = manifest;
 }