From 76bdc9681799a7ed17be1cddbe7b91adef242373 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 28 Mar 2024 08:15:31 -0700 Subject: Removed seemingly pointless config file checks * When config file can't be read, it will be reported by Configuration::init. * When config file can't be written, xmlNewTextWriterFilename will probably return nullptr. --- src/client.cpp | 25 +------------------------ src/configuration.cpp | 13 ------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 2a854bc0..afd53fa3 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1175,30 +1175,7 @@ void Client::initConfiguration() config.setValue("ChatLogLength", 128); config.setValue("disableTransparency", false); - // Checking if the configuration file exists... otherwise create it with - // default options. - FILE *configFile = nullptr; - std::string configPath; - - configPath = mConfigDir + "/config.xml"; - - configFile = fopen(configPath.c_str(), "r"); - - // If we can't read it, it doesn't exist ! - if (!configFile) - { - // We reopen the file in write mode and we create it - configFile = fopen(configPath.c_str(), "wt"); - } - if (!configFile) - { - logger->log("Can't create %s. Using defaults.", configPath.c_str()); - } - else - { - fclose(configFile); - config.init(configPath); - } + config.init(mConfigDir + "config.xml"); } /** diff --git a/src/configuration.cpp b/src/configuration.cpp index 7d2b496f..3c9fab3c 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -301,20 +301,7 @@ void ConfigurationObject::writeToXML(xmlTextWriterPtr writer) void Configuration::write() { - // Do not attempt to write to file that cannot be opened for writing - FILE *testFile = fopen(mConfigPath.c_str(), "w"); - if (!testFile) - { - logger->log("Configuration::write() couldn't open %s for writing", - mConfigPath.c_str()); - return; - } - - fclose(testFile); - - xmlTextWriterPtr writer = xmlNewTextWriterFilename(mConfigPath.c_str(), 0); - if (!writer) { logger->log("Configuration::write() error while creating writer"); -- cgit v1.2.3-60-g2f50