This is an annoying problem. Let me elaborate it.
Environment:
- I have a Ubuntu 20.04 Linux machine which have some C/C++ code in
/home/chj/gitw/bookcode-linux/TLPI, some .c file(e.g.$TLPI/lib/become_daemon.c) is actually a soft link that links to actual file$TLPI/daemons/become_daemon.c. - The Linux machine runs Samba server so that a Samba client can access the files there.
- I have another machine running Win10.22H2, it uses
net use L: \\10.22.3.213\chj /user:chj ******so that thebecome_daemon.cis accessible from this Windows PC asL:\gitw\bookcode-linux\TLPI\lib\become_daemon.c. - This Win10 PC runs VS2019 16.11, and have it open and edit
L:\gitw\bookcode-linux\TLPI\lib\become_daemon.c.
Now the bad thing happens. After VS2019 edits and saves the become_daemon.c file, the soft link at Linux side is destroyed. The $TLPI/lib/become_daemon.c becomes a normal file.
That is really not my desired behavior. I hope that $TLPI/daemons/become_daemon.c is changed after VS2019's editing, but not the soft link node itself.
I've written a simple program on Windows to CreateFile(), WriteFile(), CloseHandle() on L:\gitw\bookcode-linux\TLPI\lib\become_daemon.c, and see that the soft link is preserved.
ProcessMonitor reveals that VSIDE is actually creating a temp file to store my editd text, then rename(+overwrite) it to be the final become_daemon.c.
SetRenameInformationFile
ReplaceIfExists: True, FileName: \10.22.3.213\chj\gitw\bookcode-linux\TLPI\lib\become_daemon.c~RF321c0a07.TMP
Ouch, no wonder the soft link is overwritten to become a normal file.
Then I'd really want to ask, is there any way I can tell Visual Studio not to use a temp file and operate(WriteFile()) on the target file directly.

