using JetBrains.Annotations; using System.Collections.Generic; namespace WireMock.Handlers { /// /// Handler to interact with the file system to handle folders and read and write (static mapping) files. /// public interface IFileSystemHandler { /// /// Gets the folder where the static mappings are located. For local file system, this would be `{CurrentFolder}/__admin/mappings`. /// /// The folder name. string GetMappingFolder(); /// /// Determines whether the given path refers to an existing directory on disk. /// /// The path. /// true if path refers to an existing directory; false if the directory does not exist or an error occurs when trying to determine if the specified directory exists. bool FolderExists([NotNull] string path); /// /// Creates all directories and subdirectories in the specified path unless they already exist. /// /// The path. void CreateFolder([NotNull] string path); /// /// Returns an enumerable collection of file names in a specified path. /// /// The path. /// A value indicating whether subdirectories should also included when enumerating files. /// An enumerable collection of the full names (including paths) for the files in the directory (and optionally subdirectories) specified by path. IEnumerable EnumerateFiles([NotNull] string path, bool includeSubdirectories); /// /// Read a static mapping file as text. /// /// The path (folder + filename with .json extension). /// The file content as text. string ReadMappingFile([NotNull] string path); /// /// Write the static mapping file. /// /// The path (folder + filename with .json extension). /// The text. void WriteMappingFile([NotNull] string path, [NotNull] string text); /// /// Read a response body file as byte[]. /// /// The path or filename from the file to read. /// The file content as bytes. byte[] ReadResponseBodyAsFile([NotNull] string path); /// /// Read a response body file as text. /// /// The path or filename from the file to read. /// The file content as text. string ReadResponseBodyAsString([NotNull] string path); /// /// Delete a file. /// /// The filename. void DeleteFile([NotNull] string filename); /// /// Determines whether the given path refers to an existing file on disk. /// /// The filename. /// true if path refers to an existing file; false if the file does not exist. bool FileExists([NotNull] string filename); /// /// Write a file. /// /// The filename. /// The bytes. void WriteFile([NotNull] string filename, [NotNull] byte[] bytes); /// /// Write a file. /// /// The folder. /// The filename. /// The bytes. void WriteFile([NotNull] string folder, [NotNull] string filename, [NotNull] byte[] bytes); /// /// Read a file as bytes. /// /// The filename. /// The file content as bytes. byte[] ReadFile([NotNull] string filename); /// /// Read a file as string. /// /// The filename. /// The file content as a string. string ReadFileAsString([NotNull] string filename); /// /// Gets the folder where the unmatched requests should be stored. For local file system, this would be `{CurrentFolder}/requests/unmatched`. /// /// The folder name. string GetUnmatchedRequestsFolder(); /// /// Write a unmatched request to the Unmatched RequestsFolder. /// /// The filename. /// The text. void WriteUnmatchedRequest([NotNull] string filename, [NotNull] string text); } }