Changeset 3440 in osm for applications/editors/josm/plugins
- Timestamp:
- 2007-07-01T22:30:16+02:00 (17 years ago)
- Location:
- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/SpellCheck.java
r3038 r3440 142 142 { 143 143 String source = st.nextToken(); 144 File sourceFile = Util.mirror(new URL(source), plugin.getPluginDir());144 File sourceFile = Util.mirror(new URL(source), Util.getPluginDir(), -1); 145 145 if( sourceFile == null || !sourceFile.exists() ) 146 146 { -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/Util.java
r3038 r3440 47 47 48 48 /** 49 * Returns the plugin's directory of a plugin 50 * <p> 51 * Utility method for classes that can't acces the plugin object 49 * Returns the plugin's directory of the plugin 52 50 * 53 * @param clazz The plugin class to look for54 51 * @return The directory of the plugin 55 52 */ 56 public static String get StaticPluginDir(Class<? extends Plugin> clazz)53 public static String getPluginDir() 57 54 { 58 Plugin plugin = getPlugin(clazz); 59 return ( plugin != null ) ? plugin.getPluginDir() : null; 55 return Main.pref.getPreferencesDir() + "plugins/validator/"; 60 56 } 61 57 … … 172 168 * @param url The URL of the remote file 173 169 * @param destDir The destionation dir of the mirrored file 170 * @param maxTime The time interval, in seconds, to check if the file changed. If less than 0, it defaults to 1 week 174 171 * @return The local file 175 172 */ 176 public static File mirror(URL url, String destDir )173 public static File mirror(URL url, String destDir, long maxTime) 177 174 { 178 175 if( url.getProtocol().equals("file") ) … … 187 184 localPath = st.nextToken(); 188 185 oldFile = new File(localPath); 189 if( System.currentTimeMillis() - checkDate < 24 * 60 * 60 * 1000 ) 186 maxTime = (maxTime <= 0) ? 7 * 24 * 60 * 60 * 1000 : maxTime * 1000; 187 if( System.currentTimeMillis() - checkDate < maxTime ) 190 188 { 191 189 if( oldFile.exists() ) … … 194 192 } 195 193 196 localPath = destDir + System.currentTimeMillis() + "-" + new File(url.getPath()).getName(); 194 File destDirFile = new File(destDir); 195 if( !destDirFile.exists() ) 196 destDirFile.mkdirs(); 197 198 localPath = destDir + System.currentTimeMillis() + "-" + new File(url.getPath()).getName(); 197 199 BufferedOutputStream bos = null; 198 200 BufferedInputStream bis = null;
Note:
See TracChangeset
for help on using the changeset viewer.