public File sketchFile(String where) { return new File(sketchPath(where)); }
public File sketchFile(String where) { return new File(sketchPath(where)); }
/** * Prepend the sketch folder path to the filename (or path) that is * passed in. External libraries should use this function to save to * the sketch folder. * <p/> * Note that when running as an applet inside a web browser, * the sketchPath will be set to null, because security restrictions * prevent applets from accessing that information. * <p/> * This will also cause an error if the sketch is not inited properly, * meaning that init() was never called on the PApplet when hosted * my some other main() or by other code. For proper use of init(), * see the examples in the main description text for PApplet. */ public String sketchPath(String where) { if (sketchPath() == null) { return where; } // isAbsolute() could throw an access exception, but so will writing // to the local disk using the sketch path, so this is safe here. // for 0120, added a try/catch anyways. try { if (new File(where).isAbsolute()) return where; } catch (Exception e) { } return sketchPath() + File.separator + where; }
/** * Returns a path inside the applet folder to save to. Like sketchPath(), * but creates any in-between folders so that things save properly. * <p/> * All saveXxxx() functions use the path to the sketch folder, rather than * its data folder. Once exported, the data folder will be found inside the * jar file of the exported application or applet. In this case, it's not * possible to save data into the jar file, because it will often be running * from a server, or marked in-use if running from a local file system. * With this in mind, saving to the data path doesn't make sense anyway. * If you know you're running locally, and want to save to the data folder, * use <TT>saveXxxx("data/blah.dat")</TT>. */ public String savePath(String where) { if (where == null) return null; String filename = sketchPath(where); createPath(filename); return filename; }
return sketch.sketchPath(); return path.substring(n0, n1); } else { return sketch.sketchPath(); return sketch.sketchPath();
/** * Returns a path inside the applet folder to save to. Like sketchPath(), * but creates any in-between folders so that things save properly. * <p/> * All saveXxxx() functions use the path to the sketch folder, rather than * its data folder. Once exported, the data folder will be found inside the * jar file of the exported application or applet. In this case, it's not * possible to save data into the jar file, because it will often be running * from a server, or marked in-use if running from a local file system. * With this in mind, saving to the data path doesn't make sense anyway. * If you know you're running locally, and want to save to the data folder, * use <TT>saveXxxx("data/blah.dat")</TT>. */ public String savePath(String where) { if (where == null) return null; // System.out.println("filename before sketchpath is " + where); String filename = sketchPath(where); // System.out.println("filename after sketchpath is " + filename); createPath(filename); return filename; }
file = new File(sketchPath(filename));
String path = sketch.sketchPath(filename); stream = new FileInputStream(path); if (stream != null) {
File sketchFile = new File(sketchPath(filename)); if (sketchFile.exists()) { try {
stream = new FileInputStream(sketchPath(filename)); if (stream != null) return stream; } catch (Exception e) { } // ignored