X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fttree%2FTDirectoryTreeItem.java;h=9bdec01dffd3cf51aeb5a233768b03e2f2b4e8e4;hb=505be508ae7d3fb48122be548b310a238cfb91eb;hp=c260d7fb95212c7920fce537f5deb74066553b9f;hpb=d6ee0801333ff93dffd851f4c1a44519c96c371d;p=fanfix.git diff --git a/src/jexer/ttree/TDirectoryTreeItem.java b/src/jexer/ttree/TDirectoryTreeItem.java index c260d7f..9bdec01 100644 --- a/src/jexer/ttree/TDirectoryTreeItem.java +++ b/src/jexer/ttree/TDirectoryTreeItem.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2017 Kevin Lamonte + * Copyright (C) 2019 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -35,7 +35,6 @@ import java.util.List; import java.util.LinkedList; import jexer.TWidget; -import jexer.ttree.TTreeViewWidget; /** * TDirectoryTreeItem is a single item in a disk directory tree view. @@ -182,25 +181,28 @@ public class TDirectoryTreeItem extends TTreeItem { return; } - for (File f: file.listFiles()) { - // System.err.printf(" -> file %s %s\n", file, file.getName()); + File [] listFiles = file.listFiles(); + if (listFiles != null) { + for (File f: listFiles) { + // System.err.printf(" -> file %s %s\n", file, file.getName()); - if (f.getName().startsWith(".")) { - // Hide dot-files - continue; - } - if (!f.isDirectory()) { - continue; - } + if (f.getName().startsWith(".")) { + // Hide dot-files + continue; + } + if (!f.isDirectory()) { + continue; + } - try { - TDirectoryTreeItem item = new TDirectoryTreeItem(treeViewWidget, - f.getCanonicalPath(), false, false); + try { + TDirectoryTreeItem item = new TDirectoryTreeItem(treeViewWidget, + f.getCanonicalPath(), false, false); - item.level = this.level + 1; - getChildren().add(item); - } catch (IOException e) { - continue; + item.level = this.level + 1; + getChildren().add(item); + } catch (IOException e) { + continue; + } } } Collections.sort(getChildren());