Problem: I'm writing some code that is portable to Linux and Cygwin (compiled on msys), and the handling of symlinks is different. On Cygwin, if I create a symlink in the normal way, with a default Cygwin shell (ie. the CYGWIN
envvar not set):
$ ln -s foo bar
then fopen(bar)
doesn't follow the symlink. The first line of text appears to be !<symlink>.
and my code reports that the opened file isn't UTF-8.
I can fix this by running Cygwin as admin, setting CYGWIN
to winsymlinks:nativestrict
, deleting the symlink, and re-creating it. However, this isn't ideal: in my case, the symlinks are created by Subversion from the Linux codebase, so I now need to script the link delete and remake after every update.
- Is there a better way to do this, or do I have to ask Cygwin users
to run as admin, and set
CYGWIN
? - How do I write code to follow a native Cygwin symlink?
- How do I write code to find out what type of symlink I'm dealing with? This is also asked here, but the answer there is scripted
Thanks.
Edit
Ok, I think the answer is basically here, on the MinGW mailing list, from 2007. If you compile with MinGW you can't use Cygwin native symlinks. Maybe the situation has changed since 2007?