mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 07:51:11 +02:00
Merge branch 'master' of https://github.com/tuxbox-neutrino/gui-neutrino into ni/tuxbox
Conflicts:
src/gui/channellist.cpp
src/gui/widget/menue.cpp
src/system/settings.h
Origin commit data
------------------
Commit: 8d4677a319
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-09-21 (Thu, 21 Sep 2017)
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <algorithm>
|
||||
#include <mntent.h>
|
||||
#include <fstream>
|
||||
#include <linux/hdreg.h>
|
||||
#include <linux/fs.h>
|
||||
#include "debug.h"
|
||||
@@ -49,6 +50,7 @@
|
||||
#include <driver/fontrenderer.h>
|
||||
//#include <driver/framebuffer.h>
|
||||
#include <system/helpers.h>
|
||||
#include <system/helpers-json.h>
|
||||
#include <gui/update_ext.h>
|
||||
#include <libmd5sum.h>
|
||||
#define MD5_DIGEST_LENGTH 16
|
||||
@@ -1588,3 +1590,51 @@ string readLink(string lnk)
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
string readFile(string file)
|
||||
{
|
||||
string ret_s;
|
||||
ifstream tmpData(file.c_str(), ifstream::binary);
|
||||
if (tmpData.is_open()) {
|
||||
tmpData.seekg(0, tmpData.end);
|
||||
int length = tmpData.tellg();
|
||||
tmpData.seekg(0, tmpData.beg);
|
||||
char* buffer = new char[length+1];
|
||||
tmpData.read(buffer, length);
|
||||
tmpData.close();
|
||||
buffer[length] = '\0';
|
||||
ret_s = (string)buffer;
|
||||
delete [] buffer;
|
||||
}
|
||||
else {
|
||||
cerr << "Error read " << file << endl;
|
||||
return "";
|
||||
}
|
||||
|
||||
return ret_s;
|
||||
}
|
||||
|
||||
bool parseJsonFromFile(string& jFile, Json::Value *root, string *errMsg)
|
||||
{
|
||||
string jData = readFile(jFile);
|
||||
bool ret = parseJsonFromString(jData, root, errMsg);
|
||||
jData.clear();
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool parseJsonFromString(string& jData, Json::Value *root, string *errMsg)
|
||||
{
|
||||
Json::CharReaderBuilder builder;
|
||||
Json::CharReader* reader(builder.newCharReader());
|
||||
JSONCPP_STRING errs = "";
|
||||
const char* jData_c = jData.c_str();
|
||||
|
||||
bool ret = reader->parse(jData_c, jData_c + strlen(jData_c), root, &errs);
|
||||
if (!ret || (!errs.empty())) {
|
||||
ret = false;
|
||||
if (errMsg != NULL)
|
||||
*errMsg = errs;
|
||||
}
|
||||
delete reader;
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user