@Override
protected RootInfo setupRoot( final FileSystem fs,
final String path,
final String host,
final boolean isRoot ) {
final boolean isRooted = isRoot ? true : path.startsWith( "/" );
final Matcher hasWindowsDrive = WINDOWS_DRIVER.matcher( path );
final boolean isAbsolute;
if ( isRooted || hasWindowsDrive.matches() ) {
isAbsolute = true;
} else {
isAbsolute = false;
}
int lastOffset = isAbsolute ? 1 : 0;
int windowsDriveEndsAt = -1;
if ( isAbsolute && hasWindowsDrive.matches() ) {
windowsDriveEndsAt = hasWindowsDrive.toMatchResult().end( 1 ) + 1;
lastOffset = windowsDriveEndsAt;
}
final boolean isFinalRoot;
if ( path.length() == 1 && lastOffset == 1 ) {
isFinalRoot = true;
} else if ( hasWindowsDrive.matches() && path.length() == windowsDriveEndsAt ) {
isFinalRoot = true;
} else {
isFinalRoot = isRoot;
}
return new RootInfo( lastOffset, isAbsolute, isFinalRoot, path.getBytes() );
}