public FolderInfo getFolderInfo(final Folder folder, final int maxSubfolderScan) {
        try (ContextLogger cLog = new ContextLogger("FolderUtils.getFolderInfo: %s", folder)) {

            final int[] counts = new int[]{0, 0};
            final long[] size = new long[]{0};
            final int[] level = new int[]{0};
            final List<String> topLevelFiles = new ArrayList<>();
            final boolean result = treeWalk(folder, fi -> {
                final boolean subdirLimitReached = maxSubfolderScan >= 0 && counts[1] >= maxSubfolderScan;
                if (fi.left.isDirectory && fi.right) {
                    counts[1]++;
                    if (level[0] == 0) {
                        topLevelFiles.add(fi.left.name + "/");
                    }
                    level[0]++;
                }
                if (fi.left.isDirectory && !fi.right) {
                    level[0]--;
                }
                if (!fi.left.isDirectory) {
                    counts[0]++;
                    size[0] += fi.left.size;
                    if (level[0] == 0) {
                        topLevelFiles.add(fi.left.name);
                    }
                }
                return subdirLimitReached ? TreeWalkResult.STOP_AFTER_FOLDER : TreeWalkResult.CONTINUE;
            });
            cLog.add("#f:%d, #d:#%d, size:%d", counts[0], counts[1], size[0]);
            return new FolderInfo(counts[0], counts[1], size[0], !result, topLevelFiles);
        }
    }
returns folder informations with regards to files/dirs currently in folder, restricts scan to a maximum of subfolders e.g. to reduce info gathering time
main/src/main/java/cgeo/geocaching/storage/FolderUtils.java