Browse Source

IFileSystem: Added FileOptions parameter to OpenFile

Tal Aloni 7 years ago
parent
commit
17ba80bf91

+ 1 - 1
DiskAccessLibrary/FileSystems/NTFS/Adapters/NTFSFileSystem.cs

@@ -86,7 +86,7 @@ namespace DiskAccessLibrary.FileSystems.NTFS
             }
         }
 
-        public override Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share)
+        public override Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options)
         {
             if (mode == FileMode.Open || mode == FileMode.Truncate)
             {

+ 8 - 3
Utilities/IFileSystem/FileSystem.cs

@@ -13,7 +13,7 @@ namespace Utilities
         public abstract void Move(string source, string destination);
         public abstract void Delete(string path);
         public abstract List<FileSystemEntry> ListEntriesInDirectory(string path);
-        public abstract Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share);
+        public abstract Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options);
         public abstract void SetAttributes(string path, bool? isHidden, bool? isReadonly, bool? isArchived);
         public abstract void SetDates(string path, DateTime? creationDT, DateTime? lastWriteDT, DateTime? lastAccessDT);
 
@@ -22,6 +22,11 @@ namespace Utilities
             return ListEntriesInDirectory(@"\");
         }
 
+        public Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share)
+        {
+            return OpenFile(path, mode, access, share, FileOptions.None);
+        }
+
         public void CopyFile(string sourcePath, string destinationPath)
         {
             const int bufferLength = 1024 * 1024;
@@ -41,8 +46,8 @@ namespace Utilities
             {
                 destinationFile = CreateFile(destinationPath);
             }
-            Stream sourceStream = OpenFile(sourcePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
-            Stream destinationStream = OpenFile(destinationPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
+            Stream sourceStream = OpenFile(sourcePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, FileOptions.SequentialScan);
+            Stream destinationStream = OpenFile(destinationPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite, FileOptions.None);
             while (sourceStream.Position < sourceStream.Length)
             {
                 int readSize = (int)Math.Max(bufferLength, sourceStream.Length - sourceStream.Position);

+ 1 - 1
Utilities/IFileSystem/IFileSystem.cs

@@ -48,7 +48,7 @@ namespace Utilities
         /// <exception cref="System.IO.FileNotFoundException"></exception>
         /// <exception cref="System.IO.IOException"></exception>
         /// <exception cref="System.UnauthorizedAccessException"></exception>
-        Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share);
+        Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options);
 
         /// <exception cref="System.ArgumentException"></exception>
         /// <exception cref="System.IO.FileNotFoundException"></exception>