#pragma prototyped
#include <ast.h>
#if _UWIN
#include <uwin.h>
size_t
pathposix(const char* path, char* buf, size_t siz)
{
return uwin_unpath(path, buf, siz);
}
#else
#if __CYGWIN__
extern void cygwin_conv_to_posix_path(const char*, char*);
size_t
pathposix(const char* path, char* buf, size_t siz)
{
size_t n;
if (!buf || siz < PATH_MAX)
{
char tmp[PATH_MAX];
cygwin_conv_to_posix_path(path, tmp);
if ((n = strlen(tmp)) < siz && buf)
memcpy(buf, tmp, n + 1);
return n;
}
cygwin_conv_to_posix_path(path, buf);
return strlen(buf);
}
#else
#if __EMX__ && 0
size_t
pathposix(const char* path, char* buf, size_t siz)
{
char* s;
size_t n;
if (!_posixpath(buf, path, siz))
{
for (s = buf; *s; s++)
if (*s == '/')
*s = '\\';
}
else if ((n = strlen(path)) < siz && buf)
memcpy(buf, path, n + 1);
return n;
}
#else
#if __INTERIX
#include <interix/interix.h>
size_t
pathposix(const char* path, char *buf, size_t siz)
{
static const char pfx[] = "/dev/fs";
*buf = 0;
if (!strncasecmp(path, pfx, sizeof(pfx) - 1))
strlcpy(buf, path, siz);
else
winpath2unix(path, PATH_NONSTRICT, buf, siz);
return strlen(buf);
}
#else
size_t
pathposix(const char* path, char* buf, size_t siz)
{
size_t n;
if ((n = strlen(path)) < siz && buf)
memcpy(buf, path, n + 1);
return n;
}
#endif
#endif
#endif
#endif