public static Tuple <ReplayParseResult, Replay> ParseReplay(string fileName, bool ignoreErrors, bool deleteFile, bool allowPTRRegion = false) { try { var replay = new Replay(); // File in the version numbers for later use. MpqHeader.ParseHeader(replay, fileName); if (!ignoreErrors && replay.ReplayBuild < 32455) { return(new Tuple <ReplayParseResult, Replay>(ReplayParseResult.PreAlphaWipe, null)); } using (var archive = new MpqArchive(fileName)) ParseReplayArchive(replay, archive, ignoreErrors); if (deleteFile) { File.Delete(fileName); } return(ParseReplayResults(replay, ignoreErrors, allowPTRRegion)); } catch { return(new Tuple <ReplayParseResult, Replay>(ReplayParseResult.Exception, null)); } }
public static Tuple <ReplayParseResult, Replay> ParseReplay(byte[] bytes, bool ignoreErrors = false, bool allowPTRRegion = false) { try { var replay = new Replay(); // File in the version numbers for later use. MpqHeader.ParseHeader(replay, bytes); if (!ignoreErrors && replay.ReplayBuild < 32455) { return(new Tuple <ReplayParseResult, Replay>(ReplayParseResult.PreAlphaWipe, null)); } using (var memoryStream = new MemoryStream(bytes)) using (var archive = new MpqArchive(memoryStream)) ParseReplayArchive(replay, archive, ignoreErrors); return(ParseReplayResults(replay, ignoreErrors, allowPTRRegion)); } catch { return(new Tuple <ReplayParseResult, Replay>(ReplayParseResult.Exception, null)); } }