Skip to content

Commit

Permalink
utils: add the method FileUtils.copyFile, #TASK-6297, #TASK-6255
Browse files Browse the repository at this point in the history
On branch TASK-6255
Changes to be committed:
	modified:   commons-lib/pom.xml
	modified:   commons-lib/src/main/java/org/opencb/commons/utils/FileUtils.java
  • Loading branch information
jtarraga committed Jun 3, 2024
1 parent dd1a1b5 commit 1955035
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions commons-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,11 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
22 changes: 22 additions & 0 deletions commons-lib/src/main/java/org/opencb/commons/utils/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 1955035

Please sign in to comment.