2026-02-03 02:44:58 +08:00
|
|
|
|
|
|
|
|
namespace UniLua
|
|
|
|
|
{
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
internal class LuaOSLib
|
|
|
|
|
{
|
|
|
|
|
public const string LIB_NAME = "os";
|
|
|
|
|
|
|
|
|
|
public static int OpenLib( ILuaState lua )
|
|
|
|
|
{
|
|
|
|
|
NameFuncPair[] define = new NameFuncPair[]
|
|
|
|
|
{
|
|
|
|
|
#if !UNITY_WEBPLAYER
|
|
|
|
|
new NameFuncPair("clock", OS_Clock),
|
2026-02-03 23:41:11 +08:00
|
|
|
new NameFuncPair("gethostname", OS_Gethostname),
|
2026-02-03 02:44:58 +08:00
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
lua.L_NewLib( define );
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if !UNITY_WEBPLAYER
|
|
|
|
|
private static int OS_Clock( ILuaState lua )
|
|
|
|
|
{
|
2026-02-03 23:41:11 +08:00
|
|
|
lua.PushNumber(0);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static int OS_Gethostname( ILuaState lua )
|
|
|
|
|
{
|
|
|
|
|
string hostname = CMLeonOS.Kernel.userSystem?.GetHostname() ?? "Not set";
|
|
|
|
|
lua.PushString(hostname);
|
2026-02-03 02:44:58 +08:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|