mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-13 12:38:07 +00:00
7031166: (pack200) tools/pack200/CommandLineTests.java fail with testsdk on RO filesystem
Reviewed-by: alanb
This commit is contained in:
parent
680370af5b
commit
a1a5907f79
@ -120,9 +120,9 @@ public class CommandLineTests {
|
||||
// make a backup copy for re-use
|
||||
File bakFile = new File(f.getName() + ".bak");
|
||||
if (!bakFile.exists()) { // backup
|
||||
Utils.copyFile(f.getAbsoluteFile(), bakFile.getAbsoluteFile());
|
||||
Utils.copyFile(f, bakFile);
|
||||
} else { // restore
|
||||
Utils.copyFile(bakFile.getAbsoluteFile(), f.getAbsoluteFile());
|
||||
Utils.copyFile(bakFile, f);
|
||||
}
|
||||
cmdsList.clear();
|
||||
cmdsList.add(Utils.getPack200Cmd());
|
||||
|
||||
@ -56,7 +56,7 @@ public class TimeStamp {
|
||||
// make a local copy of our test file
|
||||
File srcFile = Utils.locateJar("golden.jar");
|
||||
File goldenFile = new File("golden.jar");
|
||||
Utils.copyFile(srcFile, goldenFile.getAbsoluteFile());
|
||||
Utils.copyFile(srcFile, goldenFile);
|
||||
|
||||
JarFile goldenJarFile = new JarFile(goldenFile);
|
||||
File packFile = new File("golden.pack");
|
||||
|
||||
@ -21,18 +21,18 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -44,6 +44,8 @@ import java.util.jar.Pack200;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import static java.nio.file.StandardCopyOption.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ksrini
|
||||
@ -180,45 +182,12 @@ class Utils {
|
||||
}
|
||||
};
|
||||
|
||||
private static void setFileAttributes(File src, File dst) throws IOException {
|
||||
dst.setExecutable(src.canExecute());
|
||||
dst.setReadable(src.canRead());
|
||||
dst.setWritable(src.canWrite());
|
||||
dst.setLastModified(src.lastModified());
|
||||
}
|
||||
|
||||
static void copyFile(File src, File dst) throws IOException {
|
||||
if (src.isDirectory()) {
|
||||
dst.mkdirs();
|
||||
setFileAttributes(src, dst);
|
||||
return;
|
||||
} else {
|
||||
File baseDirFile = dst.getParentFile();
|
||||
if (!baseDirFile.exists()) {
|
||||
baseDirFile.mkdirs();
|
||||
}
|
||||
Path parent = dst.toPath().getParent();
|
||||
if (parent != null) {
|
||||
Files.createDirectories(parent);
|
||||
}
|
||||
FileInputStream in = null;
|
||||
FileOutputStream out = null;
|
||||
FileChannel srcChannel = null;
|
||||
FileChannel dstChannel = null;
|
||||
try {
|
||||
in = new FileInputStream(src);
|
||||
out = new FileOutputStream(dst);
|
||||
srcChannel = in.getChannel();
|
||||
dstChannel = out.getChannel();
|
||||
|
||||
long retval = srcChannel.transferTo(0, src.length(), dstChannel);
|
||||
if (src.length() != dst.length()) {
|
||||
throw new IOException("file copy failed for " + src);
|
||||
}
|
||||
} finally {
|
||||
close(srcChannel);
|
||||
close(dstChannel);
|
||||
close(in);
|
||||
close(out);
|
||||
}
|
||||
setFileAttributes(src, dst);
|
||||
Files.copy(src.toPath(), dst.toPath(), COPY_ATTRIBUTES, REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
static String baseName(File file, String extension) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user