/** * @param url the "file:" URL of the file to remove from the file store. Only files in the * writable World Wind disk cache or temp file directory are removed by this method. * @throws IllegalArgumentException if <code>url</code> is null */ @SuppressWarnings({"ResultOfMethodCallIgnored"}) public void removeFile(java.net.URL url) { if (url == null) { String msg = Logging.getMessage("nullValue.URLIsNull"); Logging.logger().severe(msg); throw new IllegalArgumentException(msg); } try { java.io.File file = new java.io.File(url.toURI()); // This block of code must be synchronized for proper operation. A thread may check that the // file exists, // and become immediately suspended. A second thread may then delete that file. When the first // thread // wakes up, file.delete() fails. synchronized (this.fileLock) { if (file.exists()) { // Don't remove files outside the cache or temp directory. String parent = file.getParent(); if (!(parent.startsWith(this.getWriteLocation().getPath()) || parent.startsWith(Configuration.getSystemTempDirectory()))) return; file.delete(); } } } catch (java.net.URISyntaxException e) { Logging.logger() .log( Level.SEVERE, Logging.getMessage("FileStore.ExceptionRemovingFile", url.toString()), e); } }