From 66dbf9a6cf3d6d390ce17ed6d7f8789811a160ef Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 13 Nov 2015 12:52:31 +0100 Subject: add cleanname MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/libgen.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include') diff --git a/include/libgen.h b/include/libgen.h index 653b1c0..d417739 100644 --- a/include/libgen.h +++ b/include/libgen.h @@ -55,6 +55,27 @@ char* __xpg_basename(char*) char* dirname(char*) __GCC_ONLY(__attribute__((__warn_unused_result__))); +#if defined(__SLIBC_SOURCE) +/** + * Removes all trailing slashes (that is not the first character + * in the filename,) all '.' directory components, and when possible + * using only lexical analysis, resolves '..' directory components. + * + * '..' directory components that should resolve up beyond '/', + * are removed. Note that this can in fact mean that the resulting + * path is not the same file if the processes is `chroot`:ed. + * + * This is a slibc extension. + * + * @param filename The filename, may be edited by this function. + * @return The dirname, it is either `filename` or, + * if `filename` is `NULL` or does no contain a + * non-trailing slash, a statically allocationed + * string, so it must not freed or edited. + */ +char* cleanname(char*) +#endif + #endif -- cgit v1.2.3-70-g09d2