Skip to content

Commit 4400890

Browse files
committed
Update pathnative and pathposix for Cygwin
1 parent 883cace commit 4400890

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

src/lib/libast/path/pathnative.c

+2-15
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,12 @@
3030
#include <ast.h>
3131

3232
#if __CYGWIN__
33-
34-
extern void cygwin_conv_to_win32_path(const char*, char*);
33+
#include <sys/cygwin.h>
3534

3635
size_t
3736
pathnative(const char* path, char* buf, size_t siz)
3837
{
39-
size_t n;
40-
41-
if (!buf || siz < PATH_MAX)
42-
{
43-
char tmp[PATH_MAX];
44-
45-
cygwin_conv_to_win32_path(path, tmp);
46-
if ((n = strlen(tmp)) < siz && buf)
47-
memcpy(buf, tmp, n + 1);
48-
return n;
49-
}
50-
cygwin_conv_to_win32_path(path, buf);
51-
return strlen(buf);
38+
return cygwin_conv_path(CCP_POSIX_TO_WIN_A | CCP_ABSOLUTE, path, buf, siz);
5239
}
5340

5441
#elif __INTERIX

src/lib/libast/path/pathposix.c

+2-14
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,12 @@
3232

3333
#if __CYGWIN__
3434

35-
extern void cygwin_conv_to_posix_path(const char*, char*);
35+
#include <sys/cygwin.h>
3636

3737
size_t
3838
pathposix(const char* path, char* buf, size_t siz)
3939
{
40-
size_t n;
41-
42-
if (!buf || siz < PATH_MAX)
43-
{
44-
char tmp[PATH_MAX];
45-
46-
cygwin_conv_to_posix_path(path, tmp);
47-
if ((n = strlen(tmp)) < siz && buf)
48-
memcpy(buf, tmp, n + 1);
49-
return n;
50-
}
51-
cygwin_conv_to_posix_path(path, buf);
52-
return strlen(buf);
40+
return cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_ABSOLUTE, path, buf, siz);
5341
}
5442

5543
#elif __INTERIX

0 commit comments

Comments
 (0)