mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-26 22:41:59 -04:00
count files added to the library
This commit is contained in:
parent
7d949367eb
commit
5812890831
@ -282,7 +282,8 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
||||
changedNode = customNode;
|
||||
}
|
||||
|
||||
scanFolder(rootLibraryPath, customNode);
|
||||
int num = scanFolder(rootLibraryPath, customNode);
|
||||
LOGGER.debug("found " + num + " files");
|
||||
} else if (customNode != null) {
|
||||
root.remove(customNode);
|
||||
customNode = null;
|
||||
@ -305,7 +306,8 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
||||
l.libraryChanged(node);
|
||||
}
|
||||
|
||||
private void scanFolder(File path, LibraryNode node) {
|
||||
private int scanFolder(File path, LibraryNode node) {
|
||||
int num = 0;
|
||||
File[] list = path.listFiles();
|
||||
if (list != null) {
|
||||
ArrayList<File> orderedList = new ArrayList<>(Arrays.asList(list));
|
||||
@ -313,18 +315,21 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
||||
for (File f : orderedList) {
|
||||
if (f.isDirectory()) {
|
||||
LibraryNode n = new LibraryNode(f.getName());
|
||||
scanFolder(f, n);
|
||||
num += scanFolder(f, n);
|
||||
if (!n.isEmpty())
|
||||
node.add(n);
|
||||
}
|
||||
}
|
||||
for (File f : orderedList) {
|
||||
final String name = f.getName();
|
||||
if (f.isFile() && name.endsWith(".dig"))
|
||||
if (f.isFile() && name.endsWith(".dig")) {
|
||||
node.add(new LibraryNode(f));
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a listener to this library
|
||||
|
Loading…
x
Reference in New Issue
Block a user