49 lines
1.6 KiB
Diff
49 lines
1.6 KiB
Diff
From 6d9ecfddb197ff4fcfb8404f03d502501bafe411 Mon Sep 17 00:00:00 2001
|
|
From: Junjie Mao <eternal.n08@gmail.com>
|
|
Date: Tue, 7 Apr 2015 21:25:35 +0800
|
|
Subject: [PATCH] Convert to windows path before checking stats
|
|
|
|
Signed-off-by: Junjie Mao <eternal.n08@gmail.com>
|
|
---
|
|
byterun/win32.c | 15 ++++++++++++++-
|
|
1 file changed, 14 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/byterun/win32.c b/byterun/win32.c
|
|
index 67e9683..02d060e 100644
|
|
--- a/byterun/win32.c
|
|
+++ b/byterun/win32.c
|
|
@@ -59,9 +59,10 @@ char * caml_decompose_path(struct ext_table * tbl, char * path)
|
|
|
|
char * caml_search_in_path(struct ext_table * path, char * name)
|
|
{
|
|
- char * p, * dir, * fullname;
|
|
+ char * p, * dir, * fullname, * cmd, * output;
|
|
int i;
|
|
struct stat st;
|
|
+ FILE *pipe = NULL;
|
|
|
|
for (p = name; *p != 0; p++) {
|
|
if (*p == '/' || *p == '\\') goto not_found;
|
|
@@ -71,6 +72,18 @@ char * caml_search_in_path(struct ext_table * path, char * name)
|
|
if (dir[0] == 0) continue;
|
|
/* not sure what empty path components mean under Windows */
|
|
fullname = caml_strconcat(3, dir, "\\", name);
|
|
+ cmd = caml_strconcat(2, "cygpath -w ", fullname);
|
|
+ pipe = popen(cmd, "r");
|
|
+ output = caml_stat_alloc(strlen(cmd) + 128);
|
|
+ fscanf(pipe, "%s", output);
|
|
+ pclose(pipe);
|
|
+ caml_stat_free(cmd);
|
|
+ if (output[0] != '\0') {
|
|
+ caml_stat_free(fullname);
|
|
+ fullname = output;
|
|
+ } else {
|
|
+ caml_stat_free(output);
|
|
+ }
|
|
caml_gc_message(0x100, "Searching %s\n", (uintnat) fullname);
|
|
if (stat(fullname, &st) == 0 && S_ISREG(st.st_mode))
|
|
return fullname;
|
|
--
|
|
2.3.4
|
|
|