1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
.. _stdlib_stdsystemlib:
==================
The System library
==================
The system library exposes operating system facilities like environment variables,
date time manipulation etc..
--------------
Squirrel API
--------------
++++++++++++++
Global Symbols
++++++++++++++
.. js:function:: clock()
returns a float representing the number of seconds elapsed since the start of the process
.. js:function:: date([time [, format]])
returns a table containing a date/time splitted in the slots:
+-------------+----------------------------------------+
| sec | Seconds after minute (0 - 59). |
+-------------+----------------------------------------+
| min | Minutes after hour (0 - 59). |
+-------------+----------------------------------------+
| hour | Hours since midnight (0 - 23). |
+-------------+----------------------------------------+
| day | Day of month (1 - 31). |
+-------------+----------------------------------------+
| month | Month (0 - 11; January = 0). |
+-------------+----------------------------------------+
| year | Year (current year). |
+-------------+----------------------------------------+
| wday | Day of week (0 - 6; Sunday = 0). |
+-------------+----------------------------------------+
| yday | Day of year (0 - 365; January 1 = 0). |
+-------------+----------------------------------------+
if `time` is omitted the current time is used.
if `format` can be 'l' local time or 'u' UTC time, if omitted is defaulted as 'l'(local time).
.. js:function:: getenv(varaname)
Returns a string containing the value of the environment variable `varname`
.. js:function:: remove(path)
deletes the file specified by `path`
.. js:function:: rename(oldname, newname)
renames the file or directory specified by `oldname` to the name given by `newname`
.. js:function:: system(cmd)
xecutes the string `cmd` through the os command interpreter.
.. js:function:: time()
returns the number of seconds elapsed since midnight 00:00:00, January 1, 1970.
the result of this function can be formatted through the function `date()`
--------------
C API
--------------
.. _sqstd_register_systemlib:
.. c:function:: SQRESULT sqstd_register_systemlib(HSQUIRRELVM v)
:param HSQUIRRELVM v: the target VM
:returns: an SQRESULT
:remarks: The function aspects a table on top of the stack where to register the global library functions.
initialize and register the system library in the given VM.
|