Example #1
0
        internal static bool IsDirectory(ref RawFindData findData)
        {
            FileAttributes attributes = findData.Attributes;

            return(attributes != (FileAttributes)(-1) &&
                   (attributes & FileAttributes.Directory) != 0);
        }
Example #2
0
        internal static FileSystemInfo AsFileSystemInfo(ref RawFindData findData)
        {
            string fileName = new string(findData.FileName);
            string fullPath = PathHelpers.CombineNoChecks(findData.Directory, fileName);

            return((findData.Attributes & FileAttributes.Directory) != 0
                ? (FileSystemInfo) new DirectoryInfo(fullPath, fileName, ref findData)
                : (FileSystemInfo) new FileInfo(fullPath, fileName, ref findData));
        }
            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));
            }
Example #4
0
 public unsafe bool Match(ref RawFindData record)
 {
     foreach (var filter in _filters)
     {
         if (!filter.Match(ref record))
         {
             return(false);
         }
     }
     return(true);
 }
 protected virtual void PopulateData(ref RawFindData findData)
 {
     _source        = Source.FindResult;
     Name           = findData.FileName.ToString();
     Path           = Paths.Combine(findData.Directory, Name);
     Attributes     = (System.IO.FileAttributes)findData.FileAttributes;
     CreationTime   = findData.CreationTimeUtc;
     LastAccessTime = findData.LastAccessTimeUtc;
     LastWriteTime  = findData.LastWriteTimeUtc;
     Exists         = true;
 }
 internal static IFileSystemInformation Create(ref RawFindData findData, IFileService fileService)
 {
     if ((findData.FileAttributes & FileAttributes.Directory) != 0)
     {
         return(DirectoryInformation.Create(ref findData, fileService));
     }
     else
     {
         return(FileInformation.Create(ref findData, fileService));
     }
 }
        new static internal IFileSystemInformation Create(ref RawFindData findData, IFileService fileService)
        {
            if ((findData.FileAttributes & FileAttributes.Directory) == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(findData));
            }

            var directoryInfo = new DirectoryInformation(fileService);

            directoryInfo.PopulateData(ref findData);
            return(directoryInfo);
        }
            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);
            }
Example #9
0
 public IFileSystemInformation TransformResult(ref RawFindData findData)
 {
     return(FileSystemInformation.Create(ref findData, _fileService));
 }
Example #10
0
        internal static DirectoryInfo AsDirectoryInfo(ref RawFindData findData)
        {
            string fileName = new string(findData.FileName);

            return(new DirectoryInfo(PathHelpers.CombineNoChecks(findData.Directory, fileName), fileName, ref findData));
        }
Example #11
0
        /// <summary>
        /// Returns the full path for find results, based off of the initially provided path.
        /// </summary>
        internal static string AsUserFullPath(ref RawFindData findData)
        {
            ReadOnlySpan <char> subdirectory = findData.Directory.AsReadOnlySpan().Slice(findData.OriginalDirectory.Length);

            return(PathHelpers.CombineNoChecks(findData.OriginalUserDirectory, subdirectory, findData.FileName));
        }
Example #12
0
 internal static bool NotDotOrDotDot(ref RawFindData findData) => !PathHelpers.IsDotOrDotDot(findData.FileName);
 public unsafe string TransformResult(ref RawFindData findData)
 {
     return(findData.FileName.CreateString());
 }
 public unsafe FindResult TransformResult(ref RawFindData findData) => new FindResult(ref findData);
Example #15
0
 public bool Match(ref RawFindData findData)
 {
     return((findData.FileAttributes & _excludeAttributes) == 0 &&
            !findData.FileName.SequenceEqual("..".AsSpan()) &&
            !findData.FileName.SequenceEqual(".".AsSpan()));
 }
Example #16
0
 public bool Match(ref RawFindData findData) => true;
 public static unsafe bool NotSpecialDirectory(ref RawFindData findData)
 {
     return(findData.FileName.Length > 2 ||
            findData.FileName[0] != '.' ||
            (findData.FileName.Length == 2 && findData.FileName[1] != '.'));
 }
 public unsafe bool Match(ref RawFindData findData) => NotSpecialDirectory(ref findData);