mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 17:16:15 +02:00
dirOf: allow use on non-absolute paths
This commit is contained in:
parent
f72c907ad8
commit
d7402c9cd5
2 changed files with 2 additions and 2 deletions
|
@ -866,7 +866,7 @@ static void prim_baseNameOf(EvalState & state, const Pos & pos, Value * * args,
|
||||||
static void prim_dirOf(EvalState & state, const Pos & pos, Value * * args, Value & v)
|
static void prim_dirOf(EvalState & state, const Pos & pos, Value * * args, Value & v)
|
||||||
{
|
{
|
||||||
PathSet context;
|
PathSet context;
|
||||||
Path dir = dirOf(state.coerceToPath(pos, *args[0], context));
|
Path dir = dirOf(state.coerceToString(pos, *args[0], context, false, false));
|
||||||
if (args[0]->type == tPath) mkPath(v, dir.c_str()); else mkString(v, dir, context);
|
if (args[0]->type == tPath) mkPath(v, dir.c_str()); else mkString(v, dir, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ Path dirOf(const Path & path)
|
||||||
{
|
{
|
||||||
Path::size_type pos = path.rfind('/');
|
Path::size_type pos = path.rfind('/');
|
||||||
if (pos == string::npos)
|
if (pos == string::npos)
|
||||||
throw Error(format("invalid file name '%1%'") % path);
|
return ".";
|
||||||
return pos == 0 ? "/" : Path(path, 0, pos);
|
return pos == 0 ? "/" : Path(path, 0, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue