diff options
author | Jacob Keeler <jacob.keeler@livioradio.com> | 2018-06-08 11:25:06 -0400 |
---|---|---|
committer | Jacob Keeler <jacob.keeler@livioradio.com> | 2018-06-08 11:25:06 -0400 |
commit | 0a4344894d21e90116476c58d82a0c2995f9008b (patch) | |
tree | 8192e963fe91a9e2d705f7077b1d496822c6a5d0 | |
parent | 79012b26b614cdbe24be1859b308e8e9a96e4693 (diff) | |
download | sdl_core-0a4344894d21e90116476c58d82a0c2995f9008b.tar.gz |
Set full file path for files that aren't foundfeature/audio_file_playback_tts_chunks
-rw-r--r-- | src/components/application_manager/include/application_manager/message_helper.h | 13 | ||||
-rw-r--r-- | src/components/application_manager/src/message_helper/message_helper.cc | 33 |
2 files changed, 19 insertions, 27 deletions
diff --git a/src/components/application_manager/include/application_manager/message_helper.h b/src/components/application_manager/include/application_manager/message_helper.h index de8d92d727..57a2f847bf 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -549,19 +549,18 @@ class MessageHelper { int32_t result_code); /** - * @brief Verify that a file exists for a given application + * @brief Get the full file path of an app file * * @param file_name The relative path of an application file * @param app Current application * @param app_mngr Application manager * - * @return The full file path of the application file if found, - * NULL otherwise + * @return The full file path of the application file if valid, + * empty string otherwise */ - static utils::SharedPtr<std::string> CheckAppFileExists( - std::string file_name, - ApplicationConstSharedPtr app, - ApplicationManager& app_mngr); + static std::string GetAppFilePath(std::string file_name, + ApplicationConstSharedPtr app, + ApplicationManager& app_mngr); /** * @brief Verify that all ttsChunks with FILE type diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index 46620e878a..b674a090c0 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -2756,24 +2756,23 @@ mobile_apis::Result::eType MessageHelper::VerifyImageApplyPath( } const std::string& file_name = image[strings::value].asString(); - const utils::SharedPtr<std::string> full_file_path = - CheckAppFileExists(file_name, app, app_mngr); - if (full_file_path) { - image[strings::value] = *full_file_path; + const std::string& full_file_path = GetAppFilePath(file_name, app, app_mngr); + + image[strings::value] = full_file_path; + if (file_system::FileExists(full_file_path)) { return mobile_apis::Result::SUCCESS; } return mobile_apis::Result::INVALID_DATA; } -utils::SharedPtr<std::string> MessageHelper::CheckAppFileExists( - std::string file_name, - ApplicationConstSharedPtr app, - ApplicationManager& app_mngr) { +std::string MessageHelper::GetAppFilePath(std::string file_name, + ApplicationConstSharedPtr app, + ApplicationManager& app_mngr) { std::string str = file_name; // Verify that file name is not only space characters str.erase(remove(str.begin(), str.end(), ' '), str.end()); if (0 == str.size()) { - return utils::SharedPtr<std::string>(); + return ""; } std::string full_file_path; @@ -2799,12 +2798,7 @@ utils::SharedPtr<std::string> MessageHelper::CheckAppFileExists( full_file_path += file_name; } - if (!file_system::FileExists(full_file_path)) { - return utils::SharedPtr<std::string>(); - } - - utils::SharedPtr<std::string> path_ptr(new std::string(full_file_path)); - return path_ptr; + return full_file_path; } mobile_apis::Result::eType MessageHelper::VerifyTtsFiles( @@ -2814,12 +2808,11 @@ mobile_apis::Result::eType MessageHelper::VerifyTtsFiles( mobile_apis::Result::eType result = mobile_apis::Result::SUCCESS; for (auto& tts_chunk : *(tts_chunks.asArray())) { if (tts_chunk[strings::type] == mobile_apis::SpeechCapabilities::FILE) { - utils::SharedPtr<std::string> full_file_path = CheckAppFileExists( - tts_chunk[strings::text].asString(), app, app_mngr); - if (!full_file_path) { + const std::string full_file_path = + GetAppFilePath(tts_chunk[strings::text].asString(), app, app_mngr); + tts_chunk[strings::text] = full_file_path; + if (!file_system::FileExists(full_file_path)) { result = mobile_apis::Result::FILE_NOT_FOUND; - } else { - tts_chunk[strings::text] = *full_file_path; } } } |