1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
27 * convert native path to posix fs representation in <buf,siz>
28 * length of converted path returned
29 * if return length >= siz then buf is indeterminate, but another call
30 * with siz=length+1 would work
31 * if buf==0 then required size is returned
41 pathposix(const char* path
, char* buf
, size_t siz
)
43 return uwin_unpath(path
, buf
, siz
);
50 extern void cygwin_conv_to_posix_path(const char*, char*);
53 pathposix(const char* path
, char* buf
, size_t siz
)
57 if (!buf
|| siz
< PATH_MAX
)
61 cygwin_conv_to_posix_path(path
, tmp
);
62 if ((n
= strlen(tmp
)) < siz
&& buf
)
63 memcpy(buf
, tmp
, n
+ 1);
66 cygwin_conv_to_posix_path(path
, buf
);
72 #if __EMX__ && 0 /* show me the docs */
75 pathposix(const char* path
, char* buf
, size_t siz
)
80 if (!_posixpath(buf
, path
, siz
))
82 for (s
= buf
; *s
; s
++)
86 else if ((n
= strlen(path
)) < siz
&& buf
)
87 memcpy(buf
, path
, n
+ 1);
95 #include <interix/interix.h>
98 pathposix(const char* path
, char *buf
, size_t siz
)
100 static const char pfx
[] = "/dev/fs";
103 if (!strncasecmp(path
, pfx
, sizeof(pfx
) - 1))
104 strlcpy(buf
, path
, siz
);
106 winpath2unix(path
, PATH_NONSTRICT
, buf
, siz
);
113 pathposix(const char* path
, char* buf
, size_t siz
)
117 if ((n
= strlen(path
)) < siz
&& buf
)
118 memcpy(buf
, path
, n
+ 1);