Fix sicm_make_dir() function 92/95492/5
authorSungmin Kwak <sungmin.kwak@samsung.com>
Thu, 3 Nov 2016 10:54:59 +0000 (19:54 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 7 Nov 2016 04:54:34 +0000 (13:54 +0900)
Change-Id: I7e4a255c6dd75f11f88ba9cd47c0b40733b15f76

ism/src/scim_utility.cpp

index 2503f5d..624b2d1 100644 (file)
@@ -778,21 +778,23 @@ scim_load_file (const String &filename, char **bufptr)
 EXAPI bool
 scim_make_dir (const String &dir)
 {
-    std::vector <String> paths;
-    String path;
+    if (access (dir.c_str (), R_OK) != 0) {
+        std::vector <String> paths;
+        String path;
 
-    scim_split_string_list (paths, dir, SCIM_PATH_DELIM);
+        scim_split_string_list (paths, dir, SCIM_PATH_DELIM);
 
-    for (size_t i = 0; i < paths.size (); ++i) {
-        path += SCIM_PATH_DELIM_STRING + paths [i];
+        for (size_t i = 1; i < paths.size (); ++i) {
+            path += SCIM_PATH_DELIM_STRING + paths [i];
 
-        //Make the dir if it's not exist.
-        if (access (path.c_str (), R_OK) != 0) {
-            if (mkdir (path.c_str (), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0)
-                return false;
+            //Make the dir if it's not exist.
+            if (access (path.c_str (), R_OK) != 0) {
+                if (mkdir (path.c_str (), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0)
+                    return false;
 
-            if (access (path.c_str (), R_OK) != 0)
-                return false;
+                if (access (path.c_str (), R_OK) != 0)
+                    return false;
+            }
         }
     }
     return true;