Exemplo n.º 1
0
        public string ExtractLogFile(string cffFilename, string line, Validations validations)
        {
            string EXPECTED_LOGFILE_FORMAT = $"\"[name].{LOGFILE_EXTENSION}\"";

            // Check whether the line starts opening/closing LOGFILE section
            // If yes, mark it exist
            LogFileSection.MarkSection(line, Int16.Parse(validations.LineNumber));

            bool openingSectionVisited = LogFileSection.ValidSectionPair[0];

            // Check the line start with the expected keyword, "DEFAULT"
            if (openingSectionVisited && line.StartsWith(CffKeywords.DEFAULT_LOGFILE))
            {
                // Check whether the pair key-value exists
                string[] lineData = validations.CheckPairKeyValue(
                    line,
                    CffKeywords.DEFAULT_LOGFILE,
                    EXPECTED_LOGFILE_FORMAT);

                if (lineData != null)
                {
                    LogFile = validations.CheckTextValueExist(
                        lineData[1],
                        LogFile,
                        EXPECTED_LOGFILE_FORMAT);
                }
            }

            // Check whether the value in the above pair has the valid extension (.text),
            // and check the filename has no invalia file character
            bool logfileExtensionValid = LogFile != null &&
                                         validations.CheckExtension(LogFile, LOGFILE_EXTENSION);
            bool noInvalidFilenameChars = logfileExtensionValid &&
                                          validations.CheckInvalidFileNameChars(LogFile);

            return(LogFile);
        }