]> git.ipfire.org Git - thirdparty/ccache.git/commit
Improve functions related to CWD
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 16 Feb 2020 12:06:24 +0000 (13:06 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 16 Feb 2020 21:02:21 +0000 (22:02 +0100)
commit20696244d13f745a32006c4927b5a1013bbef289
tree2908b180b4342aa912c9a9ee927b1de8f481139e
parent8616529df5ba92047ed595ce817a3a24b2b96ee9
Improve functions related to CWD

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.
12 files changed:
src/Context.cpp
src/Context.hpp
src/Util.cpp
src/Util.hpp
src/ccache.cpp
src/legacy_globals.cpp
src/legacy_globals.hpp
src/legacy_util.cpp
src/legacy_util.hpp
unittest/framework.cpp
unittest/main.cpp
unittest/test_argument_processing.cpp