#include <ccache/util/TemporaryFile.hpp>
#include <ccache/util/conversion.hpp>
#include <ccache/util/file.hpp>
+#include <ccache/util/filesystem.hpp>
#include <ccache/util/format.hpp>
#include <ccache/util/logging.hpp>
#include <type_traits>
#include <vector>
+namespace fs = util::filesystem;
+
using pstr = util::PathString;
// The inode cache resides on a file that is mapped into shared memory by
}
bool
-InodeCache::hash_inode(const std::string& path,
+InodeCache::hash_inode(const fs::path& path,
ContentType type,
Hash::Digest& digest)
{
}
std::optional<std::pair<HashSourceCodeResult, Hash::Digest>>
-InodeCache::get(const std::string& path, ContentType type)
+InodeCache::get(const fs::path& path, ContentType type)
{
if (!initialize()) {
return std::nullopt;
}
bool
-InodeCache::put(const std::string& path,
+InodeCache::put(const fs::path& path,
ContentType type,
const Hash::Digest& file_digest,
HashSourceCodeResult return_value)
#include <sys/types.h>
#include <cstdint>
+#include <filesystem>
#include <functional>
#include <optional>
#include <string>
// Get saved hash digest and return value from a previous call to
// do_hash_file() in hashutil.cpp.
std::optional<std::pair<HashSourceCodeResult, Hash::Digest>>
- get(const std::string& path, ContentType type);
+ get(const std::filesystem::path& path, ContentType type);
// Put hash digest and return value from a successful call to do_hash_file()
// in hashutil.cpp.
//
// Returns true if values could be stored in the cache, false otherwise.
- bool put(const std::string& path,
+ bool put(const std::filesystem::path& path,
ContentType type,
const Hash::Digest& file_digest,
HashSourceCodeResult return_value);
bool mmap_file(const std::string& inode_cache_file);
- bool
- hash_inode(const std::string& path, ContentType type, Hash::Digest& digest);
+ bool hash_inode(const std::filesystem::path& path,
+ ContentType type,
+ Hash::Digest& digest);
bool with_bucket(const Hash::Digest& key_digest,
const BucketHandler& bucket_handler);
}
bool
-is_precompiled_header(std::string_view path)
+is_precompiled_header(const fs::path& path)
{
- fs::path ext = fs::path(path).extension();
+ fs::path ext = path.extension();
return ext == ".gch" || ext == ".pch" || ext == ".pth"
- || fs::path(path).parent_path().extension() == ".gch";
+ || path.parent_path().extension() == ".gch";
}
bool
#include <tl/expected.hpp>
+#include <filesystem>
#include <string>
#include <string_view>
#include <vector>
// Return whether `path` represents a precompiled header (see "Precompiled
// Headers" in GCC docs).
-bool is_precompiled_header(std::string_view path);
+bool is_precompiled_header(const std::filesystem::path& path);
bool option_should_be_ignored(const std::string& arg,
const std::vector<std::string>& patterns);
util::split_path_list(ctx.config.extra_files_to_hash())) {
LOG("Hashing extra file {}", path);
hash.hash_delimiter("extrafile");
- if (!hash_binary_file(ctx, hash, pstr(path))) {
+ if (!hash_binary_file(ctx, hash, path)) {
return tl::unexpected(Statistic::error_hashing_extra_file);
}
}
#include <ccache/util/DirEntry.hpp>
#include <ccache/util/cpu.hpp>
#include <ccache/util/file.hpp>
+#include <ccache/util/filesystem.hpp>
#include <ccache/util/format.hpp>
#include <ccache/util/logging.hpp>
+#include <ccache/util/path.hpp>
#include <ccache/util/string.hpp>
#include <ccache/util/time.hpp>
#include <ccache/util/wincompat.hpp>
# include <immintrin.h>
#endif
+namespace fs = util::filesystem;
+
namespace {
// Pre-condition: str[pos - 1] == '_'
HashSourceCodeResult
do_hash_file(const Context& ctx,
Hash::Digest& digest,
- const std::string& path,
+ const fs::path& path,
size_t size_hint,
bool check_temporal_macros)
{
HashSourceCodeResult
hash_source_code_file(const Context& ctx,
Hash::Digest& digest,
- const std::string& path,
+ const fs::path& path,
size_t size_hint)
{
const bool check_temporal_macros =
bool
hash_binary_file(const Context& ctx,
Hash::Digest& digest,
- const std::string& path,
+ const fs::path& path,
size_t size_hint)
{
return do_hash_file(ctx, digest, path, size_hint, false).empty();
}
bool
-hash_binary_file(const Context& ctx, Hash& hash, const std::string& path)
+hash_binary_file(const Context& ctx, Hash& hash, const fs::path& path)
{
Hash::Digest digest;
const bool success = hash_binary_file(ctx, digest, path);
#include <ccache/util/BitSet.hpp>
#include <cstddef>
+#include <filesystem>
#include <string>
#include <string_view>
// Hash a source code file using the inode cache if enabled.
HashSourceCodeResult hash_source_code_file(const Context& ctx,
Hash::Digest& digest,
- const std::string& path,
+ const std::filesystem::path& path,
size_t size_hint = 0);
// Hash a binary file (using the inode cache if enabled) and put its digest in
// Returns true on success, otherwise false.
bool hash_binary_file(const Context& ctx,
Hash::Digest& digest,
- const std::string& path,
+ const std::filesystem::path& path,
size_t size_hint = 0);
// Hash a binary file (using the inode cache if enabled) and hash the digest to
// `hash`.
//
// Returns true on success, otherwise false.
-bool hash_binary_file(const Context& ctx, Hash& hash, const std::string& path);
+bool hash_binary_file(const Context& ctx,
+ Hash& hash,
+ const std::filesystem::path& path);
// Hash the output of `command` (not executed via a shell). A "%compiler%"
// string in `command` will be replaced with `compiler`.