Fix to check whether it is possible to access to files 52/167952/1
authorsooyeon.kim <sooyeon.kim@samsung.com>
Fri, 5 Jan 2018 07:01:35 +0000 (16:01 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Tue, 23 Jan 2018 05:36:58 +0000 (05:36 +0000)
Change-Id: Id45fcdbd464cd7d0257c031dec6be5c8f53b42da
Signed-off-by: sooyeon.kim <sooyeon.kim@samsung.com>
(cherry picked from commit 26e12301f9afd4c20de8646e7307091741e9194e)

common/tts_config_parser.c

index a042797..ee9e5f0 100644 (file)
@@ -65,9 +65,15 @@ int tts_parser_get_engine_info(const char* path, tts_engine_info_s** engine_info
        xmlChar *key = NULL;
        xmlChar *attr = NULL;
 
-       doc = xmlParseFile(path);
-       if (doc == NULL) {
-               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse xml file");
+       if (0 == access(path, F_OK)) {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to access to %s", path);
+               doc = xmlParseFile(path);
+               if (doc == NULL) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse xml file");
+                       return -1;
+               }
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to access to %s", path);
                return -1;
        }
 
@@ -575,9 +581,15 @@ int tts_parser_copy_xml(const char* original, const char* destination)
        }
 
        xmlDocPtr doc = NULL;
-       doc = xmlParseFile(original);
-       if (doc == NULL) {
-               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", original);
+       if (0 == access(original, F_OK)) {
+               SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to access to %s", original);
+               doc = xmlParseFile(original);
+               if (doc == NULL) {
+                       SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to parse file error : %s", original);
+                       return -1;
+               }
+       } else {
+               SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to access to %s", original);
                return -1;
        }
 
@@ -852,9 +864,12 @@ int tts_parser_find_config_changed(char** engine, char**setting, bool* auto_voic
 
        int retry_count = 0;
        while (NULL == doc) {
-               doc = xmlParseFile(TTS_CONFIG);
-               if (NULL != doc) {
-                       break;
+               if (0 == access(TTS_CONFIG, F_OK)) {
+                       SLOG(LOG_DEBUG, tts_tag(), "[DEBUG] Success to access to %s", TTS_CONFIG);
+                       doc = xmlParseFile(TTS_CONFIG);
+                       if (NULL != doc) {
+                               break;
+                       }
                }
                retry_count++;
                usleep(10000);