Skip to content

feat: add directory opening support (gerbv .)#2

Merged
rampageservices merged 3 commits intodevelopfrom
feat/open-directory
Mar 6, 2026
Merged

feat: add directory opening support (gerbv .)#2
rampageservices merged 3 commits intodevelopfrom
feat/open-directory

Conversation

@rampageservices
Copy link
Copy Markdown

Summary

  • Add gerbv_is_loadable_file() content probe to detect gerber/drill/PnP files without relying on extensions
  • Add scan_directory() to main.c that filters directory contents through the probe
  • Modify the CLI file-loading loop to handle directory arguments alongside regular files

Closes gerbv#308

How it works

When a CLI argument is a directory, scan_directory() iterates its entries, probes each regular file with gerbv_is_loadable_file(), and collects matches into a sorted list. The probe reuses the exact same detection functions as gerbv_open_image (RS-274X, Excellon, PnP, RS-274D) — no extension guessing. Dot-prefixed files like .GBL and .GTL (Altium output) are included since detection is content-based.

Test plan

  • cmake --build build — clean build, zero warnings
  • ctest — 94/104 pass (unchanged baseline)
  • gerbv test/inputs/ — loads all test gerber/drill files
  • gerbv . from empty dir — prints "No loadable files found"
  • gerbv file.gbr — single file still works
  • gerbv --export=png -o out.png test/inputs/ — directory works with export
  • Extensionless gerber in a directory is detected and loaded

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.
@rampageservices rampageservices force-pushed the develop branch 3 times, most recently from 180c677 to 49d1676 Compare March 3, 2026 03:42
@rampageservices rampageservices merged commit a6c7226 into develop Mar 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: open directory of gerber files (gerbv .)

2 participants