winpath2unix()

NAME

winpath2unix() - convert a Windows pathname to Interix syntax

SYNOPSIS

#include <interix/interix.h>

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

DESCRIPTION

The winpath2unix(2) call converts a Windows pathname to an equivalent Interix pathname.

If the Windows pathname is a drive-relative pathname such as "\foo", then the current working directory is translated to Windows syntax using unixpath2win(2). If this translation fails with EWINPATH, then winpath2unix(2) also fails with EWINPATH. Otherwise, the root part of the Windows translation of the current working directory is extracted, which will be a string such as "C:\" or "\\host\share", and this string is prepended to the drive-relative pathname. Then the resultant absolute Windows pathname is translated.

A Windows pathname such as "C:foo" will be interpreted as if it were "C:\foo". That's the best we can do, since Interix processes do not have a notion of a current working directory for each mounted drive.

The Windows pathname is not required to name an existing file. However, if possible, the winpath2unix(2) call will find the longest prefix of the Windows pathname that names an existing file which is accessible to the effective user, and it will convert that prefix to canonical case. This conversion is necessary because Windows pathname lookups are case insensitive, while Interix pathname lookups are case sensitive.

If the PATH_NONSTRICT bit of the flags argument is set, then the following rules apply:

(The PATH_NONSTRICT bit is generally used to convert Windows path environment variables to UNIX syntax, and is the only bit in flags that can be set; setting any other bit in flags produces an error.)

RETURN VALUE

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

ERRORS

The winpath2unix(2) call may fail if:

[ENOENT]
The path argument points to a string which is not a syntactically correct Windows pathname. Examples include "" and "\\".
[EWINPATH]
The current working directory cannot be translated to a Windows pathname, and the value of the current working directory was required to complete the translation.
[EINVAL]
An invalid flags value was passed, such as flags & ~(PATH_NONSTRICT).
[ERANGE]
The resultant Interix pathname contains more than PATH_MAX characters.
[ERANGE]
The resultant Interix 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.

SEE ALSO

unixpath2win(2)