From 4eda49b10ccb5a4c9ebaa6595224b4cc723ca1ca Mon Sep 17 00:00:00 2001 From: Sungmin Kwak Date: Thu, 3 Nov 2016 19:54:59 +0900 Subject: [PATCH] Fix sicm_make_dir() function Change-Id: I7e4a255c6dd75f11f88ba9cd47c0b40733b15f76 --- ism/src/scim_utility.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ism/src/scim_utility.cpp b/ism/src/scim_utility.cpp index 2503f5dd..624b2d17 100644 --- a/ism/src/scim_utility.cpp +++ b/ism/src/scim_utility.cpp @@ -778,21 +778,23 @@ scim_load_file (const String &filename, char **bufptr) EXAPI bool scim_make_dir (const String &dir) { - std::vector paths; - String path; + if (access (dir.c_str (), R_OK) != 0) { + std::vector 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; -- 2.34.1