Skip to content
Snippets Groups Projects
Commit a65e8c61 authored by echicken's avatar echicken :chicken:
Browse files

Make listDirectories a bit less ugly.

Added libHasFiles(lib); returns true as soon as it encounters a
dir in a lib that has any files in it.
listLibraries() only returns libs that have populated dirs.
parent d8207cb9
No related branches found
No related tags found
No related merge requests found
...@@ -8,20 +8,25 @@ function count_files(dir) { ...@@ -8,20 +8,25 @@ function count_files(dir) {
return Math.floor(file_size(fn) / 22); // ixb record length is 22 bytes return Math.floor(file_size(fn) / 22); // ixb record length is 22 bytes
} }
function listLibraries() { function libHasFiles(lib) {
return file_area.lib_list.filter(function (library) { return lib.dir_list.some(function (e) {
return library.dir_list.length >= 1; return count_files(e.code) > 0;
}); });
} }
function listDirectories(library) { function listLibraries() {
var dirs = []; return file_area.lib_list.filter(function (lib) {
file_area.lib_list[library].dir_list.forEach(function (dir) { return lib.dir_list.length >= 1 && libHasFiles(lib);
const fc = count_files(dir.code);
if (fc < 1) return;
dirs.push({ dir: dir, fileCount: fc });
}); });
return dirs; }
function listDirectories(lib) {
return file_area.lib_list[lib].dir_list.reduce(function (a, c) {
const fc = count_files(c.code);
if (fc < 1) return a;
a.push({ dir: c, fileCount: fc });
return a;
}, []);
} }
function listFiles(dir) { function listFiles(dir) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment