void digests::reload(void) { private_lock.modify(); memset(private_paths, 0, sizeof(private_paths)); private_cache.purge(); private_lock.commit(); load(); }
static void dump(const char *path) { unsigned count = NamedObject::count(&files, 1); unsigned cols = 1, col = 0, rows, row, offset, next; const char *months[] = { _TEXT("Jan"), _TEXT("Feb"), _TEXT("Mar"), _TEXT("Apr"), _TEXT("May"), _TEXT("Jun"), _TEXT("Jul"), _TEXT("Aug"), _TEXT("Sep"), _TEXT("Oct"), _TEXT("Nov"), _TEXT("Dec") }; if(!count) return; if(dumped) printf("\n%s:\n", path); dumped = true; if(widest > (width / 2) - 2) cols = 1; else cols = (width / (widest + 1)); if(!fsys::is_tty(shell::output()) || is(longform)) cols = 1; NamedObject **index = NamedObject::index(&files, 1); index = NamedObject::sort(index, count); if((is(reverse) && !is(timesort)) || (is(timesort) && !is(reverse))) { unsigned first = 0; unsigned last = count - 1; while(first < last) { swap<NamedObject *>(index[first], index[last]); ++first; --last; } } rows = ((count + (cols - 1)) / cols); for(row = 0; row < rows; ++row) { for(col = 0; col < cols; ++col) { offset = col * rows + row; next = (col + 1) * rows + row; if(offset >= count) continue; entry *node = (entry *)index[offset]; const char *fn = node->name; size_t len = strlen(fn); struct tm *dt; dt = localtime(&node->inode.st_mtime); if(is(longform)) { printf("%10ld %s %02d %02d:%02d %s", node->inode.st_size, months[dt->tm_mon], dt->tm_mday, dt->tm_hour, dt->tm_min, fn); } else printf("%s", fn); if(fsys::is_dir(&node->inode)) { fputc('/', stdout); ++len; } while(next < count && len++ < widest + 1) fputc(' ', stdout); } fputc('\n', stdout); } delete[] index; mpager.purge(); widest = 0; files = NULL; }