Options for scripting or debugging
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+*`--checksum-file`* _PATH_::
+
+ Print the checksum (64 bit XXH64) of the file at _PATH_.
+
*`--dump-manifest`* _PATH_::
Dump manifest file at _PATH_ in text format to standard output. This is
#include "Args.hpp"
#include "ArgsInfo.hpp"
+#include "Checksum.hpp"
#include "Context.hpp"
#include "Fd.hpp"
#include "File.hpp"
-V, --version print version and copyright information
Options for scripting or debugging:
+ --checksum-file PATH print the checksum (64 bit XXH64) of the file at
+ PATH
--dump-manifest PATH dump manifest file at PATH in text format
--dump-result PATH dump result file at PATH in text format
--extract-result PATH extract data stored in result file at PATH to the
handle_main_options(int argc, const char* const* argv)
{
enum longopts {
+ CHECKSUM_FILE,
DUMP_MANIFEST,
DUMP_RESULT,
EVICT_OLDER_THAN,
PRINT_STATS,
};
static const struct option options[] = {
+ {"checksum-file", required_argument, nullptr, CHECKSUM_FILE},
{"cleanup", no_argument, nullptr, 'c'},
{"clear", no_argument, nullptr, 'C'},
{"dump-manifest", required_argument, nullptr, DUMP_MANIFEST},
std::string arg = optarg ? optarg : std::string();
switch (c) {
+ case CHECKSUM_FILE: {
+ Checksum checksum;
+ Fd fd(arg == "-" ? STDIN_FILENO : open(arg.c_str(), O_RDONLY));
+ Util::read_fd(*fd, [&checksum](const void* data, size_t size) {
+ checksum.update(data, size);
+ });
+ fmt::print("{:016x}\n", checksum.digest());
+ break;
+ }
+
case DUMP_MANIFEST:
return manifest_dump(arg, stdout) ? 0 : 1;