bool found_fpch_preprocess = false;
bool found_Yu = false;
bool found_Yc = false;
- std::filesystem::path found_Fp_file;
+ fs::path found_Fp_file;
bool found_valid_Fp = false;
bool found_syntax_only = false;
ColorDiagnostics color_diagnostics = ColorDiagnostics::automatic;
// If the option is an option for Clang (is_cc1_option), don't accept
// anything just because it has a corresponding precompiled header,
// because Clang doesn't behave that way either.
- std::filesystem::path pch_file;
+ fs::path pch_file;
if (option == "-Yc") {
state.found_Yc = true;
args_info.generating_pch = true;
bool
process_profiling_option(const Context& ctx,
ArgsInfo& args_info,
- const std::string& arg)
+ std::string_view arg)
{
static const std::vector<std::string> known_simple_options = {
"-fprofile-correction",
}
if (util::starts_with(arg, "-fprofile-prefix-path=")) {
- std::filesystem::path profile_prefix_path = arg.substr(arg.find('=') + 1);
- args_info.profile_prefix_path = profile_prefix_path;
+ args_info.profile_prefix_path = arg.substr(arg.find('=') + 1);
LOG("Set profile prefix path to {}", args_info.profile_prefix_path);
return true;
}
- std::filesystem::path new_profile_path;
+ fs::path new_profile_path;
bool new_profile_use = false;
if (util::starts_with(arg, "-fprofile-dir=")) {
{
for (auto it = m_pending_tmp_files.rbegin(); it != m_pending_tmp_files.rend();
++it) {
- // Don't call util::remove or std::filesystem::remove since they are not
- // signal safe.
+ // Don't call util::remove or fs::remove since they are not signal safe.
unlink(util::pstr(*it).c_str());
}
// Don't clear m_pending_tmp_files since this method must be signal safe.
}
}
-std::filesystem::path
-make_relative_path(const Context& ctx, const std::filesystem::path& path)
+fs::path
+make_relative_path(const Context& ctx, const fs::path& path)
{
if (!ctx.config.base_dir().empty() && path.is_absolute()
&& util::path_starts_with(path, ctx.config.base_dir())) {
}
bool
-Serializer::add_file(const FileType file_type,
- const std::filesystem::path& path)
+Serializer::add_file(const FileType file_type, const fs::path& path)
{
m_serialized_size += 1 + 1 + 8; // marker + file_type + file_size
if (!should_store_raw_file(m_config, file_type)) {
}
void
-ResultRetriever::write_dependency_file(const std::filesystem::path& path,
+ResultRetriever::write_dependency_file(const fs::path& path,
nonstd::span<const uint8_t> data)
{
ASSERT(m_ctx.args_info.dependency_target);
}
void
-execute_noreturn(const char* const* argv,
- const std::filesystem::path& /*temp_dir*/)
+execute_noreturn(const char* const* argv, const fs::path& /*temp_dir*/)
{
execv(argv[0], const_cast<char* const*>(argv));
}
};
bool
-InodeCache::mmap_file(const std::filesystem::path& path)
+InodeCache::mmap_file(const fs::path& path)
{
m_sr = nullptr;
m_map.unmap();
// to a temporary file and then renamed to `dest`. Throws `core::Error` on
// error.
static void
-clone_file(const std::filesystem::path& src,
- const std::filesystem::path& dest,
- bool via_tmp_file)
+clone_file(const fs::path& src, const fs::path& dest, bool via_tmp_file)
{
# if defined(__linux__)
util::Fd src_fd(open(util::pstr(src).c_str(), O_RDONLY));
traverse_directory(const fs::path& directory,
const TraverseDirectoryVisitor& visitor)
{
- // Note: Intentionally not using std::filesystem::recursive_directory_iterator
+ // Note: Intentionally not using fs::recursive_directory_iterator
// since it visits directories in preorder.
DirEntry dir_entry(directory);
}
try {
- for (const auto& entry : std::filesystem::directory_iterator(directory)) {
+ for (const auto& entry : fs::directory_iterator(directory)) {
if (entry.is_directory()) {
traverse_directory(entry.path(), visitor);
} else {
namespace util::filesystem {
+namespace fs = std::filesystem;
+
tl::expected<void, std::error_code>
-rename(const std::filesystem::path& old_p, const std::filesystem::path& new_p)
+rename(const fs::path& old_p, const fs::path& new_p)
{
#ifndef _WIN32
std::error_code ec;
- std::filesystem::rename(old_p, new_p, ec);
+ fs::rename(old_p, new_p, ec);
if (ec) {
return tl::unexpected(ec);
}
return k_dev_null_path;
}
-std::filesystem::path
+fs::path
make_relative_path(const fs::path& actual_cwd,
const fs::path& apparent_cwd,
const fs::path& path)
#include "string.hpp"
#include <ccache/util/assertions.hpp>
+#include <ccache/util/filesystem.hpp>
#include <ccache/util/format.hpp>
#include <algorithm>
#include <cctype>
+namespace fs = util::filesystem;
+
namespace {
template<typename T>
return std::make_pair(string.substr(0, split_pos), string.substr(split_pos));
}
-std::vector<std::filesystem::path>
+std::vector<fs::path>
split_path_list(std::string_view path_list)
{
#ifdef _WIN32
const char path_delimiter[] = ":";
#endif
auto strings = split_into_views(path_list, path_delimiter);
- std::vector<std::filesystem::path> paths;
+ std::vector<fs::path> paths;
std::copy(strings.cbegin(), strings.cend(), std::back_inserter(paths));
return paths;
}