diff --git a/source/text_funcs.hpp b/source/text_funcs.hpp index f2c0465d..3486b2fe 100644 --- a/source/text_funcs.hpp +++ b/source/text_funcs.hpp @@ -57,7 +57,6 @@ bool write_to_file(const std::string& file_path, const std::string& line) { return false; } output_file << line << std::endl; - output_file.close(); return true; } @@ -83,7 +82,6 @@ bool write_to_file(const std::string& file_path, const std::string& line) { for (const auto& existing_line : existing_lines) { output_file << existing_line << std::endl; } - output_file.close(); return true; } @@ -91,7 +89,7 @@ bool remove_txt(const std::string& file_path, const std::string& pattern) { std::vector lines; std::ifstream file(file_path); if (!file.is_open()) { - log("There is no %s in %s",pattern.c_str(), file_path.c_str()); + log("File %s not found", file_path.c_str()); return true; } @@ -105,13 +103,12 @@ bool remove_txt(const std::string& file_path, const std::string& pattern) { std::ofstream output_file(file_path); if (!output_file.is_open()) { - log("There is no %s in %s",pattern.c_str(), file_path.c_str()); + log("File %s can't be created", file_path.c_str()); return true; } for (const auto& line : lines) { output_file << line << std::endl; } - output_file.close(); return true; } \ No newline at end of file diff --git a/source/utils.hpp b/source/utils.hpp index d9cae409..588eaf94 100644 --- a/source/utils.hpp +++ b/source/utils.hpp @@ -508,25 +508,23 @@ int interpretAndExecuteCommand(const std::vector>& comm // Edit command if (command.size() == 3) { sourcePath = preprocessPath(command[1]); - - bool result = remove_txt(sourcePath, removeQuotes(command[2])); - // log(command[2]); - if (!result && catchErrors) { - log("Error in %s command", commandName.c_str()); - return -1; - } + bool result = remove_txt(sourcePath, removeQuotes(command[2])); + // log(command[2]); + if (!result && catchErrors) { + log("Error in %s command", commandName.c_str()); + return -1; + } } } else if (commandName == "add-txt-str") { // Edit command if (command.size() == 3) { sourcePath = preprocessPath(command[1]); - - bool result = write_to_file(sourcePath, removeQuotes(command[2])); - // log(command[2]); - if (!result && catchErrors) { - log("Error in %s command", commandName.c_str()); - return -1; - } + bool result = write_to_file(sourcePath, removeQuotes(command[2])); + // log(command[2]); + if (!result && catchErrors) { + log("Error in %s command", commandName.c_str()); + return -1; + } } } else if (commandName == "hex-by-offset") { // Edit command