Source
pub fn basenameWindows(path: []const u8) []const u8 {
if (path.len == 0)
return &[_]u8{};
var end_index: usize = path.len - 1;
while (true) {
const byte = path[end_index];
if (byte == '/' or byte == '\\') {
if (end_index == 0)
return &[_]u8{};
end_index -= 1;
continue;
}
if (byte == ':' and end_index == 1) {
return &[_]u8{};
}
break;
}
var start_index: usize = end_index;
end_index += 1;
while (path[start_index] != '/' and path[start_index] != '\\' and
!(path[start_index] == ':' and start_index == 1))
{
if (start_index == 0)
return path[0..end_index];
start_index -= 1;
}
return path[start_index + 1 .. end_index];
}