Improved GVFS error logging: GVFS: %s => %s
This commit is contained in:
parent
b1ade214bc
commit
9f5867f295
|
@ -1,8 +1,12 @@
|
|||
|
||||
package net.filebot.gio;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
public class PlatformGVFS implements GVFS {
|
||||
|
||||
|
@ -13,7 +17,7 @@ public class PlatformGVFS implements GVFS {
|
|||
}
|
||||
|
||||
public File getPathForURI(URI uri) {
|
||||
return Protocol.valueOf(uri.getScheme().toUpperCase()).getFile(gvfs, uri);
|
||||
return Protocol.forName(uri.getScheme()).getFile(gvfs, uri);
|
||||
}
|
||||
|
||||
public static enum Protocol {
|
||||
|
@ -82,6 +86,20 @@ public class PlatformGVFS implements GVFS {
|
|||
return new File(gvfs, getPath(uri));
|
||||
}
|
||||
|
||||
public static List<String> names() {
|
||||
return stream(values()).map(Enum::name).collect(toList());
|
||||
}
|
||||
|
||||
public static Protocol forName(String name) {
|
||||
for (Protocol protocol : values()) {
|
||||
if (protocol.name().equalsIgnoreCase(name)) {
|
||||
return protocol;
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(String.format("%s not in %s", name, names()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -92,20 +92,21 @@ public class FileTransferable implements Transferable {
|
|||
if (useGVFS()) {
|
||||
if (tr.isDataFlavorSupported(FileTransferable.uriListFlavor)) {
|
||||
// file URI list flavor (Linux)
|
||||
try {
|
||||
Readable transferData = (Readable) tr.getTransferData(FileTransferable.uriListFlavor);
|
||||
|
||||
try (Scanner scanner = new Scanner(transferData)) {
|
||||
List<File> files = new ArrayList<File>();
|
||||
Readable transferData = (Readable) tr.getTransferData(FileTransferable.uriListFlavor);
|
||||
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
try (Scanner scanner = new Scanner(transferData)) {
|
||||
List<File> files = new ArrayList<File>();
|
||||
|
||||
if (line.startsWith("#")) {
|
||||
// the line is a comment (as per RFC 2483)
|
||||
continue;
|
||||
}
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
|
||||
if (line.startsWith("#")) {
|
||||
// the line is a comment (as per RFC 2483)
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
File file = GVFS.getDefaultVFS().getPathForURI(new URI(line));
|
||||
|
||||
if (file != null && file.exists()) {
|
||||
|
@ -113,13 +114,12 @@ public class FileTransferable implements Transferable {
|
|||
} else {
|
||||
debug.warning(format("GVFS: %s => %s", line, file));
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
debug.warning(format("GVFS: %s => %s", line, e));
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
debug.warning(cause(e));
|
||||
|
||||
return files;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue