X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fttree%2FTDirectoryTreeItem.java;h=5f265ee5d32783654f67fe690bb3c666af1fbf5b;hb=a69ed767c9c07cf35cf1c5f7821fc009cfe79cd2;hp=c260d7fb95212c7920fce537f5deb74066553b9f;hpb=d36057dfab8def933a64be042b039d76708ac5ba;p=nikiroo-utils.git diff --git a/src/jexer/ttree/TDirectoryTreeItem.java b/src/jexer/ttree/TDirectoryTreeItem.java index c260d7f..5f265ee 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"), @@ -182,25 +182,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());