unixpath2win()

NAME

unixpath2win() - convert an Interix pathname to Windows syntax

SYNOPSIS

#include <interix/interix.h>

int unixpath2win(const char *path, int flags, char *buf, size_t buflen)

DESCRIPTION

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.

RETURN VALUE

On success, unixpath2win(2) returns 0 and stores a null-terminated pathname in buf. On failure, it returns -1 and sets errno.

ERRORS

The unixpath2win(2) call will fail if:

[ENOENT]
The path argument points to an empty string.
[ENAMETOOLONG]
The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
[ELOOP]
Too many symbolic links were encountered in resolving path.
[EWINPATH]
The Interix pathname names a virtual file that does not correspond to any file in the Windows name space. Examples include /proc and /dev/ptmx.
[EINVAL]
An invalid flags value was passed, such as flags & ~(PATH_SYMLINK).
[ERANGE]
The resultant Windows pathname contains more than PATH_MAX characters.
[ERANGE]
The resultant Windows pathname is too large to store in buf.
[ENOMEM]
The client program or the Interix subsystem could not allocate enough memory to complete the operation.
[EILSEQ]
The Interix pathname contains a character that is not legal in Windows pathnames.

BUGS

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.

SEE ALSO

winpath2unix(2)