components method
Implementation
Iterable<Component> components() sync* {
bool removeLast;
// trailing slash does not matter
if (string.endsWith(_pathSeparator)) {
if (string.length == 1) {
yield RootDir();
return;
}
removeLast = true;
} else {
removeLast = false;
}
final splits = string.split(_oneOrMoreSlashes);
if (removeLast) {
splits.removeLast();
}
final iterator = splits.iterator;
iterator.moveNext();
var current = iterator.current;
switch (current) {
case "":
yield RootDir();
break;
case ".":
yield CurDir();
break;
case "..":
yield ParentDir();
break;
default:
if (_regularPathComponent.hasMatch(current)) {
yield Normal(current);
} else {
yield Prefix(current);
}
}
while (iterator.moveNext()) {
current = iterator.current;
switch (current) {
case ".":
yield CurDir();
break;
case "..":
yield ParentDir();
break;
default:
yield Normal(current);
}
}
}