RESOLVEPATH(3)
π RESOLVEPATH(3) β Schily's LIBRARY FUNCTIONS πΈ
okay bestie, gather round, because this one's from Schily's LIBRARY FUNCTIONS and it's literally the glow-up your path names have been waiting for π
β¨ NAME β¨
resolvepath(), resolvenpath(), resolvefpath() β resolve all symbolic links of a path name π¦
No cap, that's the whole vibe: you hand it a path, it hands you back a path with zero symlinks in it. Iconic.
π SYNOPSIS π
#include <schily/schily.h>
int
resolvepath(path, buf, bufsiz)
const char *path;
char *buf;
size_t bufsiz;
int
resolvenpath(path, buf, bufsiz)
const char *path;
char *buf;
size_t bufsiz;
int
resolvefpath(path, buf, bufsiz, flags)
const char *path;
char *buf;
size_t bufsiz;
int flags;
look at that alignment, whoever formatted this ate π
π DESCRIPTION π
so resolvepath() takes a relative path name and resolves all symbolic links in the path name. The result is a path name that is free of symbolic links β literally symlink-free, a clean slate, main character energy β¨
pathβ a relative path name that is used as the input π«Άbufβ the buffer used for the result of the conversion πbufsizβ the size of the result buffer π
All ''.'' components are eliminated, and every non-leading ''..'' component is eliminated together with its preceding directory component. If leading ''..'' components reach to the root directory, they are replaced by ''/''. periodt β the .. drama gets cancelled out π
resolvenpath() behaves like resolvepath() except that the file does not need to exist. ghosting the filesystem, honestly π»
resolvefpath() takes an additional flags parameter from the set of flags from the following set:
RSPF_EXISTβ all path components must exist πRSPF_NOFOLLOW_LASTβ don't follow symbolic links in the last path component π
π RETURN VALUE π
Upon successful completion, resolvepath(), resolvenpath() and resolvefpath() return the number of bytes placed in the buffer. Slay π
Otherwise, -1 is returned and errno is set to indicate the error. And in case of an error, the contents of the result buffer is left in an intermediate state β so like, don't trust what's in there, it's giving half-finished group project π
π₯ ERRORS π₯
ERANGEβ the path does not fit into the suplied buffer.EFAULTβ a null pointer was suplied as pathname.EINVALβ an empty relative path was supplied.- other β any other value that may be a result of an underlying filesystem operation.
(and yes bestie the typos are in the original, I'm not fixing them, that's not my job β¨)
β USAGE β
Applications should not assume that the returned contents of the buffer are null-terminated. This is because the function resolvepath(3) may be the Solaris version if the program is compiled on Solaris. π«
ngl that's the kind of β¨platform surpriseβ¨ that ruins your whole afternoon, so just... don't assume. check bufsiz, live your truth, be free π¦
π§ SEE ALSO π§
yes, it's citing itself, we love a self-aware icon π
π NOTES π
none
that's it. that's the note. short and iconic, honestly π
anyway that's the whole page, bestie β go forth and resolve those paths, you're gonna do amazing π
this masterpiece was brought to you by Joerg Schilling, dated 2022/09/09, in the year of our lord πΈ stay hydrated, back up your buffers, and remember: no cap, always check that return value πβ¨π¦
π¦ where this page comes from
- opensuse-leap 16.0: libschily-devel-doc 2022.10.16-160000.2.2 Β· CDDL-1.0
- Copyright 2015-2020 J. Schilling
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms