()
| 7949 | |
| 7950 | |
| 7951 | static protected String calcSketchPath() { |
| 7952 | // try to get the user folder. if running under java web start, |
| 7953 | // this may cause a security exception if the code is not signed. |
| 7954 | // http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Integrate;action=display;num=1159386274 |
| 7955 | String folder = null; |
| 7956 | try { |
| 7957 | folder = System.getProperty("user.dir"); |
| 7958 | |
| 7959 | URL jarURL = |
| 7960 | PApplet.class.getProtectionDomain().getCodeSource().getLocation(); |
| 7961 | // Decode URL |
| 7962 | String jarPath = jarURL.toURI().getSchemeSpecificPart(); |
| 7963 | |
| 7964 | // Workaround for bug in Java for OS X from Oracle (7u51) |
| 7965 | // https://github.com/processing/processing/issues/2181 |
| 7966 | if (platform == MACOSX) { |
| 7967 | if (jarPath.contains("Contents/Java/")) { |
| 7968 | String appPath = jarPath.substring(0, jarPath.indexOf(".app") + 4); |
| 7969 | File containingFolder = new File(appPath).getParentFile(); |
| 7970 | folder = containingFolder.getAbsolutePath(); |
| 7971 | } |
| 7972 | } else { |
| 7973 | // Working directory may not be set properly, try some options |
| 7974 | // https://github.com/processing/processing/issues/2195 |
| 7975 | if (jarPath.contains("/lib/")) { |
| 7976 | // Windows or Linux, back up a directory to get the executable |
| 7977 | folder = new File(jarPath, "../..").getCanonicalPath(); |
| 7978 | } |
| 7979 | } |
| 7980 | } catch (Exception e) { |
| 7981 | e.printStackTrace(); |
| 7982 | } |
| 7983 | return folder; |
| 7984 | } |
| 7985 | |
| 7986 | |
| 7987 | public String sketchPath() { |
no test coverage detected