mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 06:36:31 +00:00
57 lines
1.3 KiB
C#
57 lines
1.3 KiB
C#
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);
|
|
}
|
|
}
|
|
|