Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

XtFindFile(1)

XtResolvePathname(1)

NAME

XtFilePredicate − interface definition for a filename evaluation procedure. 

Synopsis

typedef Boolean (*XtFilePredicate)(String);

    String filename;

Inputs

filenameSpecifies 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 procedures.  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() simply 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 Also

XtFindFile(1), XtResolvePathname(1). 

Copyright O’Reilly & Assoc.  —  X Toolkit Intrinsics Reference Manual © O’Reilly & Associates

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026