saving config did not worked with spaces right.

test16bit
Steffen Pohle 4 years ago
parent dfd56e3b30
commit fccdc0eed7

@ -1,4 +1,5 @@
2021-11-15: 2021-11-15:
- JSON read changed, space was interpreted as '\n'
- adding support for multiple drivers - adding support for multiple drivers
2021-10-25: 2021-10-25:

@ -71,12 +71,9 @@ void Configuration::SaveConfig(std::string filename) {
cb = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cb-videofmt")); cb = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cb-videofmt"));
cbe = gtk_bin_get_child(GTK_BIN(cb)); cbe = gtk_bin_get_child(GTK_BIN(cb));
jp.AddObject("video_format", (string) gtk_entry_get_text(GTK_ENTRY(cbe))); jp.AddObject("video_format", (string) gtk_entry_get_text(GTK_ENTRY(cbe)));
if (videodev != NULL) { cb = GTK_WIDGET(gtk_builder_get_object (GTK_BUILDER(_builder_), "cb-videodev"));
jp.AddObject("device", videodev->GetDevice()); cbe = gtk_bin_get_child(GTK_BIN(cb));
} jp.AddObject("device", (string) gtk_entry_get_text(GTK_ENTRY(cbe)));
else {
jp.AddObject("device", "");
}
// //
// save button config // save button config

@ -1,9 +1,15 @@
#include <list>
#include <string>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fstream> #include <fstream>
#include <list>
#include <string>
#include "json.h" #include "json.h"
@ -386,20 +392,21 @@ string JSONParse::ToString() {
* 0 .. on Success * 0 .. on Success
*/ */
int JSONParse::LoadFromFile(string filename) { int JSONParse::LoadFromFile(string filename) {
ifstream in(filename); int fd;
string tmp, input; struct stat fs;
char *buffer;
if (!in) return -1; if (stat(filename.c_str(), &fs) != 0) return -1;
buffer = (char *) malloc (fs.st_size+1);
memset (buffer, 0x0, fs.st_size+1);
input = ""; fd = open(filename.c_str(), O_RDONLY);
while (!in.eof()) { if (fd < 0) return -1;
if (input.length() > 0) input += ("\n" + tmp); read (fd, buffer, fs.st_size);
else input = tmp; close (fd);
in >> tmp;
}
Set(input);
in.close(); Set(buffer);
free (buffer);
return 0; return 0;
}; };

Loading…
Cancel
Save