stdsystemlib.rst 2.6 KB

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