using System;
using System.IO;
using System.Text;
using System.Xml;
namespace Wayne.Lib.IO
{
///
/// File system abstraction. Should be used instead of System.IO namespace, so we can
/// mock the file system away in unit tests.
///
public interface IFileSupport
{
///
/// Opens a file.
///
///
///
///
///
///
///
///
[System.Diagnostics.DebuggerStepThrough]
Stream Open(string fileName, FileMode fileMode, FileAccess fileAccess, FileShare fileShare, int retries, int delayBetweenRetries);
///
/// Opens a file, using standard values for retries (100) and delayBetweenRetries(100)
///
///
///
///
///
///
Stream Open(string fileName, FileMode fileMode, FileAccess fileAccess, FileShare fileShare);
///
/// Moves a file.
///
///
///
///
///
[System.Diagnostics.DebuggerStepThrough]
void Move(string sourceFileName, string destinationFileName, int retries, int delayBetweenRetries);
///
/// Moves a file, using standard values for retries (100) and delayBetweenRetries(100)
///
///
///
[System.Diagnostics.DebuggerStepThrough]
void Move(string sourceFileName, string destinationFileName);
///
/// Moves a directory.
///
///
///
///
///
[System.Diagnostics.DebuggerStepThrough]
void MoveDirectory(string sourceDirName, string destDirName, int retries, int delayBetweenRetries);
///
/// Moves a directory, using standard values for retries (100) and delayBetweenRetries(100)
///
///
///
[System.Diagnostics.DebuggerStepThrough]
void MoveDirectory(string sourceDirName, string destDirName);
///
/// Deletes a file
///
///
///
///
[System.Diagnostics.DebuggerStepThrough]
void Delete(string fileName, int retries, int delayBetweenRetries);
///
/// Deletes a file, using standard values for retries (100) and delayBetweenRetries(100)
///
///
[System.Diagnostics.DebuggerStepThrough]
void Delete(string fileName);
///
/// Get- and set property for the SecureDelete support object. Needed to create backend to the secure delete function.
///
ISecureDeleteSupport SecureDeleteSupport { get; set; }
///
/// Gets or sets tha File support extension that can be different depending on the execution platform (WinCE or Win32)
///
IFileSupportExtension FileSupportExtension { get; set; }
///
/// Paths implementation ref.
///
IPaths Paths { get;}
///
/// Deletes a file securely.
///
///
///
///
///
void SecureDelete(string fileName, out bool sDeleteOK, int retries, int delayBetweenRetries);
///
/// Deletes a file securely.
///
///
///
void SecureDelete(string fileName, out bool sDeleteOK);
///
/// Copy a file.
///
///
///
///
void Copy(string sourceFileName, string destinationFileName, bool overwrite);
///
/// Copies a file.
///
///
///
///
///
///
[System.Diagnostics.DebuggerStepThrough]
void Copy(string sourceFileName, string destinationFileName, bool overwrite, int retries, int delayBetweenRetries);
///
/// Read the lines of a text file into a string.
///
/// The path and file name.
string LoadToString(string fileName);
///
/// Read the lines of a text file into a string.
///
/// The path and file name.
/// The encoding.
string LoadToString(string fileName, System.Text.Encoding encoding);
///
/// Read the lines of a text file into an array of strings.
///
/// The path and file name.
string[] LoadToStringArray(string fileName);
///
/// Read the lines of a text file into an array of strings.
///
/// The path and file name.
/// The encoding.
string[] LoadToStringArray(string fileName, System.Text.Encoding encoding);
///
/// Saves a text string to a file.
///
/// The path and file name.
/// The text to save.
void SaveToFile(string fileName, string text);
///
/// Saves a text string to a file.
///
/// The path and file name.
/// The lines to save.
void SaveToFile(string fileName, string[] lines);
///
/// Saves a text string to a file.
///
/// The path and file name.
/// The text to save.
/// The encoding.
void SaveToFile(string fileName, string text, System.Text.Encoding encoding);
///
/// Saves a text string to a file.
///
/// The path and file name.
/// The lines to save.
/// The encoding.
void SaveToFile(string fileName, string[] lines, System.Text.Encoding encoding);
///
/// Loads the specified XML file into the XmlDocument.
///
/// The XmlDocument to load.
/// The path and file name.
void LoadXml(XmlDocument xmlDocument, string fileName);
///
/// Loads the specified XML file into the XmlDocument.
///
/// The XmlDocument to load.
/// The path and file name.
/// The encoding.
void LoadXml(XmlDocument xmlDocument, string fileName, System.Text.Encoding encoding);
///
/// Get creation time on a file.
///
///
DateTime GetCreationTime(string fileName);
///
/// Set creation time on a file.
///
///
///
void SetCreationTime(string fileName, DateTime dateTime);
///
/// Get last access time on a file.
///
///
DateTime GetLastAccessTime(string fileName);
///
/// Set last access time on a file.
///
///
///
void SetLastAccessTime(string fileName, DateTime dateTime);
///
/// Get last write time on the file.
///
///
DateTime GetLastWriteTime(string fileName);
///
/// Set last write time on the file.
///
///
///
void SetLastWriteTime(string fileName, DateTime dateTime);
///
/// Checks if the specified file exists.
///
///
///
bool FileExists(string fileName);
///
/// Checks if directory exists
///
///
///
bool DirectoryExists(string path);
///
/// Ensures the directory exists by trying to create it if it does not exist already.
///
///
///
bool EnsureDirectoryExists(string path);
///
/// Creates the specified directories if they do not exist.
///
///
[Obsolete("Use EnsureDirectoryExists() instead.")]
void EnsureDirectoriesExists(string directoryName);
///
/// Removes a directory.
///
///
///
///
bool RemoveDirectory(string path, bool onlyIfEmpty);
///
/// Copies a directory structure.
///
///
///
///
void CopyDirectory(string sourceDir, string destinationDir, bool recursive);
///
/// Returns the names of files in the specified directory that match the specified search pattern.
///
/// The directory to search.
/// The search string to match against the names of files in path. The parameter cannot end in two periods ("..") or contain two periods ("..") followed by System.IO.Path.DirectorySeparatorChar or System.IO.Path.AltDirectorySeparatorChar, nor can it contain any of the characters in System.IO.Path.InvalidPathChars.
///
string[] GetFiles(string path, string searchPattern);
///
/// Returns the names of files in the specified directory that match the specified search pattern.
///
/// The directory to search.
/// The search string to match against the names of files in path. The parameter cannot end in two periods ("..") or contain two periods ("..") followed by System.IO.Path.DirectorySeparatorChar or System.IO.Path.AltDirectorySeparatorChar, nor can it contain any of the characters in System.IO.Path.InvalidPathChars.
/// Should the subdirectories be included in the search.
///
string[] GetFiles(string path, string searchPattern, bool recursive);
///
/// Returns the names of subdirectories in the specified directory.
///
/// The directory to search.
///
string[] GetDirectories(string path);
///
/// Returns the subdirectories of the path
///
///
/// True if the method should get all subdirectories recursively.
///
string[] GetDirectories(string path, bool recursive);
///
/// Checks if the filename is valid.
///
///
/// True if the filename is valid otherwise false.
bool IsValidFileName(string fileName);
///
/// Checks if the filepath is valid
///
///
/// True if the filepath is valid otherwise false.
bool IsValidPathName(string pathName);
}
}