bigfind — find the largest files in a directory tree
bigfind is a LightGUI front-end for the bigfind command-line utility from util_box. It finds the top-N largest files in a directory tree and shows each hit with its size, age, file type and parent directory — the same information the CLI prints, in a table you can scan at a glance instead of scrolling through terminal output. It is one of the 50 apps in util_boxgui, the project recreating util_box utilities as LightGUI apps, each with a screenshot and a walkthrough on the matching LightGUI doc site. The full source is apps/c/bigfind/bigfind.cpp in that repo.
Type a directory path, pick how many hits to show, press Run, and the table lists the N largest files in the tree, largest first. The app opens already in a meaningful state: it scans /root/fileutils with N=10, so the table is populated the moment the window appears — the screenshot below is the default state, not a staged one.
The GUI layout

The window is 960×680 and holds seven widgets, all placed by hand in code — there is no designer file, and that is deliberate: the app is written the way the LightGUI designer's generated apps are structured, so the code below reads like generated output with the scan logic swapped in.
- Directory: a
GtkLabeland aGtkEntryholding the path to scan, pre-filled with/root/fileutils. Pressing Enter in the entry re-runs the scan. - Top N: a
GtkLabeland aGtkSpinButton(range 1–100, default 10). Changing the value re-runs the scan immediately — there is no Apply button to forget. - Run: a
GtkButtonthat re-scans the current path and N. - The table: a
TListViewwith five columns — Size (95 px), Age (60 px), Type (90 px), File (300 px), Parent dir (375 px). The File column holds just the name; the directory it lives in gets its own column, which is how the CLI's two-line hit layout (PATHplusin <parent>) maps onto a table. - Status line: a
GtkLabelunder the table that mirrors the CLI summary, for exampletop 10 of 1824 files; tree total 23.7 MiB.
Size is human-readable (202.8 KiB, 23.7 MiB), Age is time since last modification (23h, 1d, 2mo, 3y), and Type is the lowercased file extension — (none) when there is none. All three use exactly the CLI's formatting, quirks included: the extension is taken from the last . in the whole path, so an extensionless file under a dotted directory reports an odd "type", exactly as the CLI does.
The source, in sections
bigfind.cpp is about 340 lines, in two halves: the scan logic, ported from the CLI, and the GUI. The scan half is deliberately boring — it is a direct port of util_box's src/bigfind.c, and the GUI half is a thin shell around it.
The scan. One recursive walk keeps only the N largest files, so memory stays bounded no matter how big the tree is. A file only displaces the current smallest when it is strictly larger — the same rule as the CLI's heap:
static void consider(const std::string &p, off_t s, time_t m) {
g_total_bytes += s;
g_total_files++;
if (g_top.size() < g_cap) {
g_top.push_back({p, s, m});
return;
}
size_t mn = 0;
for (size_t i = 1; i < g_top.size(); i++)
if (g_top[i].size < g_top[mn].size) mn = i;
if (s > g_top[mn].size) g_top[mn] = {p, s, m};
}
static void walk(const std::string &dir) {
DIR *d = opendir(dir.c_str());
if (!d) return;
struct dirent *e;
while ((e = readdir(d))) {
if (!strcmp(e->d_name, ".") || !strcmp(e->d_name, "..")) continue;
std::string full = dir + "/" + e->d_name;
struct stat st;
if (lstat(full.c_str(), &st)) continue;
if (S_ISDIR(st.st_mode))
walk(full);
else if (S_ISREG(st.st_mode))
consider(full, st.st_size, st.st_mtime);
}
closedir(d);
}Directories are recursed into, regular files are considered, and everything else — symlinks, sockets, devices — is skipped; unreadable directories are silently skipped, exactly as the CLI does. The formatting helpers are copied verbatim: human() prints %.1f with B/KiB/MiB/GiB/TiB, age_str() steps through seconds, minutes, hours, days, months and years, and ext_of() reproduces the extension quirk described above. The GUI does not "fix" the quirk; it reproduces it, because the CLI's output is the spec.
The widgets. main() opens the X display, creates a 960×680 window, registers the two styles (default and dark, both 13-point fixed font), and constructs the widgets at fixed coordinates:
g_dir_label = new GtkLabel(g_display, screen, g_window, g_gc, g_styles,
20, 14, 85, 26);
g_dir_label->set_text("Directory:");
g_path_entry = new GtkEntry(g_display, screen, g_window, g_gc, g_styles,
110, 10, 540, 32);
g_path_entry->set_text("/root/fileutils");
g_n_label = new GtkLabel(g_display, screen, g_window, g_gc, g_styles,
665, 14, 55, 26);
g_n_label->set_text("Top N:");
g_n_spin = new GtkSpinButton(g_display, screen, g_window, g_gc, g_styles,
725, 10, 85, 32);
g_n_spin->set_range(1, 100);
g_n_spin->set_digits(0);
g_n_spin->set_value(10);
g_run_button = new GtkButton(g_display, screen, g_window, g_gc, g_styles,
825, 10, 95, 32);
g_run_button->set_text("Run");
g_table = new TListView(g_display, screen, g_window, g_gc, g_styles,
20, 56, 920, 540);
g_table->add_column("Size", 95);
g_table->add_column("Age", 60);
g_table->add_column("Type", 90);
g_table->add_column("File", 300);
g_table->add_column("Parent dir", 375);There is no layout manager: every widget gets explicit x, y, width and height, the same way the LightGUI designer emits its generated apps. The table's five columns are added with their pixel widths, and the spinbox gets its range and default value here. The status label sits at the bottom of the window, under the table.
Running the scan. run_scan() reads the path and N from the widgets, walks the tree, sorts largest-first, and fills the table — one row per hit, five cells in the same order as the header. It also sets the status line, and echoes the whole scan to stdout in CLI form, so the GUI's table can be diffed against bigfind <dir> -n <N>:
static void run_scan() {
std::string dir = g_path_entry->get_text();
if (dir.empty()) dir = ".";
int n = g_n_spin->get_value_as_int();
if (n < 1) n = 1;
g_cap = (size_t)n;
g_top.clear();
g_total_bytes = 0;
g_total_files = 0;
walk(dir);
std::sort(g_top.begin(), g_top.end(),
[](const Entry &a, const Entry &b) { return a.size > b.size; });
g_table->clear_items();
for (const auto &e : g_top) {
g_table->add_item({human(e.size), age_str(e.mtime), ext_of(e.path),
base_of(e.path), parent_of(e.path)});
}
char status[256];
snprintf(status, sizeof status, "top %zu of %ld files; tree total %s",
g_top.size(), g_total_files, human(g_total_bytes).c_str());
g_status_label->set_text(status);
// ... plus a printf echo of the scan in CLI form
}The callbacks wire the widgets to run_scan(): the Run button's on_click, the entry's on_activate (Enter), and the spinbox's on_value_changed — the last one guarded by a g_ready flag, so the initial scan (which runs before the window is drawn, so the table is populated on launch) doesn't re-trigger itself. The event loop is the standard XFrame pattern: XNextEvent, dispatch to each widget's on_button_press / on_button_release / on_motion / on_key, and redraw only when something handled the event. Closing the window (WM_DELETE_WINDOW) quits.
Building and running it
One make builds it — a single g++ line against the LightGUI checkout (header-only widgets on raw X11). It builds clean with no warnings, and needs g++, libx11-dev and the LightGUI checkout:
cd apps/c/bigfind
make
# g++ -std=c++17 -I/root/lg-review/lightgui/widgets/components -I/root/lg-review/lightgui/widgets -O2 -Wall bigfind.cpp -lX11 -o bigfind
Xvfb :98 -screen 0 1024x768x24 &
DISPLAY=:98 ./bigfindRun it under a real X server, or under Xvfb as above. The include paths point at the LightGUI checkout on the build machine — on your own machine, point them at wherever you cloned LightGUI. Close the window to quit. Changing the path (Enter) or the Top N value re-runs the scan; the Run button re-scans the current path and N.
What the CLI version does differently
Almost nothing, by design. The scan, the sort, the formatting and even the extension quirk are the CLI's, ported line for line. The differences are all in presentation: the CLI's two-line hit layout becomes the File and Parent dir columns; the GUI has no --min-size or --json options (the table shows the same columns the CLI prints); and the GUI echoes each scan to stdout in CLI form, so the two can be diffed. Verified against the CLI on the same inputs (/root/fileutils, N=10): the GUI's table matches bigfind /root/fileutils -n 10 exactly — same 10 files, same sizes, same order, same totals (1824 files, 23.7 MiB).
See also
- util_boxgui — the project this app belongs to: all 50 apps, with screenshots
- bigfind.cpp — the full source
- bigfind.c — the util_box CLI this ports
- XFrame widgets
- All 547 C widgets