Changeset 34396 in osm for applications/editors
- Timestamp:
- 2018-07-06T01:23:01+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/osmarender/src/org/openstreetmap/josm/plugins/osmarender/OsmarenderPlugin.java
r33916 r34396 9 9 import java.io.File; 10 10 import java.io.FileInputStream; 11 import java.io.FileNotFoundException; 11 12 import java.io.FileOutputStream; 12 13 import java.io.IOException; 14 import java.io.InputStream; 13 15 import java.io.InputStreamReader; 14 16 import java.io.OutputStreamWriter; 15 17 import java.io.PrintWriter; 16 18 import java.nio.charset.StandardCharsets; 19 import java.nio.file.Files; 20 import java.nio.file.StandardCopyOption; 17 21 import java.util.HashSet; 18 22 import java.util.Set; … … 50 54 import org.openstreetmap.josm.tools.Logging; 51 55 import org.openstreetmap.josm.tools.PlatformHookWindows; 56 import org.openstreetmap.josm.tools.Utils; 52 57 53 58 public class OsmarenderPlugin extends Plugin { … … 151 156 152 157 // install the xsl and xml file 153 copy("/osmarender.xsl", "osmarender.xsl"); 154 copy("/osm-map-features.xml", "osm-map-features.xml"); 158 _copy("/osmarender.xsl", "osmarender.xsl"); 159 _copy("/osm-map-features.xml", "osm-map-features.xml"); 160 } 161 162 /** 163 * @return The directory for the plugin to store all kind of stuff. 164 * @deprecated (since 13007) to get the same directory as this method, use {@code getPluginDirs().getUserDataDirectory(false)}. 165 * However, for files that can be characterized as cache or preferences, you are encouraged to use the appropriate 166 * {@link org.openstreetmap.josm.spi.preferences.IBaseDirectories} method from {@link #getPluginDirs()}. 167 */ 168 @Deprecated 169 public String _getPluginDir() { 170 return new File(Main.pref.getPluginsDirectory(), getPluginInformation().name).getPath(); 171 } 172 173 /** 174 * Copies the resource 'from' to the file in the plugin directory named 'to'. 175 * @param from source file 176 * @param to target file 177 * @throws FileNotFoundException if the file exists but is a directory rather than a regular file, 178 * does not exist but cannot be created, or cannot be opened for any other reason 179 * @throws IOException if any other I/O error occurs 180 * @deprecated without replacement 181 */ 182 @Deprecated 183 public void _copy(String from, String to) throws IOException { 184 String pluginDirName = _getPluginDir(); 185 File pluginDir = new File(pluginDirName); 186 if (!pluginDir.exists()) { 187 Utils.mkDirs(pluginDir); 188 } 189 try (InputStream in = getClass().getResourceAsStream(from)) { 190 if (in == null) { 191 throw new IOException("Resource not found: "+from); 192 } 193 Files.copy(in, new File(pluginDirName, to).toPath(), StandardCopyOption.REPLACE_EXISTING); 194 } 155 195 } 156 196
Note:
See TracChangeset
for help on using the changeset viewer.