comparison 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
comparison
equal deleted inserted replaced
175:633947100c86 176:67ff8c7fecb9
55 55
56 /** Constructor with digilib directory path and a parent DocuDirCache. 56 /** Constructor with digilib directory path and a parent DocuDirCache.
57 * 57 *
58 * Directory names at the given path are appended to the base directories 58 * Directory names at the given path are appended to the base directories
59 * from the cache. The directory is checked on disk and isValid is set. 59 * from the cache. The directory is checked on disk and isValid is set.
60 * If read is true the directory is read and filled.
61 * 60 *
62 * @see readDir 61 * @see readDir
63 * 62 *
64 * @param path digilib directory path name 63 * @param path digilib directory path name
65 * @param bd array of base directory names 64 * @param cache parent DocuDirCache
66 * @param read the directory is read and filled
67 */ 65 */
68 public DocuDirectory(String path, DocuDirCache cache) { 66 public DocuDirectory(String path, DocuDirCache cache) {
69 this.dirName = path; 67 this.dirName = path;
70 this.cache = cache; 68 this.cache = cache;
71 initDir(); 69 initDir();
362 * 360 *
363 * @param fn filename 361 * @param fn filename
364 * @return int index of file <code>fn</code> 362 * @return int index of file <code>fn</code>
365 */ 363 */
366 public int indexOf(String fn, int fc) { 364 public int indexOf(String fn, int fc) {
365 if (!isRead()) {
366 // read directory now
367 if (!readDir()) {
368 return -1;
369 }
370 }
367 // linear search -> worst performance 371 // linear search -> worst performance
368 int n = list[fc].size(); 372 int n = list[fc].size();
369 for (int i = 0; i < n; i++) { 373 for (int i = 0; i < n; i++) {
370 ImageFileset fs = (ImageFileset) list[fc].get(i); 374 ImageFileset fs = (ImageFileset) list[fc].get(i);
371 if (fs.getName().equals(fn)) { 375 if (fs.getName().equals(fn)) {
376 // filename matches
377 return i;
378 }
379 }
380 // try again without extension
381 for (int i = 0; i < n; i++) {
382 ImageFileset fs = (ImageFileset) list[fc].get(i);
383 if (fs.getBasename().equals(FileOps.basename(fn))) {
384 // basename matches
372 return i; 385 return i;
373 } 386 }
374 } 387 }
375 return -1; 388 return -1;
376 } 389 }