FNPATHFIND(3pub)
β¨ FNPATHFIND(3pub) β¨
okay bestie, welcome to the C Programmer's Manual, section 3pub π this one's a little publib baddie called fnpathfind, and she is literally the friend who knows where everything is.
πΈ NAME πΈ
fnpathfind β find a file in a list of directories π¦
β¨ SYNOPSIS β¨
#include <publib.h>
int fnpathfind(const char *path, const char *tgt,
char *res, size_t max);
π DESCRIPTION π
so pathfind (that's our girl, also known as fnpathfind, iykyk) goes looking for a file inside a whole list of directories. the path argument is a colon separated list of directories β and it's typically the contents of an environment variable like PATH, MANPATH, or CDPATH. iconic behaviour honestly π«Ά
what she does: she walks through the directories in the path, one by one, and in each directory she looks for the file given in the argument target, and she keeps going until she finds it. that's it, that's the whole vibe check. only an exact match gets reported β no wild cards, no globbing, none of that β
the names she matches are formed by taking an element from the path and prepending it to target. and listen, this part matters: an empty element means the current directory, and the name "." means the current directory too π
return value tea β: the function returns -1 for failure (either not found, or an error), or otherwise the total size of the full name. and heads up β the full name may have been truncated when it got stored into result. not her fault, she's just reporting the size okay π
π BUGS π
- she uses dynamic memory allocation, so she may fail due to insufficient memory. memory said no and now everyone's sad π
- it is not trivial to know in which directory the search ended. this makes it difficult to continue the search. so if you were hoping to pick up where she left off... good luck bestie π
π₯ SEE ALSO π₯
π AUTHOR π
Lars Wirzenius (lars.wirzenius@helsinki.fi) β thank you for your service king π«‘
and that's a wrap on this page from the Publib era of the C Programmer's Manual (section 3pub) π no date on the original footer, just vibes and version energy, so that's your cute lil sign-off fr fr β¨π
π¦ where this page comes from
- debian bookworm: publib-dev 0.40-3+b1 Β· BSD-2-Clause
- debian trixie: publib-dev 0.40-4 Β· BSD-2-Clause
- ubuntu jammy: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu noble: publib-dev 0.40-3build1 Β· BSD-2-Clause
- ubuntu questing: publib-dev 0.40-4
- ubuntu resolute: publib-dev 0.40-4build1 Β· BSD-2-Clause
- ubuntu stonking: publib-dev 0.40-4build1 Β· BSD-2-Clause
- Copyright (c) 1994-2006 Lars Wirzenius. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms