public class JseOsLib extends OsLib
LibFunction which implements the standard lua os library.
This contains more complete implementations of the following functions using features that are specific to JSE:
execute()remove()rename()tmpname()
Because the nature of the os library is to encapsulate
os-specific features, the behavior of these functions varies considerably
from their counterparts in the C platform.
Typically, this library is included as part of a call to
JsePlatform.standardGlobals()
Globals globals = JsePlatform.standardGlobals();
System.out.println( globals.get("os").get("time").call() );
For special cases where the smallest possible footprint is desired,
a minimal set of libraries could be loaded
directly via LuaValue.load(LuaValue) using code such as:
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new JseOsLib());
System.out.println( globals.get("os").get("time").call() );
However, other libraries such as MathLib are not loaded in this case.
LibFunction,
OsLib,
JsePlatform,
org.luaj.vm2.lib.jme.JmePlatform,
Lua 5.2 OS Lib Reference| 限定符和类型 | 字段和说明 |
|---|---|
static int |
EXEC_ERROR
return code indicating the execute() threw an unknown exception
|
static int |
EXEC_INTERRUPTED
return code indicating the execute() was interrupted
|
static int |
EXEC_IOEXCEPTION
return code indicating the execute() threw an I/O exception
|
globals, TMP_PREFIX, TMP_SUFFIXname, opcodes_metatableADD, BAND, BNOT, BOR, BXOR, CALL, CONCAT, DIV, EMPTYSTRING, ENV, EQ, FALSE, IDIV, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILS, NONE, NOVALS, ONE, POW, SHL, SHR, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, uservalue, ZERO| 构造器和说明 |
|---|
JseOsLib()
public constructor
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected Varargs |
execute(String command)
This function is equivalent to the C function system.
|
protected String |
getenv(String varname)
Returns the value of the process environment variable varname,
or the System property value for varname,
or null if the variable is not defined in either environment.
|
protected void |
remove(String filename)
Deletes the file or directory with the given name.
|
protected void |
rename(String oldname,
String newname)
Renames file or directory named oldname to newname.
|
protected String |
tmpname()
Returns a string with a file name that can be used for a temporary file.
|
call, call, call, invokecheckfunction, classnamestub, getfenv, getmetatable, isfunction, name, optfunction, setfenv, strvalue, type, typenameadd, add, add, and, arg, arg1, argerror, argerror, aritherror, aritherror, arithmt, arithmtwith, assert_, band, band, bnot, bor, bor, buffer, bxor, bxor, call, callmt, checkboolean, checkclosure, checkdouble, checkglobals, checkint, checkinteger, checkjstring, checklong, checkmetatag, checknotnil, checknumber, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, compareerror, compareerror, comparemt, concat, concat, concatmt, concatTo, concatTo, concatTo, div, div, div, divInto, eq_b, eq, eqmtcall, equals, error, get, get, get, gettable, getuservalue, gt_b, gt_b, gt_b, gt, gt, gt, gteq_b, gteq_b, gteq_b, gteq, gteq, gteq, idiv, idiv, illegal, inext, initupvalue1, invoke, invoke, invoke, invoke, invoke, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, invokemethod, isboolean, isclosure, isint, isinttype, islong, isnil, isnumber, isstring, istable, isthread, isuserdata, isuserdata, isvalidkey, jcall, jget, jset, len, lenerror, length, listOf, listOf, load, lt_b, lt_b, lt_b, lt, lt, lt, lteq_b, lteq_b, lteq_b, lteq, lteq, lteq, metatableOf, metatag, method, method, method, method, method, method, mod, mod, mod, modFrom, mul, mul, mul, narg, neg, neq_b, neq, next, not, onInvoke, optboolean, optclosure, optdouble, optint, optinteger, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, or, pow, pow, pow, powWith, powWith, presize, raweq, raweq, raweq, raweq, raweq, rawget, rawget, rawget, rawlen, rawset, rawset, rawset, rawset, rawset, rawset, rawset, rawsetlist, set, set, set, set, set, set, set, setmetatable, settable, setuservalue, shl, shl, shr, shr, strcmp, strcmp, strongvalue, sub, sub, sub, subargs, subFrom, subFrom, tableOf, tableOf, tableOf, tableOf, tableOf, tableOf, tailcallOf, testfor_b, toboolean, tobyte, tochar, todouble, tofloat, toint, tolong, tonumber, toshort, tostring, toString, touserdata, touserdata, typerror, unimplemented, userdataOf, userdataOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, valueOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOf, varargsOfargcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, dealias, eval, isfunction, isnil, isnoneornil, isnumber, isstring, istable, isTailcall, isthread, isuserdata, isvalue, optboolean, optclosure, optdouble, optfunction, optint, optinteger, optjstring, optlong, optnumber, optstring, opttable, optthread, optuserdata, optuserdata, optvalue, toboolean, tobyte, tochar, todouble, tofloat, toint, tojstring, tolong, toshort, touserdata, touserdata, typepublic static int EXEC_IOEXCEPTION
public static int EXEC_INTERRUPTED
public static int EXEC_ERROR
protected String getenv(String varname)
OsLibprotected Varargs execute(String command)
OsLibprotected void remove(String filename) throws IOException
OsLibremove 在类中 OsLibIOException - if it failsprotected void rename(String oldname, String newname) throws IOException
OsLibrename 在类中 OsLiboldname - old file namenewname - new file nameIOException - if it failsprotected String tmpname()
OsLibCopyright © 2020. All rights reserved.