This commit is contained in:
shump
2026-01-15 11:11:42 -06:00
commit 7562a4ce14
67 changed files with 5636 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using System.IO;
using System.Threading.Tasks;
namespace MarkdownEditor.Services;
/// <summary>
/// Default implementation of <see cref="IFileService"/> using System.IO.
/// Provides file system operations for reading and writing markdown files.
/// </summary>
public class FileService : IFileService
{
/// <inheritdoc/>
public async Task<string> ReadFileAsync(string path)
{
if (string.IsNullOrWhiteSpace(path))
{
throw new System.ArgumentException("File path cannot be null or empty.", nameof(path));
}
return await File.ReadAllTextAsync(path);
}
/// <inheritdoc/>
public async Task WriteFileAsync(string path, string content)
{
if (string.IsNullOrWhiteSpace(path))
{
throw new System.ArgumentException("File path cannot be null or empty.", nameof(path));
}
await File.WriteAllTextAsync(path, content ?? string.Empty);
}
/// <inheritdoc/>
public bool FileExists(string path)
{
return !string.IsNullOrWhiteSpace(path) && File.Exists(path);
}
/// <inheritdoc/>
public string GetFileName(string path)
{
if (string.IsNullOrWhiteSpace(path))
{
return string.Empty;
}
return Path.GetFileName(path);
}
}