Remove dependency on System.Linq

master
~lucidiot 10 months ago
parent 2474da3ba1
commit ebda8dbed3
  1. 23
      KaitaiStream.cs

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Globalization;
namespace Kaitai
@ -615,7 +614,8 @@ namespace Kaitai
{
using (MemoryStream target = new MemoryStream())
{
ds.CopyTo(target);
byte[] buffer = new byte[32768];
CopyTo(target, ds);
return target.ToArray();
}
}
@ -708,5 +708,24 @@ namespace Kaitai
}
#endregion
#region Compatibility methods
/// <summary>
/// Replaces Stream.CopyTo from System.Linq for backwards compatibility.
/// </summary>
/// <param name="source">Stream to copy data from.</param>
/// <param name="destination">Stream to copy data to.</param>
private static void CopyTo(Stream source, Stream destination)
{
byte[] buffer = new byte[32768];
int read;
while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
{
destination.Write(buffer, 0, read);
}
}
#endregion
}
}

Loading…
Cancel
Save