Mercurial > hg > digilib-old
comparison servlet/src/digilib/io/FileOps.java @ 197:bb4ed821d06e
Servlet version 1.18b6
- small fixes to the mapping code (really works now)
author | robcast |
---|---|
date | Tue, 23 Dec 2003 17:26:45 +0100 |
parents | b3f9a7f646c5 |
children | f8c82fea551a |
comparison
equal
deleted
inserted
replaced
196:8125a068af80 | 197:bb4ed821d06e |
---|---|
176 return fn.substring(i + 1); | 176 return fn.substring(i + 1); |
177 } | 177 } |
178 return ""; | 178 return ""; |
179 } | 179 } |
180 | 180 |
181 /** Normalize a path name. | |
182 * | |
183 * Removes leading and trailing slashes. Returns null if there is other | |
184 * unwanted stuff in the path name. | |
185 * | |
186 * @param pathname | |
187 * @return | |
188 */ | |
189 public static String normalName(String pathname) { | |
190 // upper-dir references are unwanted | |
191 if (pathname.indexOf("../") >= 0) { | |
192 return null; | |
193 } | |
194 int a = 0; | |
195 int e = pathname.length(); | |
196 // leading and trailing "/" are removed | |
197 if (pathname.startsWith("/")) { | |
198 a++; | |
199 } | |
200 if (pathname.endsWith("/")) { | |
201 e--; | |
202 } | |
203 return pathname.substring(a, e); | |
204 } | |
205 | |
206 | |
181 /** | 207 /** |
182 * FileFilter for image types (helper class for getFile) | 208 * FileFilter for image types (helper class for getFile) |
183 */ | 209 */ |
184 static class ImageFileFilter implements FileFilter { | 210 static class ImageFileFilter implements FileFilter { |
185 | 211 |