aboutsummaryrefslogtreecommitdiff
path: root/src/nix/hash.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-18 23:01:58 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-06-18 23:01:58 +0000
commit3f8dcfe3fd8372ee8fc1b3233c7e9982d1a6915d (patch)
tree5a104db035aede46168326978dd3bc387f9e49a7 /src/nix/hash.cc
parentd614166cb6864f2448b9e03f8dccccf301dc541e (diff)
parent669c3992e883414269d850bba5f00c59a1b207d0 (diff)
Merge branch 'validPathInfo-temp' into validPathInfo-ca-proper-datatype
Diffstat (limited to 'src/nix/hash.cc')
-rw-r--r--src/nix/hash.cc38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/nix/hash.cc b/src/nix/hash.cc
index a36364f50..b97c6d21f 100644
--- a/src/nix/hash.cc
+++ b/src/nix/hash.cc
@@ -11,18 +11,18 @@ using namespace nix;
struct CmdHash : Command
{
FileIngestionMethod mode;
- Base base = Base::SRI;
+ Base base = SRI;
bool truncate = false;
- HashType ht = HashType::SHA256;
+ HashType ht = htSHA256;
std::vector<std::string> paths;
std::optional<std::string> modulus;
CmdHash(FileIngestionMethod mode) : mode(mode)
{
- mkFlag(0, "sri", "print hash in Base::SRI format", &base, Base::SRI);
- mkFlag(0, "base64", "print hash in base-64", &base, Base::Base64);
- mkFlag(0, "base32", "print hash in base-32 (Nix-specific)", &base, Base::Base32);
- mkFlag(0, "base16", "print hash in base-16", &base, Base::Base16);
+ mkFlag(0, "sri", "print hash in SRI format", &base, SRI);
+ mkFlag(0, "base64", "print hash in base-64", &base, Base64);
+ mkFlag(0, "base32", "print hash in base-32 (Nix-specific)", &base, Base32);
+ mkFlag(0, "base16", "print hash in base-16", &base, Base16);
addFlag(Flag::mkHashTypeFlag("type", &ht));
#if 0
mkFlag()
@@ -69,7 +69,7 @@ struct CmdHash : Command
Hash h = hashSink->finish().first;
if (truncate && h.hashSize > 20) h = compressHash(h, 20);
- logger->stdout(h.to_string(base, base == Base::SRI));
+ logger->stdout(h.to_string(base, base == SRI));
}
}
};
@@ -92,10 +92,10 @@ struct CmdToBase : Command
std::string description() override
{
return fmt("convert a hash to %s representation",
- base == Base::Base16 ? "base-16" :
- base == Base::Base32 ? "base-32" :
- base == Base::Base64 ? "base-64" :
- "Base::SRI");
+ base == Base16 ? "base-16" :
+ base == Base32 ? "base-32" :
+ base == Base64 ? "base-64" :
+ "SRI");
}
Category category() override { return catUtility; }
@@ -103,19 +103,19 @@ struct CmdToBase : Command
void run() override
{
for (auto s : args)
- logger->stdout(Hash(s, ht).to_string(base, base == Base::SRI));
+ logger->stdout(Hash(s, ht).to_string(base, base == SRI));
}
};
-static RegisterCommand r3("to-base16", [](){ return make_ref<CmdToBase>(Base::Base16); });
-static RegisterCommand r4("to-base32", [](){ return make_ref<CmdToBase>(Base::Base32); });
-static RegisterCommand r5("to-base64", [](){ return make_ref<CmdToBase>(Base::Base64); });
-static RegisterCommand r6("to-sri", [](){ return make_ref<CmdToBase>(Base::SRI); });
+static RegisterCommand r3("to-base16", [](){ return make_ref<CmdToBase>(Base16); });
+static RegisterCommand r4("to-base32", [](){ return make_ref<CmdToBase>(Base32); });
+static RegisterCommand r5("to-base64", [](){ return make_ref<CmdToBase>(Base64); });
+static RegisterCommand r6("to-sri", [](){ return make_ref<CmdToBase>(SRI); });
/* Legacy nix-hash command. */
static int compatNixHash(int argc, char * * argv)
{
- HashType ht = HashType::MD5;
+ HashType ht = htMD5;
bool flat = false;
bool base32 = false;
bool truncate = false;
@@ -146,14 +146,14 @@ static int compatNixHash(int argc, char * * argv)
if (op == opHash) {
CmdHash cmd(flat ? FileIngestionMethod::Flat : FileIngestionMethod::Recursive);
cmd.ht = ht;
- cmd.base = base32 ? Base::Base32 : Base::Base16;
+ cmd.base = base32 ? Base32 : Base16;
cmd.truncate = truncate;
cmd.paths = ss;
cmd.run();
}
else {
- CmdToBase cmd(op == opTo32 ? Base::Base32 : Base::Base16);
+ CmdToBase cmd(op == opTo32 ? Base32 : Base16);
cmd.args = ss;
cmd.ht = ht;
cmd.run();