Changeset 873 in josm for trunk/src/org/openstreetmap/josm/plugins
- Timestamp:
- 2008-08-26T22:35:52+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/plugins
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r627 r873 53 53 */ 54 54 public final String getPluginDir() { 55 return Main.pref.getP referencesDir()+"plugins/"+info.name+"/";55 return new File(Main.pref.getPluginsDirFile(), info.name).getPath(); 56 56 } 57 57 -
trunk/src/org/openstreetmap/josm/plugins/PluginDownloader.java
r627 r873 13 13 import java.io.FileOutputStream; 14 14 import java.io.FileWriter; 15 import java.io.FilenameFilter; 15 16 import java.io.IOException; 16 17 import java.io.InputStream; … … 54 55 55 56 @Override protected void realRun() throws SAXException, IOException { 57 File pluginDir = Main.pref.getPluginsDirFile(); 58 if (!pluginDir.exists()) 59 pluginDir.mkdirs(); 56 60 for (PluginDescription d : toUpdate) { 57 File tempFile = new File(Main.pref.getPreferencesDir()+"temp.jar"); 58 if (download(d.resource, tempFile)) { 59 tempFile.renameTo(new File(Main.pref.getPreferencesDir()+"plugins/"+d.name+".jar")); 61 File pluginFile = new File(pluginDir, d.name + ".jar.new"); 62 if (download(d.resource, pluginFile)) 60 63 count++; 61 }else64 else 62 65 errors += d.name + "\n"; 63 66 } 67 PluginDownloader.moveUpdatedPlugins(); 64 68 } 65 69 } … … 79 83 r.close(); 80 84 new File(Main.pref.getPreferencesDir()+"plugins").mkdir(); 81 FileWriter out = new FileWriter(Main.pref.getPreferencesDir()+"plugins/"+count+"-site-"+site.replaceAll("[/:\\\\ <>|]", "_")+".xml"); 85 FileWriter out = new FileWriter(new File(Main.pref 86 .getPluginsDirFile(), count + "-site-" 87 + site.replaceAll("[/:\\\\ <>|]", "_") + ".xml")); 82 88 out.append(txt); 83 89 out.close(); … … 123 129 124 130 public static boolean downloadPlugin(PluginDescription pd) { 125 File file = new File(Main.pref.getP referencesDir()+"plugins/"+pd.name+".jar");131 File file = new File(Main.pref.getPluginsDirFile(), pd.name + ".jar"); 126 132 if (!download(pd.resource, file)) { 127 133 JOptionPane.showMessageDialog(Main.parent, tr("Could not download plugin: {0} from {1}", pd.name, pd.resource)); … … 163 169 Main.worker.execute(new UpdateTask(update)); 164 170 } 171 172 public static boolean moveUpdatedPlugins() { 173 File pluginDir = Main.pref.getPluginsDirFile(); 174 boolean ok = true; 175 if (pluginDir.exists() && pluginDir.isDirectory()) { 176 final File[] files = pluginDir.listFiles(new FilenameFilter() { 177 public boolean accept(File dir, String name) { 178 return name.endsWith(".new"); 179 }}); 180 for (File updatedPlugin : files) { 181 final String filePath = updatedPlugin.getPath(); 182 File plugin = new File(filePath.substring(0, filePath.length() - 4)); 183 ok = plugin.delete() && updatedPlugin.renameTo(plugin) && ok; 184 } 185 } 186 return ok; 187 } 165 188 } -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r627 r873 196 196 197 197 for (String s : locations) { 198 File pluginFile = new File(s +"/"+pluginName+".jar");198 File pluginFile = new File(s, pluginName + ".jar"); 199 199 if (pluginFile.exists()) { 200 200 PluginInformation info = new PluginInformation(pluginFile);
Note:
See TracChangeset
for help on using the changeset viewer.