Fixed bug 2322: Paths on Windows sometimes must include the trailing separator

This commit is contained in:
Bartosz Milewski 2008-08-30 19:33:22 +00:00
parent 3ac4dbb828
commit 25d0ef1dd2

View file

@ -376,7 +376,10 @@ string dirname(string fullname)
break;
if (fullname[i - 1] == sep[0] || fullname[i - 1] == altsep[0])
{
i--;
// 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--;
break;
}
}
@ -404,6 +407,8 @@ unittest
version (Win32)
{
assert(dirname(r"\path\to\file") == r"\path\to");
assert(dirname(r"\foo") == r"\");
assert(dirname(r"c:\foo") == r"c:\");
}
}
}