diff --git a/Directory.Build.props b/Directory.Build.props
index 7aca0706e..8b88b5fa9 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -13,7 +13,7 @@
$(DefineConstants);FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
$(DefineConstants);FEATURE_ASYNC_FILE;FEATURE_ENUMERATION_OPTIONS;FEATURE_ADVANCED_PATH_OPERATIONS;FEATURE_PATH_JOIN_WITH_SPAN
$(DefineConstants);FEATURE_FILE_MOVE_WITH_OVERWRITE;FEATURE_SUPPORTED_OS_ATTRIBUTE;FEATURE_FILE_SYSTEM_WATCHER_FILTERS;FEATURE_ENDS_IN_DIRECTORY_SEPARATOR;FEATURE_PATH_JOIN_WITH_PARAMS;FEATURE_PATH_JOIN_WITH_FOUR_PATHS
- $(DefineConstants);FEATURE_FILE_SYSTEM_INFO_LINK_TARGET;FEATURE_CREATE_SYMBOLIC_LINK
+ $(DefineConstants);FEATURE_FILE_SYSTEM_INFO_LINK_TARGET;FEATURE_CREATE_SYMBOLIC_LINK;FEATURE_FILESTREAMOPTIONS
diff --git a/src/System.IO.Abstractions/DirectoryBase.cs b/src/System.IO.Abstractions/DirectoryBase.cs
index bdac3c586..f11f8f577 100644
--- a/src/System.IO.Abstractions/DirectoryBase.cs
+++ b/src/System.IO.Abstractions/DirectoryBase.cs
@@ -25,7 +25,11 @@ internal DirectoryBase() { }
///
public abstract IDirectoryInfo CreateDirectory(string path);
- ///
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
[SupportedOSPlatform("windows")]
public abstract IDirectoryInfo CreateDirectory(string path, DirectorySecurity directorySecurity);
#if FEATURE_CREATE_SYMBOLIC_LINK
@@ -41,11 +45,19 @@ internal DirectoryBase() { }
///
public abstract bool Exists(string path);
- ///
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
[SupportedOSPlatform("windows")]
public abstract DirectorySecurity GetAccessControl(string path);
- ///
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
[SupportedOSPlatform("windows")]
public abstract DirectorySecurity GetAccessControl(string path, AccessControlSections includeSections);
@@ -98,6 +110,11 @@ internal DirectoryBase() { }
///
public abstract string[] GetFileSystemEntries(string path, string searchPattern, SearchOption searchOption);
+#if FEATURE_ENUMERATION_OPTIONS
+ ///
+ public abstract string[] GetFileSystemEntries(string path, string searchPattern, EnumerationOptions enumerationOptions);
+#endif
+
///
public abstract DateTime GetLastAccessTime(string path);
@@ -119,7 +136,20 @@ internal DirectoryBase() { }
///
public abstract void Move(string sourceDirName, string destDirName);
- ///
+#if FEATURE_FILE_SYSTEM_INFO_LINK_TARGET
+ ///
+ public IFileSystemInfo ResolveLinkTarget(string linkPath, bool returnFinalTarget)
+ {
+ return FileSystem.DirectoryInfo.New(linkPath)
+ .ResolveLinkTarget(returnFinalTarget);
+ }
+#endif
+
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
public abstract void SetAccessControl(string path, DirectorySecurity directorySecurity);
///
diff --git a/src/System.IO.Abstractions/DirectoryInfoBase.cs b/src/System.IO.Abstractions/DirectoryInfoBase.cs
index 49cf308ab..3cb3377ee 100644
--- a/src/System.IO.Abstractions/DirectoryInfoBase.cs
+++ b/src/System.IO.Abstractions/DirectoryInfoBase.cs
@@ -17,7 +17,11 @@ internal DirectoryInfoBase() { }
///
public abstract void Create();
- ///
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
public abstract void Create(DirectorySecurity directorySecurity);
///
@@ -68,10 +72,18 @@ internal DirectoryInfoBase() { }
public abstract IEnumerable EnumerateFileSystemInfos(string searchPattern, EnumerationOptions enumerationOptions);
#endif
- ///
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
public abstract DirectorySecurity GetAccessControl();
- ///
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
public abstract DirectorySecurity GetAccessControl(AccessControlSections includeSections);
///
@@ -120,7 +132,11 @@ internal DirectoryInfoBase() { }
///
public abstract void MoveTo(string destDirName);
- ///
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
public abstract void SetAccessControl(DirectorySecurity directorySecurity);
///
diff --git a/src/System.IO.Abstractions/DirectoryInfoFactory.cs b/src/System.IO.Abstractions/DirectoryInfoFactory.cs
index 970e59c49..0dbd5c172 100644
--- a/src/System.IO.Abstractions/DirectoryInfoFactory.cs
+++ b/src/System.IO.Abstractions/DirectoryInfoFactory.cs
@@ -3,19 +3,33 @@ namespace System.IO.Abstractions
[Serializable]
internal class DirectoryInfoFactory : IDirectoryInfoFactory
{
- private readonly IFileSystem fileSystem;
+ ///
+ public IFileSystem FileSystem { get; }
///
public DirectoryInfoFactory(IFileSystem fileSystem)
{
- this.fileSystem = fileSystem;
+ FileSystem = fileSystem;
}
///
+ [Obsolete("Use `DirectoryInfoFactory.New(string)` instead")]
public IDirectoryInfo FromDirectoryName(string directoryName)
{
- var realDirectoryInfo = new DirectoryInfo(directoryName);
- return new DirectoryInfoWrapper(fileSystem, realDirectoryInfo);
+ return New(directoryName);
+ }
+
+ ///
+ public IDirectoryInfo New(string path)
+ {
+ var realDirectoryInfo = new DirectoryInfo(path);
+ return new DirectoryInfoWrapper(FileSystem, realDirectoryInfo);
+ }
+
+ ///
+ public IDirectoryInfo Wrap(DirectoryInfo directoryInfo)
+ {
+ return new DirectoryInfoWrapper(FileSystem, directoryInfo);
}
}
}
diff --git a/src/System.IO.Abstractions/DirectoryInfoWrapper.cs b/src/System.IO.Abstractions/DirectoryInfoWrapper.cs
index d7aaccea8..b2cd81ff2 100644
--- a/src/System.IO.Abstractions/DirectoryInfoWrapper.cs
+++ b/src/System.IO.Abstractions/DirectoryInfoWrapper.cs
@@ -15,8 +15,17 @@ public class DirectoryInfoWrapper : DirectoryInfoBase
public DirectoryInfoWrapper(IFileSystem fileSystem, DirectoryInfo instance) : base(fileSystem)
{
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
+ ExtensionContainer = new FileSystemExtensionContainer(instance);
}
+#if FEATURE_CREATE_SYMBOLIC_LINK
+ ///
+ public override void CreateAsSymbolicLink(string pathToTarget)
+ {
+ instance.CreateAsSymbolicLink(pathToTarget);
+ }
+#endif
+
///
public override void Delete()
{
@@ -29,6 +38,16 @@ public override void Refresh()
instance.Refresh();
}
+#if FEATURE_CREATE_SYMBOLIC_LINK
+ ///
+ public override IFileSystemInfo ResolveLinkTarget(bool returnFinalTarget)
+ {
+ //TODO(vbreuss): Unclear how to handle this case, as no explicit `FileSystemInfoWrapper` exists
+ //return instance.ResolveLinkTarget(returnFinalTarget);
+ return null;
+ }
+#endif
+
///
public override FileAttributes Attributes
{
@@ -62,6 +81,9 @@ public override string Extension
get { return instance.Extension; }
}
+ ///
+ public override IFileSystemExtensionContainer ExtensionContainer { get; }
+
///
public override string FullName
{
diff --git a/src/System.IO.Abstractions/DirectoryWrapper.cs b/src/System.IO.Abstractions/DirectoryWrapper.cs
index cf60e4369..5061bf35f 100644
--- a/src/System.IO.Abstractions/DirectoryWrapper.cs
+++ b/src/System.IO.Abstractions/DirectoryWrapper.cs
@@ -106,7 +106,8 @@ public override string[] GetDirectories(string path, string searchPattern, Searc
#if FEATURE_ENUMERATION_OPTIONS
///
- public override string[] GetDirectories(string path, string searchPattern, EnumerationOptions enumerationOptions)
+ public override string[] GetDirectories(string path, string searchPattern,
+ EnumerationOptions enumerationOptions)
{
return Directory.GetDirectories(path, searchPattern, enumerationOptions);
}
@@ -162,6 +163,15 @@ public override string[] GetFileSystemEntries(string path, string searchPattern,
return Directory.GetFileSystemEntries(path, searchPattern, searchOption);
}
+#if FEATURE_ENUMERATION_OPTIONS
+ ///
+ public override string[] GetFileSystemEntries(string path, string searchPattern,
+ EnumerationOptions enumerationOptions)
+ {
+ return Directory.GetFileSystemEntries(path, searchPattern, enumerationOptions);
+ }
+#endif
+
///
public override DateTime GetLastAccessTime(string path)
{
@@ -273,14 +283,16 @@ public override IEnumerable EnumerateDirectories(string path, string sea
}
///
- public override IEnumerable EnumerateDirectories(string path, string searchPattern, SearchOption searchOption)
+ public override IEnumerable EnumerateDirectories(string path, string searchPattern,
+ SearchOption searchOption)
{
return Directory.EnumerateDirectories(path, searchPattern, searchOption);
}
#if FEATURE_ENUMERATION_OPTIONS
///
- public override IEnumerable EnumerateDirectories(string path, string searchPattern, EnumerationOptions enumerationOptions)
+ public override IEnumerable EnumerateDirectories(string path, string searchPattern,
+ EnumerationOptions enumerationOptions)
{
return Directory.EnumerateDirectories(path, searchPattern, enumerationOptions);
}
@@ -306,7 +318,8 @@ public override IEnumerable EnumerateFiles(string path, string searchPat
#if FEATURE_ENUMERATION_OPTIONS
///
- public override IEnumerable EnumerateFiles(string path, string searchPattern, EnumerationOptions enumerationOptions)
+ public override IEnumerable EnumerateFiles(string path, string searchPattern,
+ EnumerationOptions enumerationOptions)
{
return Directory.EnumerateFiles(path, searchPattern, enumerationOptions);
}
@@ -325,14 +338,16 @@ public override IEnumerable EnumerateFileSystemEntries(string path, stri
}
///
- public override IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, SearchOption searchOption)
+ public override IEnumerable EnumerateFileSystemEntries(string path, string searchPattern,
+ SearchOption searchOption)
{
return Directory.EnumerateFileSystemEntries(path, searchPattern, searchOption);
}
#if FEATURE_ENUMERATION_OPTIONS
///
- public override IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, EnumerationOptions enumerationOptions)
+ public override IEnumerable EnumerateFileSystemEntries(string path, string searchPattern,
+ EnumerationOptions enumerationOptions)
{
return Directory.EnumerateFileSystemEntries(path, searchPattern, enumerationOptions);
}
diff --git a/src/System.IO.Abstractions/DriveInfoFactory.cs b/src/System.IO.Abstractions/DriveInfoFactory.cs
index 9603a31a9..820340bea 100644
--- a/src/System.IO.Abstractions/DriveInfoFactory.cs
+++ b/src/System.IO.Abstractions/DriveInfoFactory.cs
@@ -3,11 +3,12 @@
[Serializable]
internal class DriveInfoFactory : IDriveInfoFactory
{
- private readonly IFileSystem fileSystem;
+ ///
+ public IFileSystem FileSystem { get; }
public DriveInfoFactory(IFileSystem fileSystem)
{
- this.fileSystem = fileSystem;
+ FileSystem = fileSystem;
}
///
@@ -21,7 +22,7 @@ public IDriveInfo[] GetDrives()
for (int index = 0; index < driveInfos.Length; index++)
{
var driveInfo = driveInfos[index];
- driveInfoWrappers[index] = new DriveInfoWrapper(fileSystem, driveInfo);
+ driveInfoWrappers[index] = new DriveInfoWrapper(FileSystem, driveInfo);
}
return driveInfoWrappers;
@@ -31,10 +32,27 @@ public IDriveInfo[] GetDrives()
/// Initializes a new instance of the class, which acts as a wrapper for a logical drive.
///
/// A valid drive path or drive letter.
- public IDriveInfo FromDriveName(string driveName)
+ public IDriveInfo New(string driveName)
{
var realDriveInfo = new DriveInfo(driveName);
- return new DriveInfoWrapper(fileSystem, realDriveInfo);
+ return new DriveInfoWrapper(FileSystem, realDriveInfo);
+ }
+
+ ///
+ public IDriveInfo Wrap(DriveInfo driveInfo)
+ {
+ return new DriveInfoWrapper(FileSystem, driveInfo);
}
+
+ ///
+ /// Initializes a new instance of the class, which acts as a wrapper for a logical drive.
+ ///
+ /// A valid drive path or drive letter.
+ [Obsolete("Use `DriveInfoFactory.New(string)` instead.")]
+ public IDriveInfo FromDriveName(string driveName)
+ {
+ return New(driveName);
+ }
+
}
}
diff --git a/src/System.IO.Abstractions/FileBase.Async.cs b/src/System.IO.Abstractions/FileBase.Async.cs
index d86f9e7e0..74364c9d6 100644
--- a/src/System.IO.Abstractions/FileBase.Async.cs
+++ b/src/System.IO.Abstractions/FileBase.Async.cs
@@ -43,10 +43,14 @@ partial class FileBase
///
public abstract Task WriteAllLinesAsync(string path, IEnumerable contents, Encoding encoding, CancellationToken cancellationToken);
- ///
+ ///
+ // TODO(vbreuss): Check where this overload comes from!
+ [Obsolete("This overload is no longer supported in the interface")]
public abstract Task WriteAllLinesAsync(string path, string[] contents, CancellationToken cancellationToken);
- ///
+ ///
+ // TODO(vbreuss): Check where this overload comes from!
+ [Obsolete("This overload is no longer supported in the interface")]
public abstract Task WriteAllLinesAsync(string path, string[] contents, Encoding encoding, CancellationToken cancellationToken);
///
diff --git a/src/System.IO.Abstractions/FileBase.cs b/src/System.IO.Abstractions/FileBase.cs
index 8b4c9d5c3..737328d61 100644
--- a/src/System.IO.Abstractions/FileBase.cs
+++ b/src/System.IO.Abstractions/FileBase.cs
@@ -45,13 +45,13 @@ internal FileBase() { }
public abstract void Copy(string sourceFileName, string destFileName, bool overwrite);
///
- public abstract Stream Create(string path);
+ public abstract FileSystemStream Create(string path);
///
- public abstract Stream Create(string path, int bufferSize);
+ public abstract FileSystemStream Create(string path, int bufferSize);
///
- public abstract Stream Create(string path, int bufferSize, FileOptions options);
+ public abstract FileSystemStream Create(string path, int bufferSize, FileOptions options);
#if FEATURE_CREATE_SYMBOLIC_LINK
///
public abstract IFileSystemInfo CreateSymbolicLink(string path, string pathToTarget);
@@ -96,11 +96,19 @@ internal FileBase() { }
public abstract bool Exists(string path);
- ///
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
[SupportedOSPlatform("windows")]
public abstract FileSecurity GetAccessControl(string path);
- ///
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
[SupportedOSPlatform("windows")]
public abstract FileSecurity GetAccessControl(string path, AccessControlSections includeSections);
@@ -268,27 +276,37 @@ internal FileBase() { }
public abstract void Move(string sourceFileName, string destFileName);
#if FEATURE_FILE_MOVE_WITH_OVERWRITE
+#if NET5_0
+ ///
+#else
///
+#endif
+ // TODO(vbreuss): Check how to proceed with this method, as `Move` was also implemented on .NET5
public abstract void Move(string sourceFileName, string destFileName, bool overwrite);
#endif
///
- public abstract Stream Open(string path, FileMode mode);
+ public abstract FileSystemStream Open(string path, FileMode mode);
///
- public abstract Stream Open(string path, FileMode mode, FileAccess access);
+ public abstract FileSystemStream Open(string path, FileMode mode, FileAccess access);
///
- public abstract Stream Open(string path, FileMode mode, FileAccess access, FileShare share);
+ public abstract FileSystemStream Open(string path, FileMode mode, FileAccess access, FileShare share);
+
+#if FEATURE_FILESTREAMOPTIONS
+ ///
+ public abstract FileSystemStream Open(string path, FileStreamOptions options);
+#endif
///
- public abstract Stream OpenRead(string path);
+ public abstract FileSystemStream OpenRead(string path);
///
public abstract StreamReader OpenText(string path);
///
- public abstract Stream OpenWrite(string path);
+ public abstract FileSystemStream OpenWrite(string path);
///
public abstract byte[] ReadAllBytes(string path);
@@ -320,7 +338,16 @@ internal FileBase() { }
///
public abstract void Replace(string sourceFileName, string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors);
- ///
+#if FEATURE_FILE_SYSTEM_INFO_LINK_TARGET
+ ///
+ public abstract IFileSystemInfo ResolveLinkTarget(string linkPath, bool returnFinalTarget);
+#endif
+
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
[SupportedOSPlatform("windows")]
public abstract void SetAccessControl(string path, FileSecurity fileSecurity);
diff --git a/src/System.IO.Abstractions/FileInfoBase.cs b/src/System.IO.Abstractions/FileInfoBase.cs
index 4255b0440..d8ef55389 100644
--- a/src/System.IO.Abstractions/FileInfoBase.cs
+++ b/src/System.IO.Abstractions/FileInfoBase.cs
@@ -24,7 +24,7 @@ internal FileInfoBase() { }
public abstract IFileInfo CopyTo(string destFileName, bool overwrite);
///
- public abstract Stream Create();
+ public abstract FileSystemStream Create();
///
public abstract StreamWriter CreateText();
@@ -35,45 +35,63 @@ internal FileInfoBase() { }
///
public abstract void Encrypt();
- ///
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
public abstract FileSecurity GetAccessControl();
- ///
+#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
+ ///
+#else
+ ///
+#endif
public abstract FileSecurity GetAccessControl(AccessControlSections includeSections);
///
public abstract void MoveTo(string destFileName);
#if FEATURE_FILE_MOVE_WITH_OVERWRITE
+#if NET5_0
+ ///
+#else
///
+#endif
+ // TODO(vbreuss): Check how to proceed with this method, as `Move` was also implemented on .NET5
public abstract void MoveTo(string destFileName, bool overwrite);
#endif
///
- public abstract Stream Open(FileMode mode);
+ public abstract FileSystemStream Open(FileMode mode);
///
- public abstract Stream Open(FileMode mode, FileAccess access);
+ public abstract FileSystemStream Open(FileMode mode, FileAccess access);
///
- public abstract Stream Open(FileMode mode, FileAccess access, FileShare share);
+ public abstract FileSystemStream Open(FileMode mode, FileAccess access, FileShare share);
+
+#if FEATURE_FILESTREAMOPTIONS
+ ///
+ public abstract FileSystemStream Open(FileStreamOptions options);
+#endif
///
- public abstract Stream OpenRead();
+ public abstract FileSystemStream OpenRead();
///
public abstract StreamReader OpenText();
///
- public abstract Stream OpenWrite();
+ public abstract FileSystemStream OpenWrite();
///
public abstract IFileInfo Replace(string destinationFileName, string destinationBackupFileName);
///
public abstract IFileInfo Replace(string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors);
-
- ///
+
+ ///
public abstract void SetAccessControl(FileSecurity fileSecurity);
///
diff --git a/src/System.IO.Abstractions/FileInfoFactory.cs b/src/System.IO.Abstractions/FileInfoFactory.cs
index 7985203f2..39e9c7bbd 100644
--- a/src/System.IO.Abstractions/FileInfoFactory.cs
+++ b/src/System.IO.Abstractions/FileInfoFactory.cs
@@ -3,19 +3,33 @@
[Serializable]
internal class FileInfoFactory : IFileInfoFactory
{
- private readonly IFileSystem fileSystem;
+ ///
+ public IFileSystem FileSystem { get; }
///
public FileInfoFactory(IFileSystem fileSystem)
{
- this.fileSystem = fileSystem;
+ FileSystem = fileSystem;
}
///
+ [Obsolete("Use `FileInfoFactory.New(fileName)` instead")]
public IFileInfo FromFileName(string fileName)
+ {
+ return New(fileName);
+ }
+
+ ///
+ public IFileInfo New(string fileName)
{
var realFileInfo = new FileInfo(fileName);
- return new FileInfoWrapper(fileSystem, realFileInfo);
+ return new FileInfoWrapper(FileSystem, realFileInfo);
+ }
+
+ ///
+ public IFileInfo Wrap(FileInfo fileInfo)
+ {
+ return new FileInfoWrapper(FileSystem, fileInfo);
}
}
}
diff --git a/src/System.IO.Abstractions/FileInfoWrapper.cs b/src/System.IO.Abstractions/FileInfoWrapper.cs
index ae14d8b69..12ee7f08a 100644
--- a/src/System.IO.Abstractions/FileInfoWrapper.cs
+++ b/src/System.IO.Abstractions/FileInfoWrapper.cs
@@ -13,8 +13,17 @@ public class FileInfoWrapper : FileInfoBase
public FileInfoWrapper(IFileSystem fileSystem, FileInfo instance) : base(fileSystem)
{
this.instance = instance ?? throw new ArgumentNullException(nameof(instance));
+ ExtensionContainer = new FileSystemExtensionContainer(instance);
}
+#if FEATURE_CREATE_SYMBOLIC_LINK
+ ///
+ public override void CreateAsSymbolicLink(string pathToTarget)
+ {
+ instance.CreateAsSymbolicLink(pathToTarget);
+ }
+#endif
+
///
public override void Delete()
{
@@ -27,6 +36,16 @@ public override void Refresh()
instance.Refresh();
}
+#if FEATURE_CREATE_SYMBOLIC_LINK
+ ///
+ public override IFileSystemInfo ResolveLinkTarget(bool returnFinalTarget)
+ {
+ //TODO(vbreuss): Unclear how to handle this case, as no explicit `FileSystemInfoWrapper` exists
+ //return new FileSystemInfoWrapper(FileSystem, instance.ResolveLinkTarget(returnFinalTarget));
+ return null;
+ }
+#endif
+
///
public override FileAttributes Attributes
{
@@ -60,6 +79,9 @@ public override string Extension
get { return instance.Extension; }
}
+ ///
+ public override IFileSystemExtensionContainer ExtensionContainer { get; }
+
///
public override string FullName
{
@@ -127,9 +149,9 @@ public override IFileInfo CopyTo(string destFileName, bool overwrite)
}
///
- public override Stream Create()
+ public override FileSystemStream Create()
{
- return instance.Create();
+ return new FileStreamWrapper(instance.Create());
}
///
@@ -183,27 +205,35 @@ public override void MoveTo(string destFileName, bool overwrite)
#endif
///
- public override Stream Open(FileMode mode)
+ public override FileSystemStream Open(FileMode mode)
+ {
+ return new FileStreamWrapper(instance.Open(mode));
+ }
+
+ ///
+ public override FileSystemStream Open(FileMode mode, FileAccess access)
{
- return instance.Open(mode);
+ return new FileStreamWrapper(instance.Open(mode, access));
}
///
- public override Stream Open(FileMode mode, FileAccess access)
+ public override FileSystemStream Open(FileMode mode, FileAccess access, FileShare share)
{
- return instance.Open(mode, access);
+ return new FileStreamWrapper(instance.Open(mode, access, share));
}
+#if FEATURE_FILESTREAMOPTIONS
///
- public override Stream Open(FileMode mode, FileAccess access, FileShare share)
+ public override FileSystemStream Open(FileStreamOptions options)
{
- return instance.Open(mode, access, share);
+ return new FileStreamWrapper(instance.Open(options));
}
+#endif
///
- public override Stream OpenRead()
+ public override FileSystemStream OpenRead()
{
- return instance.OpenRead();
+ return new FileStreamWrapper(instance.OpenRead());
}
///
@@ -213,9 +243,9 @@ public override StreamReader OpenText()
}
///
- public override Stream OpenWrite()
+ public override FileSystemStream OpenWrite()
{
- return instance.OpenWrite();
+ return new FileStreamWrapper(instance.OpenWrite());
}
///
diff --git a/src/System.IO.Abstractions/FileStreamFactory.cs b/src/System.IO.Abstractions/FileStreamFactory.cs
index 292e57377..cbd5d55e4 100644
--- a/src/System.IO.Abstractions/FileStreamFactory.cs
+++ b/src/System.IO.Abstractions/FileStreamFactory.cs
@@ -6,40 +6,54 @@ namespace System.IO.Abstractions
[Serializable]
internal sealed class FileStreamFactory : IFileStreamFactory
{
- public Stream Create(string path, FileMode mode)
- => new FileStream(path, mode);
+ public IFileSystem FileSystem { get; }
+
+ public FileStreamFactory(IFileSystem fileSystem)
+ {
+ FileSystem = fileSystem;
+ }
///
- public Stream Create(string path, FileMode mode, FileAccess access)
- => new FileStream(path, mode, access);
+ [Obsolete("Use `FileStreamFactory.New` instead")]
+ public FileSystemStream Create(string path, FileMode mode)
+ => New(path, mode);
///
- public Stream Create(string path, FileMode mode, FileAccess access, FileShare share)
- => new FileStream(path, mode, access, share);
+ [Obsolete("Use `FileStreamFactory.New` instead")]
+ public FileSystemStream Create(string path, FileMode mode, FileAccess access)
+ => New(path, mode, access);
///
- public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
- => new FileStream(path, mode, access, share, bufferSize);
+ [Obsolete("Use `FileStreamFactory.New` instead")]
+ public FileSystemStream Create(string path, FileMode mode, FileAccess access, FileShare share)
+ => New(path, mode, access, share);
///
- public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options)
- => new FileStream(path, mode, access, share, bufferSize, options);
+ [Obsolete("Use `FileStreamFactory.New` instead")]
+ public FileSystemStream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
+ => New(path, mode, access, share, bufferSize);
///
- public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync)
- => new FileStream(path, mode, access, share, bufferSize, useAsync);
+ [Obsolete("Use `FileStreamFactory.New` instead")]
+ public FileSystemStream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options)
+ => New(path, mode, access, share, bufferSize, options);
///
- public Stream Create(SafeFileHandle handle, FileAccess access)
- => new FileStream(handle, access);
+ [Obsolete("Use `FileStreamFactory.New` instead")]
+ public FileSystemStream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync)
+ => New(path, mode, access, share, bufferSize, useAsync);
+
+ ///
+ public FileSystemStream Create(SafeFileHandle handle, FileAccess access)
+ => Wrap(new FileStream(handle, access));
///
- public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize)
- => new FileStream(handle, access, bufferSize);
+ public FileSystemStream Create(SafeFileHandle handle, FileAccess access, int bufferSize)
+ => Wrap(new FileStream(handle, access, bufferSize));
///
- public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync)
- => new FileStream(handle, access, bufferSize, isAsync);
+ public FileSystemStream Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync)
+ => Wrap(new FileStream(handle, access, bufferSize, isAsync));
[Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
public Stream Create(IntPtr handle, FileAccess access)
@@ -56,5 +70,48 @@ public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int buff
[Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync) instead, and optionally make a new SafeFileHandle with ownsHandle=false if needed. http://go.microsoft.com/fwlink/?linkid=14202")]
public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync)
=> new FileStream(handle, access, ownsHandle, bufferSize, isAsync);
+
+ public FileSystemStream New(string path, FileMode mode)
+ {
+ return new FileStreamWrapper(new FileStream(path, mode));
+ }
+
+ public FileSystemStream New(string path, FileMode mode, FileAccess access)
+ {
+ return new FileStreamWrapper(new FileStream(path, mode, access));
+ }
+
+ public FileSystemStream New(string path, FileMode mode, FileAccess access, FileShare share)
+ {
+ return new FileStreamWrapper(new FileStream(path, mode, access, share));
+ }
+
+ public FileSystemStream New(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
+ {
+ return new FileStreamWrapper(new FileStream(path, mode, access, share, bufferSize));
+ }
+
+ public FileSystemStream New(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync)
+ {
+ return new FileStreamWrapper(new FileStream(path, mode, access, share, bufferSize, useAsync));
+ }
+
+ public FileSystemStream New(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
+ FileOptions options)
+ {
+ return new FileStreamWrapper(new FileStream(path, mode, access, share, bufferSize, options));
+ }
+
+#if FEATURE_FILESTREAMOPTIONS
+ public FileSystemStream New(string path, FileStreamOptions options)
+ {
+ return new FileStreamWrapper(new FileStream(path, options));
+ }
+#endif
+
+ public FileSystemStream Wrap(FileStream fileStream)
+ {
+ return new FileStreamWrapper(fileStream);
+ }
}
}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/FileStreamWrapper.cs b/src/System.IO.Abstractions/FileStreamWrapper.cs
new file mode 100644
index 000000000..b65eade1b
--- /dev/null
+++ b/src/System.IO.Abstractions/FileStreamWrapper.cs
@@ -0,0 +1,19 @@
+using System.Diagnostics.CodeAnalysis;
+
+namespace System.IO.Abstractions;
+
+internal sealed class FileStreamWrapper : FileSystemStream
+{
+ public FileStreamWrapper(FileStream fileStream)
+ : base(fileStream, fileStream.Name, fileStream.IsAsync)
+
+ {
+ ExtensionContainer = new FileSystemExtensionContainer(fileStream);
+ }
+
+ ///
+ public override IFileSystemExtensionContainer ExtensionContainer
+ {
+ get;
+ }
+}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/FileSystem.cs b/src/System.IO.Abstractions/FileSystem.cs
index 59210dc04..87c6a2ea6 100644
--- a/src/System.IO.Abstractions/FileSystem.cs
+++ b/src/System.IO.Abstractions/FileSystem.cs
@@ -13,8 +13,8 @@ public FileSystem()
Path = new PathWrapper(this);
File = new FileWrapper(this);
Directory = new DirectoryWrapper(this);
- FileStream = new FileStreamFactory();
- FileSystemWatcher = new FileSystemWatcherFactory();
+ FileStream = new FileStreamFactory(this);
+ FileSystemWatcher = new FileSystemWatcherFactory(this);
}
///
diff --git a/src/System.IO.Abstractions/FileSystemExtensionContainer.cs b/src/System.IO.Abstractions/FileSystemExtensionContainer.cs
new file mode 100644
index 000000000..07916b71a
--- /dev/null
+++ b/src/System.IO.Abstractions/FileSystemExtensionContainer.cs
@@ -0,0 +1,41 @@
+using System.Collections.Generic;
+
+namespace System.IO.Abstractions;
+
+internal class FileSystemExtensionContainer : IFileSystemExtensionContainer
+{
+ private readonly object _wrappedInstance;
+ private readonly Dictionary _metadata = new();
+
+ public FileSystemExtensionContainer(object wrappedInstance)
+ {
+ _wrappedInstance = wrappedInstance;
+ }
+
+ ///
+ public bool HasWrappedInstance(out T wrappedInstance)
+ {
+ wrappedInstance = _wrappedInstance is T
+ ? (T)_wrappedInstance
+ : default;
+ return wrappedInstance != null;
+ }
+
+ ///
+ public void StoreMetadata(string key, T value)
+ {
+ _metadata[key] = value;
+ }
+
+ ///
+ public T RetrieveMetadata(string key)
+ {
+ if (_metadata.TryGetValue(key, out object value) &&
+ value is T)
+ {
+ return (T)value;
+ }
+
+ return default;
+ }
+}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/FileSystemInfoBase.cs b/src/System.IO.Abstractions/FileSystemInfoBase.cs
index c5e4689f5..ed3a084c4 100644
--- a/src/System.IO.Abstractions/FileSystemInfoBase.cs
+++ b/src/System.IO.Abstractions/FileSystemInfoBase.cs
@@ -18,12 +18,22 @@ internal FileSystemInfoBase() { }
///
public IFileSystem FileSystem { get; }
+#if FEATURE_CREATE_SYMBOLIC_LINK
+ ///
+ public abstract void CreateAsSymbolicLink(string pathToTarget);
+#endif
+
///
public abstract void Delete();
///
public abstract void Refresh();
+#if FEATURE_CREATE_SYMBOLIC_LINK
+ ///
+ public abstract IFileSystemInfo ResolveLinkTarget(bool returnFinalTarget);
+#endif
+
///
public abstract FileAttributes Attributes { get; set; }
@@ -39,6 +49,9 @@ internal FileSystemInfoBase() { }
///
public abstract string Extension { get; }
+ ///
+ public abstract IFileSystemExtensionContainer ExtensionContainer { get; }
+
///
public abstract string FullName { get; }
diff --git a/src/System.IO.Abstractions/FileSystemWatcherBase.cs b/src/System.IO.Abstractions/FileSystemWatcherBase.cs
index 00722df6e..7cbb88efc 100644
--- a/src/System.IO.Abstractions/FileSystemWatcherBase.cs
+++ b/src/System.IO.Abstractions/FileSystemWatcherBase.cs
@@ -6,6 +6,15 @@ namespace System.IO.Abstractions
[Serializable]
public abstract class FileSystemWatcherBase : IFileSystemWatcher
{
+ ///
+ public IFileSystem FileSystem { get; }
+
+ ///
+ protected FileSystemWatcherBase(IFileSystem fileSystem)
+ {
+ FileSystem = fileSystem;
+ }
+
///
public abstract bool IncludeSubdirectories { get; set; }
@@ -64,10 +73,13 @@ public void Dispose()
public abstract void EndInit();
///
- public abstract WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType);
+ public abstract IFileSystemWatcher.IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType);
///
- public abstract WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout);
+ public abstract IFileSystemWatcher.IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout);
+
+ ///
+ public abstract IContainer Container { get; }
///
public static implicit operator FileSystemWatcherBase(FileSystemWatcher watcher)
@@ -77,7 +89,8 @@ public static implicit operator FileSystemWatcherBase(FileSystemWatcher watcher)
return null;
}
- return new FileSystemWatcherWrapper(watcher);
+ //TODO(vbreuss): Unclear how we can implement this without a IFileSystem instance?!?
+ return new FileSystemWatcherWrapper(null, watcher);
}
///
diff --git a/src/System.IO.Abstractions/FileSystemWatcherFactory.cs b/src/System.IO.Abstractions/FileSystemWatcherFactory.cs
index 1c3d40904..793cc589f 100644
--- a/src/System.IO.Abstractions/FileSystemWatcherFactory.cs
+++ b/src/System.IO.Abstractions/FileSystemWatcherFactory.cs
@@ -1,21 +1,57 @@
-namespace System.IO.Abstractions
+using Testably.Abstractions.FileSystem;
+using static System.Net.WebRequestMethods;
+
+namespace System.IO.Abstractions
{
///
[Serializable]
public class FileSystemWatcherFactory : IFileSystemWatcherFactory
{
///
- public IFileSystemWatcher CreateNew()
+ public IFileSystem FileSystem { get; }
+
+ internal FileSystemWatcherFactory(IFileSystem fileSystem)
{
- return new FileSystemWatcherWrapper();
+ FileSystem = fileSystem;
}
///
+ [Obsolete("Use `FileSystemWatcherFactory.New` instead")]
+ public IFileSystemWatcher CreateNew()
+ => New();
+
+ ///
+ [Obsolete("Use `FileSystemWatcherFactory.New` instead")]
public IFileSystemWatcher CreateNew(string path) =>
- new FileSystemWatcherWrapper(path);
+ New(path);
///
+ [Obsolete("Use `FileSystemWatcherFactory.New` instead")]
public IFileSystemWatcher CreateNew(string path, string filter)
- => new FileSystemWatcherWrapper(path, filter);
+ => New(path, filter);
+
+ ///
+ public IFileSystemWatcher New()
+ {
+ return new FileSystemWatcherWrapper(FileSystem, new FileSystemWatcher());
+ }
+
+ ///
+ public IFileSystemWatcher New(string path)
+ {
+ return new FileSystemWatcherWrapper(FileSystem, new FileSystemWatcher(path));
+ }
+
+ ///
+ public IFileSystemWatcher New(string path, string filter)
+ {
+ return new FileSystemWatcherWrapper(FileSystem, new FileSystemWatcher(path, filter));
+ }
+
+ ///
+ public IFileSystemWatcher Wrap(FileSystemWatcher fileSystemWatcher)
+ {
+ return new FileSystemWatcherWrapper(FileSystem, fileSystemWatcher);
+ }
}
}
diff --git a/src/System.IO.Abstractions/FileSystemWatcherWrapper.cs b/src/System.IO.Abstractions/FileSystemWatcherWrapper.cs
index af9fef499..5e81cf6c5 100644
--- a/src/System.IO.Abstractions/FileSystemWatcherWrapper.cs
+++ b/src/System.IO.Abstractions/FileSystemWatcherWrapper.cs
@@ -10,28 +10,29 @@ public class FileSystemWatcherWrapper : FileSystemWatcherBase
private readonly FileSystemWatcher watcher;
///
- public FileSystemWatcherWrapper()
- : this(new FileSystemWatcher())
+ public FileSystemWatcherWrapper(IFileSystem fileSystem)
+ : this(fileSystem, new FileSystemWatcher())
{
// do nothing
}
///
- public FileSystemWatcherWrapper(string path)
- : this(new FileSystemWatcher(path))
+ public FileSystemWatcherWrapper(IFileSystem fileSystem, string path)
+ : this(fileSystem, new FileSystemWatcher(path))
{
// do nothing
}
///
- public FileSystemWatcherWrapper(string path, string filter)
- : this(new FileSystemWatcher(path, filter))
+ public FileSystemWatcherWrapper(IFileSystem fileSystem, string path, string filter)
+ : this(fileSystem, new FileSystemWatcher(path, filter))
{
// do nothing
}
///
- public FileSystemWatcherWrapper(FileSystemWatcher watcher)
+ public FileSystemWatcherWrapper(IFileSystem fileSystem, FileSystemWatcher watcher)
+ : base(fileSystem)
{
this.watcher = watcher ?? throw new ArgumentNullException(nameof(watcher));
this.watcher.Created += OnCreated;
@@ -134,15 +135,45 @@ public override void EndInit()
}
///
- public override WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType)
+ public override IFileSystemWatcher.IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType)
{
- return watcher.WaitForChanged(changeType);
+ return new WaitForChangedResultWrapper(watcher.WaitForChanged(changeType));
}
///
- public override WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout)
+ public override IFileSystemWatcher.IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout)
{
- return watcher.WaitForChanged(changeType, timeout);
+ return new WaitForChangedResultWrapper(watcher.WaitForChanged(changeType, timeout));
+ }
+
+ ///
+ public override IContainer Container => watcher.Container;
+
+ private readonly struct WaitForChangedResultWrapper
+ : IFileSystemWatcher.IWaitForChangedResult
+ {
+ private readonly WaitForChangedResult instance;
+
+ public WaitForChangedResultWrapper(WaitForChangedResult instance)
+ {
+ this.instance = instance;
+ }
+
+ ///
+ public WatcherChangeTypes ChangeType
+ => instance.ChangeType;
+
+ ///
+ public string Name
+ => instance.Name;
+
+ ///
+ public string OldName
+ => instance.OldName;
+
+ ///
+ public bool TimedOut
+ => instance.TimedOut;
}
}
}
diff --git a/src/System.IO.Abstractions/FileWrapper.Async.cs b/src/System.IO.Abstractions/FileWrapper.Async.cs
index 37bfd60dd..aeda4afcb 100644
--- a/src/System.IO.Abstractions/FileWrapper.Async.cs
+++ b/src/System.IO.Abstractions/FileWrapper.Async.cs
@@ -82,12 +82,16 @@ public override Task WriteAllLinesAsync(string path, IEnumerable content
}
///
+ // TODO(vbreuss): Check where this overload comes from!
+ [Obsolete("This overload is no longer supported in the interface")]
public override Task WriteAllLinesAsync(string path, string[] contents, CancellationToken cancellationToken)
{
return File.WriteAllLinesAsync(path, contents, cancellationToken);
}
///
+ // TODO(vbreuss): Check where this overload comes from!
+ [Obsolete("This overload is no longer supported in the interface")]
public override Task WriteAllLinesAsync(string path, string[] contents, Encoding encoding, CancellationToken cancellationToken)
{
return File.WriteAllLinesAsync(path, contents, encoding, cancellationToken);
diff --git a/src/System.IO.Abstractions/FileWrapper.cs b/src/System.IO.Abstractions/FileWrapper.cs
index 36c6fcb9f..544fe8366 100644
--- a/src/System.IO.Abstractions/FileWrapper.cs
+++ b/src/System.IO.Abstractions/FileWrapper.cs
@@ -58,21 +58,21 @@ public override void Copy(string sourceFileName, string destFileName, bool overw
}
///
- public override Stream Create(string path)
+ public override FileSystemStream Create(string path)
{
- return File.Create(path);
+ return new FileStreamWrapper(File.Create(path));
}
///
- public override Stream Create(string path, int bufferSize)
+ public override FileSystemStream Create(string path, int bufferSize)
{
- return File.Create(path, bufferSize);
+ return new FileStreamWrapper(File.Create(path, bufferSize));
}
///
- public override Stream Create(string path, int bufferSize, FileOptions options)
+ public override FileSystemStream Create(string path, int bufferSize, FileOptions options)
{
- return File.Create(path, bufferSize, options);
+ return new FileStreamWrapper(File.Create(path, bufferSize, options));
}
#if FEATURE_CREATE_SYMBOLIC_LINK
@@ -186,27 +186,35 @@ public override void Move(string sourceFileName, string destFileName, bool overw
///
- public override Stream Open(string path, FileMode mode)
+ public override FileSystemStream Open(string path, FileMode mode)
{
- return File.Open(path, mode);
+ return new FileStreamWrapper(File.Open(path, mode));
}
///
- public override Stream Open(string path, FileMode mode, FileAccess access)
+ public override FileSystemStream Open(string path, FileMode mode, FileAccess access)
{
- return File.Open(path, mode, access);
+ return new FileStreamWrapper(File.Open(path, mode, access));
}
///
- public override Stream Open(string path, FileMode mode, FileAccess access, FileShare share)
+ public override FileSystemStream Open(string path, FileMode mode, FileAccess access, FileShare share)
{
- return File.Open(path, mode, access, share);
+ return new FileStreamWrapper(File.Open(path, mode, access, share));
}
+#if FEATURE_FILESTREAMOPTIONS
///
- public override Stream OpenRead(string path)
+ public override FileSystemStream Open(string path, FileStreamOptions options)
{
- return File.OpenRead(path);
+ return new FileStreamWrapper(File.Open(path, options));
+ }
+#endif
+
+ ///
+ public override FileSystemStream OpenRead(string path)
+ {
+ return new FileStreamWrapper(File.OpenRead(path));
}
///
@@ -216,9 +224,9 @@ public override StreamReader OpenText(string path)
}
///
- public override Stream OpenWrite(string path)
+ public override FileSystemStream OpenWrite(string path)
{
- return File.OpenWrite(path);
+ return new FileStreamWrapper(File.OpenWrite(path));
}
///
@@ -275,6 +283,14 @@ public override void Replace(string sourceFileName, string destinationFileName,
File.Replace(sourceFileName, destinationFileName, destinationBackupFileName, ignoreMetadataErrors);
}
+#if FEATURE_CREATE_SYMBOLIC_LINK
+ ///
+ public override IFileSystemInfo ResolveLinkTarget(string linkPath, bool returnFinalTarget)
+ {
+ return FileSystem.FileInfo.New(linkPath).ResolveLinkTarget(returnFinalTarget);
+ }
+#endif
+
///
[SupportedOSPlatform("windows")]
public override void SetAccessControl(string path, FileSecurity fileSecurity)
diff --git a/src/System.IO.Abstractions/IDirectory.cs b/src/System.IO.Abstractions/IDirectory.cs
deleted file mode 100644
index 14ef6d1b3..000000000
--- a/src/System.IO.Abstractions/IDirectory.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-using System.Collections.Generic;
-using System.Security.AccessControl;
-
-namespace System.IO.Abstractions
-{
- ///
- public interface IDirectory
- {
- ///
- /// Exposes the underlying filesystem implementation. This is useful for implementing extension methods.
- ///
- IFileSystem FileSystem { get; }
-
- ///
- IDirectoryInfo CreateDirectory(string path);
-
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- IDirectoryInfo CreateDirectory(string path, DirectorySecurity directorySecurity);
-#if FEATURE_CREATE_SYMBOLIC_LINK
- ///
- IFileSystemInfo CreateSymbolicLink(string path, string pathToTarget);
-#endif
- ///
- void Delete(string path);
- ///
- void Delete(string path, bool recursive);
- ///
- bool Exists(string path);
-
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- DirectorySecurity GetAccessControl(string path);
-
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- DirectorySecurity GetAccessControl(string path, AccessControlSections includeSections);
-
- ///
- DateTime GetCreationTime(string path);
- ///
- DateTime GetCreationTimeUtc(string path);
- ///
- string GetCurrentDirectory();
- ///
- string[] GetDirectories(string path);
- ///
- string[] GetDirectories(string path, string searchPattern);
- ///
- string[] GetDirectories(string path, string searchPattern, SearchOption searchOption);
-#if FEATURE_ENUMERATION_OPTIONS
- ///
- string[] GetDirectories(string path, string searchPattern, EnumerationOptions enumerationOptions);
-#endif
- ///
- string GetDirectoryRoot(string path);
- ///
- string[] GetFiles(string path);
- ///
- string[] GetFiles(string path, string searchPattern);
- ///
- string[] GetFiles(string path, string searchPattern, SearchOption searchOption);
-#if FEATURE_ENUMERATION_OPTIONS
- ///
- string[] GetFiles(string path, string searchPattern, EnumerationOptions enumerationOptions);
-#endif
- ///
- string[] GetFileSystemEntries(string path);
- ///
- string[] GetFileSystemEntries(string path, string searchPattern);
- ///
- string[] GetFileSystemEntries(string path, string searchPattern, SearchOption searchOption);
- ///
- DateTime GetLastAccessTime(string path);
- ///
- DateTime GetLastAccessTimeUtc(string path);
- ///
- DateTime GetLastWriteTime(string path);
- ///
- DateTime GetLastWriteTimeUtc(string path);
- ///
- string[] GetLogicalDrives();
- ///
- IDirectoryInfo GetParent(string path);
- ///
- void Move(string sourceDirName, string destDirName);
-
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- void SetAccessControl(string path, DirectorySecurity directorySecurity);
- ///
- void SetCreationTime(string path, DateTime creationTime);
- ///
- void SetCreationTimeUtc(string path, DateTime creationTimeUtc);
- ///
- void SetCurrentDirectory(string path);
- ///
- void SetLastAccessTime(string path, DateTime lastAccessTime);
- ///
- void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc);
- ///
- void SetLastWriteTime(string path, DateTime lastWriteTime);
- ///
- void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc);
- ///
- IEnumerable EnumerateDirectories(string path);
- ///
- IEnumerable EnumerateDirectories(string path, string searchPattern);
- ///
- IEnumerable EnumerateDirectories(string path, string searchPattern, SearchOption searchOption);
-
-#if FEATURE_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateDirectories(string path, string searchPattern, EnumerationOptions enumerationOptions);
-#endif
- ///
- IEnumerable EnumerateFiles(string path);
- ///
- IEnumerable EnumerateFiles(string path, string searchPattern);
- ///
- IEnumerable EnumerateFiles(string path, string searchPattern, SearchOption searchOption);
-#if FEATURE_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateFiles(string path, string searchPattern, EnumerationOptions enumerationOptions);
-#endif
- ///
- IEnumerable EnumerateFileSystemEntries(string path);
- ///
- IEnumerable EnumerateFileSystemEntries(string path, string searchPattern);
- ///
- IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, SearchOption searchOption);
-#if FEATURE_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, EnumerationOptions enumerationOptions);
-#endif
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IDirectoryInfo.cs b/src/System.IO.Abstractions/IDirectoryInfo.cs
deleted file mode 100644
index 697beb60e..000000000
--- a/src/System.IO.Abstractions/IDirectoryInfo.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-using System.Collections.Generic;
-using System.Security.AccessControl;
-
-namespace System.IO.Abstractions
-{
- ///
- public interface IDirectoryInfo : IFileSystemInfo
- {
- ///
- void Create();
-
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- void Create(DirectorySecurity directorySecurity);
- ///
- IDirectoryInfo CreateSubdirectory(string path);
- ///
- void Delete(bool recursive);
- ///
- IEnumerable EnumerateDirectories();
- ///
- IEnumerable EnumerateDirectories(string searchPattern);
- ///
- IEnumerable EnumerateDirectories(string searchPattern, SearchOption searchOption);
-
-#if FEATURE_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateDirectories(string searchPattern, EnumerationOptions enumerationOptions);
-#endif
-
- ///
- IEnumerable EnumerateFiles();
- ///
- IEnumerable EnumerateFiles(string searchPattern);
- ///
- IEnumerable EnumerateFiles(string searchPattern, SearchOption searchOption);
-
-#if FEATURE_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateFiles(string searchPattern, EnumerationOptions enumerationOptions);
-#endif
-
- ///
- IEnumerable EnumerateFileSystemInfos();
- ///
- IEnumerable EnumerateFileSystemInfos(string searchPattern);
- ///
- IEnumerable EnumerateFileSystemInfos(string searchPattern, SearchOption searchOption);
-
-#if FEATURE_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateFileSystemInfos(string searchPattern, EnumerationOptions enumerationOptions);
-#endif
-
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- DirectorySecurity GetAccessControl();
-
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- DirectorySecurity GetAccessControl(AccessControlSections includeSections);
-
- ///
- IDirectoryInfo[] GetDirectories();
- ///
- IDirectoryInfo[] GetDirectories(string searchPattern);
- ///
- IDirectoryInfo[] GetDirectories(string searchPattern, SearchOption searchOption);
-
-#if FEATURE_ENUMERATION_OPTIONS
- ///
- IDirectoryInfo[] GetDirectories(string searchPattern, EnumerationOptions enumerationOptions);
-#endif
-
- ///
- IFileInfo[] GetFiles();
- ///
- IFileInfo[] GetFiles(string searchPattern);
- ///
- IFileInfo[] GetFiles(string searchPattern, SearchOption searchOption);
-
-#if FEATURE_ENUMERATION_OPTIONS
- ///
- IFileInfo[] GetFiles(string searchPattern, EnumerationOptions enumerationOptions);
-#endif
-
- ///
- IFileSystemInfo[] GetFileSystemInfos();
- ///
- IFileSystemInfo[] GetFileSystemInfos(string searchPattern);
- ///
- IFileSystemInfo[] GetFileSystemInfos(string searchPattern, SearchOption searchOption);
-
-#if FEATURE_ENUMERATION_OPTIONS
- ///
- IFileSystemInfo[] GetFileSystemInfos(string searchPattern, EnumerationOptions enumerationOptions);
-#endif
-
- ///
- void MoveTo(string destDirName);
-
-
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- void SetAccessControl(DirectorySecurity directorySecurity);
-
- ///
- IDirectoryInfo Parent { get; }
- ///
- IDirectoryInfo Root { get; }
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IDirectoryInfoFactory.cs b/src/System.IO.Abstractions/IDirectoryInfoFactory.cs
deleted file mode 100644
index ccd299863..000000000
--- a/src/System.IO.Abstractions/IDirectoryInfoFactory.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace System.IO.Abstractions
-{
- ///
- public interface IDirectoryInfoFactory
- {
- ///
- /// Initializes a new instance of the class, which acts as a wrapper for a directory path.
- ///
- /// The fully qualified name of the new directory, or the relative directory name.
- IDirectoryInfo FromDirectoryName(string directoryName);
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IDriveInfo.cs b/src/System.IO.Abstractions/IDriveInfo.cs
deleted file mode 100644
index 69fdeda97..000000000
--- a/src/System.IO.Abstractions/IDriveInfo.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace System.IO.Abstractions
-{
- ///
- public interface IDriveInfo
- {
- ///
- /// Exposes the underlying filesystem implementation. This is useful for implementing extension methods.
- ///
- IFileSystem FileSystem { get; }
- ///
- long AvailableFreeSpace { get; }
- ///
- string DriveFormat { get; }
- ///
- DriveType DriveType { get; }
- ///
- bool IsReady { get; }
- ///
- string Name { get; }
- ///
- IDirectoryInfo RootDirectory { get; }
- ///
- long TotalFreeSpace { get; }
- ///
- long TotalSize { get; }
- ///
- string VolumeLabel { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IDriveInfoFactory.cs b/src/System.IO.Abstractions/IDriveInfoFactory.cs
deleted file mode 100644
index 7a2cca36a..000000000
--- a/src/System.IO.Abstractions/IDriveInfoFactory.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace System.IO.Abstractions
-{
- ///
- /// A factory to create all for a .
- ///
- public interface IDriveInfoFactory
- {
- ///
- /// Retrieves the drive names of all logical drives on a computer.
- ///
- /// An array of type that represents the logical drives on a computer.
- IDriveInfo[] GetDrives();
-
- ///
- /// Initializes a new instance of the class, which acts as a wrapper for a logical drive.
- ///
- /// A valid drive path or drive letter.
- IDriveInfo FromDriveName(string driveName);
- }
-}
diff --git a/src/System.IO.Abstractions/IFile.Async.cs b/src/System.IO.Abstractions/IFile.Async.cs
deleted file mode 100644
index b461e15e2..000000000
--- a/src/System.IO.Abstractions/IFile.Async.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-#if FEATURE_ASYNC_FILE
-
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
-using System.Threading;
-
-namespace System.IO.Abstractions
-{
- partial interface IFile
- {
- ///
- Task AppendAllLinesAsync(string path, IEnumerable contents, CancellationToken cancellationToken = default(CancellationToken));
- ///
- Task AppendAllLinesAsync(string path, IEnumerable contents, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken));
- ///
-
- ///
- Task AppendAllTextAsync(String path, String contents, CancellationToken cancellationToken = default(CancellationToken));
- ///
- Task AppendAllTextAsync(String path, String contents, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken));
- ///
- Task ReadAllBytesAsync(string path, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- Task ReadAllLinesAsync(string path, CancellationToken cancellationToken = default(CancellationToken));
- ///
- Task ReadAllLinesAsync(string path, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- Task ReadAllTextAsync(string path, CancellationToken cancellationToken = default(CancellationToken));
- ///
- Task ReadAllTextAsync(string path, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken));
- ///
- Task WriteAllLinesAsync(string path, IEnumerable contents, CancellationToken cancellationToken = default(CancellationToken));
- ///
- Task WriteAllLinesAsync(string path, IEnumerable contents, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken));
- ///
- Task WriteAllLinesAsync(string path, string[] contents, CancellationToken cancellationToken = default(CancellationToken));
- ///
- Task WriteAllLinesAsync(string path, string[] contents, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- Task WriteAllTextAsync(string path, string contents, CancellationToken cancellationToken = default(CancellationToken));
- ///
- Task WriteAllTextAsync(string path, string contents, Encoding encoding, CancellationToken cancellationToken = default(CancellationToken));
-
- ///
- Task WriteAllBytesAsync(string path, byte[] bytes, CancellationToken cancellationToken = default(CancellationToken));
- }
-}
-
-#endif
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IFile.cs b/src/System.IO.Abstractions/IFile.cs
deleted file mode 100644
index e1d8e155d..000000000
--- a/src/System.IO.Abstractions/IFile.cs
+++ /dev/null
@@ -1,151 +0,0 @@
-using System.Collections.Generic;
-using System.Runtime.Versioning;
-using System.Security.AccessControl;
-using System.Text;
-
-namespace System.IO.Abstractions
-{
- ///
- public partial interface IFile
- {
- ///
- /// Exposes the underlying filesystem implementation. This is useful for implementing extension methods.
- ///
- IFileSystem FileSystem { get; }
-
- ///
- void AppendAllLines(string path, IEnumerable contents);
- ///
- void AppendAllLines(string path, IEnumerable contents, Encoding encoding);
- ///
- void AppendAllText(string path, string contents);
- ///
- void AppendAllText(string path, string contents, Encoding encoding);
- ///
- StreamWriter AppendText(string path);
- ///
- void Copy(string sourceFileName, string destFileName);
- ///
- void Copy(string sourceFileName, string destFileName, bool overwrite);
- ///
- Stream Create(string path);
- ///
- Stream Create(string path, int bufferSize);
- ///
- Stream Create(string path, int bufferSize, FileOptions options);
-#if FEATURE_CREATE_SYMBOLIC_LINK
- ///
- IFileSystemInfo CreateSymbolicLink(string path, string pathToTarget);
-#endif
- ///
- StreamWriter CreateText(string path);
- ///
- void Decrypt(string path);
- ///
- void Delete(string path);
- ///
- void Encrypt(string path);
- ///
- bool Exists(string path);
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- [SupportedOSPlatform("windows")]
- FileSecurity GetAccessControl(string path);
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- [SupportedOSPlatform("windows")]
- FileSecurity GetAccessControl(string path, AccessControlSections includeSections);
-
- ///
- FileAttributes GetAttributes(string path);
- ///
- DateTime GetCreationTime(string path);
- ///
- DateTime GetCreationTimeUtc(string path);
- ///
- DateTime GetLastAccessTime(string path);
- ///
- DateTime GetLastAccessTimeUtc(string path);
- ///
- DateTime GetLastWriteTime(string path);
- ///
- DateTime GetLastWriteTimeUtc(string path);
- ///
- void Move(string sourceFileName, string destFileName);
-#if FEATURE_FILE_MOVE_WITH_OVERWRITE
- ///
- void Move(string sourceFileName, string destFileName, bool overwrite);
-#endif
- ///
- Stream Open(string path, FileMode mode);
- ///
- Stream Open(string path, FileMode mode, FileAccess access);
- ///
- Stream Open(string path, FileMode mode, FileAccess access, FileShare share);
- ///
- Stream OpenRead(string path);
- ///
- StreamReader OpenText(string path);
- ///
- Stream OpenWrite(string path);
- ///
- byte[] ReadAllBytes(string path);
- ///
- string[] ReadAllLines(string path);
- ///
- string[] ReadAllLines(string path, Encoding encoding);
- ///
- string ReadAllText(string path);
- ///
- string ReadAllText(string path, Encoding encoding);
- ///
- IEnumerable ReadLines(string path);
- ///
- IEnumerable ReadLines(string path, Encoding encoding);
- ///
- void Replace(string sourceFileName, string destinationFileName, string destinationBackupFileName);
- ///
- void Replace(string sourceFileName, string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors);
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- [SupportedOSPlatform("windows")]
- void SetAccessControl(string path, FileSecurity fileSecurity);
- ///
- void SetAttributes(string path, FileAttributes fileAttributes);
- ///
- void SetCreationTime(string path, DateTime creationTime);
- ///
- void SetCreationTimeUtc(string path, DateTime creationTimeUtc);
- ///
- void SetLastAccessTime(string path, DateTime lastAccessTime);
- ///
- void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc);
- ///
- void SetLastWriteTime(string path, DateTime lastWriteTime);
- ///
- void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc);
- ///
- void WriteAllBytes(string path, byte[] bytes);
- ///
- void WriteAllLines(string path, IEnumerable contents);
- ///
- void WriteAllLines(string path, IEnumerable contents, Encoding encoding);
- ///
- void WriteAllLines(string path, string[] contents);
- ///
- void WriteAllLines(string path, string[] contents, Encoding encoding);
- ///
- void WriteAllText(string path, string contents);
- ///
- void WriteAllText(string path, string contents, Encoding encoding);
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IFileInfo.cs b/src/System.IO.Abstractions/IFileInfo.cs
deleted file mode 100644
index 08f10b903..000000000
--- a/src/System.IO.Abstractions/IFileInfo.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using System.Security.AccessControl;
-
-namespace System.IO.Abstractions
-{
- ///
- public interface IFileInfo : IFileSystemInfo
- {
- ///
- StreamWriter AppendText();
- ///
- IFileInfo CopyTo(string destFileName);
- ///
- IFileInfo CopyTo(string destFileName, bool overwrite);
- ///
- Stream Create();
- ///
- StreamWriter CreateText();
- ///
- void Decrypt();
- ///
- void Encrypt();
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- FileSecurity GetAccessControl();
-#if FEATURE_FILE_SYSTEM_ACL_EXTENSIONS
- ///
-#else
- ///
-#endif
- FileSecurity GetAccessControl(AccessControlSections includeSections);
- ///
- void MoveTo(string destFileName);
-#if FEATURE_FILE_MOVE_WITH_OVERWRITE
- ///
- void MoveTo(string destFileName, bool overwrite);
-#endif
- ///
- Stream Open(FileMode mode);
- ///
- Stream Open(FileMode mode, FileAccess access);
- ///
- Stream Open(FileMode mode, FileAccess access, FileShare share);
- ///
- Stream OpenRead();
- ///
- StreamReader OpenText();
- ///
- Stream OpenWrite();
- ///
- IFileInfo Replace(string destinationFileName, string destinationBackupFileName);
- ///
- IFileInfo Replace(string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors);
- ///
- void SetAccessControl(FileSecurity fileSecurity);
- ///
- IDirectoryInfo Directory { get; }
- ///
- string DirectoryName { get; }
- ///
- bool IsReadOnly { get; set; }
- ///
- long Length { get; }
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IFileInfoFactory.cs b/src/System.IO.Abstractions/IFileInfoFactory.cs
deleted file mode 100644
index 3771ea83e..000000000
--- a/src/System.IO.Abstractions/IFileInfoFactory.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace System.IO.Abstractions
-{
- ///
- /// Provides factory methods for creating instances.
- ///
- public interface IFileInfoFactory
- {
- ///
- /// Initializes a new instance of the class, which acts as a wrapper for a file path.
- ///
- /// The fully qualified name of the new file, or the relative file name.
- IFileInfo FromFileName(string fileName);
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IFileStreamFactory.cs b/src/System.IO.Abstractions/IFileStreamFactory.cs
deleted file mode 100644
index ee7a472cd..000000000
--- a/src/System.IO.Abstractions/IFileStreamFactory.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System.Security.AccessControl;
-using Microsoft.Win32.SafeHandles;
-
-namespace System.IO.Abstractions
-{
- ///
- public interface IFileStreamFactory
- {
- ///
- Stream Create(string path, FileMode mode);
-
- ///
- Stream Create(string path, FileMode mode, FileAccess access);
-
- ///
- Stream Create(string path, FileMode mode, FileAccess access, FileShare share);
-
- ///
- Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize);
-
- ///
- Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options);
-
- ///
- Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync);
-
- ///
- Stream Create(SafeFileHandle handle, FileAccess access);
-
- ///
- Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize);
-
- ///
- Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync);
-
- ///
- [Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
- Stream Create(IntPtr handle, FileAccess access);
-
- ///
- [Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access) instead, and optionally make a new SafeFileHandle with ownsHandle=false if needed. http://go.microsoft.com/fwlink/?linkid=14202")]
- Stream Create(IntPtr handle, FileAccess access, bool ownsHandle);
-
- ///
- [Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access, int bufferSize) instead, and optionally make a new SafeFileHandle with ownsHandle=false if needed. http://go.microsoft.com/fwlink/?linkid=14202")]
- Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize);
-
- ///
- [Obsolete("This method has been deprecated. Please use new Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync) instead, and optionally make a new SafeFileHandle with ownsHandle=false if needed. http://go.microsoft.com/fwlink/?linkid=14202")]
- Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync);
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IFileSystem.cs b/src/System.IO.Abstractions/IFileSystem.cs
deleted file mode 100644
index 564a37291..000000000
--- a/src/System.IO.Abstractions/IFileSystem.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace System.IO.Abstractions
-{
- ///
- ///
- public interface IFileSystem
- {
- ///
- ///
- IFile File { get; }
-
- ///
- ///
- IDirectory Directory { get; }
-
- ///
- ///
- IFileInfoFactory FileInfo { get; }
-
- ///
- ///
- IFileStreamFactory FileStream { get; }
-
- ///
- ///
- IPath Path { get; }
-
- ///
- ///
- IDirectoryInfoFactory DirectoryInfo { get; }
-
- ///
- ///
- IDriveInfoFactory DriveInfo { get; }
-
- ///
- ///
- IFileSystemWatcherFactory FileSystemWatcher { get; }
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IFileSystemInfo.cs b/src/System.IO.Abstractions/IFileSystemInfo.cs
deleted file mode 100644
index 0171994a0..000000000
--- a/src/System.IO.Abstractions/IFileSystemInfo.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-namespace System.IO.Abstractions
-{
- ///
- public interface IFileSystemInfo
- {
- ///
- /// Exposes the underlying filesystem implementation. This is useful for implementing extension methods.
- ///
- IFileSystem FileSystem { get; }
- ///
- void Delete();
- ///
- void Refresh();
- ///
- FileAttributes Attributes { get; set; }
- ///
- DateTime CreationTime { get; set; }
- ///
- DateTime CreationTimeUtc { get; set; }
- ///
- bool Exists { get; }
- ///
- string Extension { get; }
- ///
- string FullName { get; }
- ///
- DateTime LastAccessTime { get; set; }
- ///
- DateTime LastAccessTimeUtc { get; set; }
- ///
- DateTime LastWriteTime { get; set; }
- ///
- DateTime LastWriteTimeUtc { get; set; }
-#if FEATURE_FILE_SYSTEM_INFO_LINK_TARGET
- ///
- string LinkTarget { get; }
-#endif
- ///
- string Name { get; }
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IFileSystemWatcher.cs b/src/System.IO.Abstractions/IFileSystemWatcher.cs
deleted file mode 100644
index db1c6cb0c..000000000
--- a/src/System.IO.Abstractions/IFileSystemWatcher.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using System.ComponentModel;
-
-namespace System.IO.Abstractions
-{
- ///
- public interface IFileSystemWatcher : IDisposable
- {
- ///
- bool IncludeSubdirectories { get; set; }
- ///
- bool EnableRaisingEvents { get; set; }
- ///
- string Filter { get; set; }
-#if FEATURE_FILE_SYSTEM_WATCHER_FILTERS
- ///
- System.Collections.ObjectModel.Collection Filters { get; }
-#endif
- ///
- int InternalBufferSize { get; set; }
- ///
- NotifyFilters NotifyFilter { get; set; }
- ///
- string Path { get; set; }
- ///
- ISite Site { get; set; }
- ///
- ISynchronizeInvoke SynchronizingObject { get; set; }
- ///
- event FileSystemEventHandler Changed;
- ///
- event FileSystemEventHandler Created;
- ///
- event FileSystemEventHandler Deleted;
- ///
- event ErrorEventHandler Error;
- ///
- event RenamedEventHandler Renamed;
- ///
- void BeginInit();
- ///
- void EndInit();
- ///
- WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType);
- ///
- WaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout);
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/IFileSystemWatcherFactory.cs b/src/System.IO.Abstractions/IFileSystemWatcherFactory.cs
deleted file mode 100644
index 4f5f13e86..000000000
--- a/src/System.IO.Abstractions/IFileSystemWatcherFactory.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace System.IO.Abstractions
-{
- ///
- /// Exposes factory methods for creating file system watchers.
- ///
- public interface IFileSystemWatcherFactory
- {
- ///
- /// Initializes a new instance of the class, which acts as a wrapper for a FileSystemWatcher
- ///
- ///
- IFileSystemWatcher CreateNew();
-
- ///
- /// Initializes a new instance of the class, given the specified directory to monitor, which acts as a wrapper for a FileSystemWatcher
- ///
- /// The directory to monitor, in standard or Universal Naming Convention (UNC) notation.
- ///
- IFileSystemWatcher CreateNew(string path);
-
- ///
- /// Initializes a new instance of the class, given the specified directory and type of files to monitor, which acts as a wrapper for a FileSystemWatcher
- ///
- /// The directory to monitor, in standard or Universal Naming Convention (UNC) notation.
- /// The type of files to watch. For example, "*.txt" watches for changes to all text files.
- ///
- IFileSystemWatcher CreateNew(string path, string filter);
- }
-}
diff --git a/src/System.IO.Abstractions/IPath.cs b/src/System.IO.Abstractions/IPath.cs
deleted file mode 100644
index 1f9d98953..000000000
--- a/src/System.IO.Abstractions/IPath.cs
+++ /dev/null
@@ -1,142 +0,0 @@
-namespace System.IO.Abstractions
-{
- ///
- public interface IPath
- {
- ///
- char AltDirectorySeparatorChar { get; }
- ///
- char DirectorySeparatorChar { get; }
- ///
- /// Exposes the underlying filesystem implementation. This is useful for implementing extension methods.
- ///
- IFileSystem FileSystem { get; }
- ///
- char PathSeparator { get; }
- ///
- char VolumeSeparatorChar { get; }
- ///
- char[] InvalidPathChars { get; }
- ///
- string ChangeExtension(string path, string extension);
- ///
- string Combine(params string[] paths);
- ///
- string Combine(string path1, string path2);
- ///
- string Combine(string path1, string path2, string path3);
- ///
- string Combine(string path1, string path2, string path3, string path4);
- ///
- string GetDirectoryName(string path);
- ///
- string GetExtension(string path);
- ///
- string GetFileName(string path);
- ///
- string GetFileNameWithoutExtension(string path);
- ///
- string GetFullPath(string path);
-#if FEATURE_ADVANCED_PATH_OPERATIONS
- ///
- string GetFullPath(string path, string basePath);
-#endif
- ///
- char[] GetInvalidFileNameChars();
- ///
- char[] GetInvalidPathChars();
- ///
- string GetPathRoot(string path);
- ///
- string GetRandomFileName();
- ///
- string GetTempFileName();
- ///
- string GetTempPath();
- ///
- bool HasExtension(string path);
- ///
- bool IsPathRooted(string path);
-
-#if FEATURE_ADVANCED_PATH_OPERATIONS
- ///
- bool IsPathFullyQualified(string path);
-
- ///
- string GetRelativePath(string relativeTo, string path);
-#endif
-
-#if FEATURE_PATH_JOIN_WITH_SPAN
- ///
- string Join(ReadOnlySpan path1, ReadOnlySpan path2);
-
- ///
- string Join(ReadOnlySpan path1, ReadOnlySpan path2, ReadOnlySpan path3);
-
- ///
- bool TryJoin(ReadOnlySpan path1, ReadOnlySpan path2, ReadOnlySpan path3, Span destination, out int charsWritten);
-
- ///
- bool TryJoin(ReadOnlySpan path1, ReadOnlySpan path2, Span destination, out int charsWritten);
-#endif
-
-#if FEATURE_ADVANCED_PATH_OPERATIONS
- ///
- bool HasExtension(ReadOnlySpan path);
-
- ///
- bool IsPathFullyQualified(ReadOnlySpan path);
-
- ///
- bool IsPathRooted(ReadOnlySpan path);
-
- ///
- ReadOnlySpan GetDirectoryName(ReadOnlySpan path);
-
- ///
- ReadOnlySpan GetExtension(ReadOnlySpan path);
-
- ///
- ReadOnlySpan GetFileName(ReadOnlySpan path);
-
- ///
- ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path);
-
- ///
- ReadOnlySpan GetPathRoot(ReadOnlySpan path);
-
-#endif
-
-#if FEATURE_PATH_JOIN_WITH_PARAMS
- ///
- string Join(string path1, string path2);
-
- ///
- string Join(string path1, string path2, string path3);
-
- ///
- string Join(params string[] paths);
-#endif
-
-#if FEATURE_ENDS_IN_DIRECTORY_SEPARATOR
- ///
- bool EndsInDirectorySeparator(ReadOnlySpan path);
-
- ///
- bool EndsInDirectorySeparator(string path);
-
- ///
- ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path);
- ///
- string TrimEndingDirectorySeparator(string path);
-#endif
-
-#if FEATURE_PATH_JOIN_WITH_FOUR_PATHS
- ///
- string Join(ReadOnlySpan path1, ReadOnlySpan path2, ReadOnlySpan path3, ReadOnlySpan path4);
-
- ///
- string Join(string path1, string path2, string path3, string path4);
-#endif
- }
-}
\ No newline at end of file
diff --git a/src/System.IO.Abstractions/System.IO.Abstractions.csproj b/src/System.IO.Abstractions/System.IO.Abstractions.csproj
index a98d5e687..497fd02b8 100644
--- a/src/System.IO.Abstractions/System.IO.Abstractions.csproj
+++ b/src/System.IO.Abstractions/System.IO.Abstractions.csproj
@@ -4,6 +4,7 @@
System.IO.Abstractions
A set of abstractions to help make file system interactions testable.
net6.0;net5.0;netstandard2.1;netstandard2.0;net461
+ latest
icon_256x256.png
@@ -17,6 +18,7 @@
all
runtime; build; native; contentfiles; analyzers
+
diff --git a/src/System.IO.Abstractions/Usings.cs b/src/System.IO.Abstractions/Usings.cs
new file mode 100644
index 000000000..f53a53309
--- /dev/null
+++ b/src/System.IO.Abstractions/Usings.cs
@@ -0,0 +1,2 @@
+global using Testably.Abstractions;
+global using Testably.Abstractions.FileSystem;
\ No newline at end of file