Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
GZipStream.cs
Go to the documentation of this file.
3
5
6public class GZipStream : Stream
7{
9
10 public override bool CanRead => _deflateStream?.CanRead ?? false;
11
12 public override bool CanWrite => _deflateStream?.CanWrite ?? false;
13
14 public override bool CanSeek => _deflateStream?.CanSeek ?? false;
15
16 public override long Length
17 {
18 get
19 {
21 }
22 }
23
24 public override long Position
25 {
26 get
27 {
29 }
30 set
31 {
33 }
34 }
35
37
39 : this(stream, mode, leaveOpen: false)
40 {
41 }
42
43 public GZipStream(Stream stream, CompressionMode mode, bool leaveOpen)
44 {
45 _deflateStream = new DeflateStream(stream, mode, leaveOpen, 31, -1L);
46 }
47
48 public GZipStream(Stream stream, CompressionLevel compressionLevel)
49 : this(stream, compressionLevel, leaveOpen: false)
50 {
51 }
52
53 public GZipStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen)
54 {
55 _deflateStream = new DeflateStream(stream, compressionLevel, leaveOpen, 31);
56 }
57
58 public override void Flush()
59 {
62 }
63
64 public override long Seek(long offset, SeekOrigin origin)
65 {
67 }
68
69 public override void SetLength(long value)
70 {
72 }
73
74 public override int ReadByte()
75 {
77 return _deflateStream.ReadByte();
78 }
79
80 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback? asyncCallback, object? asyncState)
81 {
82 return System.Threading.Tasks.TaskToApm.Begin(ReadAsync(buffer, offset, count, CancellationToken.None), asyncCallback, asyncState);
83 }
84
85 public override int EndRead(IAsyncResult asyncResult)
86 {
88 }
89
90 public override int Read(byte[] buffer, int offset, int count)
91 {
94 }
95
96 public override int Read(Span<byte> buffer)
97 {
98 if (GetType() != typeof(GZipStream))
99 {
100 return base.Read(buffer);
101 }
104 }
105
106 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback? asyncCallback, object? asyncState)
107 {
108 return System.Threading.Tasks.TaskToApm.Begin(WriteAsync(buffer, offset, count, CancellationToken.None), asyncCallback, asyncState);
109 }
110
111 public override void EndWrite(IAsyncResult asyncResult)
112 {
114 }
115
116 public override void Write(byte[] buffer, int offset, int count)
117 {
120 }
121
122 public override void Write(ReadOnlySpan<byte> buffer)
123 {
124 if (GetType() != typeof(GZipStream))
125 {
126 base.Write(buffer);
127 return;
128 }
131 }
132
133 public override void CopyTo(Stream destination, int bufferSize)
134 {
136 _deflateStream.CopyTo(destination, bufferSize);
137 }
138
139 protected override void Dispose(bool disposing)
140 {
141 try
142 {
143 if (disposing && _deflateStream != null)
144 {
146 }
147 _deflateStream = null;
148 }
149 finally
150 {
151 base.Dispose(disposing);
152 }
153 }
154
155 public override ValueTask DisposeAsync()
156 {
157 if (GetType() != typeof(GZipStream))
158 {
159 return base.DisposeAsync();
160 }
161 DeflateStream deflateStream = _deflateStream;
162 if (deflateStream != null)
163 {
164 _deflateStream = null;
165 return deflateStream.DisposeAsync();
166 }
167 return default(ValueTask);
168 }
169
175
177 {
178 if (GetType() != typeof(GZipStream))
179 {
180 return base.ReadAsync(buffer, cancellationToken);
181 }
184 }
185
191
193 {
194 if (GetType() != typeof(GZipStream))
195 {
196 return base.WriteAsync(buffer, cancellationToken);
197 }
200 }
201
207
213
214 private void CheckDeflateStream()
215 {
216 if (_deflateStream == null)
217 {
219 }
220 }
221
222 private static void ThrowStreamClosedException()
223 {
225 }
226}
override void EndWrite(IAsyncResult asyncResult)
override Task< int > ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override Task FlushAsync(CancellationToken cancellationToken)
override void Write(byte[] buffer, int offset, int count)
ValueTask WriteAsyncMemory(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken)
override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override int EndRead(IAsyncResult asyncResult)
override void CopyTo(Stream destination, int bufferSize)
override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
unsafe void WriteCore(ReadOnlySpan< byte > buffer)
ValueTask< int > ReadAsyncMemory(Memory< byte > buffer, CancellationToken cancellationToken)
int ReadCore(Span< byte > buffer)
override int Read(byte[] buffer, int offset, int count)
override void Dispose(bool disposing)
override void SetLength(long value)
Definition GZipStream.cs:69
override int EndRead(IAsyncResult asyncResult)
Definition GZipStream.cs:85
override int Read(Span< byte > buffer)
Definition GZipStream.cs:96
override void Write(ReadOnlySpan< byte > buffer)
override long Seek(long offset, SeekOrigin origin)
Definition GZipStream.cs:64
GZipStream(Stream stream, CompressionMode mode, bool leaveOpen)
Definition GZipStream.cs:43
override void Write(byte[] buffer, int offset, int count)
override void EndWrite(IAsyncResult asyncResult)
override Task< int > ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
static void ThrowStreamClosedException()
override Task FlushAsync(CancellationToken cancellationToken)
override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
GZipStream(Stream stream, CompressionLevel compressionLevel)
Definition GZipStream.cs:48
override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback? asyncCallback, object? asyncState)
override ValueTask DisposeAsync()
GZipStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen)
Definition GZipStream.cs:53
override void CopyTo(Stream destination, int bufferSize)
GZipStream(Stream stream, CompressionMode mode)
Definition GZipStream.cs:38
override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override ValueTask< int > ReadAsync(Memory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback? asyncCallback, object? asyncState)
Definition GZipStream.cs:80
override int Read(byte[] buffer, int offset, int count)
Definition GZipStream.cs:90
override void Dispose(bool disposing)
static string ObjectDisposed_StreamClosed
Definition SR.cs:20
static string NotSupported
Definition SR.cs:28
Definition SR.cs:7
static IAsyncResult Begin(Task task, AsyncCallback callback, object state)
Definition TaskToApm.cs:43