mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-01 09:51:22 +02:00
system/helpers: add mkdirhier(); gui/themes: use mkdirhier()
Conflicts: src/system/helpers.h
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;
|
||||
|
@@ -34,6 +34,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <map>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int my_system(const char * cmd);
|
||||
int my_system(int argc, const char *arg, ...); /* argc is number of arguments including command */
|
||||
|
||||
@@ -41,6 +44,8 @@ FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type);
|
||||
|
||||
int safe_mkdir(const char * path);
|
||||
inline int safe_mkdir(std::string path) { return safe_mkdir(path.c_str()); }
|
||||
int mkdirhier(const char *pathname, mode_t mode = 0755);
|
||||
inline int mkdirhier(std::string path, mode_t mode = 0755) { return mkdirhier(path.c_str(), mode); }
|
||||
off_t file_size(const char *filename);
|
||||
bool file_exists(const char *filename);
|
||||
void wakeup_hdd(const char *hdd_dir);
|
||||
|
Reference in New Issue
Block a user