430
/*----------------------------------------------------------------------*
434
#ifdef XPM_BACKGROUND
436
* search for FILE in the current working directory, and within the
437
* colon-delimited PATHLIST, adding the file extension EXT if required.
439
* FILE is either semi-colon or zero terminated
442
rxvt_File_search_path (const char *pathlist, const char *file, const char *ext) NOTHROW
445
const char *p, *path;
448
if (!access (file, R_OK)) /* found (plain name) in current directory */
449
return strdup (file);
451
/* semi-colon delimited */
452
if ((p = strchr (file, ';')))
457
/* leave room for an extra '/' and trailing '\0' */
458
maxpath = sizeof (name) - (len + (ext ? strlen (ext) : 0) + 2);
462
/* check if we can find it now */
463
strncpy (name, file, len);
466
if (!access (name, R_OK))
467
return strdup (name);
471
if (!access (name, R_OK))
472
return strdup (name);
474
for (path = pathlist; path != NULL && *path != '\0'; path = p)
478
/* colon delimited */
479
if ((p = strchr (path, ':')) == NULL)
480
p = strchr (path, '\0');
486
if (n > 0 && n <= maxpath)
488
strncpy (name, path, n);
489
if (name[n - 1] != '/')
492
strncat (name, file, len);
494
if (!access (name, R_OK))
495
return strdup (name);
499
if (!access (name, R_OK))
500
return strdup (name);
508
rxvt_File_find (const char *file, const char *ext, const char *path) NOTHROW
512
if (file == NULL || *file == '\0')
515
f = rxvt_File_search_path (path, file, ext);