mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-03-02 18:00:05 +00:00
Use longs instead of ints within .seek
Some crazy person decided they wanted a 20GB file. I'm not judging.
This commit is contained in:
parent
afdfcb21b7
commit
949b71d40c
@ -70,12 +70,17 @@ public final class ArgumentHelper
|
||||
}
|
||||
|
||||
public static int getInt( @Nonnull Object[] args, int index ) throws LuaException
|
||||
{
|
||||
return (int) getLong( args, index );
|
||||
}
|
||||
|
||||
public static long getLong( @Nonnull Object[] args, int index ) throws LuaException
|
||||
{
|
||||
if( index >= args.length ) throw badArgument( index, "number", "nil" );
|
||||
Object value = args[ index ];
|
||||
if( value instanceof Number )
|
||||
{
|
||||
return (int) ((Number) value).longValue();
|
||||
return checkReal( index, (Number) value ).longValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -151,6 +156,11 @@ public final class ArgumentHelper
|
||||
}
|
||||
|
||||
public static int optInt( @Nonnull Object[] args, int index, int def ) throws LuaException
|
||||
{
|
||||
return (int) optLong( args, index, def );
|
||||
}
|
||||
|
||||
public static long optLong( @Nonnull Object[] args, int index, long def ) throws LuaException
|
||||
{
|
||||
Object value = index < args.length ? args[ index ] : null;
|
||||
if( value == null )
|
||||
@ -159,7 +169,7 @@ public final class ArgumentHelper
|
||||
}
|
||||
else if( value instanceof Number )
|
||||
{
|
||||
return (int) ((Number) value).longValue();
|
||||
return checkReal( index, (Number) value ).longValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -224,6 +234,12 @@ public final class ArgumentHelper
|
||||
}
|
||||
}
|
||||
|
||||
private static Number checkReal( int index, Number value ) throws LuaException
|
||||
{
|
||||
checkReal( index, value.doubleValue() );
|
||||
return value;
|
||||
}
|
||||
|
||||
private static double checkReal( int index, double value ) throws LuaException
|
||||
{
|
||||
if( Double.isNaN( value ) )
|
||||
|
@ -9,7 +9,7 @@ import java.io.IOException;
|
||||
import java.nio.channels.Channel;
|
||||
import java.nio.channels.SeekableByteChannel;
|
||||
|
||||
import static dan200.computercraft.core.apis.ArgumentHelper.optInt;
|
||||
import static dan200.computercraft.core.apis.ArgumentHelper.optLong;
|
||||
import static dan200.computercraft.core.apis.ArgumentHelper.optString;
|
||||
|
||||
public abstract class HandleGeneric implements ILuaObject
|
||||
@ -54,7 +54,7 @@ public abstract class HandleGeneric implements ILuaObject
|
||||
try
|
||||
{
|
||||
String whence = optString( args, 0, "cur" );
|
||||
long offset = optInt( args, 1, 0 );
|
||||
long offset = optLong( args, 1, 0 );
|
||||
switch( whence )
|
||||
{
|
||||
case "set":
|
||||
|
Loading…
x
Reference in New Issue
Block a user