mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-27 23:42:51 +02:00
Merge branch 'ni/tuxbox' into ni/mp/tuxbox
Origin commit data
------------------
Branch: ni/coolstream
Commit: 2b7afc5b38
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-09-21 (Thu, 21 Sep 2017)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <algorithm>
|
||||
#include <mntent.h>
|
||||
#include <fstream>
|
||||
#include <linux/hdreg.h>
|
||||
#include <linux/fs.h>
|
||||
#include "debug.h"
|
||||
@@ -52,6 +53,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
|
||||
@@ -1593,3 +1595,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