Mercurial > hg > digilib-old
diff servlet/src/digilib/io/DocuDirectory.java @ 176:67ff8c7fecb9
Servlet version 1.17b2
- new mapping file for "virtual directories"
- direct file URLs now work without extension (even with wrong ones)
author | robcast |
---|---|
date | Mon, 10 Nov 2003 20:59:00 +0100 |
parents | e743b853efca |
children | afe7ff98bb71 |
line wrap: on
line diff
--- a/servlet/src/digilib/io/DocuDirectory.java Mon Nov 10 20:50:32 2003 +0100 +++ b/servlet/src/digilib/io/DocuDirectory.java Mon Nov 10 20:59:00 2003 +0100 @@ -57,13 +57,11 @@ * * Directory names at the given path are appended to the base directories * from the cache. The directory is checked on disk and isValid is set. - * If read is true the directory is read and filled. * * @see readDir * * @param path digilib directory path name - * @param bd array of base directory names - * @param read the directory is read and filled + * @param cache parent DocuDirCache */ public DocuDirectory(String path, DocuDirCache cache) { this.dirName = path; @@ -364,11 +362,26 @@ * @return int index of file <code>fn</code> */ public int indexOf(String fn, int fc) { + if (!isRead()) { + // read directory now + if (!readDir()) { + return -1; + } + } // linear search -> worst performance int n = list[fc].size(); for (int i = 0; i < n; i++) { ImageFileset fs = (ImageFileset) list[fc].get(i); if (fs.getName().equals(fn)) { + // filename matches + return i; + } + } + // try again without extension + for (int i = 0; i < n; i++) { + ImageFileset fs = (ImageFileset) list[fc].get(i); + if (fs.getBasename().equals(FileOps.basename(fn))) { + // basename matches return i; } }