コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: ObjectsManager.cs プロジェクト: DroneDB/Registry
        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);
        }
コード例 #3
0
ファイル: DllStorage.cs プロジェクト: guerro323/GameHost
        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))));
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        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
        }
コード例 #6
0
        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)),
            });
コード例 #7
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
 public static void SimpleMatch(string expression, string name, bool ignoreCase, bool expected)
 {
     Assert.Equal(expected, FileSystemName.MatchesSimpleExpression(expression, name.AsSpan(), ignoreCase));
 }
コード例 #11
0
 public static bool MatchesPattern(string searchPattern, string name, bool ignoreCase)
 {
     return(FileSystemName.MatchesSimpleExpression(searchPattern.AsSpan(),
                                                   name.AsSpan(), ignoreCase));
 }
コード例 #12
0
 private bool IsMatchingNamespaceSelector(string comparator)
 => string.IsNullOrWhiteSpace(NamespaceSelector) ||
 FileSystemName.MatchesSimpleExpression(NamespaceSelector, comparator ?? string.Empty, true);
コード例 #13
0
 public IEnumerable <FileEntry> EnumerateFiles(string searchFilter = "*")
 {
     return(_entries.Where(file => FileSystemName.MatchesSimpleExpression(searchFilter, file.Name)));
 }
コード例 #14
0
 /// <inheritdoc />
 public bool MatchesSimpleExpression(ReadOnlySpan <char> expression, ReadOnlySpan <char> name, bool ignoreCase = true)
 {
     return(FileSystemName.MatchesSimpleExpression(expression, name, ignoreCase));
 }
コード例 #15
0
        /// <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);
        }
コード例 #16
0
 protected internal override bool Matches(string?input, string?pattern)
 => FileSystemName.MatchesSimpleExpression(pattern, input);