system/helpers: add mkdirhier(); gui/themes: use mkdirhier()

Conflicts:
	src/system/helpers.h


Origin commit data
------------------
Branch: ni/coolstream
Commit: 431657e35d
Author: martii <m4rtii@gmx.de>
Date: 2014-01-06 (Mon, 06 Jan 2014)



------------------
This commit was generated by Migit
This commit is contained in:
martii
2014-01-06 12:44:45 +01:00
committed by [CST] Focus
parent 7caa10aeb2
commit e06663874d
3 changed files with 31 additions and 7 deletions

View File

@@ -213,6 +213,28 @@ FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type)
return(fp);
}
int mkdirhier(const char *pathname, mode_t mode)
{
int res = -1;
if (!pathname || !*pathname)
return res;
char path[strlen(pathname) + 1];
strcpy(path, pathname);
char *p = path;
while ((p = strchr(p + 1, '/'))) {
*p = 0;
res = mkdir(path, mode);
if (res < 0 && errno != EEXIST)
break;
*p = '/';
}
res = mkdir(path, mode);
if (errno == EEXIST)
res = 0;
return res;
}
int safe_mkdir(const char * path)
{
struct statfs s;