Skip to content

Fix renaming files on Windows

Han-Wen Nienhuys requested to merge dev/hanwen/windows-rename into master

The GUILE rename-file function calls rename, which according to https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/rename-wrename requires that the destination does not exist.

Add a work-around by removing the destination if it exists. The result is no longer atomic.

There is support for atomic renames on Windows by using MoveFileExW, available from XP onwards. This is supported in gnulib's lib/rename.c, but importing that as a lilypond dependency (or as a GUILE bugfix) goes beyond the scope of an urgent bugfix for our windows release.

Tested: Replaced "(eq? PLATFORM 'windows)" with #t, and verified:

  • code path is called (debug print)

  • repeated 'lilypond --png --pdf input/regression/les-nereides.ly' succeeds.

This should fix bug #6009 (closed)

Merge request reports