()
| 7160 | |
| 7161 | |
| 7162 | static protected String calcSketchPath() { |
| 7163 | // try to get the user folder. if running under java web start, |
| 7164 | // this may cause a security exception if the code is not signed. |
| 7165 | // http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Integrate;action=display;num=1159386274 |
| 7166 | String folder = null; |
| 7167 | try { |
| 7168 | folder = System.getProperty("user.dir"); |
| 7169 | |
| 7170 | URL jarURL = |
| 7171 | PApplet.class.getProtectionDomain().getCodeSource().getLocation(); |
| 7172 | // Decode URL |
| 7173 | String jarPath = jarURL.toURI().getSchemeSpecificPart(); |
| 7174 | |
| 7175 | // Workaround for bug in Java for OS X from Oracle (7u51) |
| 7176 | // https://github.com/processing/processing/issues/2181 |
| 7177 | if (platform == MACOS) { |
| 7178 | if (jarPath.contains("Contents/Java/")) { |
| 7179 | String appPath = jarPath.substring(0, jarPath.indexOf(".app") + 4); |
| 7180 | File containingFolder = new File(appPath).getParentFile(); |
| 7181 | folder = containingFolder.getAbsolutePath(); |
| 7182 | } |
| 7183 | } else { |
| 7184 | // Working directory may not be set properly, try some options |
| 7185 | // https://github.com/processing/processing/issues/2195 |
| 7186 | if (jarPath.contains("/lib/")) { |
| 7187 | // Windows or Linux, back up a directory to get the executable |
| 7188 | folder = new File(jarPath, "../..").getCanonicalPath(); |
| 7189 | } |
| 7190 | } |
| 7191 | } catch (Exception e) { |
| 7192 | e.printStackTrace(); |
| 7193 | } |
| 7194 | return folder; |
| 7195 | } |
| 7196 | |
| 7197 | |
| 7198 | public String sketchPath() { |
no test coverage detected