51 char *
path_combine(
const char *src,
const char *dst,
char *path,
size_t size) {
54 if (*dst ==
'/' || *dst ==
'~') {
60 p = strrchr(path,
'/');
71 #if defined(DEBUG_PATH) 72 LOG(
llevDebug,
"path_combine(%s, %s) = %s\n", src, dst, path);
93 #if defined(DEBUG_PATH) 101 if ((w == path && *path ==
'/') || (w > path && w[-1] !=
'/'))
113 #if defined(DEBUG_PATH) 114 LOG(
llevDebug,
"path_normalize: checking '%.*s'\n", (
int)len, p);
117 if (len == 1 && *p ==
'.') {
119 }
else if (len == 2 && memcmp(p,
"..", 2) == 0) {
120 if (w == path || (w == path+3 && memcmp(path,
"../", 3) == 0)) {
124 }
else if (w == path+1 && *path ==
'/') {
128 if (w > path && w[-1] ==
'/')
130 while (w > path && w[-1] !=
'/')
141 #if defined(DEBUG_PATH) 142 LOG(
llevDebug,
"path_normalize: so far '%.*s'\n", (
int)(w-path), path);
147 while (w > path+1 && w[-1] ==
'/') {
153 #if defined(DEBUG_PATH)
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
void path_normalize(char *path)
char * path_combine(const char *src, const char *dst, char *path, size_t size)
void LOG(LogLevel logLevel, const char *format,...)
size_t strlcpy(char *dst, const char *src, size_t size)