示例#1
0
 /**
  * Determines whether one file is the parent of another.
  *
  * @param ancestor possible parent of <code>descendant</code>
  * @param descendant possible child 0f <code>ancestor</code>
  * @return return true if ancestor is a parent of descendant
  */
 static boolean isParentOf(final File ancestor, File descendant) {
   if (ancestor != null) {
     if (ancestor.equals(descendant)) {
       return false;
     }
     while (descendant != null && !ancestor.equals(descendant)) {
       descendant = descendant.getParentFile();
     }
   }
   return ancestor != null && descendant != null;
 }
示例#2
0
 /**
  * Returns <CODE>true</CODE> if the first provided path is under the second path in the file
  * system.
  *
  * @param descendant the descendant candidate path.
  * @param path the path.
  * @return <CODE>true</CODE> if the first provided path is under the second path in the file
  *     system; <code>false</code> otherwise or if either of the files are null
  */
 static boolean isDescendant(File descendant, File path) {
   if (descendant != null && path != null) {
     File parent = descendant.getParentFile();
     while (parent != null) {
       if (path.equals(parent)) {
         return true;
       }
       parent = parent.getParentFile();
     }
   }
   return false;
 }