Mercurial > hg > digilib-old
diff servlet/src/digilib/io/FileOps.java @ 246:aaf6eace011d
Servlet version 1.19b4
- bug fixes
- new stuff in DocumentBean
author | robcast |
---|---|
date | Wed, 04 Aug 2004 20:42:48 +0200 |
parents | f8c82fea551a |
children | beed92ee6022 |
line wrap: on
line diff
--- a/servlet/src/digilib/io/FileOps.java Wed Aug 04 20:36:08 2004 +0200 +++ b/servlet/src/digilib/io/FileOps.java Wed Aug 04 20:42:48 2004 +0200 @@ -178,6 +178,24 @@ return ""; } + /** + * Extract the parent directory of a (digilib) path name. + * + * Returns the parent directory of a path name. The parent is the part before + * the last slash in the path name. If the path name has no slash the empty + * string is returned. + * + * @param fn + * @return + */ + public static String parent(String fn) { + int i = fn.lastIndexOf('/'); + if (i > 0) { + return fn.substring(0, i); + } + return ""; + } + /** Normalize a path name. * * Removes leading and trailing slashes. Returns null if there is other