From 32984b9f41e57d31b5bd859c3163bfdf65e3f537 Mon Sep 17 00:00:00 2001 From: myk Date: Sun, 17 Mar 2013 06:07:28 +0000 Subject: [PATCH] remove empty dirs after migration. tree conflicts still exist, but at least they won't get in the way --- src/main/java/forge/view/FView.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/forge/view/FView.java b/src/main/java/forge/view/FView.java index 828c78637a5..164ff5c1bd5 100644 --- a/src/main/java/forge/view/FView.java +++ b/src/main/java/forge/view/FView.java @@ -219,16 +219,29 @@ public enum FView { // will populate remainingFiles with remaining files if not null, returns whether any files have // been added to remainingFiles (or would have been added if remainingFiles is null) // directories listed in profileDirs will not be searched + // removes empty directories to reduce tree conflicts private static boolean _addRemainingFiles(List remainingFiles, List dirRoots, Set profileDirs) { Deque stack = new LinkedList(dirRoots); + Set seenDirs = new HashSet(); boolean ret = false; while (!stack.isEmpty()) { - File cur = stack.pop(); + File cur = stack.peek(); if (profileDirs.contains(cur)) { - // don't search active profile dirs + // don't touch active profile dirs + stack.pop(); continue; } + if (seenDirs.contains(cur)) { + cur = stack.pop(); + if (cur.exists()) { + // remove empty dir (will fail if not empty) + cur.delete(); + } + continue; + } + + seenDirs.add(cur); File[] curListing = cur.listFiles(); if (null == curListing) { continue;