Import sample fragbuts.xml if user file does not exist

This commit is contained in:
Jean-Francois Dockes
2015-03-28 08:43:45 +01:00
parent 4da2e34b2f
commit e2e7d3d6d0
4 changed files with 58 additions and 13 deletions
+7
View File
@@ -36,6 +36,7 @@
#include "recoll.h"
#include "debuglog.h"
#include "readfile.h"
#include "copyfile.h"
using namespace std;
@@ -147,6 +148,12 @@ FragButs::FragButs(QWidget* parent)
m_fn = path_cat(theconfig->getConfDir(), "fragbuts.xml");
string data, reason;
if (access(m_fn.c_str(), 0) != 0) {
// config does not exist: try to create it from sample
string src = path_cat(theconfig->getDatadir(), "examples");
src = path_cat(src, "fragbuts.xml");
copyfile(src.c_str(), m_fn.c_str(), reason);
}
if (!file_to_string(m_fn, data, &reason)) {
QMessageBox::warning(0, "Recoll",
tr("%1 not found.").arg(