using System.Threading.Tasks;

namespace MarkdownEditor.Services;

/// <summary>
/// Interface for file system operations.
/// Abstracts file I/O to improve testability and separation of concerns.
/// </summary>
public interface IFileService
{
    /// <summary>
    /// Reads the entire contents of a file as text.
    /// </summary>
    /// <param name="path">The file path to read from.</param>
    /// <returns>The file contents as a string.</returns>
    /// <exception cref="System.IO.IOException">Thrown when the file cannot be read.</exception>
    Task<string> ReadFileAsync(string path);

    /// <summary>
    /// Writes text content to a file, creating or overwriting as necessary.
    /// </summary>
    /// <param name="path">The file path to write to.</param>
    /// <param name="content">The text content to write.</param>
    /// <exception cref="System.IO.IOException">Thrown when the file cannot be written.</exception>
    Task WriteFileAsync(string path, string content);

    /// <summary>
    /// Checks if a file exists at the specified path.
    /// </summary>
    /// <param name="path">The file path to check.</param>
    /// <returns>True if the file exists, false otherwise.</returns>
    bool FileExists(string path);

    /// <summary>
    /// Gets the file name from a full path.
    /// </summary>
    /// <param name="path">The full file path.</param>
    /// <returns>The file name without directory information.</returns>
    string GetFileName(string path);
}

