ok, finished incremental update!

now just need to polish up a few things with update

git-svn-id: https://svn.musicpd.org/mpd/trunk@745 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Warren Dukes
2004-04-14 05:26:32 +00:00
parent ba1d3302e2
commit 2a24a94ba7
4 changed files with 135 additions and 28 deletions

View File

@@ -20,6 +20,7 @@
#include "log.h"
#include "charConv.h"
#include "conf.h"
#include "utf8.h"
#include <stdlib.h>
#include <string.h>
@@ -202,3 +203,41 @@ char * parentPath(char * path) {
return parentPath;
}
char * sanitizePathDup(char * path) {
int len = strlen(path)+1;
char * ret = malloc(len);
char * cp = ret;
memset(ret,0,len);
len = 0;
/* illeminate more than one '/' in a row, like "///" */
while(*path) {
while(*path=='/') path++;
if(*path=='.') {
/* we dont want to have hidden directoires, or '.' or
".." in our path */
free(ret);
return NULL;
}
while(*path && *path!='/') {
*(cp++) = *(path++);
len++;
}
if(*path=='/') {
*(cp++) = *(path++);
len++;
}
}
if(len && ret[len-1]=='/') {
len--;
ret[len] = '\0';
}
printf("sanitized: %s\n", ret);
return realloc(ret,len+1);
}