mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 07:51:11 +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:
@@ -32,10 +32,12 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <global.h>
|
#include <global.h>
|
||||||
#include <neutrino.h>
|
#include <neutrino.h>
|
||||||
#include "widget/menue.h"
|
#include "widget/menue.h"
|
||||||
|
#include <system/helpers.h>
|
||||||
#include <system/setting_helpers.h>
|
#include <system/setting_helpers.h>
|
||||||
#include <gui/widget/stringinput.h>
|
#include <gui/widget/stringinput.h>
|
||||||
#include <gui/widget/stringinput_ext.h>
|
#include <gui/widget/stringinput_ext.h>
|
||||||
@@ -157,13 +159,8 @@ int CThemes::Show()
|
|||||||
CStringInputSMS nameInput(LOCALE_COLORTHEMEMENU_NAME, &file_name, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789- ");
|
CStringInputSMS nameInput(LOCALE_COLORTHEMEMENU_NAME, &file_name, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789- ");
|
||||||
CMenuForwarder *m1 = new CMenuForwarder(LOCALE_COLORTHEMEMENU_SAVE, true , NULL, &nameInput, NULL, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN);
|
CMenuForwarder *m1 = new CMenuForwarder(LOCALE_COLORTHEMEMENU_SAVE, true , NULL, &nameInput, NULL, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN);
|
||||||
|
|
||||||
// Don't show SAVE if UserDir does'nt exist
|
if (mkdirhier(USERDIR) && errno != EEXIST) {
|
||||||
if ( access(USERDIR, F_OK) != 0 ) { // check for existance
|
printf("[neutrino theme] error creating %s\n", USERDIR);
|
||||||
// mkdir must be called for each subdir which does not exist
|
|
||||||
// mkdir (USERDIR, S_IRUSR | S_IREAD | S_IWUSR | S_IWRITE | S_IXUSR | S_IEXEC) == 0) {
|
|
||||||
if (system (((std::string)"mkdir -p " + USERDIR).c_str()) != 0) {
|
|
||||||
printf("[neutrino theme] error creating %s\n", USERDIR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (access(USERDIR, F_OK) == 0 ) {
|
if (access(USERDIR, F_OK) == 0 ) {
|
||||||
themes.addItem(GenericMenuSeparatorLine);
|
themes.addItem(GenericMenuSeparatorLine);
|
||||||
|
@@ -213,6 +213,28 @@ FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type)
|
|||||||
return(fp);
|
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)
|
int safe_mkdir(const char * path)
|
||||||
{
|
{
|
||||||
struct statfs s;
|
struct statfs s;
|
||||||
|
@@ -34,6 +34,9 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
int my_system(const char * cmd);
|
int my_system(const char * cmd);
|
||||||
int my_system(int argc, const char *arg, ...); /* argc is number of arguments including command */
|
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);
|
int safe_mkdir(const char * path);
|
||||||
inline int safe_mkdir(std::string path) { return safe_mkdir(path.c_str()); }
|
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);
|
off_t file_size(const char *filename);
|
||||||
bool file_exists(const char *filename);
|
bool file_exists(const char *filename);
|
||||||
void wakeup_hdd(const char *hdd_dir);
|
void wakeup_hdd(const char *hdd_dir);
|
||||||
|
Reference in New Issue
Block a user