Browse Source

Updated Utilities

Tal Aloni 6 years ago
parent
commit
fa0e6d7b67

+ 0 - 1
Utilities/ByteUtils/BigEndianReader.cs

@@ -1,6 +1,5 @@
 using System;
 using System.IO;
-using System.Text;
 
 namespace Utilities
 {

+ 0 - 1
Utilities/ByteUtils/BigEndianWriter.cs

@@ -1,6 +1,5 @@
 using System;
 using System.IO;
-using System.Text;
 
 namespace Utilities
 {

+ 0 - 1
Utilities/ByteUtils/ByteUtils.cs

@@ -1,6 +1,5 @@
 using System;
 using System.IO;
-using System.Text;
 
 namespace Utilities
 {

+ 0 - 1
Utilities/ByteUtils/LittleEndianReader.cs

@@ -1,6 +1,5 @@
 using System;
 using System.IO;
-using System.Text;
 
 namespace Utilities
 {

+ 0 - 1
Utilities/ByteUtils/LittleEndianWriter.cs

@@ -1,6 +1,5 @@
 using System;
 using System.IO;
-using System.Text;
 
 namespace Utilities
 {

+ 0 - 1
Utilities/Comparers/ReverseComparer.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Text;
 
 namespace Utilities
 {

+ 0 - 1
Utilities/Conversion/BigEndianConverter.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Text;
 
 namespace Utilities
 {

+ 0 - 1
Utilities/Conversion/LittleEndianConverter.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Text;
 
 namespace Utilities
 {

+ 29 - 0
Utilities/IFileSystem/FileSystem.cs

@@ -22,6 +22,17 @@ namespace Utilities
             return ListEntriesInDirectory(@"\");
         }
 
+        public virtual List<KeyValuePair<string, ulong>> ListDataStreams(string path)
+        {
+            FileSystemEntry entry = GetEntry(path);
+            List<KeyValuePair<string, ulong>> result = new List<KeyValuePair<string, ulong>>();
+            if (!entry.IsDirectory)
+            {
+                result.Add(new KeyValuePair<string, ulong>("::$DATA", entry.Size));
+            }
+            return result;
+        }
+
         public Stream OpenFile(string path, FileMode mode, FileAccess access, FileShare share)
         {
             return OpenFile(path, mode, access, share, FileOptions.None);
@@ -59,6 +70,24 @@ namespace Utilities
             destinationStream.Close();
         }
 
+        public virtual bool Exists(string path)
+        {
+            try
+            {
+                GetEntry(path);
+            }
+            catch (FileNotFoundException)
+            {
+                return false;
+            }
+            catch (DirectoryNotFoundException)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
         public abstract string Name
         {
             get;

+ 8 - 9
Utilities/IFileSystem/IFileSystem.cs

@@ -6,57 +6,56 @@ namespace Utilities
 {
     public interface IFileSystem
     {
-        /// <exception cref="System.ArgumentException"></exception>
+        /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
+        /// <exception cref="System.IO.FileNotFoundException"></exception>
         /// <exception cref="System.IO.IOException"></exception>
         /// <exception cref="System.UnauthorizedAccessException"></exception>
         FileSystemEntry GetEntry(string path);
 
-        /// <exception cref="System.ArgumentException"></exception>
         /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
         /// <exception cref="System.IO.IOException"></exception>
         /// <exception cref="System.UnauthorizedAccessException"></exception>
         FileSystemEntry CreateFile(string path);
 
-        /// <exception cref="System.ArgumentException"></exception>
         /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
         /// <exception cref="System.IO.IOException"></exception>
         /// <exception cref="System.UnauthorizedAccessException"></exception>
         FileSystemEntry CreateDirectory(string path);
 
-        /// <exception cref="System.ArgumentException"></exception>
         /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
         /// <exception cref="System.IO.FileNotFoundException"></exception>
         /// <exception cref="System.IO.IOException"></exception>
         /// <exception cref="System.UnauthorizedAccessException"></exception>
         void Move(string source, string destination);
 
-        /// <exception cref="System.ArgumentException"></exception>
         /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
         /// <exception cref="System.IO.FileNotFoundException"></exception>
         /// <exception cref="System.IO.IOException"></exception>
         /// <exception cref="System.UnauthorizedAccessException"></exception>
         void Delete(string path);
 
-        /// <exception cref="System.ArgumentException"></exception>
         /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
         /// <exception cref="System.IO.IOException"></exception>
         /// <exception cref="System.UnauthorizedAccessException"></exception>
         List<FileSystemEntry> ListEntriesInDirectory(string path);
 
-        /// <exception cref="System.ArgumentException"></exception>
+        /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
+        /// <exception cref="System.IO.FileNotFoundException"></exception>
+        /// <exception cref="System.IO.IOException"></exception>
+        /// <exception cref="System.UnauthorizedAccessException"></exception>
+        List<KeyValuePair<string, ulong>> ListDataStreams(string path);
+
         /// <exception cref="System.IO.DirectoryNotFoundException"></exception>
         /// <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, FileOptions options);
 
-        /// <exception cref="System.ArgumentException"></exception>
         /// <exception cref="System.IO.FileNotFoundException"></exception>
         /// <exception cref="System.IO.IOException"></exception>
         /// <exception cref="System.UnauthorizedAccessException"></exception>
         void SetAttributes(string path, bool? isHidden, bool? isReadonly, bool? isArchived);
 
-        /// <exception cref="System.ArgumentException"></exception>
         /// <exception cref="System.IO.FileNotFoundException"></exception>
         /// <exception cref="System.IO.IOException"></exception>
         /// <exception cref="System.UnauthorizedAccessException"></exception>