Changeset 5711


Ignore:
Timestamp:
2003-10-23T10:44:45+13:00 (21 years ago)
Author:
jmt12
Message:

Added a new method for determining if a certain file describes a descendant of a certain folder as a String. This is useful for determining if a origin file comes from the collection a new collection was based on

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r5708 r5711  
    708708    }
    709709
     710   /** Determines if the given file is a descendant of the folder described.
     711    * @param pos_parent the possible parent folder as a String
     712    * @param child the child File which we are checking
     713    * @return true if the child is a descendant of the pos_parent, false otherwise
     714    */
     715   static public boolean isParentFolderOf(String pos_parent, File child) {
     716      while(child != null) {
     717     if(pos_parent.equals(child.getAbsolutePath())) {
     718        return true;
     719     }
     720     // Just keep looping checking each of childs parent folders. Not a brilliantly efficient algorithm, but it should still be pretty fast compared to the algorithm for merging elements.
     721     child = child.getParentFile();
     722      }
     723      return false;
     724   }
     725   
    710726    /** Method to determine if the host system is Microsoft Windows based.
    711727     * @return A <i>boolean</i> which is <i>true</i> if the platform is Windows, <i>false</i> otherwise.
Note: See TracChangeset for help on using the changeset viewer.