feat: add directory opening support (gerbv .)#309
Merged
spe-ciellt merged 3 commits intogerbv:developfrom Mar 5, 2026
Merged
Conversation
Allow passing a directory path as a CLI argument to load all recognized gerber, drill, and pick-and-place files from it. Detection is content-based using the existing probe functions, so extensionless and dot-prefixed files (e.g. Altium output) are handled correctly.
7064013 to
1ca0dd8
Compare
1ca0dd8 to
c2ab127
Compare
This was referenced Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Like
code .opens VS Code with the current directory,gerbv .should open all recognized gerber/drill/PnP files from a directory. Currently gerbv treats.as a filename, which fails.Changes
src/gerbv.c— Addgerbv_is_loadable_file()content probe that runs the same four detection functions used bygerbv_open_image(RS-274X, Excellon, PnP, RS-274D)src/gerbv.h— Declaregerbv_is_loadable_file()src/main.c— Addscan_directory()helper and modify the CLI file-loading loop to handle directory argumentsHow it works
When a CLI argument is a directory,
scan_directory()iterates its entries, probes each regular file withgerbv_is_loadable_file(), and collects matches into a sorted list. The probe reuses the exact same detection functions asgerbv_open_image— no extension guessing. This handles extensionless files and dot-prefixed files like.GBL,.GTL(Altium output) since detection is purely content-based.Usage
gerbv .gerbv ./gerbers/gerbers/gerbv file.gbrgerbv ./gerbers/ extra.gbrgerbv empty-dir/Export mode
Directory arguments work with
--exporttoo. All files from the directory are loaded as layers and composited into a single output image, exactly as if each file had been listed individually:# These are equivalent: gerbv --export=png -o board.png ./gerbers/ gerbv --export=png -o board.png gerbers/copper.gbr gerbers/mask.gbr gerbers/drill.drlThe output is one image with all layers stacked and color-coded — the same view you'd see in the GUI.
Design decisions
code .convention and avoids surprises with nested output directories..GBL). Since every file is content-probed, non-gerber files are silently skipped regardless of name.Closes #308
Test plan
cmake --build build— clean build, zero warningsctest— 94/104 pass (unchanged from baseline)gerbv test/inputs/— loads all test gerber/drill filesgerbv .from empty dir — prints "No loadable files found"gerbv file.gbr— single file unchangedgerbv --export=png -o out.png test/inputs/— directory works with export