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); }
/// <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); }
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."); } }
public override void Dispose() { InReader.Dispose(); base.Dispose(); }