mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[Chore] System.IO.Abstractions update (#21061)
* System.IO.Abstractions update * fix tests
This commit is contained in:
committed by
GitHub
parent
1c264e0899
commit
887da6dc1a
@@ -4,6 +4,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.Linq;
|
||||
using Microsoft.Plugin.Folder.Sources;
|
||||
@@ -31,7 +32,7 @@ namespace Microsoft.Plugin.Folder.UnitTests
|
||||
{ @"c:\Test\b\", new MockDirectoryData() },
|
||||
});
|
||||
|
||||
_queryFileSystemInfoMock = new QueryFileSystemInfo(_fileSystem.DirectoryInfo);
|
||||
_queryFileSystemInfoMock = new QueryFileSystemInfo(_fileSystem.DirectoryInfo, MatchType.Simple, FileAttributes.Hidden | FileAttributes.System);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="12.2.3" />
|
||||
<PackageReference Include="System.IO.Abstractions.TestingHelpers" Version="17.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="12.2.5" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="17.2.3" />
|
||||
<PackageReference Include="System.Runtime" Version="4.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
@@ -12,23 +12,27 @@ namespace Microsoft.Plugin.Folder.Sources
|
||||
public class QueryFileSystemInfo : IQueryFileSystemInfo
|
||||
{
|
||||
private readonly IDirectoryInfoFactory _directoryInfoFactory;
|
||||
private readonly MatchType _matchType;
|
||||
private readonly FileAttributes _attributesToSkip;
|
||||
|
||||
public QueryFileSystemInfo(IDirectoryInfoFactory directoryInfoFactory)
|
||||
public QueryFileSystemInfo(IDirectoryInfoFactory directoryInfoFactory, MatchType matchType = MatchType.Win32, FileAttributes attributesToSkip = FileAttributes.Hidden)
|
||||
{
|
||||
_directoryInfoFactory = directoryInfoFactory;
|
||||
_matchType = matchType;
|
||||
_attributesToSkip = attributesToSkip;
|
||||
}
|
||||
|
||||
public IEnumerable<DisplayFileInfo> MatchFileSystemInfo(string search, string incompleteName, bool isRecursive)
|
||||
{
|
||||
// search folder and add results
|
||||
var directoryInfo = _directoryInfoFactory.FromDirectoryName(search);
|
||||
var fileSystemInfos = directoryInfo.EnumerateFileSystemInfos(incompleteName, new EnumerationOptions()
|
||||
var fileSystemInfos = directoryInfo.EnumerateFileSystemInfos(incompleteName, new EnumerationOptions
|
||||
{
|
||||
MatchType = MatchType.Win32,
|
||||
MatchType = _matchType,
|
||||
RecurseSubdirectories = isRecursive,
|
||||
IgnoreInaccessible = true,
|
||||
ReturnSpecialDirectories = false,
|
||||
AttributesToSkip = FileAttributes.Hidden,
|
||||
AttributesToSkip = _attributesToSkip,
|
||||
MatchCasing = MatchCasing.PlatformDefault,
|
||||
});
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" />
|
||||
<PackageReference Include="NLog.Schema" Version="5.0.4" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="12.2.5" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="17.2.3" />
|
||||
<PackageReference Include="System.Runtime" Version="4.3.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user