From 773835e9fc0892f8cf370c10ed496dea3d538d86 Mon Sep 17 00:00:00 2001 From: sebastid Date: Wed, 28 Sep 2005 02:08:52 +0000 Subject: [PATCH] Strip arguments SVN revision: 17011 --- .../src/lib/ecore_file/ecore_file_path.c | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file_path.c b/legacy/ecore/src/lib/ecore_file/ecore_file_path.c index cc0b8526af..e84037f694 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file_path.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file_path.c @@ -62,11 +62,11 @@ ecore_file_app_installed(const char *app) { char *dir; char buf[PATH_MAX]; + char *file, *p; if (!app) return 0; if (ecore_file_exists(app) && ecore_file_can_exec(app)) return 1; - if (ecore_list_is_empty(__ecore_file_path_bin)) return 0; ecore_list_goto_first(__ecore_file_path_bin); while ((dir = ecore_list_next(__ecore_file_path_bin)) != NULL) { @@ -75,5 +75,30 @@ ecore_file_app_installed(const char *app) return 1; } + /* Maybe the app has arguments */ + file = strdup(app); + if (!file) return 0; + p = strchr(file, ' '); + if (!p) + p = strchr(file, '\t'); + if (!p) + p = strchr(file, '\n'); + if (p) + { + *p = '\0'; + if (ecore_file_exists(file) && ecore_file_can_exec(file)) return 1; + ecore_list_goto_first(__ecore_file_path_bin); + while ((dir = ecore_list_next(__ecore_file_path_bin)) != NULL) + { + snprintf(buf, sizeof(buf), "%s/%s", dir, file); + if (ecore_file_exists(buf) && ecore_file_can_exec(buf)) + { + free(file); + return 1; + } + } + } + free(file); + return 0; }