MCPcopy Index your code
hub / github.com/benfry/processing4 / dataFile

Method dataFile

core/src/processing/core/PApplet.java:7314–7336  ·  view source on GitHub ↗

Return a full path to an item in the data folder as a File object. See the dataPath() method for more information.

(String where)

Source from the content-addressed store, hash-verified

7312 * See the dataPath() method for more information.
7313 */
7314 public File dataFile(String where) {
7315 // isAbsolute() could throw an access exception, but so will writing
7316 // to the local disk using the sketch path, so this is safe here.
7317 File why = new File(where);
7318 if (why.isAbsolute()) return why;
7319
7320 URL jarURL = getClass().getProtectionDomain().getCodeSource().getLocation();
7321 // Decode URL
7322 String jarPath;
7323 try {
7324 jarPath = jarURL.toURI().getPath();
7325 } catch (URISyntaxException e) {
7326 e.printStackTrace();
7327 return null;
7328 }
7329 if (jarPath.contains("Contents/Java/")) {
7330 File containingFolder = new File(jarPath).getParentFile();
7331 File dataFolder = new File(containingFolder, "data");
7332 return new File(dataFolder, where);
7333 }
7334 // Windows, Linux, or when not using a Mac OS X .app file
7335 return new File(sketchPath + File.separator + "data" + File.separator + where);
7336 }
7337
7338
7339 /**

Callers 1

dataPathMethod · 0.95

Calls 3

getPathMethod · 0.45
printStackTraceMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected