Copyright | (c) Dong Han 2020 |
---|---|
License | BSD |
Maintainer | winterland1989@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
This module provide methods for retrieving various environment infomation. There's no encoding guarantee about these information, if you want textual representation, UTF8 assumption is recommended. i.e. use validate
.
Synopsis
- getArgs :: IO [CBytes]
- getAllEnv :: HasCallStack => IO [(CBytes, CBytes)]
- getEnv :: HasCallStack => CBytes -> IO (Maybe CBytes)
- getEnv' :: HasCallStack => CBytes -> IO CBytes
- setEnv :: HasCallStack => CBytes -> CBytes -> IO ()
- unsetEnv :: HasCallStack => CBytes -> IO ()
- getCWD :: HasCallStack => IO CBytes
- chDir :: HasCallStack => CBytes -> IO ()
- getHomeDir :: HasCallStack => IO CBytes
- getTempDir :: HasCallStack => IO CBytes
- getResUsage :: HasCallStack => IO ResUsage
- getResidentSetMemory :: HasCallStack => IO CSize
- getUpTime :: HasCallStack => IO Double
- getHighResolutionTime :: IO Word64
- newtype PID = PID CInt
- getPID :: IO PID
- getPPID :: IO PID
- getHostname :: HasCallStack => IO CBytes
- getOSName :: IO OSName
- data OSName = OSName {
- os_sysname :: CBytes
- os_release :: CBytes
- os_version :: CBytes
- os_machine :: CBytes
- getPassWD :: IO PassWD
- data PassWD = PassWD {}
- data UID
- data GID
- getRandom :: Int -> IO Bytes
- getRandomT :: Int -> IO Bytes
arguments
environment variables
getAllEnv :: HasCallStack => IO [(CBytes, CBytes)] Source #
Retrieves the environment variable.
Warning: This function is not thread safe.
getEnv :: HasCallStack => CBytes -> IO (Maybe CBytes) Source #
Retrieves the environment variable specified by name.
Warning: This function is not thread safe.
getEnv' :: HasCallStack => CBytes -> IO CBytes Source #
Retrieves the environment variable specified by name, throw NoSuchThing
if not exists.
Warning: This function is not thread safe.
setEnv :: HasCallStack => CBytes -> CBytes -> IO () Source #
Creates or updates the environment variable specified by name with value.
Warning: This function is not thread safe.
unsetEnv :: HasCallStack => CBytes -> IO () Source #
Deletes the environment variable specified by name if such environment variable exists.
Warning: This function is not thread safe.
other environment infos
getHomeDir :: HasCallStack => IO CBytes Source #
Gets the current user’s home directory.
On Windows, first checks the USERPROFILE environment variable using GetEnvironmentVariableW(). If USERPROFILE is not set, GetUserProfileDirectoryW() is called. On all other operating systems, first checks the HOME environment variable using getenv(3). If HOME is not set, getpwuid_r(3) is called.
Warning getHomeDir
is not thread safe.
getTempDir :: HasCallStack => IO CBytes Source #
Gets the temp directory.
On Windows, uses GetTempPathW(). On all other operating systems,
uses the first environment variable found in the ordered list TMPDIR, TMP, TEMP, and TEMPDIR.
If none of these are found, the path /tmp
is used, or, on Android, /data/local/tmp
is used.
Warning getHomeDir
is not thread safe.
getResUsage :: HasCallStack => IO ResUsage Source #
Gets the resource usage measures for the current process.
On Windows not all fields are set, the unsupported fields are filled with zeroes.
See ResUsage
for more details.
getResidentSetMemory :: HasCallStack => IO CSize Source #
Gets the resident set size (RSS) for the current process.
getHighResolutionTime :: IO Word64 Source #
Returns the current high-resolution real time.
This is expressed in nanoseconds. It is relative to an arbitrary time in the past. It is not related to the time of day and therefore not subject to clock drift. The primary use is for measuring performance between intervals.
Instances
getHostname :: HasCallStack => IO CBytes Source #
Returns the hostname as a null-terminated string.
OSName | |
|
Instances
Eq OSName Source # | |
Ord OSName Source # | |
Show OSName Source # | |
Generic OSName Source # | |
ToValue OSName Source # | |
Defined in Z.IO.UV.FFI | |
EncodeJSON OSName Source # | |
Defined in Z.IO.UV.FFI encodeJSON :: OSName -> Builder () # | |
FromValue OSName Source # | |
ShowT OSName Source # | |
Defined in Z.IO.UV.FFI toTextBuilder :: Int -> OSName -> TextBuilder () # | |
type Rep OSName Source # | |
Defined in Z.IO.UV.FFI type Rep OSName = D1 (MetaData "OSName" "Z.IO.UV.FFI" "Z-IO-0.1.6.0-GaocTtZII6UDtCkzE4xnxb" False) (C1 (MetaCons "OSName" PrefixI True) ((S1 (MetaSel (Just "os_sysname") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CBytes) :*: S1 (MetaSel (Just "os_release") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CBytes)) :*: (S1 (MetaSel (Just "os_version") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CBytes) :*: S1 (MetaSel (Just "os_machine") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 CBytes)))) |
getPassWD :: IO PassWD Source #
Gets a subset of the password file entry for the current effective uid (not the real uid).
The populated data includes the username, euid, gid, shell, and home directory. On non-Windows systems, all data comes from getpwuid_r(3). On Windows, uid and gid are set to -1 and have no meaning, and shell is empty.
Data type for password file information.
PassWD | |
|