...
 
Commits (1)
  • echicken's avatar
    Make listDirectories a bit less ugly. · 5746fd1b
    echicken authored
    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.
    5746fd1b
......@@ -8,20 +8,25 @@ function count_files(dir) {
return Math.floor(file_size(fn) / 22); // ixb record length is 22 bytes
}
function libHasFiles(lib) {
return lib.dir_list.some(function (e) {
return count_files(e.code) > 0;
});
}
function listLibraries() {
return file_area.lib_list.filter(function (library) {
return library.dir_list.length >= 1;
return file_area.lib_list.filter(function (lib) {
return lib.dir_list.length >= 1 && libHasFiles(lib);
});
}
function listDirectories(library) {
var dirs = [];
file_area.lib_list[library].dir_list.forEach(function (dir) {
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) {
......