ソースを参照

Couple of bug fixes.

Don't try and resole using a path from another FS provider.

Create paths via URIs not via strings, as otherwise it gets
confused with protocols.

Change-Id: Ibb33317ee9ce8d1567535e464c8f59667ea5e65a
Reviewed-on: http://gerrit.dmdirc.com/4043
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
changes/43/4043/2
Chris Smith 9年前
コミット
2b76d27c6f
1個のファイルの変更8行の追加4行の削除
  1. 8
    4
      src/com/dmdirc/util/io/FileUtils.java

+ 8
- 4
src/com/dmdirc/util/io/FileUtils.java ファイルの表示

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.util.io;
24 24
 
25 25
 import java.io.IOException;
26
+import java.net.URISyntaxException;
26 27
 import java.net.URL;
27 28
 import java.nio.file.CopyOption;
28 29
 import java.nio.file.DirectoryStream;
@@ -49,9 +50,12 @@ public final class FileUtils {
49 50
      * @throws IOException If the resource couldn't be copied.
50 51
      */
51 52
     public static void copyResources(final URL source, final Path destination) throws IOException {
52
-        final Path sourcePath = Paths.get(source.toString());
53
-
54
-        copyRecursively(sourcePath, destination, StandardCopyOption.REPLACE_EXISTING);
53
+        try {
54
+            copyRecursively(Paths.get(source.toURI()), destination,
55
+                    StandardCopyOption.REPLACE_EXISTING);
56
+        } catch (URISyntaxException ex) {
57
+            throw new IOException("Unable to get source URI", ex);
58
+        }
55 59
     }
56 60
 
57 61
     /**
@@ -65,7 +69,7 @@ public final class FileUtils {
65 69
      */
66 70
     public static void copyRecursively(final Path source, final Path destination,
67 71
             final CopyOption... options) throws IOException {
68
-        final Path destinationPath = destination.resolve(source.getFileName());
72
+        final Path destinationPath = destination.resolve(source.getFileName().toString());
69 73
 
70 74
         if (Files.isDirectory(source)) {
71 75
             Files.createDirectories(destinationPath);

読み込み中…
キャンセル
保存