FNQUALIFY(3pub)
π FNQUALIFY π
okay bestie, so you know how filenames be out here acting like they don't need to be fully qualified? yeah. this is the fnqualify function from the C Programmer's Manual, section 3pub, and it's about to fix all of that for you. no cap. β¨
β¨ NAME β¨
fnqualify β qualify a filename πΈ
π SYNOPSIS π
#include <publib.h>
size_t fnqualify(char *result, const char *path, size_t max);
π¦ DESCRIPTION π¦
so fname_qualify qualifies a filename, which is giving "let me make this path make sense from literally anywhere" energy. π
here's the tea: if the input name is not an absolute name β meaning it does not start from the root directory, like foo instead of /tmp/foo β then the current directory gets prepended to it. boom. done. π«Ά
and there's more! tilde conversion is also happening:
- if the filename begins with a tilde (
~), that tilde gets replaced with the home directory of the user π - if it begins with a tilde and a username, both of them get replaced with the home directory of the given user π
β οΈ okay important: simplifications like replacing/./with/, and/foo/../barwith/barare NOT done, because of problems with symbolic links. do not come for me about it, it's just the vibes. the symlinks said no. π
π RETURNS π
the function returns -1 if there was some error, or the total size of the full name otherwise. π₯
and like, plot twist: the return value may be greater than the maximum size given by the last argument. only as much as allowed by that is actually written, though. so the number can be bigger than what actually landed in your buffer, fr fr. keep that in mind bestie π
π SEE ALSO π
π AUTHOR π
Lars Wirzenius (lars.wirzenius@helsinki.fi) β the icon, the legend, the moment β¨
and that's the whole page, bestie π this came to you straight out of the <strong>Publib</strong> C Programmer's Manual, FNQUALIFY(3pub) edition, no date on the tin because time is a construct and we simply don't do that here. mwah π
π
π¦ 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