| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
package net.sourceforge.cobertura.reporting.html.files; |
| 24 | |
|
| 25 | |
import java.io.File; |
| 26 | |
import java.io.FileOutputStream; |
| 27 | |
import java.io.IOException; |
| 28 | |
import java.io.InputStream; |
| 29 | |
|
| 30 | 0 | public abstract class CopyFiles |
| 31 | |
{ |
| 32 | |
|
| 33 | |
public static void copy(File destinationDir) throws IOException |
| 34 | |
{ |
| 35 | 5 | File cssOutputDir = new File(destinationDir, "css"); |
| 36 | 5 | File imagesOutputDir = new File(destinationDir, "images"); |
| 37 | 5 | File jsOutputDir = new File(destinationDir, "js"); |
| 38 | |
|
| 39 | 5 | destinationDir.mkdirs(); |
| 40 | 5 | cssOutputDir.mkdir(); |
| 41 | 5 | imagesOutputDir.mkdir(); |
| 42 | 5 | jsOutputDir.mkdir(); |
| 43 | |
|
| 44 | 5 | copyResourceFromJar("help.css", cssOutputDir); |
| 45 | 5 | copyResourceFromJar("main.css", cssOutputDir); |
| 46 | 5 | copyResourceFromJar("sortabletable.css", cssOutputDir); |
| 47 | 5 | copyResourceFromJar("source-viewer.css", cssOutputDir); |
| 48 | 5 | copyResourceFromJar("tooltip.css", cssOutputDir); |
| 49 | |
|
| 50 | 5 | copyResourceFromJar("blank.png", imagesOutputDir); |
| 51 | 5 | copyResourceFromJar("downsimple.png", imagesOutputDir); |
| 52 | 5 | copyResourceFromJar("upsimple.png", imagesOutputDir); |
| 53 | |
|
| 54 | 5 | copyResourceFromJar("customsorttypes.js", jsOutputDir); |
| 55 | 5 | copyResourceFromJar("popup.js", jsOutputDir); |
| 56 | 5 | copyResourceFromJar("sortabletable.js", jsOutputDir); |
| 57 | 5 | copyResourceFromJar("stringbuilder.js", jsOutputDir); |
| 58 | |
|
| 59 | 5 | copyResourceFromJar("help.html", destinationDir); |
| 60 | 5 | copyResourceFromJar("index.html", destinationDir); |
| 61 | 5 | } |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
private static void copyResourceFromJar(String resourceName, |
| 73 | |
File directory) throws IOException |
| 74 | |
{ |
| 75 | |
int n; |
| 76 | 70 | byte[] buf = new byte[1024]; |
| 77 | |
|
| 78 | 70 | InputStream in = null; |
| 79 | 70 | FileOutputStream out = null; |
| 80 | 70 | directory.mkdirs(); |
| 81 | |
try |
| 82 | |
{ |
| 83 | 70 | in = CopyFiles.class.getResourceAsStream(resourceName); |
| 84 | 70 | if (in == null) |
| 85 | 0 | throw new IllegalArgumentException("Resource " + resourceName |
| 86 | |
+ " does not exist in this package."); |
| 87 | 70 | out = new FileOutputStream(new File(directory, resourceName)); |
| 88 | 250 | while ((n = in.read(buf, 0, buf.length)) != -1) |
| 89 | |
{ |
| 90 | 180 | out.write(buf, 0, n); |
| 91 | 180 | } |
| 92 | |
} |
| 93 | |
finally |
| 94 | |
{ |
| 95 | 70 | if (in != null) |
| 96 | |
{ |
| 97 | |
try |
| 98 | |
{ |
| 99 | 70 | in.close(); |
| 100 | |
} |
| 101 | 0 | catch (IOException e) |
| 102 | |
{ |
| 103 | 70 | } |
| 104 | |
} |
| 105 | 70 | if (out != null) |
| 106 | |
{ |
| 107 | |
try |
| 108 | |
{ |
| 109 | 70 | out.close(); |
| 110 | |
} |
| 111 | 0 | catch (IOException e) |
| 112 | |
{ |
| 113 | 70 | } |
| 114 | 0 | } |
| 115 | 0 | } |
| 116 | 70 | } |
| 117 | |
|
| 118 | |
} |