unixpath2win() - convert an Interix pathname to Windows syntax
#include <interix/interix.h>
int unixpath2win(const char *path, int flags, char *buf, size_t buflen)
The unixpath2win(2) call converts an Interix pathname to an equivalent Windows pathname.
The Interix pathname is not required to name an existing file. However, some prefix of the pathname will name an existing file, even if the prefix is the degenerate case of "/". The unixpath2win(2) call will find the longest prefix of the Interix path that names an existing file and which is accessible to the effective user, and it will resolve symbolic links within this prefix.
If the PATH_SYMLINK bit of the flags argument is set, and if the path names an existing symlink file, then the symlink named by path will not be followed, although symlinks named by prefixes of path will still be followed. (The PATH_SYMLINK bit is the only bit in flags that can be set; setting any other bit in flags produces an error.)
The Interix pathname /dev/null is translated to the Windows pathname "nul". Support for other device names will be added in the future.
On success, unixpath2win(2) returns 0 and stores a null-terminated pathname in buf. On failure, it returns -1 and sets errno.
The unixpath2win(2) call will fail if:
If path contains funny characters such as ? or *, which are legal in Interix pathnames but not legal in Windows pathnames, then these are translated internally into bizarre Unicode characters, which cause an EILSEQ error when the Unicode string is translated back to an 8-bit or multi-byte string. This nastiness would be avoided if we had a way to return the Windows pathname as a Unicode or UTF-8 string.
The unixpath2win(2) call will fail if the resultant Windows pathname contains more than PATH_MAX characters, even if the buffer you supplied is big enough to hold the result. But that's okay, since most Windows programs will fail if given a pathname longer than PATH_MAX characters, due to restrictions imposed by the Windows operating system.
The resultant Windows pathname is always an absolute pathname, even if the original Interix pathname is a relative pathname.
winpath2unix(2)