FileSystemWrap
Represents a IO class object wrapper to access and create file system related objects.
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
namespace Relativity.DataExchange.Io
{
[CLSCompliant(false)]
internal class FileSystemWrap : IFileSystem
{
public IDirectory Directory { get; }
public IFile File { get; }
public IPath Path { get; }
internal FileSystemWrap()
{
Path = new PathWrap();
Directory = new DirectoryWrap(Path);
File = new FileWrap(Path);
}
public IDirectoryInfo CreateDirectoryInfo(string path)
{
path = Path.NormalizePath(path);
return new DirectoryInfoWrap(path);
}
public IFileInfo CreateFileInfo(string fileName)
{
return new FileInfoWrap(Path.NormalizePath(fileName));
}
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "This is an appropriate construction pattern.")]
public IStreamWriter CreateStreamWriter(string path, bool append)
{
path = Path.NormalizePath(path);
return new StreamWriterWrap(Path.NormalizePath(path), append, new UTF8Encoding(false, true));
}
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "This is an appropriate construction pattern.")]
public IStreamWriter CreateStreamWriter(string path, bool append, Encoding encoding)
{
path = Path.NormalizePath(path);
return new StreamWriterWrap(Path.NormalizePath(path), append, encoding);
}
public IFileSystem DeepCopy()
{
return new FileSystemWrap();
}
}
}