/
PhysicalDirectoryContents.cs
46 lines (39 loc) · 1.63 KB
/
PhysicalDirectoryContents.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.FileProviders.Physical;
namespace Microsoft.Extensions.FileProviders.Internal
{
/// <summary>
/// Represents the contents of a physical file directory
/// </summary>
public class PhysicalDirectoryContents : IDirectoryContents
{
private readonly PhysicalDirectoryInfo _info;
/// <summary>
/// Initializes an instance of <see cref="PhysicalDirectoryContents"/>
/// </summary>
/// <param name="directory">The directory</param>
public PhysicalDirectoryContents(string directory)
: this(directory, ExclusionFilters.Sensitive)
{ }
/// <summary>
/// Initializes an instance of <see cref="PhysicalDirectoryContents"/>
/// </summary>
/// <param name="directory">The directory</param>
/// <param name="filters">Specifies which files or directories are excluded from enumeration.</param>
public PhysicalDirectoryContents(string directory, ExclusionFilters filters)
{
ThrowHelper.ThrowIfNull(directory);
_info = new PhysicalDirectoryInfo(new DirectoryInfo(directory), filters);
}
/// <inheritdoc/>
public bool Exists => _info.Exists;
/// <inheritdoc/>
public IEnumerator<IFileInfo> GetEnumerator() => _info.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => _info.GetEnumerator();
}
}