private void setParentFileAndName ( F parentFile , String name , LinkTracker < N , F > linkTracker ) throws IOException { if ( parentFile != null ) { parentFile = parentFile . followLinks ( linkTracker ) ; if ( StringUtils . isBlank ( name ) || "." . equals ( name ) ) { name = parentFile . getName ( ) ; parentFile = parentFile . getParentFile ( ) ; } else if ( ".." . equals ( name ) ) { parentFile = parentFile . getParentFile ( ) ; if ( parentFile == null ) { name = "" ; } else { name = parentFile . getName ( ) ; parentFile = parentFile . getParentFile ( ) ; } } } _parentFile = parentFile ; _name = name ; setPathFields ( ) ; }
This method handles special cases such as symbolic links in the parent directory empty filenames or the special names . and .. . The algorithm required is simplified by the fact that special cases for the parent file are handled before this is called as the path is always resolved from the bottom up . This means that the special cases have already been resolved for the parents and all supporting ancestors so those possibilities need only be considered at the current level eliminating any need for explicit recursive handling here .