Improved GVFS error logging: GVFS: %s => %s

This commit is contained in:
Reinhard Pointner 2017-02-25 16:03:05 +08:00
parent d2df8d8923
commit c97057b197
1 changed files with 22 additions and 22 deletions

View File

@ -7,7 +7,6 @@ import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.nio.CharBuffer; import java.nio.CharBuffer;
@ -93,33 +92,34 @@ public class FileTransferable implements Transferable {
if (useGVFS()) { if (useGVFS()) {
if (tr.isDataFlavorSupported(FileTransferable.uriListFlavor)) { if (tr.isDataFlavorSupported(FileTransferable.uriListFlavor)) {
// file URI list flavor (Linux) // file URI list flavor (Linux)
Readable transferData = (Readable) tr.getTransferData(FileTransferable.uriListFlavor); try {
Readable transferData = (Readable) tr.getTransferData(FileTransferable.uriListFlavor);
try (Scanner scanner = new Scanner(transferData)) { try (Scanner scanner = new Scanner(transferData)) {
List<File> files = new ArrayList<File>(); List<File> files = new ArrayList<File>();
while (scanner.hasNextLine()) { while (scanner.hasNextLine()) {
String line = scanner.nextLine(); String line = scanner.nextLine();
if (line.startsWith("#")) { if (line.startsWith("#")) {
// the line is a comment (as per RFC 2483) // the line is a comment (as per RFC 2483)
continue; continue;
}
try {
File file = GVFS.getDefaultVFS().getPathForURI(new URI(line));
if (file == null || !file.exists()) {
throw new FileNotFoundException(line);
} }
files.add(file); File file = GVFS.getDefaultVFS().getPathForURI(new URI(line));
} catch (Throwable e) {
debug.warning(e::toString);
}
}
return files; if (file != null && file.exists()) {
files.add(file);
} else {
debug.warning(format("GVFS: %s => %s", line, file));
}
}
return files;
}
} catch (Throwable e) {
debug.warning(cause(e));
} }
} }
} }