/** * Creates an empty {@code TFileTree} with no root. * You shouldn't use this constructor. * It's only provided to implement the JavaBean pattern. */ public TFileTree() { this(new TFileTreeModel(null, null, new TFileComparator())); }
/** * Creates a new {@code TFileTree} which traverses the given * root {@code root} file. */ public TFileTree(TFile root) { this(new TFileTreeModel(root, null, new TFileComparator())); }
/** * Lists the given file with the given display path. */ private void ls( final TFile file, final String path, final boolean detailed, final boolean recursive) throws IOException { if (file.isDirectory()) { final TFile[] entries = file.listFiles(); if (entries == null) throw new IOException(path + " (" + resources.getString("ls.dia") + ")"); // Sort directories to the start. Arrays.sort(entries, new TFileComparator()); for (int i = 0; i < entries.length; i++) { final TFile entry = entries[i]; final String entryPath = path.length() > 0 ? path + TFile.separator + entry.getName() : entry.getName(); ls(entry, entryPath, detailed); if (recursive && entry.isDirectory()) ls(entries[i], entryPath, detailed, true); } } else if (file.exists()) { ls(file, path, detailed); } else { throw new IOException(path + " (" + resources.getString("ls.nsfod") + ")"); } }