(String _codebase, String _filename)
| 20 | static private java.util.Hashtable<String, ImageIcon> cacheImages = new java.util.Hashtable<String, ImageIcon>(); |
| 21 | |
| 22 | static public boolean fileExists(String _codebase, String _filename) { |
| 23 | if(_filename==null) { |
| 24 | return false; |
| 25 | } |
| 26 | if(cacheImages.get(_filename)!=null) { |
| 27 | return true; |
| 28 | } |
| 29 | if (OSPRuntime.isJS && _codebase == null) { |
| 30 | URL u = Utils.class.getClassLoader().getResource(_filename); |
| 31 | return (u != null); |
| 32 | } |
| 33 | if(_codebase!=null) { |
| 34 | if(_codebase.startsWith("file:")) { //$NON-NLS-1$ |
| 35 | _codebase = "file:///"+_codebase.substring(6); //$NON-NLS-1$ |
| 36 | } |
| 37 | if(!_filename.startsWith("/") && !_codebase.endsWith("/")) { //$NON-NLS-1$ |
| 38 | _codebase += "/"; //$NON-NLS-1$ |
| 39 | } |
| 40 | } |
| 41 | int index = _filename.indexOf('+'); |
| 42 | if(index>=0) { |
| 43 | return fileExistsInJar(_codebase, _filename.substring(0, index), _filename.substring(index+1)); |
| 44 | } else if(_codebase==null) { |
| 45 | java.io.File file = new java.io.File(_filename); |
| 46 | return file.exists(); |
| 47 | } else { |
| 48 | try { |
| 49 | java.net.URL url = new java.net.URL(_codebase+_filename); |
| 50 | java.io.InputStream stream = ResourceLoader.openStream(url); |
| 51 | stream.close(); |
| 52 | return true; |
| 53 | } catch(Exception exc) { |
| 54 | return false; |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | static public boolean fileExistsInJar(String _codebase, String _jarFile, String _filename) { |
| 60 | if((_filename==null)||(_jarFile==null)) { |
no test coverage detected