I’m porting C/C++ code from Unix to Windows that makes use of the symlink() function.
From what I understand, recent Windows file systems have a equivalent of symbolic links.
What would be the best / most portable way replace the symlink() function, so the same code works on both platforms ?
Since Windows Vista there’s a function to create true symbolic links: CreateSymbolicLink
Note that Junctions as mentioned in the other answers only support directories, and even with the newer feature, windows symbolic links require you to specify whether the target is a directory or a file. So you won’t necessarily be able to get a trivial “drop-in replacement”
symlink()function.