init commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
(ns os
|
||||
"Erlang :os module — operating system interface.
|
||||
|
||||
In CljElixir: (os/cmd \"ls\"), (os/type), etc.")
|
||||
|
||||
(defn cmd
|
||||
"Executes an OS command and returns the output as a charlist.
|
||||
(os/cmd \"ls -la\") ;=> 'total 42\\n...'"
|
||||
([command])
|
||||
([command opts]))
|
||||
|
||||
(defn type
|
||||
"Returns the OS type.
|
||||
(os/type) ;=> {:unix :darwin} or {:win32 :nt}"
|
||||
[])
|
||||
|
||||
(defn version
|
||||
"Returns the OS version.
|
||||
(os/version) ;=> {14 3 0}"
|
||||
[])
|
||||
|
||||
(defn getenv
|
||||
"Gets an environment variable. Returns charlist or false.
|
||||
(os/getenv \"HOME\") ;=> '/Users/ajet'
|
||||
(os/getenv \"MISSING\") ;=> false"
|
||||
([name])
|
||||
([name default]))
|
||||
|
||||
(defn putenv
|
||||
"Sets an environment variable.
|
||||
(os/putenv \"MY_VAR\" \"value\") ;=> true"
|
||||
[name value])
|
||||
|
||||
(defn unsetenv
|
||||
"Removes an environment variable.
|
||||
(os/unsetenv \"MY_VAR\") ;=> true"
|
||||
[name])
|
||||
|
||||
(defn getenv
|
||||
"Gets all environment variables as list of \"KEY=VALUE\" strings."
|
||||
[])
|
||||
|
||||
(defn timestamp
|
||||
"Returns OS timestamp as {megasecs secs microsecs}.
|
||||
(os/timestamp) ;=> {1709 123456 789012}"
|
||||
[])
|
||||
|
||||
(defn system-time
|
||||
"Returns OS system time.
|
||||
(os/system-time :millisecond)"
|
||||
([])
|
||||
([unit]))
|
||||
|
||||
(defn perf-counter
|
||||
"Returns a performance counter value.
|
||||
(os/perf-counter :nanosecond)"
|
||||
([])
|
||||
([unit]))
|
||||
|
||||
(defn find-executable
|
||||
"Finds an executable in PATH. Returns path or false.
|
||||
(os/find-executable \"elixir\") ;=> '/usr/local/bin/elixir'"
|
||||
[name])
|
||||
|
||||
(defn getpid
|
||||
"Returns the OS process ID as a string.
|
||||
(os/getpid) ;=> \"12345\""
|
||||
[])
|
||||
|
||||
(defn set-signal
|
||||
"Sets OS signal handler."
|
||||
[signal action])
|
||||
Reference in New Issue
Block a user