aboutsummaryrefslogtreecommitdiff
path: root/src/nix-store/main.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-09-10 13:32:08 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-09-10 13:32:08 +0000
commitdcc433de47d4bf4a27fe63bc8996e946164ae885 (patch)
tree0d27a8f0433094144b7cdab591726f2ec288d937 /src/nix-store/main.cc
parentc16be6ac92b86981e8e4bb6703e694b675a28b0d (diff)
* Operation `--delete-generations' to delete generations of a
profile. Arguments are either generation number, or `old' to delete all non-current generations. Typical use: $ nix-env --delete-generations old $ nix-collect-garbage * istringstream -> string2Int.
Diffstat (limited to 'src/nix-store/main.cc')
-rw-r--r--src/nix-store/main.cc14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/nix-store/main.cc b/src/nix-store/main.cc
index a8acd30c7..febe65e5c 100644
--- a/src/nix-store/main.cc
+++ b/src/nix-store/main.cc
@@ -1,5 +1,4 @@
#include <iostream>
-#include <sstream>
#include "globals.hh"
#include "normalise.hh"
@@ -171,10 +170,8 @@ static void opSubstitute(Strings opFlags, Strings opArgs)
getline(cin, sub.program);
string s;
getline(cin, s);
- istringstream st(s);
int n;
- st >> n;
- if (!st) throw Error("number expected");
+ if (!string2Int(s, n)) throw Error("number expected");
while (n--) {
getline(cin, s);
sub.args.push_back(s);
@@ -224,11 +221,10 @@ static void opGC(Strings opFlags, Strings opArgs)
else if (*i == "--print-dead") subOp = soPrintDead;
else if (*i == "--delete") subOp = soDelete;
else if (*i == "--min-age") {
- if (opArgs.size() == 0)
- throw UsageError("`--min-age' requires an argument");
- istringstream st(opArgs.front());
- st >> minAge;
- if (!st) throw Error("number expected");
+ int n;
+ if (opArgs.size() == 0 || !string2Int(opArgs.front(), n))
+ throw UsageError("`--min-age' requires an integer argument");
+ minAge = n;
}
else throw UsageError(format("bad sub-operation `%1%' in GC") % *i);