Updated Utilities

This commit is contained in:
Tal Aloni 2018-11-30 14:38:05 +02:00
parent 41474b87ac
commit 73b6c288a4
2 changed files with 38 additions and 0 deletions

View file

@ -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;