forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRawContentStream.cs
More file actions
30 lines (26 loc) · 892 Bytes
/
RawContentStream.cs
File metadata and controls
30 lines (26 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.IO;
using LibGit2Sharp.Core.Handles;
namespace LibGit2Sharp.Core
{
internal class RawContentStream : UnmanagedMemoryStream
{
private readonly ObjectSafeWrapper wrapper;
internal RawContentStream(ObjectId id, RepositorySafeHandle repo,
Func<GitObjectSafeHandle, IntPtr> bytePtrProvider, long length)
: this(new ObjectSafeWrapper(id, repo), bytePtrProvider, length)
{
}
unsafe RawContentStream(ObjectSafeWrapper wrapper,
Func<GitObjectSafeHandle, IntPtr> bytePtrProvider, long length)
: base((byte*)bytePtrProvider(wrapper.ObjectPtr).ToPointer(), length)
{
this.wrapper = wrapper;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
wrapper.SafeDispose();
}
}
}