63 char *
path_combine(
const char *src,
const char *dst,
char *path,
size_t size) {
72 p = strrchr(path,
'/');
80 snprintf(p, size-(p-path),
"%s", dst);
83 #if defined(DEBUG_PATH)
84 LOG(
llevDebug,
"path_combine(%s, %s) = %s\n", src, dst, path);
105 #if defined(DEBUG_PATH)
113 if ((w == path && *path ==
'/') || (w > path && w[-1] !=
'/'))
125 #if defined(DEBUG_PATH)
126 LOG(
llevDebug,
"path_normalize: checking '%.*s'\n", (
int)len, p);
129 if (len == 1 && *p ==
'.') {
131 }
else if (len == 2 && memcmp(p,
"..", 2) == 0) {
132 if (w == path || (w == path+3 && memcmp(path,
"../", 3) == 0)) {
136 }
else if (w == path+1 && *path ==
'/') {
140 if (w > path && w[-1] ==
'/')
142 while (w > path && w[-1] !=
'/')
153 #if defined(DEBUG_PATH)
154 LOG(
llevDebug,
"path_normalize: so far '%.*s'\n", (
int)(w-path), path);
159 while (w > path+1 && w[-1] ==
'/') {
165 #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)
int snprintf(char *dest, int max, const char *format,...)
char * path_combine(const char *src, const char *dst, char *path, size_t size)
void LOG(LogLevel logLevel, const char *format,...)