forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteStream.cs
More file actions
63 lines (50 loc) · 1.61 KB
/
WriteStream.cs
File metadata and controls
63 lines (50 loc) · 1.61 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.IO;
namespace LibGit2Sharp.Core
{
class WriteStream : Stream
{
readonly GitWriteStream nextStream;
readonly IntPtr nextPtr;
public WriteStream(GitWriteStream nextStream, IntPtr nextPtr)
{
this.nextStream = nextStream;
this.nextPtr = nextPtr;
}
public override bool CanWrite { get { return true; } }
public override bool CanRead { get { return false; } }
public override bool CanSeek { get { return false; } }
public override long Position
{
get { throw new NotImplementedException(); }
set { throw new InvalidOperationException(); }
}
public override long Length { get { throw new InvalidOperationException(); } }
public override void Flush()
{ }
public override void SetLength(long value)
{
throw new InvalidOperationException();
}
public override int Read(byte[] buffer, int offset, int count)
{
throw new InvalidOperationException();
}
public override long Seek(long offset, SeekOrigin origin)
{
throw new InvalidOperationException();
}
public override void Write(byte[] buffer, int offset, int count)
{
int res;
unsafe
{
fixed (byte* bufferPtr = &buffer[offset])
{
res = nextStream.write(nextPtr, (IntPtr)bufferPtr, (UIntPtr)count);
}
}
Ensure.Int32Result(res);
}
}
}