Function
func currentDir()
public func currentDir(): Directory
Description: Obtains the current working directory.
Notes:
Returns:
- Directory: current working directory
func envVars()
public func envVars(): HashMap<String, String>
Description: Obtains all environment variables.
Notes:
- The return value is HashMap, which stores environment variables in the form of
key
andvalue
.
Returns:
func getArgs()
public func getArgs(): Array<String>
Description: Obtains the command line parameter list, for example, running a.out ab cd ef
in the command line, where a.out
is the program name. The returned list contains three elements: ab, cd, and ef.
Notes:
- When the C language is used to call the Cangjie dynamic library, the first parameter set by int SetCJCommandLineArgs(int argc, const char* argv[]) is discarded when getArgs() is used to obtain the command line parameters.
Returns:
func getEnv(String)
public func getEnv(k: String): Option<String>
Description: Obtains the value of a specified environment variable.
Parameters:
- k: String: environment variable name
Returns:
Throws:
- IllegalArgumentException: When the function parameter
k
contains null characters, this exception is thrown.
func homeDir()
public func homeDir(): Directory
Description: Obtains the home
directory.
Notes:
Returns:
- Directory:
home
directory
func processorCount()
public func processorCount(): Int64
Description: Obtains the number of processors.
Returns:
- Int64: number of processors
func removeEnv(String)
public func removeEnv(k: String): Unit
Description: Removes an environment variable by specifying its name.
Parameters:
- k: String: environment variable name
Throws:
- IllegalArgumentException: When the function parameter
k
contains null characters, this exception is thrown.
func setEnv(String, String)
public func setEnv(k: String, v: String): Unit
Description: Sets a pair of environment variables. If an environment variable with the same name is set, the original environment variable value is overwritten.
Parameters:
Throws:
- IllegalArgumentException: When the function parameter
k
orv
contains null characters, this exception is thrown.
func tempDir()
public func tempDir(): Directory
Description: Obtains the temporary directory. Obtains the TMPDIR
, TMP
, TEMP
, and TEMPDIR
environment variables from the environment variables. If the preceding values do not exist in the environment variables, the directory /tmp
is returned to by default.
Notes:
Returns:
- Directory: temporary directory