| | |
| | | import java.io.File; |
| | | import java.io.FileFilter; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.util.logging.Logger; |
| | |
| | | */ |
| | | public void apply() throws IOException |
| | | { |
| | | File objectFile = getObjectFile(); |
| | | final File objectFile = getObjectFile(); |
| | | if (objectFile.isDirectory()) |
| | | { |
| | | if (!destination.exists()) |
| | |
| | | } |
| | | else |
| | | { |
| | | |
| | | // If overwriting and the destination exists then kill it |
| | | if (destination.exists() && overwrite) |
| | | { |
| | |
| | | { |
| | | fis = new FileInputStream(objectFile); |
| | | fos = new FileOutputStream(destination); |
| | | byte[] buf = new byte[1024]; |
| | | final byte[] buf = new byte[1024]; |
| | | int i; |
| | | while ((i = fis.read(buf)) != -1) |
| | | { |
| | |
| | | // Java 1.6 but until then use the TestUtilities methods |
| | | if (UpgradeUtils.isUnix()) |
| | | { |
| | | FilePermission permissions = |
| | | final FilePermission permissions = |
| | | getFileSystemPermissions(objectFile); |
| | | FilePermission.setPermissions(destination, permissions); |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch (FileNotFoundException e) |
| | | catch (IOException e) |
| | | { |
| | | throw new IOException(e.getMessage()); |
| | | throw e; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | final Message errMsg = INFO_ERROR_COPYING_FILE.get( |
| | | objectFile.getAbsolutePath(), destination.getAbsolutePath()); |
| | | throw new IOException(errMsg.toString()); |
| | | throw new IOException(errMsg.toString(), e); |
| | | } |
| | | finally |
| | | { |