Skip to content

Commit

Permalink
std.path.absolutePath should accept mutable pathnames.
Browse files Browse the repository at this point in the history
  • Loading branch information
H. S. Teoh committed Sep 19, 2014
1 parent 84d2b52 commit ecde625
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions std/path.d
Expand Up @@ -1986,17 +1986,16 @@ unittest
Throws:
$(D Exception) if the specified _base directory is not absolute.
*/
string absolutePath(string path, lazy string base = getcwd())
inout(char)[] absolutePath(inout(char)[] path, lazy const(char)[] base = getcwd())
@safe pure
{
if (path.empty) return null;
if (isAbsolute(path)) return path;
immutable baseVar = base;
const baseVar = base;
if (!isAbsolute(baseVar)) throw new Exception("Base directory must be absolute");
return buildPath(baseVar, path);
}


unittest
{
version (Posix)
Expand All @@ -2021,7 +2020,13 @@ unittest
assertThrown(absolutePath("bar", "foo"));
}


unittest
{
// Issue 12083
char[] path = ".".dup;
auto abs = path.absolutePath;
assert(abs == getcwd() ~ dirSeparator ~ ".");
}


/** Translates $(D path) into a relative _path.
Expand Down

0 comments on commit ecde625

Please sign in to comment.