return m_stats_log.string();
case ConfigItem::temporary_dir:
- return m_temporary_dir;
+ return m_temporary_dir.string();
case ConfigItem::umask:
return format_umask(m_umask);
}
}
-std::string
+fs::path
Config::default_temporary_dir() const
{
- static const std::string run_user_tmp_dir = [] {
+ static const fs::path run_user_tmp_dir = [] {
#ifndef _WIN32
const char* const xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
if (xdg_runtime_dir && DirEntry(xdg_runtime_dir).is_directory()) {
- auto dir = FMT("{}/ccache-tmp", xdg_runtime_dir);
+ fs::path dir = FMT("{}/ccache-tmp", xdg_runtime_dir);
if (fs::create_directories(dir) && access(dir.c_str(), W_OK) == 0) {
return dir;
}
}
#endif
- return std::string();
+ return fs::path();
}();
- return !run_user_tmp_dir.empty() ? run_user_tmp_dir
- : util::pstr(m_cache_dir / "tmp");
+ return !run_user_tmp_dir.empty() ? run_user_tmp_dir : m_cache_dir / "tmp";
}
bool stats() const;
const std::filesystem::path& stats_log() const;
const std::string& namespace_() const;
- const std::string& temporary_dir() const;
+ const std::filesystem::path& temporary_dir() const;
std::optional<mode_t> umask() const;
// Return true for Clang and clang-cl.
bool is_compiler_group_msvc() const;
util::SizeUnitPrefixType size_unit_prefix_type() const;
- std::string default_temporary_dir() const;
+ std::filesystem::path default_temporary_dir() const;
void set_base_dir(const std::filesystem::path& value);
void set_cache_dir(const std::filesystem::path& value);
void set_max_files(uint64_t value);
void set_msvc_dep_prefix(const std::string& value);
void set_run_second_cpp(bool value);
- void set_temporary_dir(const std::string& value);
+ void set_temporary_dir(const std::filesystem::path& value);
// Where to write configuration changes.
const std::filesystem::path& config_path() const;
bool m_stats = true;
std::filesystem::path m_stats_log;
std::string m_namespace;
- std::string m_temporary_dir;
+ std::filesystem::path m_temporary_dir;
std::optional<mode_t> m_umask;
bool m_temporary_dir_configured_explicitly = false;
return m_namespace;
}
-inline const std::string&
+inline const std::filesystem::path&
Config::temporary_dir() const
{
return m_temporary_dir;
}
inline void
-Config::set_temporary_dir(const std::string& value)
+Config::set_temporary_dir(const std::filesystem::path& value)
{
m_temporary_dir = value;
}
#else
ULARGE_INTEGER free_space_for_user{};
- if (GetDiskFreeSpaceExA(m_config.temporary_dir().c_str(),
+ if (GetDiskFreeSpaceExA(util::pstr(m_config.temporary_dir()).c_str(),
&free_space_for_user,
nullptr,
nullptr)
bool fall_back_to_original_compiler = false;
Args saved_orig_args;
std::optional<uint32_t> original_umask;
- std::string saved_temp_dir;
+ fs::path saved_temp_dir;
auto argv_parts = split_argv(argc, argv);
if (argv_parts.compiler_and_args.empty()) {
1,
fd_out.release(),
fd_err.release(),
- ctx.config.temporary_dir());
+ util::pstr(ctx.config.temporary_dir()));
}
void
-execute_noreturn(const char* const* argv, const std::string& temp_dir)
+execute_noreturn(const char* const* argv, const fs::path& temp_dir)
{
- win32execute(argv[0], argv, 0, -1, -1, temp_dir);
+ win32execute(argv[0], argv, 0, -1, -1, util::pstr(temp_dir).c_str());
}
std::string
}
void
-execute_noreturn(const char* const* argv, const std::string& /*temp_dir*/)
+execute_noreturn(const char* const* argv,
+ const std::filesystem::path& /*temp_dir*/)
{
execv(argv[0], const_cast<char* const*>(argv));
}
util::Fd&& fd_out,
util::Fd&& fd_err);
-void execute_noreturn(const char* const* argv, const std::string& temp_dir);
+void execute_noreturn(const char* const* argv,
+ const std::filesystem::path& temp_dir);
// Find an executable named `name` in `$PATH`. Exclude any executables that are
// links to `exclude_path`.
{
config.set_debug(true);
config.set_inode_cache(true);
- config.set_temporary_dir(util::pstr(*fs::current_path()));
+ config.set_temporary_dir(*fs::current_path());
}
bool