Index of Section 2 Manual Pages
| Interix / SUA | winpath2unix.2 | Interix / SUA |
winpath2unix(2) winpath2unix(2)
winpath2unix()
NAME
winpath2unix() - convert a Windows pathname to Interix syntax
SYNOPSIS
#include
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:
* An empty string maps to an empty string instead of failing with an
ENOENT error.
* A dot (.) maps to a dot, not to the absolute pathname of the current
working directory of the current process.
* Dot-relative path names are converted by translating \ to / so that
the result is a relative path name. No attempt is made to convert
the path name to the correct case.
* Syntactically incorrect pathnames such as \\\ and \\ are converted
to /?untranslated?/// and /?untranslated?// instead of failing with
an ENOENT error.
* The only possible error is ERANGE (output buffer too small).
(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)
USAGE NOTES
The winpath2unix function is thread safe.
The winpath2unix function is not async-signal safe.