private static void CHDOutputHandler(object sendingProcess, DataReceivedEventArgs outLine) { // Collect the process command output. if (String.IsNullOrEmpty(outLine.Data)) { return; } string sOut = outLine.Data; //ReportError.LogOut("CHDOutput: " + _outputLineCount + " : " + sOut); switch (_outputLineCount) { case 0: if (sOut.Length < 53 || sOut.Substring(0, 53) != "chdman - MAME Compressed Hunks of Data (CHD) manager ") { _result = "Incorrect startup of CHDMan :" + sOut; _resultType = CHDManCheck.CHDReturnError; } break; case 1: if (sOut != "Raw SHA1 verification successful!") { _result = "Raw SHA1 check failed :" + sOut; _resultType = CHDManCheck.CHDReturnError; } break; case 2: if (sOut != "Overall SHA1 verification successful!") { _result = "Overall SHA1 check failed :" + sOut; _resultType = CHDManCheck.CHDReturnError; } break; default: _result = "Unexpected output from chdman :" + sOut; ReportError.SendErrorMessage("CHDOutputHandler returned =" + sOut); _resultType = CHDManCheck.CHDUnknownError; break; } _outputLineCount++; }
private static void CHDErrorHandler(object sendingProcess, DataReceivedEventArgs outLine) { // Collect the process command output. if (String.IsNullOrEmpty(outLine.Data)) { return; } string sOut = outLine.Data; ReportError.LogOut("CHDError: " + sOut); _bgw.ReportProgress(0, new bgwText3(sOut)); if (_resultType != CHDManCheck.Unset) { if (_errorLines > 0) { _errorLines -= 1; _result += "\r\n" + sOut; } return; } if (sOut.Length > 44) { if (sOut.Substring(0, 23) == "Error reading CHD file " && sOut.Substring(sOut.Length - 21, 21) == ": decompression error") { _result = sOut; _resultType = CHDManCheck.Corrupt; return; } } if (sOut.Length > 35) { if (sOut.Substring(0, 23) == "Error opening CHD file " && sOut.Substring(sOut.Length - 21, 21) == ": decompression error") { _result = sOut; _resultType = CHDManCheck.Corrupt; return; } } if (sOut.Length > 35) { if (sOut.Substring(0, 23) == "Error opening CHD file " && sOut.Substring(sOut.Length - 12, 12) == ": read error") { _result = sOut; _resultType = CHDManCheck.Corrupt; return; } } if (sOut.Length > 25) { if (sOut.Substring(0, 25) == "Error: Raw SHA1 in header") { _result = sOut; _errorLines = 1; _resultType = CHDManCheck.Corrupt; return; } } if (sOut.Length == 13) { if (sOut == "Out of memory") { _result = sOut; _resultType = CHDManCheck.Corrupt; return; } } // check for Verifying message if (sOut.Length >= 24) { if (sOut.Substring(0, 11) == "Verifying, " && sOut.Substring(sOut.Length - 13, 13) == " complete... ") { //_resultType = CHDManCheck.Good; return; } } ReportError.SendErrorMessage("CHDErrorHandler returned =" + sOut); _result = "Unknown message : " + sOut; _resultType = CHDManCheck.CHDUnknownError; }