From 73b6c288a448b7e584f8199bb9d4c43cb78d0584 Mon Sep 17 00:00:00 2001 From: Tal Aloni Date: Fri, 30 Nov 2018 14:38:05 +0200 Subject: [PATCH] Updated Utilities --- Utilities/IFileSystem/FileSystem.cs | 29 ++++++++++++++++++++++++++++ Utilities/IFileSystem/IFileSystem.cs | 9 +++++++++ 2 files changed, 38 insertions(+) diff --git a/Utilities/IFileSystem/FileSystem.cs b/Utilities/IFileSystem/FileSystem.cs index 1245005..897eddc 100644 --- a/Utilities/IFileSystem/FileSystem.cs +++ b/Utilities/IFileSystem/FileSystem.cs @@ -22,6 +22,17 @@ namespace Utilities return ListEntriesInDirectory(@"\"); } + public virtual List> ListDataStreams(string path) + { + FileSystemEntry entry = GetEntry(path); + List> result = new List>(); + if (!entry.IsDirectory) + { + result.Add(new KeyValuePair("::$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; diff --git a/Utilities/IFileSystem/IFileSystem.cs b/Utilities/IFileSystem/IFileSystem.cs index 9894ce8..a09a2e4 100644 --- a/Utilities/IFileSystem/IFileSystem.cs +++ b/Utilities/IFileSystem/IFileSystem.cs @@ -7,6 +7,8 @@ namespace Utilities public interface IFileSystem { /// + /// + /// /// /// FileSystemEntry GetEntry(string path); @@ -43,6 +45,13 @@ namespace Utilities /// List ListEntriesInDirectory(string path); + /// + /// + /// + /// + /// + List> ListDataStreams(string path); + /// /// ///