mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 18:46:43 +00:00
Support for multiple args in file:read
This commit is contained in:
parent
e6c70d43a0
commit
eb58bdda14
1 changed files with 34 additions and 31 deletions
|
@ -193,43 +193,46 @@ public class FileHandle : IComponent
|
|||
L.PushString("l");
|
||||
}
|
||||
|
||||
bool success;
|
||||
if (L.Type(2) == LuaType.Number)
|
||||
for (int i = 2; i <= nargs + 1; i++)
|
||||
{
|
||||
success = ReadChars(L, stream, (int)L.ToNumber(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
var p = L.CheckString(2);
|
||||
var mode = CheckMode(p);
|
||||
switch (mode)
|
||||
bool success;
|
||||
if (L.Type(i) == LuaType.Number)
|
||||
{
|
||||
case 'n':
|
||||
success = ReadNumber(L, stream);
|
||||
break;
|
||||
case 'l':
|
||||
success = ReadLine(L, stream, true);
|
||||
break;
|
||||
case 'L':
|
||||
success = ReadLine(L, stream, false);
|
||||
break;
|
||||
case 'a':
|
||||
ReadAll(L, stream);
|
||||
success = true;
|
||||
break;
|
||||
default:
|
||||
return L.ArgumentError(2, "invalid format");
|
||||
success = ReadChars(L, stream, (int)L.ToNumber(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
var p = L.CheckString(i);
|
||||
var mode = CheckMode(p);
|
||||
switch (mode)
|
||||
{
|
||||
case 'n':
|
||||
success = ReadNumber(L, stream);
|
||||
break;
|
||||
case 'l':
|
||||
success = ReadLine(L, stream, true);
|
||||
break;
|
||||
case 'L':
|
||||
success = ReadLine(L, stream, false);
|
||||
break;
|
||||
case 'a':
|
||||
ReadAll(L, stream);
|
||||
success = true;
|
||||
break;
|
||||
default:
|
||||
return L.ArgumentError(i, "invalid format");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
L.Pop(1);
|
||||
L.PushNil();
|
||||
}
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
L.Pop(1);
|
||||
L.PushNil();
|
||||
}
|
||||
|
||||
return 1;
|
||||
return nargs;
|
||||
}
|
||||
|
||||
private static int L_Write(IntPtr state)
|
||||
|
|
Loading…
Reference in a new issue