From 720f06e3b05502df2dc84afb7a3ad2ea5518246a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 6 Aug 2003 09:06:32 +0000 Subject: [PATCH] * A flag `--flat' to just compute the MD5 checksum of the contents of a regular file. I.e., `nix-hash --flat' is equivalent to the coreutils `md5sum' command (which doesn't exist on all systems). --- src/nix-hash.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nix-hash.cc b/src/nix-hash.cc index e35d0a1fe..77c169b9a 100644 --- a/src/nix-hash.cc +++ b/src/nix-hash.cc @@ -6,9 +6,13 @@ void run(Strings args) { - for (Strings::iterator it = args.begin(); - it != args.end(); it++) - cout << format("%1%\n") % (string) hashPath(*it); + bool flat = false; + for (Strings::iterator i = args.begin(); + i != args.end(); i++) + if (*i == "--flat") flat = true; + else + cout << format("%1%\n") % (string) + (flat ? hashFile(*i) : hashPath(*i)); }