Mercurial > hg > digilib-old
comparison servlet/src/digilib/io/FileOps.java @ 86:997ba69afb81
New version 1.8b1.
With directory and file information cache.
With enhanceRGB method for color correction.
author | robcast |
---|---|
date | Sun, 09 Mar 2003 21:37:27 +0100 |
parents | 4e6757e8ccd4 |
children | a398fc09ba71 |
comparison
equal
deleted
inserted
replaced
85:4e6757e8ccd4 | 86:997ba69afb81 |
---|---|
76 if (f.isFile()) { | 76 if (f.isFile()) { |
77 return f; | 77 return f; |
78 } | 78 } |
79 // if fn is a directory name then open directory | 79 // if fn is a directory name then open directory |
80 if (f.isDirectory()) { | 80 if (f.isDirectory()) { |
81 File[] fl = f.listFiles(new ImgFileFilter()); | 81 File[] fl = f.listFiles(new ImageFileFilter()); |
82 Arrays.sort(fl); | 82 Arrays.sort(fl); |
83 if ((n > 0) && (n <= fl.length)) { | 83 if ((n > 0) && (n <= fl.length)) { |
84 return fl[n - 1]; | 84 return fl[n - 1]; |
85 } | 85 } |
86 } | 86 } |
100 if (f.isFile()) { | 100 if (f.isFile()) { |
101 return 1; | 101 return 1; |
102 } | 102 } |
103 // if fn is a directory name then return the number of files | 103 // if fn is a directory name then return the number of files |
104 if (f.isDirectory()) { | 104 if (f.isDirectory()) { |
105 return f.listFiles(new ImgFileFilter()).length; | 105 return f.listFiles(new ImageFileFilter()).length; |
106 } | 106 } |
107 // then fn must be something strange... | 107 // then fn must be something strange... |
108 return 0; | 108 return 0; |
109 } | 109 } |
110 | 110 |
159 } | 159 } |
160 | 160 |
161 /** | 161 /** |
162 * FileFilter for image types (helper class for getFile) | 162 * FileFilter for image types (helper class for getFile) |
163 */ | 163 */ |
164 private class ImgFileFilter implements FileFilter { | 164 static class ImageFileFilter implements FileFilter { |
165 | 165 |
166 public boolean accept(File f) { | 166 public boolean accept(File f) { |
167 if (f.isFile()) { | 167 if (f.isFile()) { |
168 return (mimeForFile(f) != null); | 168 return (mimeForFile(f) != null); |
169 } else { | 169 } else { |