diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-02-25T10·25+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-02-25T10·25+0100 |
commit | f1bdeac9864de8cd9994bb41da79f3a4d812dadc (patch) | |
tree | 9ea00480f826dc8d8d8248e11323266a42f9d4ae /src/libutil/util.hh | |
parent | 9b05d5848c2fce73b75b3411e362c2bd48d53dcb (diff) | |
parent | 152b1d6bf9c89b4db9848475e3000821e159d479 (diff) |
Merge branch 'master' into new-cli
Diffstat (limited to 'src/libutil/util.hh')
-rw-r--r-- | src/libutil/util.hh | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh index b714cdc64a5a..3606f6ec9eb2 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -92,8 +92,8 @@ string readLine(int fd); void writeLine(int fd, string s); /* Delete a path; i.e., in the case of a directory, it is deleted - recursively. Don't use this at home, kids. The second variant - returns the number of bytes and blocks freed. */ + recursively. It's not an error if the path does not exist. The + second variant returns the number of bytes and blocks freed. */ void deletePath(const Path & path); void deletePath(const Path & path, unsigned long long & bytesFreed); @@ -366,6 +366,14 @@ template<class N> bool string2Int(const string & s, N & n) return str && str.get() == EOF; } +/* Parse a string into a float. */ +template<class N> bool string2Float(const string & s, N & n) +{ + std::istringstream str(s); + str >> n; + return str && str.get() == EOF; +} + /* Return true iff `s' ends in `suffix'. */ bool hasSuffix(const string & s, const string & suffix); |