|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.luaj.vm2.Varargs
org.luaj.vm2.LuaValue
org.luaj.vm2.LuaFunction
org.luaj.vm2.lib.LibFunction
org.luaj.vm2.lib.TwoArgFunction
org.luaj.vm2.lib.OsLib
public class OsLib
Subclass of LibFunction
which implements the standard lua os
library.
It is a usable base with simplified stub functions for library functions that cannot be implemented uniformly on Jse and Jme.
This can be installed as-is on either platform, or extended and refined to be used in a complete Jse implementation.
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.
The following functions have limited implementations of features that are not supported well on Jme:
execute()
remove()
rename()
tmpname()
Typically, this library is included as part of a call to either
JsePlatform.standardGlobals()
or JmePlatform.standardGlobals()
Globals globals = JsePlatform.standardGlobals();
System.out.println( globals.get("os").get("time").call() );
In this example the platform-specific JseOsLib
library will be loaded, which will include
the base functionality provided by this class.
To instantiate and use it directly,
link it into your globals table via LuaValue.load(LuaValue)
using code such as:
Globals globals = new Globals();
globals.load(new JseBaseLib());
globals.load(new PackageLib());
globals.load(new OsLib());
System.out.println( globals.get("os").get("time").call() );
LibFunction
,
JseOsLib
,
JsePlatform
,
JmePlatform
,
http://www.lua.org/manual/5.1/manual.html#5.8Field Summary | |
---|---|
protected Globals |
globals
|
static java.lang.String |
TMP_PREFIX
|
static java.lang.String |
TMP_SUFFIX
|
Fields inherited from class org.luaj.vm2.lib.LibFunction |
---|
name, opcode |
Fields inherited from class org.luaj.vm2.LuaFunction |
---|
s_metatable |
Fields inherited from class org.luaj.vm2.LuaValue |
---|
ADD, CALL, CONCAT, DIV, EMPTYSTRING, ENV, EQ, FALSE, INDEX, LE, LEN, LT, METATABLE, MINUSONE, MOD, MODE, MUL, NEWINDEX, NIL, NILS, NONE, NOVALS, ONE, POW, SUB, TBOOLEAN, TFUNCTION, TINT, TLIGHTUSERDATA, TNIL, TNONE, TNUMBER, TOSTRING, TRUE, TSTRING, TTABLE, TTHREAD, TUSERDATA, TVALUE, TYPE_NAMES, UNM, ZERO |
Constructor Summary | |
---|---|
OsLib()
Create and OsLib instance. |
Method Summary | |
---|---|
LuaValue |
call(LuaValue modname,
LuaValue env)
Perform one-time initialization on the library by creating a table containing the library functions, adding that table to the supplied environment, adding the table to package.loaded, and returning table as the return value. |
protected double |
clock()
|
java.lang.String |
date(java.lang.String format,
double time)
If the time argument is present, this is the time to be formatted (see the os.time function for a description of this value). |
protected double |
difftime(double t2,
double t1)
Returns the number of seconds from time t1 to time t2. |
protected Varargs |
execute(java.lang.String command)
This function is equivalent to the C function system. |
protected void |
exit(int code)
Calls the C function exit, with an optional code, to terminate the host program. |
protected java.lang.String |
getenv(java.lang.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(java.lang.String filename)
Deletes the file or directory with the given name. |
protected void |
rename(java.lang.String oldname,
java.lang.String newname)
Renames file or directory named oldname to newname. |
protected java.lang.String |
setlocale(java.lang.String locale,
java.lang.String category)
Sets the current locale of the program. |
protected double |
time(LuaTable table)
Returns the current time when called without arguments, or a time representing the date and time specified by the given table. |
protected java.lang.String |
tmpname()
Returns a string with a file name that can be used for a temporary file. |
Methods inherited from class org.luaj.vm2.lib.TwoArgFunction |
---|
call, call, call, invoke |
Methods inherited from class org.luaj.vm2.lib.LibFunction |
---|
bind, bind, call, newupe, newupl, newupn, tojstring |
Methods inherited from class org.luaj.vm2.LuaFunction |
---|
checkfunction, classnamestub, getmetatable, isfunction, name, optfunction, strvalue, type, typename |
Methods inherited from class org.luaj.vm2.Varargs |
---|
argcheck, checkboolean, checkclosure, checkdouble, checkfunction, checkint, checkinteger, checkjstring, checklong, checknotnil, checknumber, checkstring, checktable, checkthread, checkuserdata, checkuserdata, checkvalue, 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, type |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static java.lang.String TMP_PREFIX
public static java.lang.String TMP_SUFFIX
protected Globals globals
Constructor Detail |
---|
public OsLib()
Method Detail |
---|
public LuaValue call(LuaValue modname, LuaValue env)
call
in class TwoArgFunction
modname
- the module name supplied if this is loaded via 'require'.env
- the environment to load into, typically a Globals instance.
(this(arg1,arg2))
, or LuaValue.NIL
if there were none.LuaValue.call()
,
LuaValue.call(LuaValue)
,
LuaValue.call(LuaValue, LuaValue, LuaValue)
,
LuaValue.invoke(LuaValue, Varargs)
,
LuaValue.method(String,LuaValue,LuaValue)
,
LuaValue.method(LuaValue,LuaValue,LuaValue)
protected double clock()
protected double difftime(double t2, double t1)
t2
- t1
-
public java.lang.String date(java.lang.String format, double time)
format
- time
- time since epoch, or -1 if not supplied
protected Varargs execute(java.lang.String command)
command
- command to pass to the systemprotected void exit(int code)
code
- protected java.lang.String getenv(java.lang.String varname)
varname
-
protected void remove(java.lang.String filename) throws java.io.IOException
filename
-
java.io.IOException
- if it failsprotected void rename(java.lang.String oldname, java.lang.String newname) throws java.io.IOException
oldname
- old file namenewname
- new file name
java.io.IOException
- if it failsprotected java.lang.String setlocale(java.lang.String locale, java.lang.String category)
locale
- category
-
protected double time(LuaTable table)
table
-
protected java.lang.String tmpname()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |