CLEANNAME(3)

πŸ“¦ version 0_git20260208, in alpine 3.24, arch rolling, nixos 26.05, nixpkgs unstable

πŸ’– CLEANNAME(3) β€” from the Library Functions Manual β€” cleanname πŸ’–

okay bestie, welcome to CLEANNAME(3), the page for cleanname, aka the little function that gives your path name a full lexical glow-up. no filesystem drama, just string vibes. periodt.


🌸 NAME 🌸

cleanname β€” clean a path name

✨ SYNOPSIS ✨

#include <u.h>
#include <libc.h>

char*     cleanname(char *filename)

πŸ¦‹ DESCRIPTION πŸ¦‹

So cleanname takes a filename and β€” by lexical processing only, bestie, no cap β€” returns the shortest string that names the same (possibly hypothetical) file. It is not out here checking whether the file is real; it is literally just doing string surgery and serving.

It eliminates multiple and trailing slashes, and it lexically interprets . and .. directory components in the name. The string is overwritten in place.

The shortest string cleanname can return is two bytes: the null-terminated string ".". Therefore filename must contain room for at least two bytes.

🚨 bestie, this is the part where you pay attention: filename needs room for at least two bytes, because "." plus its null terminator is already two bytes. do not skimp on the buffer, i am begging.

πŸŽ€ SOURCE πŸŽ€

/src/lib9/cleanname.c

🌈 SEE ALSO 🌈

cleanname(1)


and that’s the cute sign-off, bestie: CLEANNAME(3) β€” footer vibes only, mwah πŸ’…πŸ’–βœ¨