Add links to documentation to auto-saved config.json
This commit is contained in:
parent
2c52a5a352
commit
ed1a02cccb
4 changed files with 16 additions and 4 deletions
|
@ -46,7 +46,7 @@ public:
|
|||
static unsigned getUint(const rapidjson::Value &obj, const char *key, unsigned defaultValue = 0);
|
||||
|
||||
static bool get(const char *fileName, rapidjson::Document &doc);
|
||||
static bool save(const char *fileName, const rapidjson::Document &doc);
|
||||
static bool save(const char *fileName, const rapidjson::Document &doc, const std::string& header_comment = std::string());
|
||||
|
||||
static bool convertOffset(const char *fileName, size_t offset, size_t &line, size_t &pos, std::vector<std::string> &s);
|
||||
static rapidjson::Value normalize(double value, bool zero);
|
||||
|
|
|
@ -41,13 +41,17 @@ bool xmrig::Json::get(const char *fileName, rapidjson::Document &doc)
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc)
|
||||
bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc, const std::string& header_comment)
|
||||
{
|
||||
std::ofstream ofs(fileName, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
|
||||
if (!ofs.is_open()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!header_comment.empty()) {
|
||||
ofs << header_comment << std::endl;
|
||||
}
|
||||
|
||||
rapidjson::OStreamWrapper osw(ofs);
|
||||
rapidjson::PrettyWriter<rapidjson::OStreamWrapper> writer(osw);
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ bool xmrig::Json::get(const char *fileName, rapidjson::Document &doc)
|
|||
}
|
||||
|
||||
|
||||
bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc)
|
||||
bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc, const std::string& header_comment)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
constexpr const std::ios_base::openmode mode = std::ios_base::out | std::ios_base::binary | std::ios_base::trunc;
|
||||
|
@ -119,6 +119,10 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc)
|
|||
}
|
||||
# endif
|
||||
|
||||
if (!header_comment.empty()) {
|
||||
ofs << header_comment << std::endl;
|
||||
}
|
||||
|
||||
OStreamWrapper osw(ofs);
|
||||
PrettyWriter<OStreamWrapper> writer(osw);
|
||||
|
||||
|
|
|
@ -126,7 +126,11 @@ bool xmrig::BaseConfig::save()
|
|||
rapidjson::Document doc;
|
||||
getJSON(doc);
|
||||
|
||||
if (Json::save(m_fileName, doc)) {
|
||||
const char* header_comment = "\
|
||||
// See https://github.com/xmrig/xmrig/blob/master/doc/CPU.md for the description of the config.json parameters\n\
|
||||
// General documentation: https://xmrig.com/docs/miner";
|
||||
|
||||
if (Json::save(m_fileName, doc, header_comment)) {
|
||||
LOG_NOTICE("%s " WHITE_BOLD("configuration saved to: \"%s\""), Tags::config(), m_fileName.data());
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue