public List <string> GetPossibleConfigVarsFilepaths() { if (!string.IsNullOrEmpty(_configurationService.CustomProfileVarsFileSearchLocation)) { var customProfilePath = _environmentWrapper.ExpandEnvironmentVariables(_configurationService.CustomProfileVarsFileSearchLocation); if (_fileWrapper.Exists(customProfilePath)) { var attributes = _fileWrapper.GetAttributes(customProfilePath); if (!attributes.HasFlag(FileAttributes.Directory)) { return(new List <string> { customProfilePath }); } var files = _directoryWrapper.GetFiles(customProfilePath); return(files.Where(x => x.EndsWith(".vars.Arma3Profile")).ToList()); } } var possibleConfigVarsPaths = new List <string>(); var defaultProfilePath = _environmentWrapper.ExpandEnvironmentVariables(_configurationService.DefaultProfileVarsFileSearchLocation); var defaultPathFiles = _directoryWrapper.GetFiles(defaultProfilePath).Where(x => x.EndsWith(".vars.Arma3Profile")).ToList(); possibleConfigVarsPaths.AddRange(defaultPathFiles); var otherProfilePath = _environmentWrapper.ExpandEnvironmentVariables(_configurationService.OtherProfilesVarsFileSearchLocation); var otherProfileDirectories = _directoryWrapper.GetDirectories(otherProfilePath).ToList(); otherProfileDirectories.ForEach( directory => possibleConfigVarsPaths.AddRange( _directoryWrapper.GetFiles(directory) .Where(x => x.EndsWith(".vars.Arma3Profile")).ToList())); return(possibleConfigVarsPaths); }
public ProviderXmlData[] LoadAll() { var absolutePath = pathUtility.GetAbsolutePath(dataDirectory); if (!directory.Exists(absolutePath)) { return(new ProviderXmlData[0]); } var dataFiles = directory.GetFiles(absolutePath, "*.xml", SearchOption.AllDirectories); var documents = dataFiles .Select(Create) .Where(f => f != null) .ToArray(); return(documents); }
public IEnumerable <string> FindTrxFiles(string buildRootDirectory, bool shouldLog = true) { Debug.Assert(!string.IsNullOrEmpty(buildRootDirectory)); Debug.Assert(directoryWrapper.Exists(buildRootDirectory), "The specified build root directory should exist: " + buildRootDirectory); if (shouldLog) { this.logger.LogInfo(Resources.TRX_DIAG_LocatingTrx); } var testDirectories = directoryWrapper.GetDirectories(buildRootDirectory, TestResultsFolderName, SearchOption.AllDirectories); if (testDirectories == null || !testDirectories.Any()) { if (shouldLog) { this.logger.LogInfo(Resources.TRX_DIAG_TestResultsDirectoryNotFound, buildRootDirectory); } return(Enumerable.Empty <string>()); } if (shouldLog) { this.logger.LogInfo(Resources.TRX_DIAG_FolderPaths, string.Join(", ", testDirectories)); } var trxFiles = testDirectories.SelectMany(dir => directoryWrapper.GetFiles(dir, "*.trx")).ToArray(); if (shouldLog) { if (trxFiles.Length == 0) { this.logger.LogInfo(Resources.TRX_DIAG_NoTestResultsFound); } else { this.logger.LogInfo(Resources.TRX_DIAG_TrxFilesFound, string.Join(", ", trxFiles)); } } return(trxFiles); }
internal IEnumerable <string> GetFiles(string path, string searchPattern) { try { return(DirectoryWrapper.GetFiles(path, searchPattern)); } catch (DirectoryNotFoundException) { throw new XamarinSecurityScannerException("Incorrect scan path. Directory not found."); } catch (PathTooLongException) { throw new XamarinSecurityScannerException("Scan path is too long."); } catch (IOException) { throw new XamarinSecurityScannerException("Scan path must be a folder."); } }
private void ProcessAssemblyFromDirectoryAttribute(ScriptAnalyzerResult analyzerResult, string line) { var parameters = GetMultipleParametersFromAttribute(line); bool includeSubDirectories = false; if (parameters.Length > 1) { includeSubDirectories = bool.Parse(parameters[1]); } var directory = Path.GetFullPath(parameters[0].Replace("\"", string.Empty)); var assemblies = _directory.GetFiles(directory, "*.dll", includeSubDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly); foreach (var assembly in assemblies) { ProcessAssembly(analyzerResult, assembly); } }
public List <string> GetPostCodeLines(string path) { var postalCodeLines = new List <string>(); var files = _directory.GetFiles(path); foreach (var file in files) { var lines = _fileIo.ReadAllLines(file).ToList(); foreach (var line in lines) { var words = line.Split(' '); for (var i = 0; i < words.Length; i++) { var postCodeDigit = new string(words[i].Where(char.IsDigit).ToArray()); if (postCodeDigit.Length == 4 && i != words.Length) { var postCodeAlphabets = new string(words[i + 1].Where(char.IsLetter).ToArray()); if (postCodeAlphabets.Length == 2) { var postalCode = $"{postCodeDigit}{postCodeAlphabets}"; // Validate Postal code var isValidPostalCode = _postCodeValidationService.Validate(postalCode); if (isValidPostalCode) { postalCodeLines.Add(line); break; } } } } } } return(postalCodeLines); }