/// <summary> /// Runs the IoCheck. /// </summary> private CheckResult IoCheck(out List <TerminalMessage> messages) { var ioCheck = new IoCheck(); var ioCheckInputFile = ioCheck.CheckReadableAndAccessible(InputFile); var ioCheckOutputFile = ioCheck.CheckWritable(OutputFile); var combinedIoCheck = Check.Combine(ioCheckInputFile, ioCheckOutputFile); messages = new List <TerminalMessage>(); if (combinedIoCheck.CheckResult == CheckResult.Error) { messages = combinedIoCheck.Messages; return(CheckResult.Error); } return(CheckResult.Ok); }
public override string Run() { var matchedStr = MatchInspection.Match.Value; var extractedCommandParamAndVars = StrHelper.RemoveHtmlVarCommand(matchedStr); LinebreakToSingleWhiteSpace = IsLineBreakToSingleWhitespaceCommanded(extractedCommandParamAndVars, out extractedCommandParamAndVars); EscapeDoubleQuotes = IsEscapeDoubleQuotesCommanded(extractedCommandParamAndVars, out extractedCommandParamAndVars); EscapeSingleQuotes = IsEscapeSingleQuotesCommanded(extractedCommandParamAndVars, out extractedCommandParamAndVars); var fileToInclude = GetFilePathToInclude(extractedCommandParamAndVars); if (null == fileToInclude) { throw new JsMrgRunnerException($"Failed to extract file to load within JsMrgHtmlVarRunner."); } var iOCheck = new IoCheck(); var checkResult = iOCheck.CheckReadableAndAccessible(fileToInclude); if (CheckResult.Error == checkResult.CheckResult) { throw new JsMrgRunnerException($"{fileToInclude} commanded by {matchedStr} is not readable."); } List <string> varParams; VerifyVarCommands(extractedCommandParamAndVars, out varParams); var fileToIncludeContent = File.ReadAllText(fileToInclude); fileToIncludeContent = ApplyEscapings(fileToIncludeContent); fileToIncludeContent = OperateIncludeContentWithVarParams(fileToIncludeContent, varParams); fileToIncludeContent = ReduceToOneLine(fileToIncludeContent); FileContent = FileContent.Replace(matchedStr, fileToIncludeContent); return(FileContent); }