Skip to content

Commit

Permalink
restore open/close config functions
Browse files Browse the repository at this point in the history
  • Loading branch information
iCollin committed Apr 22, 2021
1 parent 0303374 commit a03c694
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
12 changes: 12 additions & 0 deletions src/components/config_profile/include/config_profile/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,18 @@ class Profile : public protocol_handler::ProtocolHandlerSettings,
const std::string ErrorDescription() const;

private:
/**
* @brief Opens the configuration file
* @return a pointer to the FILE
*/
FILE* OpenConfig();

/**
* @brief Closes the configuration file
* @param pointer to the FILE to be closed
*/
void CloseConfig(FILE* config_file_);

/**
* @brief Checks that filename consists of portable symbols
* @param file_name - file name to check
Expand Down
19 changes: 14 additions & 5 deletions src/components/config_profile/src/profile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1220,10 +1220,22 @@ const std::string Profile::hmi_origin_id() const {
return hmi_origin_id_;
}

FILE* Profile::OpenConfig() {
FILE* config_file_ = fopen(config_file_name_.c_str(), "r");
return config_file_;
}

void Profile::CloseConfig(FILE* config_file_) {
if (nullptr != config_file_) {
fclose(config_file_);
config_file_ = nullptr;
}
}

void Profile::UpdateValues() {
SDL_LOG_AUTO_TRACE();

FILE* config_file_ = fopen(config_file_name_.c_str(), "r");
FILE* config_file_ = OpenConfig();
config_obj_ = smart_objects::SmartObject(smart_objects::SmartType_Map);

if (nullptr != config_file_) {
Expand Down Expand Up @@ -1286,10 +1298,7 @@ void Profile::UpdateValues() {
}
}

if (nullptr != config_file_) {
fclose(config_file_);
config_file_ = nullptr;
}
CloseConfig(config_file_);

// SDL version
ReadStringValue(
Expand Down

0 comments on commit a03c694

Please sign in to comment.