Skip to content

util: Move platform.c file helpers into platform-file.c - #1443

Merged
zackees merged 1 commit into
obs-rust:masterfrom
swilk19:port/platform-file
Oct 18, 2026
Merged

zackees merged 1 commit into
obs-rust:masterfrom
swilk19:port/platform-file

Conversation

@swilk19

@swilk19 swilk19 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Refs #262 (slice 3, files).

Behavior-neutral extraction, as the testing policy asks before a partial-file port: os_wfopen, os_fopen, os_fgetsize, os_stat (Windows), os_fseeki64/os_ftelli64, os_fread_mbs/os_fread_utf8, os_quick_read_*/os_quick_write_* (incl. _safe) and os_get_file_size move verbatim from libobs/util/platform.c.h into libobs/util/platform-file.c.h (both halves checked with diff against the original). No Rust, no signature, header or behavior change.

  • Build: the new file joins the existing libobs.platform unity group and libobs-platform.pch.h (it needs the same _FILE_OFFSET_BITS 64).
  • Oracle: rust/obs-c-oracle/oracle/platform.c includes both files, so the oracle still runs the real C.
  • Ifdef ratchet: the five host conditionals all sit in this slice and move with it (platform.c.h 5 → platform-file.c.h 5, total unchanged).

New characterization test test_platform_file (tests.d/ fragment, plus the Cargo C-test manifest) for what test_platform doesn't cover: os_wfopen with a non-ASCII path, os_fread_mbs called directly (it leaves the position at EOF: characterized, not endorsed), os_fgetsize restoring the position, os_fseeki64/os_ftelli64 past 4 GiB, os_stat on a file, directory and missing path, zero-length writes, and NULL paths.

Local: ./unittest green, with 305/305 cmocka tests passing against both libobs and libobs-with-rust, including test_platform_file. ./lint: build-groups, ifdef ratchet, clang-format and gersemi pass. Windows locally (xwin, clang-cl oracle): 499/508 obs-util tests pass; the 9 failures are WSL-only (UNC working directory, interop process spawns) and are in pipe/abs-path code outside this slice.

Windows/macOS: this changes a unity group, and the moved code has Windows branches, but PR CI scopes it Linux-only. Per BUILD.md ("Verifying a change"), could a maintainer dispatch the full build (gh workflow run ci.yml --ref <branch>)? I don't have dispatch rights. Kept as a draft until Windows passes. The Rust port (RED, then GREEN) follows in a separate PR.

🤖 Generated with Claude Code

Refs obs-rust#262 (slice 3, files).

Behavior-neutral extraction before the Rust port: os_wfopen, os_fopen,
os_fgetsize, os_stat (Windows), os_fseeki64, os_ftelli64, os_fread_mbs,
os_fread_utf8, os_quick_read_*/os_quick_write_* (incl. _safe) and
os_get_file_size move verbatim from libobs/util/platform.c.h into
libobs/util/platform-file.c.h, in the same libobs.platform unity group
and precompiled header. The oracle compiles both files. The five host
conditionals move with the code (platform-ifdef baseline 5 -> 5).

test_platform_file characterizes what test_platform leaves uncovered:
os_wfopen, os_fread_mbs, os_fgetsize restoring the position, seeks past
4 GiB, os_stat, zero-length writes and NULL paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@swilk19

swilk19 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor Author

Windows/macOS evidence for this PR, from the stacked port #1444, whose head (ba9394422) contains this PR's commit a873cd4ae unchanged. That run started the Windows and macOS lanes, which this PR's path scope skips. All jobs passed (run 39172548715):

The full app builds (Build / Windows, macOS) are still path-scoped off in both PRs. BUILD.md's gh workflow run ci.yml for a group change is still a maintainer call. Marking this ready for review.

@swilk19
swilk19 marked this pull request as ready for review October 18, 2026 22:42
@swilk19
swilk19 requested a review from zackees as a code owner October 18, 2026 22:42
@zackees
zackees added this pull request to the merge queue Oct 18, 2026
Merged via the queue into obs-rust:master with commit 711bd28 Oct 18, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants