The different functions related to current working directory (CWD) have
become messy during the years:
- gnu_getcwd is a simple wrapper around getcwd(3), thus returning the
actual canonical path.
- get_cwd returns $PWD, falling back to getcwd(3) if $PWD is not sane.
- get_current_working_dir (local function in ccache.cpp) memoizes
x_realpath(get_cwd()) (i.e., getcwd(3) in essence...) in the global
current_working_dir variable. Unit tests may manipulate
current_working_dir.
Improve this by:
- Replacing gnu_getcwd with Util::get_actual_cwd.
- Replacing get_cwd with Util::get_apparent_cwd.
- Removing get_current_working_dir and placing both actual and apparent
CWD in the context object.