aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/common-opts.cc11
-rw-r--r--src/libexpr/common-opts.hh2
2 files changed, 13 insertions, 0 deletions
diff --git a/src/libexpr/common-opts.cc b/src/libexpr/common-opts.cc
index d029d2ec3..e0865d9fc 100644
--- a/src/libexpr/common-opts.cc
+++ b/src/libexpr/common-opts.cc
@@ -44,4 +44,15 @@ bool parseSearchPathArg(const string & arg, Strings::iterator & i,
}
+Path lookupFileArg(EvalState & state, string s)
+{
+ if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') {
+ Path p = state.findFile(s.substr(1, s.size() - 2));
+ if (p == "") throw Error(format("file `%1%' was not found in the Nix search path (add it using $NIX_PATH or -I)") % p);
+ return p;
+ } else
+ return absPath(s);
+}
+
+
}
diff --git a/src/libexpr/common-opts.hh b/src/libexpr/common-opts.hh
index 6b7247fc3..c28641e90 100644
--- a/src/libexpr/common-opts.hh
+++ b/src/libexpr/common-opts.hh
@@ -14,6 +14,8 @@ bool parseOptionArg(const string & arg, Strings::iterator & i,
bool parseSearchPathArg(const string & arg, Strings::iterator & i,
const Strings::iterator & argsEnd, EvalState & state);
+Path lookupFileArg(EvalState & state, string s);
+
}