mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 15:32:52 +02:00
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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user