public void Unprepare() { if (PreparedStream == null) { return; } PreparedStream.Close(); PreparedStream.Dispose(); PreparedStream = null; }
public override IPatchResult Parse(string inputDir, string outputDir) { if (!IsFile) { var path = Path.Combine(outputDir, Filename).TrimEnd('\\'); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } return(new PatchResultSuccessful(path)); } using (var reader = new BinaryReader(PreparedStream)) { var Length = reader.ReadInt32(); var Checksum = reader.ReadUInt32(); var calculatedChecksum = CRC32.CalculateChecksumStream(PreparedStream); PreparedStream.Position = 8; var outputFile = Path.Combine(outputDir, Filename); Directory.CreateDirectory(Path.GetDirectoryName(outputFile)); using (var os = File.OpenWrite(outputFile)) { PreparedStream.CopyTo(os); } if (calculatedChecksum != Checksum) { return(new PatchResultPatchedFileCorrupt(outputFile)); } return(new PatchResultSuccessful(outputFile)); } }