- Fix to Path handling c:\foo and \home parent. #2569

This commit is contained in:
Christoffer Lerno
2025-11-08 23:42:47 +01:00
parent ffc65bcbf4
commit 52ececba37
3 changed files with 21 additions and 0 deletions

View File

@@ -399,6 +399,19 @@ fn Path? Path.parent(self)
{
if (is_separator(c, self.env))
{
if (i == 0) return { self.path_string[..0], self.env, null };
if (self.env == WIN32 && i > 1)
{
if (try volume_len = volume_name_len(self.path_string, WIN32))
{
// Handle C:\foo
if (volume_len == i)
{
if (i + 1 == self.path_string.len) return NO_PARENT?;
return { self.path_string[:i + 1], WIN32, null };
}
}
}
return { self.path_string[:i], self.env, null };
}
}