diff --git a/src/blackhole.cc b/src/blackhole.cc index 1f5a8e4..c084d65 100644 --- a/src/blackhole.cc +++ b/src/blackhole.cc @@ -1,6 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-only #include #include +#include #include #include @@ -60,15 +61,10 @@ static std::string get_tmpdir(void) if (is_writable_dir("/var/tmp")) return "/var/tmp"; - int old_errno = errno; - char *workdir = get_current_dir_name(); - errno = old_errno; - if (workdir != nullptr) { - std::string wdir_str(workdir); - free(workdir); - if (is_writable_dir(workdir)) - return workdir; - } + std::string workdir = std::filesystem::current_path(); + + if (is_writable_dir(workdir)) + return workdir; LOG(FATAL) << "Unable to get temporary directory."; std::abort(); diff --git a/src/rules/parse.cc b/src/rules/parse.cc index 3c8bf99..b03e180 100644 --- a/src/rules/parse.cc +++ b/src/rules/parse.cc @@ -1,6 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-only #include #include +#include #include #include #include @@ -322,7 +323,7 @@ std::string make_absolute(const std::string &path) if (path.empty() || path[0] == '/') return path; - return std::string(get_current_dir_name()) + '/' + path; + return std::filesystem::current_path() / path; } std::optional parse_rule_arg(size_t rulepos, const std::string &arg)