Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CopyToAsync() [4/4]

virtual Task System.IO.Stream.CopyToAsync ( Stream destination,
int bufferSize,
CancellationToken cancellationToken )
inlinevirtualinherited

Reimplemented in System.IO.Compression.DeflateStream, System.IO.Compression.GZipStream, System.IO.Compression.ZLibStream, System.IO.DelegatingStream, System.IO.ReadOnlyMemoryStream, System.Net.Http.DecompressionHandler.DeflateDecompressedContent.ZLibOrDeflateStream.PeekFirstByteReadStream, System.Net.Http.DecompressionHandler.DeflateDecompressedContent.ZLibOrDeflateStream, System.Net.Http.EmptyReadStream, System.Net.Http.Http2Connection.Http2Stream.Http2ReadStream, System.Net.Http.HttpConnection.ChunkedEncodingReadStream, System.Net.Http.HttpConnection.ConnectionCloseReadStream, System.Net.Http.HttpConnection.ContentLengthReadStream, System.Net.Http.HttpConnection.HttpContentWriteStream, System.Net.Http.HttpConnection.RawConnectionStream, System.Net.Http.HttpContent.LimitMemoryStream, System.Net.WebFileStream, System.IO.DelegatingStream, System.IO.Strategies.AsyncWindowsFileStreamStrategy, System.IO.Strategies.BufferedFileStreamStrategy, System.IO.Strategies.DerivedFileStreamStrategy, System.IO.Strategies.Net5CompatFileStreamStrategy, System.IO.BufferedStream, System.IO.FileStream, System.IO.MemoryStream, System.IO.Stream.NullStream, System.IO.UnmanagedMemoryStreamWrapper, and System.Security.Cryptography.CryptoStream.

Definition at line 586 of file Stream.cs.

587 {
589 if (!CanRead)
590 {
591 if (CanWrite)
592 {
593 ThrowHelper.ThrowNotSupportedException_UnreadableStream();
594 }
595 ThrowHelper.ThrowObjectDisposedException_StreamClosed(GetType().Name);
596 }
597 return Core(this, destination, bufferSize, cancellationToken);
598 static async Task Core(Stream source, Stream destination, int bufferSize, CancellationToken cancellationToken)
599 {
600 byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize);
601 try
602 {
603 int length;
604 while ((length = await source.ReadAsync(new Memory<byte>(buffer), cancellationToken).ConfigureAwait(continueOnCapturedContext: false)) != 0)
605 {
606 await destination.WriteAsync(new ReadOnlyMemory<byte>(buffer, 0, length), cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
607 }
608 }
609 finally
610 {
612 }
613 }
614 }
static ArrayPool< T > Shared
Definition ArrayPool.cs:7
static void ValidateCopyToArguments(Stream destination, int bufferSize)
Definition Stream.cs:1060

References System.buffer, System.cancellationToken, System.IO.Stream.CanRead, System.IO.Stream.CanWrite, System.destination, System.length, System.Name, System.Buffers.ArrayPool< T >.Shared, System.source, System.ThrowHelper.ThrowNotSupportedException_UnreadableStream(), System.ThrowHelper.ThrowObjectDisposedException_StreamClosed(), and System.IO.Stream.ValidateCopyToArguments().