This repository was archived by the owner on Nov 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathNotFoundFileInfo.cs
61 lines (52 loc) · 1.71 KB
/
NotFoundFileInfo.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
namespace Microsoft.Extensions.FileProviders
{
/// <summary>
/// Represents a non-existing file.
/// </summary>
public class NotFoundFileInfo : IFileInfo
{
/// <summary>
/// Initializes an instance of <see cref="NotFoundFileInfo"/>.
/// </summary>
/// <param name="name">The name of the file that could not be found</param>
public NotFoundFileInfo(string name)
{
Name = name;
}
/// <summary>
/// Always false.
/// </summary>
public bool Exists => false;
/// <summary>
/// Always false.
/// </summary>
public bool IsDirectory => false;
/// <summary>
/// Returns <see cref="DateTimeOffset.MinValue"/>.
/// </summary>
public DateTimeOffset LastModified => DateTimeOffset.MinValue;
/// <summary>
/// Always equals -1.
/// </summary>
public long Length => -1;
/// <inheritdoc />
public string Name { get; }
/// <summary>
/// Always null.
/// </summary>
public string PhysicalPath => null;
/// <summary>
/// Always throws. A stream cannot be created for non-existing file.
/// </summary>
/// <exception cref="FileNotFoundException">Always thrown.</exception>
/// <returns>Does not return</returns>
public Stream CreateReadStream()
{
throw new FileNotFoundException($"The file {Name} does not exist.");
}
}
}