toPosixPath function
To posix path.
\a\b => /a/b /a\b => /a/b C:\ => /C:/
Implementation
String toPosixPath(String anyPath) {
var context = posix;
var parts = contextPathSplit(context, anyPath);
// Handle C:\
if (parts.isNotEmpty) {
var rootPart = parts[0];
if (rootPart.endsWith(':')) {
parts = ['/', ...parts];
} else if (rootPart.endsWith(':\\')) {
parts = [
'/',
rootPart.substring(0, rootPart.length - 1),
...parts.sublist(1)
];
}
}
return context.joinAll(parts);
}