예제 #1
0
        protected override void Check()
        {
            // Check file header
            if (InReader.ReadUInt64() != 0x4d4144464e455443)
            {
                throw new FileLoadException($"Failed to verify header of \"{InPath}\".");
            }

            // Skip ahead
            _ = InBuffer.Seek(2, SeekOrigin.Current);
        }
예제 #2
0
        /// <summary>
        /// Reads an option from <see cref="InReader"/>.
        /// </summary>
        /// <param name="prompt">A message to prompt the user with.</param>
        /// <returns>
        /// The option read from <see cref="InReader"/>.
        /// </returns>
        protected string ReadOption(string prompt)
        {
            string option;

            do
            {
                OutWriter.Write($"{prompt}: ");
                option = InReader.ReadLine();
            } while (string.IsNullOrEmpty(option));

            return(option);
        }
예제 #3
0
        private byte[] ReadIndexedChunk(byte?obfuscator)
        {
            int chunkSize = InReader.ReadInt32();

            if (chunkSize > 0)
            {
                byte[] chunk = new byte[chunkSize];
                InBuffer.Read(chunk, 0, chunkSize);
                if (obfuscator != null)
                {
                    for (int i = 0; i < chunkSize; i++)
                    {
                        chunk[i] ^= obfuscator.Value;
                    }
                }
                return(chunk);
            }
            else
            {
                throw new NullFileChunkException("Failed to load file chunk.");
            }
        }
예제 #4
0
 public override void Dispose()
 {
     InReader.Dispose();
     base.Dispose();
 }