-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathFileSupport.cs
More file actions
38 lines (32 loc) · 891 Bytes
/
FileSupport.cs
File metadata and controls
38 lines (32 loc) · 891 Bytes
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
namespace System.IO.Abstractions.Benchmarks.Support;
public class FileSupport
{
private readonly IFileSystem _fileSystem;
public FileSupport(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
}
public FileSupport() : this(new FileSystem())
{
// Default implementation for FileSystem
}
private static string GetRandomTempFile()
{
return Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
}
public bool IsFile(string path)
{
return _fileSystem.File.Exists(path);
}
/// <summary>
/// Checks and deletes given file if it does exists.
/// </summary>
/// <param name="filePath">Path of the file</param>
public void DeleteIfExists(string filePath)
{
if (_fileSystem.File.Exists(filePath))
{
_fileSystem.File.Delete(filePath);
}
}
}