Prep for 2019 release
[fanfix.git] / src / jexer / ttree / TDirectoryTreeItem.java
index c260d7fb95212c7920fce537f5deb74066553b9f..5f265ee5d32783654f67fe690bb3c666af1fbf5b 100644 (file)
@@ -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());