Exemplo n.º 1
0
        /// <summary>
        /// Function to determine if the data in a stream is readable by this codec.
        /// </summary>
        /// <param name="stream">The stream containing the data.</param>
        /// <returns><b>true</b> if the data can be read, or <b>false</b> if not.</returns>
        protected override bool OnIsReadable(Stream stream)
        {
            using (var reader = new GorgonBinaryReader(stream, true))
            {
                if ((stream.Length - stream.Position) < sizeof(ulong) * 2)
                {
                    return(false);
                }

                ulong chunkHeader = reader.ReadUInt64();
                // Skip the size, we don't need it.
                reader.ReadUInt32();
                ulong chunkFileData = reader.ReadUInt64();

                return((chunkHeader == FileHeader.ChunkID()) && (chunkFileData == SpriteDataChunk.ChunkID()));
            }
        }