/// <summary> /// Sees if the name given matches the name filter we have. /// </summary> private bool MatchPattern(ReadOnlySpan <char> relativePath) { ReadOnlySpan <char> name = IO.Path.GetFileName(relativePath); if (name.Length == 0) { return(false); } string[] filters = _filters.GetFilters(); if (filters.Length == 0) { return(true); } foreach (string filter in filters) { if (FileSystemName.MatchesSimpleExpression(filter, name, ignoreCase: !PathInternal.IsCaseSensitive)) { return(true); } } return(false); }
public async Task <IEnumerable <EntryDto> > Search(string orgSlug, string dsSlug, string query = null, string path = null, bool recursive = true, EntryType?type = null) { var ds = await _utils.GetDataset(orgSlug, dsSlug); _logger.LogInformation("In Search('{OrgSlug}/{DsSlug}')", orgSlug, dsSlug); var ddb = _ddbManager.Get(orgSlug, ds.InternalRef); _logger.LogInformation("Searching in '{Path}' -> {Query} ({Recursive}", path, query, recursive ? 'r' : 'n'); var entities = await ddb.SearchAsync(path, recursive); if (type != null) { entities = entities.Where(item => item.Type == type); } var files = (from entry in entities let name = Path.GetFileName(entry.Path) where FileSystemName.MatchesSimpleExpression(query, name) select entry.ToDto()).ToArray(); _logger.LogInformation("Found {FilesCount} objects", files.Length); return(files); }
public Task <IEnumerable <IFile> > GetFilesAsync(string pattern) { pattern = pattern.Replace('\\', '/'); return(Task.FromResult(Assembly.GetManifestResourceNames() .Select(mrn => (IFile) new DllEmbeddedFile(Assembly, mrn)) .Where(file => FileSystemName.MatchesSimpleExpression(CurrentPath + "/" + pattern, file.FullName)))); }
/// <devdoc> /// Sees if the name given matches the name filter we have. /// </devdoc> /// <internalonly/> private bool MatchPattern(string relativePath) { ReadOnlySpan <char> name = IO.Path.GetFileName(relativePath.AsSpan()); return(name.Length > 0 ? FileSystemName.MatchesSimpleExpression(_filter, name, ignoreCase: !PathInternal.IsCaseSensitive) : false); }
public static bool MatchesPattern(string searchPattern, string name, bool ignoreCase) { #if HAS_FILE_SYSTEM_NAME return(FileSystemName.MatchesSimpleExpression(searchPattern.AsSpan(), name.AsSpan(), ignoreCase)); #else return(Compatibility.FileSystemName.MatchesSimpleExpression(searchPattern.AsSpan(), name.AsSpan(), ignoreCase)); #endif }
private static bool MatchesPattern(string expression, ReadOnlySpan <char> name, EnumerationOptions options) { bool ignoreCase = (options.MatchCasing == MatchCasing.PlatformDefault && !PathInternal.IsCaseSensitive) || options.MatchCasing == MatchCasing.CaseInsensitive; return(options.MatchType switch { MatchType.Simple => FileSystemName.MatchesSimpleExpression(expression.AsSpan(), name, ignoreCase), MatchType.Win32 => FileSystemName.MatchesWin32Expression(expression.AsSpan(), name, ignoreCase), _ => throw new ArgumentOutOfRangeException(nameof(options)), });
protected internal virtual bool ShouldIncludeEntry(ref FileSystemEntry entry) { if (entry.IsDirectory) { return(false); } bool ignoreCase = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX); if (FileSystemName.MatchesSimpleExpression(Filter, entry.FileName, ignoreCase: ignoreCase)) { return(true); } return(false); }
protected override bool ShouldIncludeEntry(ref FileSystemEntry entry) { //if(currentDirectory == null) // currentDirectory = entry.Directory.ToString(); if (entry.IsDirectory) { return(false); } if (FileSystemName.MatchesSimpleExpression(filter, entry.FileName, ignoreCase: ignoreCase)) { return(true); } return(false); }
internal bool IsWatched(ref FileSystemEntry entry) { if (entry.IsDirectory) { return(false); } if (Filter == null) { return(true); } bool ignoreCase = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX); if (FileSystemName.MatchesSimpleExpression(Filter, entry.FileName, ignoreCase: ignoreCase)) { return(true); } return(false); }
public static void SimpleMatch(string expression, string name, bool ignoreCase, bool expected) { Assert.Equal(expected, FileSystemName.MatchesSimpleExpression(expression, name.AsSpan(), ignoreCase)); }
public static bool MatchesPattern(string searchPattern, string name, bool ignoreCase) { return(FileSystemName.MatchesSimpleExpression(searchPattern.AsSpan(), name.AsSpan(), ignoreCase)); }
private bool IsMatchingNamespaceSelector(string comparator) => string.IsNullOrWhiteSpace(NamespaceSelector) || FileSystemName.MatchesSimpleExpression(NamespaceSelector, comparator ?? string.Empty, true);
public IEnumerable <FileEntry> EnumerateFiles(string searchFilter = "*") { return(_entries.Where(file => FileSystemName.MatchesSimpleExpression(searchFilter, file.Name))); }
/// <inheritdoc /> public bool MatchesSimpleExpression(ReadOnlySpan <char> expression, ReadOnlySpan <char> name, bool ignoreCase = true) { return(FileSystemName.MatchesSimpleExpression(expression, name, ignoreCase)); }
/// <inheritdoc /> public FileSystemEnumerable <(string Path, long Length)> EnumerateFiles() { var options = new EnumerationOptions() { RecurseSubdirectories = this.recurse, AttributesToSkip = 0, }; FileSystemEnumerable <(string Path, long Length)> files; if (this.excludeDir == null) { files = new FileSystemEnumerable <(string Path, long Length)>(this.SearchPath, (ref FileSystemEntry entry) => (entry.ToFullPath(), entry.Length), options) { ShouldIncludePredicate = (ref FileSystemEntry entry) => !entry.IsDirectory && FileSystemName.MatchesSimpleExpression(this.searchFile, entry.FileName), }; } else { files = new FileSystemEnumerable <(string Path, long Length)>(this.SearchPath, (ref FileSystemEntry entry) => (entry.ToFullPath(), entry.Length), options) { ShouldIncludePredicate = (ref FileSystemEntry entry) => !entry.IsDirectory && FileSystemName.MatchesSimpleExpression(this.searchFile, entry.FileName) && !this.excludeDir.IsMatch(entry.Directory.ToString()), }; } return(files); }
protected internal override bool Matches(string?input, string?pattern) => FileSystemName.MatchesSimpleExpression(pattern, input);