mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-01 18:01:06 +02:00
Merge branch 'cst-next.pre' into cst-next
Origin commit data
------------------
Branch: ni/coolstream
Commit: a58f1621b4
Author: Thilo Graf <dbt@novatux.de>
Date: 2015-04-30 (Thu, 30 Apr 2015)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -38,19 +38,21 @@
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <stdarg.h>
|
||||
#include <algorithm>
|
||||
#include <mntent.h>
|
||||
#include <linux/hdreg.h>
|
||||
#include <linux/fs.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include <system/helpers.h>
|
||||
#include <gui/update_ext.h>
|
||||
using namespace std;
|
||||
|
||||
void mySleep(int sec) {
|
||||
int mySleep(int sec) {
|
||||
struct timeval timeout;
|
||||
|
||||
timeout.tv_sec = sec;
|
||||
timeout.tv_usec = 0;
|
||||
select(0,0,0,0, &timeout);
|
||||
return select(0,0,0,0, &timeout);
|
||||
}
|
||||
|
||||
off_t file_size(const char *filename)
|
||||
@@ -215,7 +217,7 @@ FILE* my_popen( pid_t& pid, const char *cmdstring, const char *type)
|
||||
}
|
||||
return(fp);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int mkdirhier(const char *pathname, mode_t mode)
|
||||
{
|
||||
int res = -1;
|
||||
@@ -236,7 +238,7 @@ int mkdirhier(const char *pathname, mode_t mode)
|
||||
res = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
# endif
|
||||
|
||||
int safe_mkdir(const char * path)
|
||||
{
|
||||
@@ -338,7 +340,7 @@ std::string find_executable(const char *name)
|
||||
if (tmpPath)
|
||||
path = strdupa(tmpPath);
|
||||
else
|
||||
path = strdupa("/bin:/usr/bin:/sbin:/usr/sbin");
|
||||
path = strdupa("/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin");
|
||||
if (name[0] == '/') { /* full path given */
|
||||
if (!access(name, X_OK) && !stat(name, &s) && S_ISREG(s.st_mode))
|
||||
return std::string(name);
|
||||
@@ -421,8 +423,9 @@ std::string getNowTimeStr(const char* format)
|
||||
{
|
||||
char tmpStr[256];
|
||||
struct timeval tv;
|
||||
struct tm t;
|
||||
gettimeofday(&tv, NULL);
|
||||
strftime(tmpStr, sizeof(tmpStr), format, localtime(&tv.tv_sec));
|
||||
strftime(tmpStr, sizeof(tmpStr), format, localtime_r(&tv.tv_sec, &t));
|
||||
return (std::string)tmpStr;
|
||||
}
|
||||
|
||||
@@ -671,32 +674,25 @@ bool CFileHelpers::copyDir(const char *Src, const char *Dst, bool backupMode)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFileHelpers::createDir(const char *Dir, mode_t mode)
|
||||
int CFileHelpers::createDir(string& Dir, mode_t mode)
|
||||
{
|
||||
char dirPath[PATH_MAX];
|
||||
DIR *dir;
|
||||
if ((dir = opendir(Dir)) != NULL) {
|
||||
closedir(dir);
|
||||
errno = EEXIST;
|
||||
return false;
|
||||
}
|
||||
|
||||
int ret = -1;
|
||||
while (ret == -1) {
|
||||
strcpy(dirPath, Dir);
|
||||
ret = mkdir(dirPath, mode);
|
||||
if ((errno == ENOENT) && (ret == -1)) {
|
||||
char * pos = strrchr(dirPath,'/');
|
||||
if (pos != NULL) {
|
||||
pos[0] = '\0';
|
||||
createDir(dirPath, mode);
|
||||
}
|
||||
struct stat st;
|
||||
int res = 0;
|
||||
for(string::iterator iter = Dir.begin() ; iter != Dir.end();) {
|
||||
string::iterator newIter = find(iter, Dir.end(), '/' );
|
||||
string newPath = string( Dir.begin(), newIter );
|
||||
if( !newPath.empty() && stat(newPath.c_str(), &st) != 0) {
|
||||
res = mkdir( newPath.c_str(), mode);
|
||||
if (errno == EEXIST)
|
||||
res = 0;
|
||||
if(res != 0)
|
||||
dprintf(DEBUG_NORMAL, "[CFileHelpers %s] creating directory %s: %s\n", __func__, newPath.c_str(), strerror(errno));
|
||||
}
|
||||
else
|
||||
return !ret || (errno == EEXIST);
|
||||
iter = newIter;
|
||||
if(newIter != Dir.end())
|
||||
++ iter;
|
||||
}
|
||||
errno = 0;
|
||||
return true;
|
||||
return res;
|
||||
}
|
||||
|
||||
bool CFileHelpers::removeDir(const char *Dir)
|
||||
@@ -726,6 +722,41 @@ bool CFileHelpers::removeDir(const char *Dir)
|
||||
return true;
|
||||
}
|
||||
|
||||
u_int64_t CFileHelpers::getDirSize(const char *dirname)
|
||||
{
|
||||
DIR *dir;
|
||||
char fullDirName[500];
|
||||
struct dirent *dirPnt;
|
||||
struct stat cur_file;
|
||||
uint64_t total_size = 0;
|
||||
|
||||
//open current dir
|
||||
sprintf(fullDirName, "%s/", dirname);
|
||||
if((dir = opendir(fullDirName)) == NULL) {
|
||||
fprintf(stderr, "Couldn't open %s\n", fullDirName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//go through the directory
|
||||
while( (dirPnt = readdir(dir)) != NULL ) {
|
||||
if(strcmp((*dirPnt).d_name, "..") == 0 || strcmp((*dirPnt).d_name, ".") == 0)
|
||||
continue;
|
||||
|
||||
//create current filepath
|
||||
sprintf(fullDirName, "%s/%s", dirname, (*dirPnt).d_name);
|
||||
if(stat(fullDirName, &cur_file) == -1)
|
||||
continue;
|
||||
|
||||
if(cur_file.st_mode & S_IFREG) //file...
|
||||
total_size += cur_file.st_size;
|
||||
else if(cur_file.st_mode & S_IFDIR) //dir...
|
||||
total_size += getDirSize(fullDirName);
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
return total_size;
|
||||
}
|
||||
|
||||
static int hdd_open_dev(const char * fname)
|
||||
{
|
||||
FILE * fp;
|
||||
|
@@ -44,15 +44,15 @@ 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); }
|
||||
//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);
|
||||
int check_dir(const char * dir, bool allow_tmp = false);
|
||||
bool get_fs_usage(const char * dir, uint64_t &btotal, uint64_t &bused, long *bsize=NULL);
|
||||
bool get_mem_usage(unsigned long &total, unsigned long &free);
|
||||
void mySleep(int sec);
|
||||
int mySleep(int sec);
|
||||
|
||||
std::string find_executable(const char *name);
|
||||
/* basically what "foo=`command`" does in the shell */
|
||||
@@ -88,8 +88,11 @@ class CFileHelpers
|
||||
|
||||
bool copyFile(const char *Src, const char *Dst, mode_t mode);
|
||||
bool copyDir(const char *Src, const char *Dst, bool backupMode=false);
|
||||
bool createDir(const char *Dir, mode_t mode);
|
||||
bool removeDir(const char *Dir);
|
||||
static int createDir(std::string& Dir, mode_t mode = 755);
|
||||
static int createDir(const char *Dir, mode_t mode = 755){std::string dir = std::string(Dir);return createDir(dir, mode);}
|
||||
static bool removeDir(const char *Dir);
|
||||
static uint64_t getDirSize(const char *dir);
|
||||
static uint64_t getDirSize(const std::string& dir){return getDirSize(dir.c_str());};
|
||||
};
|
||||
|
||||
std::string to_string(int);
|
||||
|
@@ -327,6 +327,7 @@ typedef enum
|
||||
LOCALE_COLORSTATUSBAR_TEXT,
|
||||
LOCALE_COLORTHEMEMENU_HEAD,
|
||||
LOCALE_COLORTHEMEMENU_HEAD2,
|
||||
LOCALE_COLORTHEMEMENU_MENU_HINTS,
|
||||
LOCALE_COLORTHEMEMENU_NAME,
|
||||
LOCALE_COLORTHEMEMENU_NEUTRINO_THEME,
|
||||
LOCALE_COLORTHEMEMENU_QUESTION,
|
||||
|
@@ -327,6 +327,7 @@ const char * locale_real_names[] =
|
||||
"colorstatusbar.text",
|
||||
"colorthememenu.head",
|
||||
"colorthememenu.head2",
|
||||
"colorthememenu.menu_hints",
|
||||
"colorthememenu.name",
|
||||
"colorthememenu.neutrino_theme",
|
||||
"colorthememenu.question",
|
||||
|
@@ -60,6 +60,8 @@ struct SNeutrinoTheme
|
||||
unsigned char menu_Head_Text_green;
|
||||
unsigned char menu_Head_Text_blue;
|
||||
|
||||
int menu_Head_gradient;
|
||||
|
||||
unsigned char menu_Content_alpha;
|
||||
unsigned char menu_Content_red;
|
||||
unsigned char menu_Content_green;
|
||||
@@ -90,6 +92,8 @@ struct SNeutrinoTheme
|
||||
unsigned char menu_Content_inactive_Text_green;
|
||||
unsigned char menu_Content_inactive_Text_blue;
|
||||
|
||||
int menu_Hint_gradient;
|
||||
|
||||
unsigned char infobar_alpha;
|
||||
unsigned char infobar_red;
|
||||
unsigned char infobar_green;
|
||||
@@ -366,7 +370,6 @@ struct SNeutrinoSettings
|
||||
int colored_events_channellist;
|
||||
int colored_events_infobar;
|
||||
int contrast_fonts;
|
||||
int gradiant;
|
||||
|
||||
//network
|
||||
#define NETWORK_NFS_NR_OF_ENTRIES 8
|
||||
|
Reference in New Issue
Block a user