}
bool
-Serializer::add_file(const FileType file_type, const std::string& path)
+Serializer::add_file(const FileType file_type,
+ const std::filesystem::path& path)
{
m_serialized_size += 1 + 1 + 8; // marker + file_type + file_size
if (!should_store_raw_file(m_config, file_type)) {
}
m_serialized_size += entry.size();
}
- m_file_entries.push_back(FileEntry{file_type, path});
+ m_file_entries.push_back(FileEntry{file_type, path.string()});
return true;
}
#include <nonstd/span.hpp>
#include <cstdint>
+#include <filesystem>
#include <string>
#include <variant>
#include <vector>
void add_data(FileType file_type, nonstd::span<const uint8_t> data);
// Register a file path whose content should be included in the result.
- [[nodiscard]] bool add_file(FileType file_type, const std::string& path);
+ [[nodiscard]] bool add_file(FileType file_type,
+ const std::filesystem::path& path);
// core::Serializer
uint32_t serialized_size() const override;
struct RawFile
{
uint8_t file_number;
- std::string path;
+ std::filesystem::path path;
};
// Get raw files to store in local storage.
}
}
-std::string
+fs::path
ResultRetriever::get_dest_path(FileType file_type) const
{
switch (file_type) {
case FileType::coverage_unmangled:
if (m_ctx.args_info.generating_coverage) {
- return util::pstr(
- util::with_extension(m_ctx.args_info.output_obj, ".gcno"));
+ return util::with_extension(m_ctx.args_info.output_obj, ".gcno");
}
break;
}
void
-ResultRetriever::write_dependency_file(const std::string& path,
+ResultRetriever::write_dependency_file(const std::filesystem::path& path,
nonstd::span<const uint8_t> data)
{
ASSERT(m_ctx.args_info.dependency_target);
- util::Fd fd(
- open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666));
+ util::Fd fd(open(
+ util::pstr(path).c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666));
if (!fd) {
throw WriteError(FMT("Failed to open {} for writing", path));
}
#include <nonstd/span.hpp>
#include <cstdint>
+#include <filesystem>
#include <optional>
-#include <string>
class Context;
const Context& m_ctx;
std::optional<Hash::Digest> m_result_key;
- std::string get_dest_path(Result::FileType file_type) const;
+ std::filesystem::path get_dest_path(Result::FileType file_type) const;
- void write_dependency_file(const std::string& path,
+ void write_dependency_file(const std::filesystem::path& path,
nonstd::span<const uint8_t> data);
};
// to a temporary file and then renamed to `dest`. Throws `core::Error` on
// error.
static void
-clone_file(const std::string& src, const std::string& dest, bool via_tmp_file)
+clone_file(const std::filesystem::path& src,
+ const std::filesystem::path& dest,
+ bool via_tmp_file)
{
# if defined(__linux__)
- util::Fd src_fd(open(src.c_str(), O_RDONLY));
+ util::Fd src_fd(open(util::pstr(src).c_str(), O_RDONLY));
if (!src_fd) {
throw core::Error(FMT("{}: {}", src, strerror(errno)));
}
}
# elif defined(__APPLE__)
(void)via_tmp_file;
- if (clonefile(src.c_str(), dest.c_str(), CLONE_NOOWNERCOPY) != 0) {
+ if (clonefile(
+ util::pstr(src).c_str(), util::pstr(dest).c_str(), CLONE_NOOWNERCOPY)
+ != 0) {
throw core::Error(strerror(errno));
}
# else
}
void
-LocalStorage::clone_hard_link_or_copy_file(const std::string& source,
- const std::string& dest,
+LocalStorage::clone_hard_link_or_copy_file(const fs::path& source,
+ const fs::path& dest,
bool via_tmp_file) const
{
if (m_config.file_clone()) {
// Clone, hard link or copy a file from `source` to `dest` depending on
// settings in `ctx`. If cloning or hard linking cannot and should not be done
// the file will be copied instead. Throws `core::Error` on error.
- void clone_hard_link_or_copy_file(const std::string& source,
- const std::string& dest,
+ void clone_hard_link_or_copy_file(const std::filesystem::path& source,
+ const std::filesystem::path& dest,
bool via_tmp_file = false) const;
// --- Statistics ---