mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 07:00:37 +03:00
Fixed bug 2322: Paths on Windows sometimes must include the trailing separator
This commit is contained in:
parent
3ac4dbb828
commit
25d0ef1dd2
1 changed files with 6 additions and 1 deletions
|
@ -376,6 +376,9 @@ string dirname(string fullname)
|
||||||
break;
|
break;
|
||||||
if (fullname[i - 1] == sep[0] || fullname[i - 1] == altsep[0])
|
if (fullname[i - 1] == sep[0] || fullname[i - 1] == altsep[0])
|
||||||
{
|
{
|
||||||
|
// Leave separator when it's the starting character (current root)
|
||||||
|
// or when it's preceded by ':' (absolute root)
|
||||||
|
if (i != 1 && fullname[i - 2] != ':')
|
||||||
i--;
|
i--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -404,6 +407,8 @@ unittest
|
||||||
version (Win32)
|
version (Win32)
|
||||||
{
|
{
|
||||||
assert(dirname(r"\path\to\file") == r"\path\to");
|
assert(dirname(r"\path\to\file") == r"\path\to");
|
||||||
|
assert(dirname(r"\foo") == r"\");
|
||||||
|
assert(dirname(r"c:\foo") == r"c:\");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue