Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/eglib
diff options
context:
space:
mode:
authorBill Holmes <holmes@mono-cvs.ximian.com>2009-06-03 01:05:53 +0400
committerBill Holmes <holmes@mono-cvs.ximian.com>2009-06-03 01:05:53 +0400
commitbad8da7a7c5df9be6df14ffeba28eecc468c41d5 (patch)
tree80aa6a7cdba9f93139bc45dc14df608fc3465a24 /eglib
parentdcd2eb9f91ddfeb979cef2b2a18b00735d0ced23 (diff)
2009-06-02 Bill Holmes <billholmes54@gmail.com>
* src/gpath.c (g_find_program_in_path): While searching on Windows also try additional suffixes .exe, .cmd, .bat, and.com. Contributed under MIT/X11 license. svn path=/trunk/mono/; revision=135235
Diffstat (limited to 'eglib')
-rw-r--r--eglib/ChangeLog7
-rw-r--r--eglib/src/gpath.c35
2 files changed, 42 insertions, 0 deletions
diff --git a/eglib/ChangeLog b/eglib/ChangeLog
index cdae34e3f18..45dc9f3e9bd 100644
--- a/eglib/ChangeLog
+++ b/eglib/ChangeLog
@@ -1,3 +1,10 @@
+2009-06-02 Bill Holmes <billholmes54@gmail.com>
+
+ * src/gpath.c (g_find_program_in_path): While searching on Windows
+ also try additional suffixes .exe, .cmd, .bat, and.com.
+
+ Contributed under MIT/X11 license.
+
2009-05-27 Geoff Norton <gnorton@novell.com>
* src/gfile-posix.c: Fix g_get_current_dir on amd64
diff --git a/eglib/src/gpath.c b/eglib/src/gpath.c
index 78a2b5f919b..39c6aa150be 100644
--- a/eglib/src/gpath.c
+++ b/eglib/src/gpath.c
@@ -195,6 +195,12 @@ g_find_program_in_path (const gchar *program)
char *x = p, *l;
gchar *curdir = NULL;
char *save;
+#ifdef G_OS_WIN32
+ char *program_exe;
+ char *suffix_list[5] = {".exe",".cmd",".bat",".com",NULL};
+ int listx;
+ gboolean hasSuffix;
+#endif
g_return_val_if_fail (program != NULL, NULL);
@@ -203,6 +209,15 @@ g_find_program_in_path (const gchar *program)
x = curdir;
}
+#ifdef G_OS_WIN32
+ /* see if program already has a suffix */
+ listx = 0;
+ hasSuffix = FALSE;
+ while (!hasSuffix && suffix_list[listx]) {
+ hasSuffix = g_str_has_suffix(program,suffix_list[listx++]);
+ }
+#endif
+
while ((l = strtok_r (x, G_SEARCHPATH_SEPARATOR_S, &save)) != NULL){
char *probe_path;
@@ -214,6 +229,26 @@ g_find_program_in_path (const gchar *program)
return probe_path;
}
g_free (probe_path);
+
+#ifdef G_OS_WIN32
+ /* check for program with a suffix attached */
+ if (!hasSuffix) {
+ listx = 0;
+ while (suffix_list[listx]) {
+ program_exe = g_strjoin(NULL,program,suffix_list[listx],NULL);
+ probe_path = g_build_path (G_DIR_SEPARATOR_S, l, program_exe, NULL);
+ if (access (probe_path, X_OK) == 0){ /* FIXME: on windows this is just a read permissions test */
+ g_free (curdir);
+ g_free (p);
+ g_free (program_exe);
+ return probe_path;
+ }
+ listx++;
+ g_free (probe_path);
+ g_free (program_exe);
+ }
+ }
+#endif
}
g_free (curdir);
g_free (p);