Changeset 14005 in josm for trunk/src/org/openstreetmap/josm/plugins
- Timestamp:
- 2018-07-06T01:32:11+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r13193 r14005 5 5 6 6 import java.io.File; 7 import java.io.FileNotFoundException;8 import java.io.IOException;9 import java.io.InputStream;10 7 import java.net.URL; 11 8 import java.net.URLClassLoader; 12 import java.nio.file.Files;13 import java.nio.file.StandardCopyOption;14 9 import java.security.AccessController; 15 10 import java.security.PrivilegedAction; … … 138 133 } 139 134 140 /**141 * @return The directory for the plugin to store all kind of stuff.142 * @deprecated (since 13007) to get the same directory as this method, use {@code getPluginDirs().getUserDataDirectory(false)}.143 * However, for files that can be characterized as cache or preferences, you are encouraged to use the appropriate144 * {@link IBaseDirectories} method from {@link #getPluginDirs()}.145 */146 @Deprecated147 public String getPluginDir() {148 return new File(Main.pref.getPluginsDirectory(), info.name).getPath();149 }150 151 135 @Override 152 136 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {} … … 167 151 */ 168 152 public void addDownloadSelection(List<DownloadSelection> list) {} 169 170 /**171 * Copies the resource 'from' to the file in the plugin directory named 'to'.172 * @param from source file173 * @param to target file174 * @throws FileNotFoundException if the file exists but is a directory rather than a regular file,175 * does not exist but cannot be created, or cannot be opened for any other reason176 * @throws IOException if any other I/O error occurs177 * @deprecated without replacement178 */179 @Deprecated180 public void copy(String from, String to) throws IOException {181 String pluginDirName = getPluginDir();182 File pluginDir = new File(pluginDirName);183 if (!pluginDir.exists()) {184 Utils.mkDirs(pluginDir);185 }186 try (InputStream in = getClass().getResourceAsStream(from)) {187 if (in == null) {188 throw new IOException("Resource not found: "+from);189 }190 Files.copy(in, new File(pluginDirName, to).toPath(), StandardCopyOption.REPLACE_EXISTING);191 }192 }193 153 194 154 /**
Note:
See TracChangeset
for help on using the changeset viewer.