XtFilePredicate()XtFilePredicate()NameXtFilePredicate - interface definition for a filename evaluation proce‐
dure.
Synopsis
typedef Boolean (*XtFilePredicate)(String);
String filename;
Inputs
filename Specifies a potential filename.
Returns
True if filename is acceptable; False otherwise.
Description
An XtFilePredicate is specified in calls to XtResolvePathname() and
XtFindFile(), and is called to judge filenames found by those proce‐
dures. If the string is appropriate for the intended use (if it names
a readable file, for example) then the XtFilePredicate should return
True; otherwise it should return False.
Example
The default predicate used by XtResolvePathname() and XtFindFile() sim‐
ply tests that the specified filename exists, is readable, and is not a
directory. This default procedure is shown below. Note that it
attempts to handle some operating system dependencies.
static Boolean TestFile(path)
String path;
{
#ifdef VMS
return TRUE; /* Who knows what to do here? */
#else
struct stat status;
return (access(path, R_OK) == 0 && /* exists and is readable */
stat(path, &status) == 0 && /* get the status */
#ifndef X_NOT_POSIX
S_ISDIR(status.st_mode) == 0); /* not a directory */
#else
(status.st_mode & S_IFDIR) == 0); /* not a directory */
#endif /* X_NOT_POSIX else */
#endif /* VMS */
}
See AlsoXtFindFile(1), XtResolvePathname(1).
Xt - File Searching XtFilePredicate()