三国卡牌客户端基础资源仓库
hch
2025-06-20 4841e82bd5e399c4fc39313bbc93c6fc1bb12b2a
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
using System.IO;
 
namespace UnityFS
{
    public static class StreamExtensions
    {
        private const int BufferSize = 81920;
 
        public static void CopyTo(this Stream source, Stream destination, long size)
        {
            var buffer = new byte[BufferSize];
            for (var left = size; left > 0; left -= BufferSize)
            {
                int toRead = BufferSize < left ? BufferSize : (int)left;
                int read = source.Read(buffer, 0, toRead);
                destination.Write(buffer, 0, read);
                if (read != toRead)
                {
                    return;
                }
            }
        }
 
        public static byte[] ReadAllBytes(this Stream source)
        {
            source.Position = 0;
            var bytes = new byte[source.Length];
            source.Read(bytes, 0, bytes.Length);
            return bytes;
        }
    }
}