Skip to content

facade: plugins/image-source: move 7 platform conditionals behind a per-platform layer #858

Closed

Description

@zackees

Inventory of platform conditionals in shared-named files of plugins/image-source/ (7 #ifs in 4 files). Existing pattern: image-file-version-win32.c holds the Windows implementation; image-file-version.c is the non-Windows one but is named shared.

file lines macro what the branch does
image-file-version.c 8 !_WIN32 whole nix implementation of image_file_version_get (Windows variant in -win32.c)
20 __APPLE__ st_mtimespec vs st_mtim nanoseconds
image-source.c 285, 294 _WIN32 file-dialog filter string includes JXR
obs-slideshow.c 241, 916 _WIN32 .jxr accepted as image ext; extension filter string
obs-slideshow-mk2.c 968 _WIN32 extension filter string includes *.jxr

Proposed facade

  • Rename image-file-version.c to image-file-version-posix.c (path marks platform) and move the __APPLE__ mtime nanosecond choice into a tiny image_file_version_mtime_nsec(const struct stat*) implemented in -posix.c and -mac.c, or use a helper from util/platform.h.
  • image-source/platform.h: image_platform_supports_jxr() plus image_platform_extra_filters() (Windows returns the JXR entries) so the three filter/extension sites call one function.

Likely must stay

Nothing structurally; the JXR rows are small data differences and are best served by the facade getter. CMake OS_WINDOWS (CMakeLists.txt:21) stays.

Test approach

Behaviour-preserving moves. Verify with: the plugin's native builds on each platform (ci-full label, since these are outside the quick gate), the existing cmocka tests where the moved function is testable, and ./lint. Where a facade function is pure (path/name/constant selection) add a small unit test per platform implementation. The #847 ratchet lint baseline must go down by the count moved.

Part of #847.

Activity

  1. zackees commented on Oct 17, 2026

    @zackees
    MemberAuthor

    Claiming. Same shape as #857 (PR #1248): upstream files stay in place and keep their names (#1051, so no -posix.c rename); a conditional-free image-source-host.h (JXR support/filter strings, mtime nanoseconds) with image-source-host-{windows,macos,posix}.c.h in per-OS unity groups picked by CMake (BUILD.md). Pure getters get a cmocka test; baseline goes down by what moves.

  2. added
    claimed
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions