[io] rename copyContent to copyRecursive
This commit is contained in:
parent
2d3c1c6a19
commit
29bda2154c
|
@ -75,14 +75,23 @@ public class JFiles {
|
|||
else Files.delete(path);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void copyContent(Path source, Path destination) throws IOException {
|
||||
copyRecursive(source, destination);
|
||||
}
|
||||
@Deprecated
|
||||
public static void copyContent(Path source, Path target, CopyOption... copyOptions) throws IOException {
|
||||
copyRecursive(source, target, copyOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the source is a file, copy it to the target. If it is a directory, create the target directory if it doesn't exist and copy the source directories content there
|
||||
* @param source The path to copy from
|
||||
* @param destination The path to copy to
|
||||
* @throws IOException Something went wrong
|
||||
*/
|
||||
public static void copyContent(Path source, Path destination) throws IOException {
|
||||
copyContent(source, destination, StandardCopyOption.COPY_ATTRIBUTES);
|
||||
public static void copyRecursive(Path source, Path destination) throws IOException {
|
||||
copyRecursive(source, destination, StandardCopyOption.COPY_ATTRIBUTES);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,7 +101,7 @@ public class JFiles {
|
|||
* @param copyOptions Copy options to use
|
||||
* @throws IOException Something went wrong
|
||||
*/
|
||||
public static void copyContent(Path source, Path target, CopyOption... copyOptions) throws IOException {
|
||||
public static void copyRecursive(Path source, Path target, CopyOption... copyOptions) throws IOException {
|
||||
if (!Files.exists(target)) Files.createDirectories(target);
|
||||
boolean replaceExisting = Arrays.asList(copyOptions).contains(StandardCopyOption.REPLACE_EXISTING);
|
||||
if (Files.isDirectory(source)) {
|
||||
|
@ -102,7 +111,7 @@ public class JFiles {
|
|||
if (!replaceExisting) return;
|
||||
if (!Files.isDirectory(sourceResolved)) Files.delete(target);
|
||||
}
|
||||
copyContent(sourceResolved, targetResolved, copyOptions);
|
||||
copyRecursive(sourceResolved, targetResolved, copyOptions);
|
||||
});
|
||||
} else if (Files.exists(source)) {
|
||||
if (!Files.exists(target) || replaceExisting) Files.copy(source, target, copyOptions);
|
||||
|
|
Loading…
Reference in New Issue