blob: 73a423288477c28b45743caf59992ccb5e643575 [file] [log] [blame]
Jens Geyer197b0622017-05-31 10:35:00 +02001using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Linq;
5using System.Text;
6
7#if (!NET45)
8namespace Thrift
9{
10 static class StreamExtensionsNet35
11 {
12 // CopyTo() has been added in 4.0
13 public static long CopyTo(this Stream source, Stream target)
14 {
15 byte[] buffer = new byte[8192]; // multiple of 4096
16 long nTotal = 0;
17 while (true)
18 {
19 int nRead = source.Read(buffer, 0, buffer.Length);
20 if (nRead <= 0) // done?
21 return nTotal;
22
23 target.Write(buffer, 0, nRead);
24 nTotal += nRead;
25 }
26 }
27 }
28
29}
30#endif
31