logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

fnpathfind - find a file in a list of directories

Author

       Lars Wirzenius (lars.wirzenius@helsinki.fi)

Publib                                        C Programmer's Manual                             FNPATHFIND(3pub)

Bugs

       The function uses dynamic memory allocation and may therefore fail due to insufficient memory.

       It  is  not trivial to know in which directory the search ended.  This makes is difficult to continue the
       search.

Description

pathfind  looks  for  a  file in a list of directories.  The argument `path' is a colon separated list of
       directories, typically the contents of an environment  variable  like  PATH,  MANPATH,  or  CDPATH.   The
       function  will  go  through  the  directories  in the path and look in each directory for a file given in
       argument `target' until it finds it.  Only an exact match is reported, no wild cards or globbing.

       The names that are matched are formed by taking an element from the path and prepending it to target.  An
       empty element means the current directory, as does the name ".".

       The function returns -1 for failure (not found or error), or the total size for the full name  (the  full
       name may have been truncated when stored into result).

Name

       fnpathfind - find a file in a list of directories

See Also

publib(3), fname(3)

Synopsis

       #include <publib.h>

       int fnpathfind(const char *path, const char *tgt,
                            char *res, size_t max);

See Also