Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > P

pathfind(3G)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

pathfind() — search for named file in named directories

SYNOPSIS

#include <libgen.h>

char *pathfind (const char *path, const char *name, const char *mode);

DESCRIPTION

pathfind searches the directories named in path for the file name. The directories named in path are separated by colons. mode is a string of option letters chosen from the set rwxfbcdpugks:

LetterMeaning
rreadable
wwritable
xexecutable
fnormal file
bblock special
ccharacter special
ddirectory
pFIFO (pipe)
uset user ID bit
gset group ID bit
ksticky bit
ssize nonzero

Options read, write, and execute are checked relative to the real (not the effective) user ID and group ID of the current process.

If the file name, with all the characteristics specified by mode, is found in any of the directories specified by path, then pathfind returns a pointer to a string containing the member of path, followed by a slash character (/), followed by name.

If name begins with a slash, it is treated as an absolute path name, and path is ignored.

An empty path member is treated as the current directory. . is not prepended at the occurrence of the first match; rather, the unadorned name is returned.

To use this interface, link in the libgen library by specifying -lgen. For example:

cc foo.c -lgen

RETURN VALUE

If no match is found, pathname returns a null pointer, ((char *) 0).

EXAMPLES

To find the ls command using the PATH environment variable:

pathfind (getenv ("PATH"), "ls", "rx")

WARNINGS

The string pointed to by the returned pointer is stored in a static area that is reused on subsequent calls to pathfind.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.