mirror of
https://github.com/processing/processing4.git
synced 2026-02-14 02:45:36 +01:00
trying to sort out path and bits issues for 2.0a2
This commit is contained in:
@@ -6548,8 +6548,8 @@ public class PApplet extends Applet
|
||||
|
||||
return sketchPath + File.separator + "data" + File.separator + where;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return a full path to an item in the data folder as a File object.
|
||||
* See the dataPath() method for more information.
|
||||
@@ -6559,6 +6559,32 @@ public class PApplet extends Applet
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* On Windows and Linux, this is simply the data folder. On Mac OS X, this is
|
||||
* the path to the data folder buried inside Contents/Resources/Java
|
||||
*/
|
||||
public File inputFile(String where) {
|
||||
// isAbsolute() could throw an access exception, but so will writing
|
||||
// to the local disk using the sketch path, so this is safe here.
|
||||
File why = new File(where);
|
||||
if (why.isAbsolute()) return why;
|
||||
|
||||
String jarPath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
|
||||
if (jarPath.contains("Contents/Resources/Java/")) {
|
||||
File containingFolder = new File(jarPath).getParentFile();
|
||||
File dataFolder = new File(containingFolder, "data");
|
||||
return new File(dataFolder, where);
|
||||
}
|
||||
// Windows, Linux, or when not using a Mac OS X .app file
|
||||
return new File(sketchPath + File.separator + "data" + File.separator + where);
|
||||
}
|
||||
|
||||
|
||||
public String inputPath(String where) {
|
||||
return inputFile(where).getAbsolutePath();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Takes a path and creates any in-between folders if they don't
|
||||
* already exist. Useful when trying to save to a subfolder that
|
||||
|
||||
Reference in New Issue
Block a user