Class JseOsLib

All Implemented Interfaces:
KryoSerializable

public class JseOsLib extends OsLib
Subclass of 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 org.luaj.vm2.lib.jse.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.

See Also:
  • Field Details

    • EXEC_IOEXCEPTION

      public static final int EXEC_IOEXCEPTION
      return code indicating the execute() threw an I/O exception
      See Also:
    • EXEC_INTERRUPTED

      public static final int EXEC_INTERRUPTED
      return code indicating the execute() was interrupted
      See Also:
    • EXEC_ERROR

      public static final int EXEC_ERROR
      return code indicating the execute() threw an unknown exception
      See Also:
  • Constructor Details

    • JseOsLib

      public JseOsLib()
      public constructor