MCPcopy Index your code
hub / github.com/processing/processing / calcFolderSize

Method calcFolderSize

app/src/processing/app/Util.java:360–379  ·  view source on GitHub ↗

Calculate the size of the contents of a folder. Used to determine whether sketches are empty or not. Note that the function calls itself recursively.

(File folder)

Source from the content-addressed store, hash-verified

358 * Note that the function calls itself recursively.
359 */
360 static public long calcFolderSize(File folder) {
361 int size = 0;
362
363 String files[] = folder.list();
364 // null if folder doesn't exist, happens when deleting sketch
365 if (files == null) return -1;
366
367 for (int i = 0; i < files.length; i++) {
368 if (files[i].equals(".") ||
369 files[i].equals("..") ||
370 files[i].equals(".DS_Store")) continue;
371 File fella = new File(folder, files[i]);
372 if (fella.isDirectory()) {
373 size += calcFolderSize(fella);
374 } else {
375 size += (int) fella.length();
376 }
377 }
378 return size;
379 }
380
381
382 /**

Callers 1

calcSizeMethod · 0.95

Calls 2

listMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected