Function rcutils_get_home_dir

Function Documentation

const char *rcutils_get_home_dir(void)

Retrieve the full path to the home directory.

The c-string which is returned is only valid until the next time this function is called, because it is a direct pointer to the static storage. Also note that the string returned here should not be freed.

The function first tries to get the HOME environment variable. If that variable exists and is non-empty, that will be returned. Otherwise, on Windows, the function tries to get the USERPROFILE environment variable. If that variable exists and is non-empty, that will be returned. Otherwise, NULL will be returned.

This function cannot be thread-safely called together with rcutils_set_env (or any platform specific equivalent), but multiple calls to this function are thread safe.

Returns:

The home directory on success, or

Returns:

NULL on failure.