mirror of
https://github.com/mitb-archive/filebot
synced 2025-01-11 05:48:01 -05:00
* fix NPE issue
@see http://www.filebot.net/forums/viewtopic.php?f=6&t=1199&p=7243#p7243
This commit is contained in:
parent
f5910f837d
commit
0827fda189
@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
package net.sourceforge.filebot.ui.rename;
|
package net.sourceforge.filebot.ui.rename;
|
||||||
|
|
||||||
|
|
||||||
import static java.util.Arrays.*;
|
import static java.util.Arrays.*;
|
||||||
import static net.sourceforge.filebot.MediaTypes.*;
|
import static net.sourceforge.filebot.MediaTypes.*;
|
||||||
import static net.sourceforge.filebot.ui.transfer.FileTransferable.*;
|
import static net.sourceforge.filebot.ui.transfer.FileTransferable.*;
|
||||||
@ -20,29 +18,24 @@ import net.sourceforge.filebot.media.MediaDetection;
|
|||||||
import net.sourceforge.filebot.ui.transfer.FileTransferablePolicy;
|
import net.sourceforge.filebot.ui.transfer.FileTransferablePolicy;
|
||||||
import net.sourceforge.tuned.FastFile;
|
import net.sourceforge.tuned.FastFile;
|
||||||
|
|
||||||
|
|
||||||
class FilesListTransferablePolicy extends FileTransferablePolicy {
|
class FilesListTransferablePolicy extends FileTransferablePolicy {
|
||||||
|
|
||||||
private final List<File> model;
|
private final List<File> model;
|
||||||
|
|
||||||
|
|
||||||
public FilesListTransferablePolicy(List<File> model) {
|
public FilesListTransferablePolicy(List<File> model) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean accept(List<File> files) {
|
protected boolean accept(List<File> files) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void clear() {
|
protected void clear() {
|
||||||
model.clear();
|
model.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleTransferable(Transferable tr, TransferAction action) throws Exception {
|
public void handleTransferable(Transferable tr, TransferAction action) throws Exception {
|
||||||
if (action == TransferAction.LINK) {
|
if (action == TransferAction.LINK) {
|
||||||
@ -54,24 +47,22 @@ class FilesListTransferablePolicy extends FileTransferablePolicy {
|
|||||||
super.handleTransferable(tr, action);
|
super.handleTransferable(tr, action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void load(List<File> files) {
|
protected void load(List<File> files) {
|
||||||
load(files, true);
|
load(files, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void load(List<File> files, boolean recursive) {
|
protected void load(List<File> files, boolean recursive) {
|
||||||
List<File> entries = new ArrayList<File>();
|
List<File> entries = new ArrayList<File>();
|
||||||
LinkedList<File> queue = new LinkedList<File>(files);
|
LinkedList<File> queue = new LinkedList<File>(files);
|
||||||
|
|
||||||
while (queue.size() > 0) {
|
while (queue.size() > 0) {
|
||||||
File f = queue.removeFirst();
|
File f = queue.removeFirst();
|
||||||
|
|
||||||
if (f.isHidden())
|
if (f.isHidden())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (recursive && LIST_FILES.accept(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)
|
// don't use new Scanner(File) because of BUG 6368019 (http://bugs.sun.com/view_bug.do?bug_id=6368019)
|
||||||
try {
|
try {
|
||||||
@ -87,7 +78,7 @@ class FilesListTransferablePolicy extends FileTransferablePolicy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
scanner.close();
|
scanner.close();
|
||||||
|
|
||||||
if (paths.isEmpty()) {
|
if (paths.isEmpty()) {
|
||||||
entries.add(f); // treat as simple text file
|
entries.add(f); // treat as simple text file
|
||||||
} else {
|
} else {
|
||||||
@ -98,18 +89,20 @@ class FilesListTransferablePolicy extends FileTransferablePolicy {
|
|||||||
}
|
}
|
||||||
} else if (!recursive || f.isFile() || MediaDetection.isDiskFolder(f)) {
|
} else if (!recursive || f.isFile() || MediaDetection.isDiskFolder(f)) {
|
||||||
entries.add(f);
|
entries.add(f);
|
||||||
} else {
|
} else if (f.isDirectory()) {
|
||||||
queue.addAll(0, asList(f.listFiles()));
|
File[] children = f.listFiles();
|
||||||
|
if (children != null) {
|
||||||
|
queue.addAll(0, asList(children));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model.addAll(FastFile.foreach(entries));
|
model.addAll(FastFile.foreach(entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFileFilterDescription() {
|
public String getFileFilterDescription() {
|
||||||
return "files and folders";
|
return "files and folders";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user