Contents    Page-10    Prev    Next    Page+10    Index   

Java Version of Findpath


public static String
findpath(Cons dirtree, Cons path) {
 if ( dirtree == null )
  return null;                      // not found
  else if ( consp(first(dirtree)) ) // directory?
    if (((String) first(path))      // first(path)
        .equals(first((Cons)        //   = dir name?
                      first(dirtree))) )
      return findpath(rest((Cons)   // yes: go in
                      first(dirtree)),  // contents
                      rest(path)) ;     // pop path
    else return findpath(rest(dirtree), // no: keep
                          path);        //  looking
  else if (((String) first(path))       // first(path)
             .equals(first(dirtree)) )  //  = file name?
          return (String) first(path);  // yes: success
          else                          // no: keep
            return findpath(rest(dirtree), //  looking
                                path); }