summaryrefslogtreecommitdiff
path: root/src/Hash.hpp
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2022-08-15 21:25:37 +0200
committerJoel Rosdahl <joel@rosdahl.net>2022-08-15 22:13:32 +0200
commit3c55dbffd2bdbba1825b0ae982537a9de10f2b76 (patch)
tree0b4dc599ad01120983b77e843b6f66599ac7ec15 /src/Hash.hpp
parentb6f80ea9f54b75eac68bb07d6b1079bc4b7db172 (diff)
downloadccache-3c55dbffd2bdbba1825b0ae982537a9de10f2b76.tar.gz
refactor: Use util::{read_fd,read_file,write_file} functions
Diffstat (limited to 'src/Hash.hpp')
-rw-r--r--src/Hash.hpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/Hash.hpp b/src/Hash.hpp
index 269026e3..3e8d5573 100644
--- a/src/Hash.hpp
+++ b/src/Hash.hpp
@@ -21,6 +21,7 @@
#include "Digest.hpp"
#include "third_party/blake3/blake3.h"
+#include <third_party/nonstd/expected.hpp>
#include <cstdint>
#include <cstdio>
@@ -80,21 +81,17 @@ public:
// text input file followed by a newline.
Hash& hash(int64_t x);
- // Add contents read from an open file descriptor to the hash.
+ // Add file contents to the hash.
//
// If hash debugging is enabled, the data is written verbatim to the text
// input file.
- //
- // Returns true on success, otherwise false.
- bool hash_fd(int fd);
+ nonstd::expected<void, std::string> hash_file(const std::string& path);
- // Add file contents to the hash.
+ // Add contents read from an open file descriptor to the hash.
//
// If hash debugging is enabled, the data is written verbatim to the text
// input file.
- //
- // Returns true on success, otherwise false.
- bool hash_file(const std::string& path);
+ nonstd::expected<void, std::string> hash_fd(int fd);
// Add `text` to the text debug file.
void add_debug_text(std::string_view text);