diff --git a/commons-lib/pom.xml b/commons-lib/pom.xml index dccbe7ec..0e057979 100644 --- a/commons-lib/pom.xml +++ b/commons-lib/pom.xml @@ -68,5 +68,11 @@ com.fasterxml.jackson.core jackson-databind + + commons-io + commons-io + 2.8.0 + compile + diff --git a/commons-lib/src/main/java/org/opencb/commons/utils/FileUtils.java b/commons-lib/src/main/java/org/opencb/commons/utils/FileUtils.java index 93fba0f0..1ae5ba87 100644 --- a/commons-lib/src/main/java/org/opencb/commons/utils/FileUtils.java +++ b/commons-lib/src/main/java/org/opencb/commons/utils/FileUtils.java @@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils; import org.opencb.commons.exec.Command; +import org.slf4j.LoggerFactory; import java.io.*; import java.nio.charset.Charset; @@ -188,6 +189,27 @@ public static String[] getUserAndGroup(Path path, boolean numericId) throws IOEx return new String[]{split[2], split[3]}; } + + public static void copyFile(File src, File dest) throws IOException { + try { + org.apache.commons.io.FileUtils.copyFile(src, dest); + } catch (IOException e) { + try { + if (src.length() == dest.length()) { + LoggerFactory.getLogger(FileUtils.class).warn(e.getMessage()); + return; + } + throw e; + } catch (Exception e1) { + throw e; + } + } + } + + //------------------------------------------------------------------------- + // P R I V A T E M E T H O D S + //------------------------------------------------------------------------- + private static String getLsOutput(Path path, boolean numericId) throws IOException { FileUtils.checkPath(path);