aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-29 21:04:40 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-29 21:07:47 +0200
commitd8bf0d4859e28ddd23401fbe89f4e528aa09ddb3 (patch)
treeb10ec7730294bb404cb08cdf2a85c93e631212bd /src/libutil
parent38539b943a060d9cdfc24d6e5d997c0885b8aa2f (diff)
Support Git repos in the Nix path
E.g. $ nix-build -I nixpkgs=git://github.com/NixOS/nixpkgs '<nixpkgs>' -A hello This is not extremely useful yet because you can't specify a branch/revision.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.cc6
-rw-r--r--src/libutil/util.hh4
2 files changed, 10 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index d73800905..67558cc0b 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -1082,6 +1082,12 @@ bool statusOk(int status)
}
+bool hasPrefix(const string & s, const string & suffix)
+{
+ return s.compare(0, suffix.size(), suffix) == 0;
+}
+
+
bool hasSuffix(const string & s, const string & suffix)
{
return s.size() >= suffix.size() && string(s, s.size() - suffix.size()) == suffix;
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 6e5ab55e3..f3f0f92a0 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -333,6 +333,10 @@ template<class N> bool string2Float(const string & s, N & n)
}
+/* Return true iff `s' starts with `prefix'. */
+bool hasPrefix(const string & s, const string & prefix);
+
+
/* Return true iff `s' ends in `suffix'. */
bool hasSuffix(const string & s, const string & suffix);