Closed wdoekes closed 1 year ago
Looks reasonable to not rename symlinks in general, unless we want to be more precise as in resolve to a file itself and operate on it.
lstat
is not crossplatform, this looks like solution https://en.cppreference.com/w/cpp/filesystem/is_symlink
removal of ( !file_exists( backup ) || file_remove( backup ) ) // remove backup
is error, rename does not necessarily overwrite https://stackoverflow.com/a/41926145/16652886
Confirmed, Microsoft decided to behave differently indeed:
The new name must not be the name of an existing file or directory.
https://man7.org/linux/man-pages/man2/rename.2.html
If newpath already exists, it will be atomically replaced, [...]
This looks like a portable version, behaving like posix: https://en.cppreference.com/w/cpp/filesystem/rename
I can whip up a PR.
^- PR
When a file is a symlink, do not replace it with a real file: https://github.com/wdoekes/nrcradiant-deb/blob/main/patches/nrcradiant-no-move-map-symlink.patch
This patch also helps when coopering on map editing through a shared VCS.