mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 20:04:13 +08:00
(LittleEndian): methods made generic.
This commit is contained in:
parent
bb18303eb4
commit
762396d045
@ -109,7 +109,7 @@ namespace GameRes.Formats.Abel
|
|||||||
{
|
{
|
||||||
uint offset = arc.File.View.ReadUInt32 (entry.Offset+8);
|
uint offset = arc.File.View.ReadUInt32 (entry.Offset+8);
|
||||||
if (offset >= entry.Size)
|
if (offset >= entry.Size)
|
||||||
return base.OpenEntry (arc, entry);
|
return base.OpenEntry (arc, entry);
|
||||||
return arc.File.CreateStream (entry.Offset+offset, entry.Size-offset);
|
return arc.File.CreateStream (entry.Offset+offset, entry.Size-offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,7 @@ namespace GameRes.Utility
|
|||||||
|
|
||||||
public static bool AsciiEqual (byte[] name1, int offset, string name2)
|
public static bool AsciiEqual (byte[] name1, int offset, string name2)
|
||||||
{
|
{
|
||||||
if (name1.Length-offset < name2.Length)
|
return name1.AsciiEqual (offset, name2);
|
||||||
return false;
|
|
||||||
for (int i = 0; i < name2.Length; ++i)
|
|
||||||
if ((char)name1[offset+i] != name2[i])
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CopyOverlapped (byte[] data, int src, int dst, int count)
|
public static void CopyOverlapped (byte[] data, int src, int dst, int count)
|
||||||
@ -169,12 +164,12 @@ namespace GameRes.Utility
|
|||||||
|
|
||||||
public static class LittleEndian
|
public static class LittleEndian
|
||||||
{
|
{
|
||||||
public static ushort ToUInt16 (byte[] value, int index)
|
public static ushort ToUInt16<TArray> (TArray value, int index) where TArray : IList<byte>
|
||||||
{
|
{
|
||||||
return (ushort)(value[index] | value[index+1] << 8);
|
return (ushort)(value[index] | value[index+1] << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static short ToInt16 (byte[] value, int index)
|
public static short ToInt16<TArray> (TArray value, int index) where TArray : IList<byte>
|
||||||
{
|
{
|
||||||
return (short)(value[index] | value[index+1] << 8);
|
return (short)(value[index] | value[index+1] << 8);
|
||||||
}
|
}
|
||||||
@ -184,17 +179,17 @@ namespace GameRes.Utility
|
|||||||
return (uint)(value[index] | value[index+1] << 8 | value[index+2] << 16 | value[index+3] << 24);
|
return (uint)(value[index] | value[index+1] << 8 | value[index+2] << 16 | value[index+3] << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int ToInt32 (byte[] value, int index)
|
public static int ToInt32<TArray> (TArray value, int index) where TArray : IList<byte>
|
||||||
{
|
{
|
||||||
return (int)ToUInt32 (value, index);
|
return (int)ToUInt32 (value, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ulong ToUInt64 (byte[] value, int index)
|
public static ulong ToUInt64<TArray> (TArray value, int index) where TArray : IList<byte>
|
||||||
{
|
{
|
||||||
return (ulong)ToUInt32 (value, index) | ((ulong)ToUInt32 (value, index+4) << 32);
|
return (ulong)ToUInt32 (value, index) | ((ulong)ToUInt32 (value, index+4) << 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long ToInt64 (byte[] value, int index)
|
public static long ToInt64<TArray> (TArray value, int index) where TArray : IList<byte>
|
||||||
{
|
{
|
||||||
return (long)ToUInt64 (value, index);
|
return (long)ToUInt64 (value, index);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user