ITextFileStore.cs 644 B

1234567891011121314151617181920212223242526
  1. namespace RackPeek.Domain.Persistence.Yaml;
  2. public interface ITextFileStore
  3. {
  4. Task<bool> ExistsAsync(string path);
  5. Task<string> ReadAllTextAsync(string path);
  6. Task WriteAllTextAsync(string path, string contents);
  7. }
  8. public sealed class PhysicalTextFileStore : ITextFileStore
  9. {
  10. public Task<bool> ExistsAsync(string path)
  11. {
  12. return Task.FromResult(File.Exists(path));
  13. }
  14. public Task<string> ReadAllTextAsync(string path)
  15. {
  16. return File.ReadAllTextAsync(path);
  17. }
  18. public Task WriteAllTextAsync(string path, string contents)
  19. {
  20. return File.WriteAllTextAsync(path, contents);
  21. }
  22. }