XtFindFile(3)
π XtFindFile(3) π
okay bestie, welcome to the XT FUNCTIONS corner of the manual, this one's called XtFindFile and it is literally the girl who goes hunting through your path list looking for a file, doing cute little substitutions along the way π¦
β¨ NAME β¨
XtFindFile β search for a file using substitutions in the path list π
β¨ SYNTAX β¨
#include <X11/Intrinsic.h>
char * XtFindFile(const char *path, Substitution substitutions, Cardinal
num_substitutions, XtFilePredicate predicate);
β¨ ARGUMENTS β¨
pathβ the path of file names, and yes it's got substitution characters in it, she's fancy like that πsubstitutionsβ a list of substitutions to make into a path, the little glow-up kit β¨num_substitutionsβ how many substitutions got passed in, we're counting fr fr π’predicateβ a procedure to call to judge a potential file name, orNULLif you're not about that judgey life π
β¨ DESCRIPTION β¨
so the path parameter is a string made of a whole series of potential file names, all delimited by colons. classic. within each name, the percent character % is like "bestie, a substitution is coming" and the character right after it decides which one π
the character sequence %: means an embedded colon that is not a delimiter β it gets replaced by a single colon, sneaky but valid π«Ά
the character sequence %% means a literal percent character that does not introduce a substitution β it gets replaced by a single percent character, periodt π
if a percent character is followed by any other character, XtFindFile looks through the specified substitutions for that character in the match field, and if she finds it, she replaces the percent and match characters with the string in the corresponding substitution field β¨
a substitution field entry of NULL is equivalent to a pointer to an empty string, so like, no drama, it just means nothing goes there π
okay and here's a very specific technical moment, stay with me: if the operating system does not interpret multiple embedded name separators in the path (i.e., / in POSIX) the same way as a single separator, then XtFindFile will collapse multiple separators into a single one after performing all string substitutions. she tidies up at the end, iconic π§
except for that collapsing-embedded-separators thing, the contents of the string substitutions are not interpreted by XtFindFile at all, so they may therefore contain any operating-system-dependent characters, including additional name separators. she does not read your vibes, she just uses them π
each resulting string gets passed to the predicate procedure until a string is found for which the procedure returns True. that string is the return value for XtFindFile π
if no string yields a True return from the predicate, XtFindFile returns NULL. it's giving "we looked everywhere and found nothing" π
πΈ the NULL predicate situation πΈ
if the predicate parameter is NULL, an internal procedure that checks if the file exists, is readable, and is not a directory will be used instead. so she's got a built-in vibe check, no cap π₯
π memory business π
it is the responsibility of the caller to free the returned string using XtFree when it is no longer needed. do not forget, bestie, that's a leak and we don't do leaks π
β¨ SEE ALSO β¨
- X Toolkit Intrinsics - C Language Interface
- Xlib - C Language X Interface
X Version 11 β¦ libXt 1.3.1 β¦ XtFindFile(3)
and that's the whole page, you ate it, go free your strings with XtFree and slay the rest of your day πβ¨π
π¦ where this page comes from
- alpine 3.22: libxt-doc 1.3.1-r0 Β· MIT
- alpine 3.23: libxt-doc 1.3.1-r0 Β· MIT
- alpine 3.24: libxt-doc 1.3.1-r0 Β· MIT
- arch rolling: libxt 1.3.1-1 Β· MIT AND HPND-sell-variant AND SMLNJ AND MIT-open-group AND X11
- fedora 43: libXt-devel 1.3.1-3.fc43 Β· MIT AND HPND-sell-variant AND SMLNJ AND MIT-open-group AND X11
- fedora 43: libXt-devel 1.3.1-3.fc43 Β· MIT AND HPND-sell-variant AND SMLNJ AND MIT-open-group AND X11
- fedora 44: libXt-devel 1.3.1-4.fc44 Β· MIT AND HPND-sell-variant AND SMLNJ AND MIT-open-group AND X11
- fedora 44: libXt-devel 1.3.1-4.fc44 Β· MIT AND HPND-sell-variant AND SMLNJ AND MIT-open-group AND X11
- opensuse-leap 16.0: libXt-devel 1.3.1-160000.3.2 Β· MIT
- opensuse-leap 16.0: libXt-devel 1.3.1-160000.3.2 Β· MIT
- opensuse-leap 16.0: libXt-devel 1.3.1-160000.3.2 Β· MIT
- opensuse-leap 16.0: libXt-devel 1.3.1-160000.3.2 Β· MIT
- Copyright (c) 1993, 1994 X Consortium
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms