Changeset 16769 in osm for applications/viewer/jmapviewer/src
- Timestamp:
- 2009-08-02T14:36:37+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java
r16768 r16769 21 21 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource; 22 22 import org.openstreetmap.gui.jmapviewer.interfaces.TileSource.TileUpdate; 23 import static org.openstreetmap.josm.tools.I18n.tr; 23 24 24 25 /** … … 53 54 * @param cacheDir 54 55 */ 55 public OsmFileCacheTileLoader(TileLoaderListener map, File cacheDir) {56 public OsmFileCacheTileLoader(TileLoaderListener map, File cacheDir) throws SecurityException{ 56 57 super(map); 57 String tempDir = System.getProperty("java.io.tmpdir");58 String tempDir = null; 58 59 String userName = System.getProperty("user.name"); 59 60 try { 61 tempDir = System.getProperty("java.io.tmpdir"); 62 } catch(SecurityException e) { 63 log.warning(tr("Failed to access system property ''{0}'' for security reasons. Exception was: {1}", "java.io.tmpdir", e.toString())); 64 throw e; // rethrow 65 } 66 try { 60 67 if (cacheDir == null) { 61 if (tempDir == null) {68 if (tempDir == null) 62 69 throw new IOException("No temp directory set"); 63 }64 70 String subDirName = "JMapViewerTiles"; 65 71 // On Linux/Unix systems we do not have a per user tmp directory. … … 70 76 } 71 77 log.finest("Tile cache directory: " + cacheDir); 72 if (!cacheDir.exists() && !cacheDir.mkdirs()) {78 if (!cacheDir.exists() && !cacheDir.mkdirs()) 73 79 throw new IOException(); 74 }75 80 cacheDirBase = cacheDir.getAbsolutePath(); 76 81 } catch (Exception e) { … … 80 85 81 86 /** 82 * Create a OSMFileCacheTileLoader with system property temp dir. 87 * Create a OSMFileCacheTileLoader with system property temp dir. 83 88 * If not set an IOException will be thrown. 84 89 * @param map 85 90 */ 86 public OsmFileCacheTileLoader(TileLoaderListener map) {91 public OsmFileCacheTileLoader(TileLoaderListener map) throws SecurityException { 87 92 this(map, null); 88 93 } 89 94 95 @Override 90 96 public Runnable createTileLoaderJob(final TileSource source, final int tilex, final int tiley, final int zoom) { 91 97 return new FileLoadJob(source, tilex, tiley, zoom); … … 120 126 } 121 127 tileCacheDir = new File(cacheDirBase, source.getName()); 122 if (!tileCacheDir.exists()) 128 if (!tileCacheDir.exists()) { 123 129 tileCacheDir.mkdirs(); 130 } 124 131 if (loadTileFromFile()) 125 132 return; … … 200 207 tile.setImage(Tile.ERROR_IMAGE); 201 208 listener.tileLoadingFinished(tile, false); 202 if (input == null) 209 if (input == null) { 203 210 System.err.println("failed loading " + zoom + "/" + tilex + "/" + tiley + " " + e.getMessage()); 211 } 204 212 } finally { 205 213 tile.loading = false; … … 249 257 do { 250 258 int read = input.read(buffer); 251 if (read >= 0) 259 if (read >= 0) { 252 260 bout.write(buffer, 0, read); 253 else261 } else { 254 262 finished = true; 263 } 255 264 } while (!finished); 256 265 if (bout.size() == 0)
Note:
See TracChangeset
for help on using the changeset viewer.