path: Move path related utility functions to separate files

This commit is contained in:
Martin Willi
2015-04-16 14:50:04 +02:00
parent 7585a85f1a
commit 001a22e2c1
6 changed files with 249 additions and 201 deletions
+1 -52
View File
@@ -81,20 +81,12 @@
#include "utils/string.h"
#include "utils/memory.h"
#include "utils/strerror.h"
#include "utils/path.h"
#include "utils/tty.h"
#ifdef __APPLE__
# include "compat/apple.h"
#endif
/**
* Directory separator character in paths on this platform
*/
#ifdef WIN32
# define DIRECTORY_SEPARATOR "\\"
#else
# define DIRECTORY_SEPARATOR "/"
#endif
/**
* Initialize utility functions
*/
@@ -389,49 +381,6 @@ void free_align(void *ptr);
*/
void wait_sigint();
/**
* 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);
/**
* Check if a given path is absolute.
*
* @param path path to check
* @return TRUE if absolute, FALSE if relative
*/
bool path_absolute(const char *path);
/**
* Creates a directory and all required parent directories.
*
* @param path path to the new directory
* @param mode permissions of the new directory/directories
* @return TRUE on success
*/
bool mkdir_p(const char *path, mode_t mode);
#ifndef HAVE_CLOSEFROM
/**
* Close open file descriptors greater than or equal to lowfd.