diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2020-07-25 15:56:29 +0200 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2020-07-25 16:04:39 +0200 |
commit | 53b35a42b7cde0038369ef33fd687942f4dfb64d (patch) | |
tree | 8e53dd3eb93cf9bd37323884c388eab63fa6c620 /src/MiniTrace.cpp | |
parent | 60d774d42c0900696a5bb95ebac59134bf3091b8 (diff) | |
download | ccache-53b35a42b7cde0038369ef33fd687942f4dfb64d.tar.gz |
Introduce and use TemporaryFile class
In addition to improving code clarity, this fixes a bug where the
fallback code for “-fdiagnostics-color” tried to operate on a closed
file descriptor.
Diffstat (limited to 'src/MiniTrace.cpp')
-rw-r--r-- | src/MiniTrace.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/MiniTrace.cpp b/src/MiniTrace.cpp index 90caad30..f82b27e1 100644 --- a/src/MiniTrace.cpp +++ b/src/MiniTrace.cpp @@ -22,6 +22,7 @@ # include "ArgsInfo.hpp" # include "MiniTrace.hpp" +# include "TemporaryFile.hpp" # include "Util.hpp" # include "legacy_util.hpp" @@ -49,10 +50,8 @@ get_system_tmp_dir() MiniTrace::MiniTrace(const ArgsInfo& args_info) : m_args_info(args_info), m_trace_id(reinterpret_cast<void*>(getpid())) { - auto fd_and_path = - Util::create_temp_fd(get_system_tmp_dir() + "/ccache-trace"); - m_tmp_trace_file = fd_and_path.second; - close(fd_and_path.first); + TemporaryFile tmp_file(get_system_tmp_dir() + "/ccache-trace"); + m_tmp_trace_file = tmp_file.path; mtr_init(m_tmp_trace_file.c_str()); MTR_INSTANT_C("", "", "time", fmt::format("{:f}", time_seconds()).c_str()); |