public unsafe bool Match(ref RawFindData findData)
            {
                if (_filter == null)
                {
                    return(true);
                }

                // RtlIsNameInExpression is the native API DosMatcher is replicating.
                return(DosMatcher.MatchPattern(_filter, findData.FileName, _ignoreCase));
            }
Exemple #2
0
 public FindResult(ref RawFindData findData)
 {
     Directory     = findData.Directory;
     FileName      = findData.FileName.CreateString();
     Attributes    = findData.FileAttributes;
     CreationUtc   = findData.CreationTimeUtc;
     LastAccessUtc = findData.LastAccessTimeUtc;
     LastWriteUtc  = findData.LastWriteTimeUtc;
     Length        = (uint)findData.FileSize;
 }
Exemple #3
0
 public unsafe bool Match(ref RawFindData record)
 {
     foreach (var filter in _filters)
     {
         if (!filter.Match(ref record))
         {
             return(false);
         }
     }
     return(true);
 }
Exemple #4
0
            public unsafe string TransformResult(ref RawFindData findData)
            {
                int    totalLength = findData.FileName.Length + findData.Directory.Length + 1;
                string fullPath    = new string('\0', totalLength);

                fixed(char *f = fullPath)
                {
                    Span <char>         pathSpan      = new Span <char>(f, totalLength);
                    ReadOnlySpan <char> directorySpan = findData.Directory.AsSpan();

                    directorySpan.CopyTo(pathSpan);
                    pathSpan[directorySpan.Length] = Paths.DirectorySeparator;
                    findData.FileName.CopyTo(pathSpan.Slice(directorySpan.Length + 1));
                }

                return(fullPath);
            }
Exemple #5
0
            public bool MoveNext()
            {
                if (_lastEntryFound)
                {
                    return(false);
                }

                RawFindData data = default;

                do
                {
                    FindNextFile();
                    if (!_lastEntryFound && _info != null)
                    {
                        data = new RawFindData(_info, _path);

                        if (_pending != null && (data.FileAttributes & FileAttributes.Directory) != 0 &&
                            FindFilters.NormalDirectory.NotSpecialDirectory(ref data))
                        {
                            // Stash directory to recurse into
                            string fileName     = data.FileName.CreateString();
                            string subDirectory = string.Concat(_path, "\\", fileName);
                            _pending.Enqueue(ValueTuple.Create(
                                                 CreateDirectoryHandle(fileName, subDirectory),
                                                 subDirectory));
                        }
                    }
                } while (!_lastEntryFound && !_findOperation._filter.Match(ref data));

                if (!_lastEntryFound)
                {
                    _current = _findOperation._transform.TransformResult(ref data);
                    return(true);
                }

                return(false);
            }
 public unsafe FindResult TransformResult(ref RawFindData findData) => new FindResult(ref findData);
Exemple #7
0
 public bool Match(ref RawFindData findData) => true;
Exemple #8
0
 public static unsafe bool NotSpecialDirectory(ref RawFindData findData)
 {
     return(findData.FileName.Length > 2 ||
            findData.FileName[0] != '.' ||
            (findData.FileName.Length == 2 && findData.FileName[1] != '.'));
 }
Exemple #9
0
 public unsafe bool Match(ref RawFindData findData) => NotSpecialDirectory(ref findData);
Exemple #10
0
 public unsafe string TransformResult(ref RawFindData findData)
 {
     return(findData.FileName.CreateString());
 }