Function

func currentDir()

public func currentDir(): Directory

Description: Obtains the current working directory.

Notes:

  • The return value is of the Directory type. Directory.info.path.toString() can be used to obtain the string of the path.

Returns:

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 and value.

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:

  • Option<String>: environment variable value corresponding to the specified name

Throws:

func homeDir()

public func homeDir(): Directory

Description: Obtains the home directory.

Notes:

  • The return value is of the Directory type. Directory.info.path.toString() can be used to obtain the string of the path.

Returns:

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:

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:

  • k: String: environment variable name
  • v: String: environment variable value

Throws:

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:

  • The return value is of the Directory type. Directory.info.path.toString() can be used to obtain the string of the path.

Returns: