utils: Add thread-safe variants of dirname(3) and basename(3)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2013 Tobias Brunner
|
||||
* Copyright (C) 2008-2014 Tobias Brunner
|
||||
* Copyright (C) 2008 Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
@@ -486,6 +486,32 @@ char *translate(char *str, const char *from, const char *to);
|
||||
*/
|
||||
char *strreplace(const char *str, const char *search, const char *replace);
|
||||
|
||||
/**
|
||||
* Like dirname(3) returns the directory part of the given null-terminated
|
||||
* pathname, up to but not including the final '/' (or '.' if no '/' is found).
|
||||
* Trailing '/' are not counted as part of the pathname.
|
||||
*
|
||||
* The difference is that it does this in a thread-safe manner (i.e. it does not
|
||||
* use static buffers) and does not modify the original path.
|
||||
*
|
||||
* @param path original pathname
|
||||
* @return allocated directory component
|
||||
*/
|
||||
char *path_dirname(const char *path);
|
||||
|
||||
/**
|
||||
* Like basename(3) returns the filename part of the given null-terminated path,
|
||||
* i.e. the part following the final '/' (or '.' if path is empty or NULL).
|
||||
* Trailing '/' are not counted as part of the pathname.
|
||||
*
|
||||
* The difference is that it does this in a thread-safe manner (i.e. it does not
|
||||
* use static buffers) and does not modify the original path.
|
||||
*
|
||||
* @param path original pathname
|
||||
* @return allocated filename component
|
||||
*/
|
||||
char *path_basename(const char *path);
|
||||
|
||||
/**
|
||||
* Creates a directory and all required parent directories.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user