private boolean isSymbolicDirectoryLink ( final File pParentDirectory , final File pDirectory ) { try { final String canonicalParentPath1 = pParentDirectory . getCanonicalPath ( ) ; final String canonicalParentPath2 = pDirectory . getCanonicalFile ( ) . getParent ( ) ; return ! canonicalParentPath1 . equals ( canonicalParentPath2 ) ; } catch ( final IOException e ) { return true ; } catch ( final NoSuchElementException e ) { // See: http://code.google.com/p/android/issues/detail?id=4961 // See: http://code.google.com/p/android/issues/detail?id=5807 return true ; } }
Checks to see if it appears that a directory is a symbolic link . It does this by comparing the canonical path of the parent directory and the parent directory of the directory s canonical path . If they are equal then they come from the same true parent . If not then pDirectory is a symbolic link . If we get an exception we err on the side of caution and return true expecting the calculateDirectorySize to now skip further processing since something went goofy .