MCPcopy Index your code
hub / github.com/VolmitSoftware/Adapt / doCopyFile

Method doCopyFile

src/main/java/com/volmit/adapt/util/IO.java:447–464  ·  view source on GitHub ↗

Internal copy file method. @param srcFile the validated source file, not null @param destFile the validated destination file, not null @param preserveFileDate whether to preserve the file date @throws IOException if an error occurs

(File srcFile, File destFile, boolean preserveFileDate)

Source from the content-addressed store, hash-verified

445 * @throws IOException if an error occurs
446 */
447 private static void doCopyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException {
448 if (destFile.exists() && destFile.isDirectory()) {
449 throw new IOException("Destination '" + destFile + "' exists but is a directory");
450 }
451
452 try (FileInputStream input = new FileInputStream(srcFile)) {
453 try (FileOutputStream output = new FileOutputStream(destFile)) {
454 IO.copy(input, output);
455 }
456 }
457
458 if (srcFile.length() != destFile.length()) {
459 throw new IOException("Failed to copy full contents from '" + srcFile + "' to '" + destFile + "'");
460 }
461 if (preserveFileDate) {
462 destFile.setLastModified(srcFile.lastModified());
463 }
464 }
465
466 /**
467 * Unconditionally close an <code>Reader</code>.

Callers 1

copyFileMethod · 0.95

Calls 2

copyMethod · 0.95
lengthMethod · 0.45

Tested by

no test coverage detected