mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-23 15:34:34 +00:00
Fix all platform support
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace SharpCompress.Archives.Rar
|
||||
|
||||
public IArchive Archive => archive;
|
||||
|
||||
internal override IEnumerable<FilePart> Parts => this.parts;
|
||||
internal override IEnumerable<FilePart> Parts => parts.Cast<FilePart>();
|
||||
|
||||
internal override FileHeader FileHeader => parts.First().FileHeader;
|
||||
|
||||
|
||||
@@ -10,10 +10,6 @@ using size_t = System.UInt64;
|
||||
using int64 = System.Int64;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharpCompress.Compressors.Rar.UnpackV2017
|
||||
{
|
||||
|
||||
@@ -334,7 +334,7 @@ void UnpWriteBuf()
|
||||
FragWindow.CopyData(Mem,0,BlockStart,BlockLength);
|
||||
else
|
||||
//x memcpy(Mem,Window+BlockStart,BlockLength);
|
||||
Array.Copy(Window, BlockStart, Mem, 0, BlockLength);
|
||||
Utility.Copy(Window, BlockStart, Mem, 0, BlockLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -347,9 +347,9 @@ void UnpWriteBuf()
|
||||
else
|
||||
{
|
||||
//x memcpy(Mem,Window+BlockStart,FirstPartLength);
|
||||
Array.Copy(Window, BlockStart, Mem, 0, FirstPartLength);
|
||||
Utility.Copy(Window, BlockStart, Mem, 0, FirstPartLength);
|
||||
//x memcpy(Mem+FirstPartLength,Window,BlockEnd);
|
||||
Array.Copy(Window, 0, Mem, FirstPartLength,BlockEnd);
|
||||
Utility.Copy(Window, 0, Mem, FirstPartLength,BlockEnd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
29
src/SharpCompress/Lazy.cs
Normal file
29
src/SharpCompress/Lazy.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace SharpCompress
|
||||
{
|
||||
public class Lazy<T>
|
||||
{
|
||||
private readonly Func<T> _lazyFunc;
|
||||
private bool _evaluated;
|
||||
private T _value;
|
||||
|
||||
public Lazy(Func<T> lazyFunc)
|
||||
{
|
||||
_lazyFunc = lazyFunc;
|
||||
}
|
||||
|
||||
public T Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_evaluated)
|
||||
{
|
||||
_value = _lazyFunc();
|
||||
_evaluated = true;
|
||||
}
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using SharpCompress.Common;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<AssemblyVersion>0.20.0</AssemblyVersion>
|
||||
<FileVersion>0.20.0</FileVersion>
|
||||
<Authors>Adam Hathcock</Authors>
|
||||
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">netstandard2.0</TargetFrameworks>
|
||||
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">net45;net35;netstandard1.0;netstandard1.3;netstandard2.0</TargetFrameworks>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AssemblyName>SharpCompress</AssemblyName>
|
||||
|
||||
@@ -184,6 +184,18 @@ namespace SharpCompress
|
||||
action(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Copy(Array sourceArray, long sourceIndex, Array destinationArray, long destinationIndex, long length)
|
||||
{
|
||||
if (sourceIndex > Int32.MaxValue || sourceIndex < Int32.MinValue)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
if (destinationIndex > Int32.MaxValue || destinationIndex < Int32.MinValue)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
if (length > Int32.MaxValue || length < Int32.MinValue)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
||||
Array.Copy(sourceArray, (int)sourceIndex, destinationArray, (int)destinationIndex, (int)length);
|
||||
}
|
||||
|
||||
public static IEnumerable<T> AsEnumerable<T>(this T item)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user