MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / getSystemParameters

Method getSystemParameters

src/openms/source/SYSTEM/File.cpp:649–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

647 }
648
649 Param File::getSystemParameters()
650 {
651 String home_path = File::getOpenMSHomePath();
652 String filename;
653 //Comply with https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html on unix identifying systems
654 #ifdef __unix__
655 if (getenv("XDG_CONFIG_HOME"))
656 {
657 filename = String(getenv("XDG_CONFIG_HOME")) + "/OpenMS/OpenMS.ini";
658 }
659 else
660 {
661 filename = File::getOpenMSHomePath() + "/.config/OpenMS/OpenMS.ini";
662 }
663 #else
664 filename = home_path + "/.OpenMS/OpenMS.ini";
665 #endif
666
667 Param p;
668 if (!File::readable(filename)) // no file, lets keep it that way
669 {
670 p = getSystemParameterDefaults_();
671 }
672 else
673 {
674 ParamXMLFile paramFile;
675 paramFile.load(filename, p);
676
677 // check version
678 if (!p.exists("version") || (p.getValue("version") != VersionInfo::getVersion()))
679 {
680 if (!p.exists("version"))
681 {
682 OPENMS_LOG_WARN << "Broken file '" << filename << "' discovered. The 'version' tag is missing." << std::endl;
683 }
684 else // old version
685 {
686 OPENMS_LOG_WARN << "File '" << filename << "' is deprecated." << std::endl;
687 }
688 OPENMS_LOG_WARN << "Updating missing/wrong entries in '" << filename << "' with defaults!" << std::endl;
689 Param p_new = getSystemParameterDefaults_();
690 p.setValue("version", VersionInfo::getVersion()); // update old version, such that p_new:version does not get overwritten during update()
691 p_new.update(p);
692 // no new version is stored
693 }
694 }
695 return p;
696 }
697
698 Param File::getSystemParameterDefaults_()
699 {

Callers

nothing calls this directly

Calls 6

StringClass · 0.50
loadMethod · 0.45
existsMethod · 0.45
getValueMethod · 0.45
setValueMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected