Strip arguments

SVN revision: 17011
This commit is contained in:
sebastid 2005-09-28 02:08:52 +00:00 committed by sebastid
parent 8264fcfca2
commit 773835e9fc
1 changed files with 26 additions and 1 deletions

View File

@ -62,11 +62,11 @@ ecore_file_app_installed(const char *app)
{ {
char *dir; char *dir;
char buf[PATH_MAX]; char buf[PATH_MAX];
char *file, *p;
if (!app) return 0; if (!app) return 0;
if (ecore_file_exists(app) && ecore_file_can_exec(app)) return 1; 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); ecore_list_goto_first(__ecore_file_path_bin);
while ((dir = ecore_list_next(__ecore_file_path_bin)) != NULL) while ((dir = ecore_list_next(__ecore_file_path_bin)) != NULL)
{ {
@ -75,5 +75,30 @@ ecore_file_app_installed(const char *app)
return 1; 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; return 0;
} }