|
@@ -23,14 +23,19 @@
|
23
|
23
|
package com.dmdirc.util.io;
|
24
|
24
|
|
25
|
25
|
import java.io.IOException;
|
|
26
|
+import java.net.URI;
|
26
|
27
|
import java.net.URISyntaxException;
|
27
|
28
|
import java.net.URL;
|
28
|
29
|
import java.nio.file.CopyOption;
|
29
|
30
|
import java.nio.file.DirectoryStream;
|
|
31
|
+import java.nio.file.FileSystem;
|
|
32
|
+import java.nio.file.FileSystems;
|
30
|
33
|
import java.nio.file.Files;
|
31
|
34
|
import java.nio.file.Path;
|
32
|
35
|
import java.nio.file.Paths;
|
33
|
36
|
import java.nio.file.StandardCopyOption;
|
|
37
|
+import java.util.HashMap;
|
|
38
|
+import java.util.Map;
|
34
|
39
|
|
35
|
40
|
/**
|
36
|
41
|
* Utility class to deal with files.
|
|
@@ -51,8 +56,19 @@ public final class FileUtils {
|
51
|
56
|
*/
|
52
|
57
|
public static void copyResources(final URL source, final Path destination) throws IOException {
|
53
|
58
|
try {
|
54
|
|
- copyRecursively(Paths.get(source.toURI()), destination,
|
55
|
|
- StandardCopyOption.REPLACE_EXISTING);
|
|
59
|
+ final String path = source.toURI().toString();
|
|
60
|
+ final int index = path.indexOf("!/");
|
|
61
|
+ if (index > -1) {
|
|
62
|
+ final String file = path.substring(0, index);
|
|
63
|
+ final Map<String, String> env = new HashMap<>();
|
|
64
|
+ try (final FileSystem fs = FileSystems.newFileSystem(URI.create(file), env)) {
|
|
65
|
+ copyRecursively(fs.getPath(path.substring(index + 2)), destination,
|
|
66
|
+ StandardCopyOption.REPLACE_EXISTING);
|
|
67
|
+ }
|
|
68
|
+ } else {
|
|
69
|
+ copyRecursively(Paths.get(source.toURI()), destination,
|
|
70
|
+ StandardCopyOption.REPLACE_EXISTING);
|
|
71
|
+ }
|
56
|
72
|
} catch (URISyntaxException ex) {
|
57
|
73
|
throw new IOException("Unable to get source URI", ex);
|
58
|
74
|
}
|