public Path getParent ( ) { String path = uri . getPath ( ) ; int lastSlash = path . lastIndexOf ( ' ' ) ; int start = hasWindowsDrive ( path , true ) ? 3 : 0 ; if ( ( path . length ( ) == start ) || // empty path ( lastSlash == start && path . length ( ) == start + 1 ) ) { // at root return null ; } String parent ; if ( lastSlash == - 1 ) { parent = CUR_DIR ; } else { int end = hasWindowsDrive ( path , true ) ? 3 : 0 ; parent = path . substring ( 0 , lastSlash == end ? end + 1 : lastSlash ) ; } return new Path ( uri . getScheme ( ) , uri . getAuthority ( ) , parent ) ; }
Returns the parent of a path or null if at root .