Skip to content

Commit

Permalink
Add file access overload to RootStorage.Open
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-visionaid committed Nov 21, 2024
1 parent 8124b1c commit 1c1d53e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions OpenMcdf.Tests/RootStorageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void Open(string fileName)
using var rootStorage2 = RootStorage.OpenRead(fileName);

Assert.ThrowsException<IOException>(() => RootStorage.Open(fileName, FileMode.Open));
Assert.ThrowsException<IOException>(() => RootStorage.Open(fileName, FileMode.Open, FileAccess.ReadWrite));
Assert.ThrowsException<IOException>(() => RootStorage.OpenWrite(fileName));
}

Expand Down
8 changes: 8 additions & 0 deletions OpenMcdf/RootStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ public static RootStorage Open(string fileName, FileMode mode, StorageModeFlags
return Open(stream, flags);
}

public static RootStorage Open(string fileName, FileMode mode, FileAccess access, StorageModeFlags flags = StorageModeFlags.None)
{
ThrowIfLeaveOpen(flags);

FileStream stream = File.Open(fileName, mode, access);
return Open(stream, flags);
}

public static RootStorage Open(Stream stream, StorageModeFlags flags = StorageModeFlags.None)
{
stream.ThrowIfNotSeekable();
Expand Down

0 comments on commit 1c1d53e

Please sign in to comment.