From dcc433de47d4bf4a27fe63bc8996e946164ae885 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 10 Sep 2004 13:32:08 +0000 Subject: * 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. --- src/libutil/util.cc | 8 ++++++++ src/libutil/util.hh | 4 ++++ 2 files changed, 12 insertions(+) (limited to 'src/libutil') diff --git a/src/libutil/util.cc b/src/libutil/util.cc index a25665e4a88c..5a41c098654e 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -616,3 +616,11 @@ bool statusOk(int status) { return WIFEXITED(status) && WEXITSTATUS(status) == 0; } + + +bool string2Int(const string & s, int & n) +{ + istringstream str(s); + str >> n; + return str && str.eof(); +} diff --git a/src/libutil/util.hh b/src/libutil/util.hh index ae5b4882e62d..a79c07305df8 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -246,6 +246,10 @@ string statusToString(int status); bool statusOk(int status); +/* Parse a string into an integer. */ +bool string2Int(const string & s, int & n); + + /* !!! HACK HACK HACK - this should be in shared.hh, but it's to facilitate a quick hack - will remove this eventually (famous last words). */ -- cgit 1.4.1