private void DoParse(SourceFile file, ModuleContainer module, ParserSession session, Report report, SeekableStreamReader reader) { Parse(reader, file, module, session, report); if (!_ctx.Settings.GenerateDebugInfo || report.Errors != 0 || file.HasChecksum) { return; } reader.Stream.Position = 0; var checksum = session.GetChecksumAlgorithm(); file.SetChecksum(checksum.ComputeHash(reader.Stream)); }
public void Parse(SourceFile source, ModuleContainer module, ParserSession session, Report report) { Stream input = null; try { // Get the stream input = source.GetDataStream(); } catch { // Generate an error Report.Error(2001, "Failed to open file '{0}' for reading", source.Name); return; } // Check for header if (input.ReadByte() == 77 && input.ReadByte() == 90) { report.Error(2015, "Failed to open file '{0}' for reading because it is a binary file. A text file was expected", source.Name); input.Close(); return; } // Back to start input.Position = 0; // Create a seekable stream SeekableStreamReader reader = new SeekableStreamReader(input, context.Settings.Encoding, session.StreamReaderBuffer); // Parse the source Parse(reader, source, module, session, report); if (context.Settings.GenerateDebugInfo == true && report.Errors == 0 && source.HasChecksum == false) { // Back to start input.Position = 0; // Get the session checksum MD5 checksum = session.GetChecksumAlgorithm(); // Apply the checksum source.SetChecksum(checksum.ComputeHash(input)); } // Dispose of streams reader.Dispose(); input.Close(); }
public void Parse(SourceFile file, ModuleContainer module, ParserSession session, Report report) { Stream input; try { input = file.GetDataStream(); } catch { report.Error(2001, "Source file `{0}' could not be found", file.Name); return; } // Check 'MZ' header if (input.ReadByte() == 77 && input.ReadByte() == 90) { report.Error(2015, "Source file `{0}' is a binary file and not a text file", file.Name); input.Close(); return; } input.Position = 0; SeekableStreamReader reader = new SeekableStreamReader(input, ctx.Settings.Encoding, session.StreamReaderBuffer); Parse(reader, file, module, session, report); if (ctx.Settings.GenerateDebugInfo && report.Errors == 0 && !file.HasChecksum) { input.Position = 0; var checksum = session.GetChecksumAlgorithm(); file.SetChecksum(checksum.ComputeHash(input)); } reader.Dispose(); input.Close(); }
public void Parse (SourceFile file, ModuleContainer module, ParserSession session, Report report) { Stream input; try { input = File.OpenRead (file.Name); } catch { report.Error (2001, "Source file `{0}' could not be found", file.Name); return; } // Check 'MZ' header if (input.ReadByte () == 77 && input.ReadByte () == 90) { report.Error (2015, "Source file `{0}' is a binary file and not a text file", file.Name); input.Close (); return; } input.Position = 0; SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding, session.StreamReaderBuffer); Parse (reader, file, module, session, report); if (ctx.Settings.GenerateDebugInfo && report.Errors == 0 && !file.HasChecksum) { input.Position = 0; var checksum = session.GetChecksumAlgorithm (); file.SetChecksum (checksum.ComputeHash (input)); } reader.Dispose (); input.Close (); }