mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:06:30 +00:00
big refactoring. get rid of static properties and coupled architecture. prepare system for integration tests
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Azaion.Common.Services;
|
||||
|
||||
public class PhysicalFileSystem : IFileSystem
|
||||
{
|
||||
public Task<byte[]> ReadAllBytesAsync(string path, CancellationToken ct = default)
|
||||
{
|
||||
return File.ReadAllBytesAsync(path, ct);
|
||||
}
|
||||
|
||||
public Task WriteAllBytesAsync(string path, byte[] content, CancellationToken ct = default)
|
||||
{
|
||||
return File.WriteAllBytesAsync(path, content, ct);
|
||||
}
|
||||
|
||||
public bool FileExists(string path)
|
||||
{
|
||||
return File.Exists(path);
|
||||
}
|
||||
|
||||
public void DeleteFile(string path)
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetFiles(string directory, string searchPattern)
|
||||
{
|
||||
return Directory.GetFiles(directory, searchPattern);
|
||||
}
|
||||
|
||||
public IEnumerable<FileInfo> GetFileInfos(string directory, string[] searchPatterns)
|
||||
{
|
||||
var dir = new DirectoryInfo(directory);
|
||||
if (!dir.Exists)
|
||||
return Enumerable.Empty<FileInfo>();
|
||||
|
||||
return searchPatterns.SelectMany(pattern => dir.GetFiles(pattern));
|
||||
}
|
||||
|
||||
public DirectoryInfo GetDirectoryInfo(string path)
|
||||
{
|
||||
return new DirectoryInfo(path);
|
||||
}
|
||||
|
||||
public bool DirectoryExists(string path)
|
||||
{
|
||||
return Directory.Exists(path);
|
||||
}
|
||||
|
||||
public void CreateDirectory(string path)
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user