-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from 0xced/machO-shouldOwnStream
Fix shouldOwnStream argument of MachO instances
- Loading branch information
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace Tests | ||
{ | ||
public class StreamWrapper : Stream | ||
{ | ||
private readonly Stream stream; | ||
private readonly Action onDispose; | ||
|
||
public StreamWrapper(Stream stream, Action onDispose) | ||
{ | ||
this.stream = stream; | ||
this.onDispose = onDispose; | ||
} | ||
|
||
public override void Flush() => stream.Flush(); | ||
|
||
public override int Read(byte[] buffer, int offset, int count) => stream.Read(buffer, offset, count); | ||
|
||
public override long Seek(long offset, SeekOrigin origin) => stream.Seek(offset, origin); | ||
|
||
public override void SetLength(long value) => stream.SetLength(value); | ||
|
||
public override void Write(byte[] buffer, int offset, int count) => stream.Write(buffer, offset, count); | ||
|
||
public override bool CanRead => stream.CanRead; | ||
|
||
public override bool CanSeek => stream.CanSeek; | ||
|
||
public override bool CanWrite => stream.CanWrite; | ||
|
||
public override long Length => stream.Length; | ||
|
||
public override long Position | ||
{ | ||
get => stream.Position; | ||
set => stream.Position = value; | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
onDispose(); | ||
base.Dispose(disposing); | ||
} | ||
} | ||
} |