Skip to content
Snippets Groups Projects
Commit 6cc1fea9 authored by Lars Bilke's avatar Lars Bilke Committed by Dmitri Naumov
Browse files

[T] Added base_file attribute to patch files.

E.g. in square_1e1.xml:

    <OpenGeoSysProjectDiff base_file="square_1e0.prj">

Then run this with:

    ogs square_1e1.xml
parent bf2b7a01
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <xml_patch.h> #include <xml_patch.h>
#include <chrono> #include <chrono>
#include <sstream>
#ifndef _WIN32 #ifndef _WIN32
#ifdef __APPLE__ #ifdef __APPLE__
...@@ -190,14 +191,42 @@ int main(int argc, char* argv[]) ...@@ -190,14 +191,42 @@ int main(int argc, char* argv[])
run_time.start(); run_time.start();
std::string prj_file; std::string prj_file = project_arg.getValue();
if (!xml_patch_files.getValue().empty()) auto patch_files = xml_patch_files.getValue();
if (BaseLib::getFileExtension(prj_file) == ".xml")
{ {
std::string current_prj_file = project_arg.getValue(); if (!patch_files.empty())
{
OGS_FATAL(
"It is not allowed to specify additional patch files "
"if a patch file was already specified as the "
"prj-file.");
}
auto patch = xmlParseFile(prj_file.c_str());
auto node = xmlDocGetRootElement(patch);
auto base_file = xmlGetProp(node, (const xmlChar*)"base_file");
if (base_file != nullptr)
{
patch_files = {prj_file};
std::stringstream ss;
ss << base_file;
prj_file = BaseLib::joinPaths(
BaseLib::extractPath(prj_file), ss.str());
}
else
{
OGS_FATAL(
"Error reading base prj file in given patch file {:s}.",
prj_file);
}
}
if (!patch_files.empty())
{
std::string current_prj_file = prj_file;
std::string current_prj_file_base = std::string current_prj_file_base =
BaseLib::extractBaseNameWithoutExtension(current_prj_file); BaseLib::extractBaseNameWithoutExtension(current_prj_file);
// apply patch files for (const auto& patch_file : patch_files)
for (const auto& patch_file : xml_patch_files.getValue())
{ {
auto patch = xmlParseFile(patch_file.c_str()); auto patch = xmlParseFile(patch_file.c_str());
if (patch == NULL) if (patch == NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment