java.io.File.getParent() bug (kaffe 1.0.b1)

Giles Lean giles at nemeton.com.au
Mon Jul 27 07:06:39 PDT 1998


Seems a popular place for bugs -- Sun have some too.  (Different ones,
of course!).

The diff below will make getParent() return "/" instead of "" when
called for a second level directory, e.g. "/tmp".  What do do in the
presence of drive letters and such I leave for someone else!

Regards,

Giles

*** libraries/javalib/java/io/File.java	1998/07/25 07:58:40	1.1
--- libraries/javalib/java/io/File.java	1998/07/25 07:55:43
***************
*** 115,122 ****
  	int slashIndex=path.lastIndexOf(separatorChar);
  	if (slashIndex==-1) {
  		return null;
! 	}
! 	else {
  		return path.substring(0, slashIndex);
  	}
  }
--- 115,123 ----
  	int slashIndex=path.lastIndexOf(separatorChar);
  	if (slashIndex==-1) {
  		return null;
! 	} else if (slashIndex==0) {
! 		return File.separator;
! 	} else {
  		return path.substring(0, slashIndex);
  	}
  }


More information about the kaffe mailing list