hle(host_posix): the file calls a title manages its saves with (MoveFileW, CopyFileW, ReplaceFileW, GetFileType, CreateFileMappingA) are stubs #627

Closed
opened 2026-11-28 15:57:50 +00:00 by github-bot · 3 comments
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 15:54 UTC · original

Summary

Five file calls a title makes when it manages its own files were unimplemented and answered through the loader's import stub: MoveFileW, CopyFileW, ReplaceFileW, GetFileType and CreateFileMappingA.

The first three are how a title writes a save file without leaving a half-written one: write a new file, copy the old one to a backup, then replace. With stubs, every one of those steps silently failed, and a title that checks the return value gives up on saving (or worse, saves nothing and reports success to the wrong layer). GetFileType is what a title asks before reading or seeking a handle, and CreateFileMappingA is the ANSI form of the mapping added in #623.

What the change does

  • MoveFileW: the plain form of MoveFileExW.
  • CopyFileW: copies the bytes; FAIL_IF_EXISTS on an existing target is ERROR_FILE_EXISTS, otherwise the copy replaces what was there. A missing source is ERROR_FILE_NOT_FOUND.
  • ReplaceFileW: gives the backup the file being replaced, then the replacement takes its name, which is the order Windows uses.
  • GetFileType: reads the handle's own node — a disk, a character device (a console, /dev/null), or a pipe (a fifo or a socket) — and ERROR_INVALID_HANDLE with FILE_TYPE_UNKNOWN for a handle that is no handle.
  • CreateFileMappingA: the ANSI form of CreateFileMappingW; a section name is not a path, so it is widened byte by byte rather than through the drive table.

Tests

Three new ones in files.rs: a file is copied (including the FAIL_IF_EXISTS refusal and the replace-with-backup order) and moved; a file handle is a disk, /dev/null is a character device and a garbage handle is unknown with its error; and the ANSI mapping form makes a section that maps and unmaps like the wide one.

One thing the tests taught me and the code now says: the standard handles are not asserted on. This suite's stdout is a pipe when cargo pipes it and a file when it is redirected, and FILE_TYPE_PIPE and FILE_TYPE_DISK are both right for the handle in those cases — a test that insisted on one of them failed the gate while passing when run by hand.

**@⁠AnastasisKon** on GitHub · 2026-11-28 15:54 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/623) ## Summary Five file calls a title makes when it manages its own files were unimplemented and answered through the loader's import stub: `MoveFileW`, `CopyFileW`, `ReplaceFileW`, `GetFileType` and `CreateFileMappingA`. The first three are how a title writes a save file without leaving a half-written one: write a new file, copy the old one to a backup, then replace. With stubs, every one of those steps silently failed, and a title that checks the return value gives up on saving (or worse, saves nothing and reports success to the wrong layer). `GetFileType` is what a title asks before reading or seeking a handle, and `CreateFileMappingA` is the ANSI form of the mapping added in #623. ## What the change does - `MoveFileW`: the plain form of `MoveFileExW`. - `CopyFileW`: copies the bytes; `FAIL_IF_EXISTS` on an existing target is `ERROR_FILE_EXISTS`, otherwise the copy replaces what was there. A missing source is `ERROR_FILE_NOT_FOUND`. - `ReplaceFileW`: gives the backup the file being replaced, then the replacement takes its name, which is the order Windows uses. - `GetFileType`: reads the handle's own node — a disk, a character device (a console, `/dev/null`), or a pipe (a fifo or a socket) — and `ERROR_INVALID_HANDLE` with `FILE_TYPE_UNKNOWN` for a handle that is no handle. - `CreateFileMappingA`: the ANSI form of `CreateFileMappingW`; a section name is not a path, so it is widened byte by byte rather than through the drive table. ## Tests Three new ones in `files.rs`: a file is copied (including the `FAIL_IF_EXISTS` refusal and the replace-with-backup order) and moved; a file handle is a disk, `/dev/null` is a character device and a garbage handle is unknown with its error; and the ANSI mapping form makes a section that maps and unmaps like the wide one. One thing the tests taught me and the code now says: the *standard* handles are not asserted on. This suite's stdout is a pipe when cargo pipes it and a file when it is redirected, and `FILE_TYPE_PIPE` and `FILE_TYPE_DISK` are both right for the handle in those cases — a test that insisted on one of them failed the gate while passing when run by hand.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 15:57:50 +00:00
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 15:54 UTC · original

/claim

**@⁠AnastasisKon** on GitHub · 2026-11-28 15:54 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/623#issuecomment-7241826184) /claim
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-28 15:54 UTC · original

Claimed by @⁠AnastasisKon. Open a draft pull request with Refs #623 in its description within 24 hours, or the claim expires.

**@⁠github-actions[bot]** on GitHub · 2026-11-28 15:54 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/623#issuecomment-7241828215) Claimed by @⁠AnastasisKon. Open a draft pull request with `Refs #623` in its description within 24 hours, or the claim expires.
Author
Owner

@⁠AnastasisKon on GitHub · 2026-11-28 16:31 UTC · original

Merged with the PR that serves these calls; closing.

**@⁠AnastasisKon** on GitHub · 2026-11-28 16:31 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/623#issuecomment-7242312794) Merged with the PR that serves these calls; closing.
This discussion has been locked. Commenting is limited to contributors.
No description provided.