From 332e4d1f93aa8cdef984b93dd0bb7cbb423f0bc2 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Fri, 15 Mar 2013 01:08:40 +0000 Subject: [PATCH] * allow dropping in files by dropping in a text files containing paths --- .../net/sourceforge/filebot/MediaTypes.java | 1 + .../rename/FilesListTransferablePolicy.java | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/source/net/sourceforge/filebot/MediaTypes.java b/source/net/sourceforge/filebot/MediaTypes.java index 0b2e7974..e78a3b38 100644 --- a/source/net/sourceforge/filebot/MediaTypes.java +++ b/source/net/sourceforge/filebot/MediaTypes.java @@ -92,4 +92,5 @@ public class MediaTypes { public static final ExtensionFileFilter VIDEO_FILES = getDefaultFilter("video"); public static final ExtensionFileFilter SUBTITLE_FILES = getDefaultFilter("subtitle"); public static final ExtensionFileFilter NFO_FILES = getDefaultFilter("application/nfo"); + public static final ExtensionFileFilter LIST_FILES = getDefaultFilter("application/list"); } diff --git a/source/net/sourceforge/filebot/ui/rename/FilesListTransferablePolicy.java b/source/net/sourceforge/filebot/ui/rename/FilesListTransferablePolicy.java index 852ed2f7..186a792f 100644 --- a/source/net/sourceforge/filebot/ui/rename/FilesListTransferablePolicy.java +++ b/source/net/sourceforge/filebot/ui/rename/FilesListTransferablePolicy.java @@ -3,13 +3,18 @@ package net.sourceforge.filebot.ui.rename; import static java.util.Arrays.*; +import static net.sourceforge.filebot.MediaTypes.*; import static net.sourceforge.filebot.ui.transfer.FileTransferable.*; +import static net.sourceforge.tuned.FileUtilities.*; import java.awt.datatransfer.Transferable; import java.io.File; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import java.util.Scanner; +import java.util.logging.Level; +import java.util.logging.Logger; import net.sourceforge.filebot.media.MediaDetection; import net.sourceforge.filebot.ui.transfer.FileTransferablePolicy; @@ -67,7 +72,24 @@ class FilesListTransferablePolicy extends FileTransferablePolicy { if (f.isHidden()) continue; - if (!recursive || f.isFile() || MediaDetection.isDiskFolder(f)) { + if (recursive && LIST_FILES.accept(f)) { + // don't use new Scanner(File) because of BUG 6368019 (http://bugs.sun.com/view_bug.do?bug_id=6368019) + try { + Scanner scanner = new Scanner(createTextReader(f)); + while (scanner.hasNextLine()) { + String line = scanner.nextLine().trim(); + if (line.length() > 0) { + File path = new File(line); + if (path.isAbsolute() && path.exists()) { + queue.add(0, path); + } + } + } + scanner.close(); + } catch (Exception e) { + Logger.getLogger(FilesListTransferablePolicy.class.getName()).log(Level.WARNING, e.getMessage()); + } + } else if (!recursive || f.isFile() || MediaDetection.isDiskFolder(f)) { entries.add(f); } else { queue.addAll(0, asList(f.listFiles()));