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

Method copyDir

app/src/processing/app/Util.java:316–345  ·  view source on GitHub ↗

Copy a folder from one place to another. This ignores all dot files and folders found in the source directory, to avoid copying silly .DS_Store files and potentially troublesome .svn folders.

(File sourceDir,
                             File targetDir)

Source from the content-addressed store, hash-verified

314 * files and potentially troublesome .svn folders.
315 */
316 static public void copyDir(File sourceDir,
317 File targetDir) throws IOException {
318 if (sourceDir.equals(targetDir)) {
319 final String urDum = "source and target directories are identical";
320 throw new IllegalArgumentException(urDum);
321 }
322 if (!targetDir.exists() && !targetDir.mkdirs()) {
323 throw new IOException("Could not create " + targetDir);
324 }
325 String[] filenames = sourceDir.list();
326 if (filenames != null) {
327 for (String filename : filenames) {
328 // Ignore dot files (.DS_Store), dot folders (.svn) while copying
329 if (filename.charAt(0) != '.') {
330 File source = new File(sourceDir, filename);
331 File target = new File(targetDir, filename);
332 if (source.isDirectory()) {
333 //target.mkdirs();
334 copyDir(source, target);
335 //noinspection ResultOfMethodCallIgnored
336 target.setLastModified(source.lastModified());
337 } else {
338 copyFile(source, target);
339 }
340 }
341 }
342 } else {
343 throw new IOException("Could not read " + sourceDir);
344 }
345 }
346
347
348 static public void copyDirNative(File sourceDir,

Callers 4

addTemplateFilesMethod · 0.95
copyAndLoadMethod · 0.95
backupMethod · 0.95
exportApplicationMethod · 0.95

Calls 4

copyFileMethod · 0.95
setLastModifiedMethod · 0.80
equalsMethod · 0.45
listMethod · 0.45

Tested by

no test coverage detected