|
|
@@ -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);
|