[wesnoth-commits] [wesnoth/wesnoth] 0fec8c: campaignd/fs_commit: Reimplement for Windows

Iris Morelle noreply at github.com
Sun Nov 22 02:59:02 UTC 2020


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 0fec8c905a7d1a527e19b8a2554e4392110677ad
      https://github.com/wesnoth/wesnoth/commit/0fec8c905a7d1a527e19b8a2554e4392110677ad
  Author: Iris Morelle <shadowm at wesnoth.org>
  Date:   2020-11-21 (Sat, 21 Nov 2020)

  Changed paths:
    M src/server/campaignd/fs_commit.cpp
    M src/server/campaignd/fs_commit.hpp

  Log Message:
  -----------
  campaignd/fs_commit: Reimplement for Windows

This replaces the existing low-effort implementation on Windows (which
was broken and made it impossible to use campaignd in a meaningful
fashion at all) with one that actually attempts to replace files in the
most atomic fashion we can afford using the Windows API.

Temporary files are now opened with FILE_SHARE_DELETE so that we can
perform rename and delete operations on them without having to close
them first, which would be an open invitation for UB if any references
held to the underlying ostream get used again.

Instead of calling std::remove and std::rename (both of which weren't
Unicode-safe anyway) we now use the kernel32 API
SetFileInformationByHandle() to forcefully replace a potentially
existing file. It's a win-win.

Some of the POSIX code is touched here in order to keep things tidy;
namely the get_stream_file_descriptor() helper.





More information about the Commits mailing list