Fix Recursive_Mkdir if path doesn't end with "/"

Somewhat surprisingly, Recursive_Mkdir(TWRES "customlanguages")
did not create the "customlanguages" directory because it expected
a trailing slash. Fixed by rewriting the loop to be more like
Create_Dir_Recursive.

Also fixed error handling for the final directory, and fixed incorrect
return value handling for "mkdir" ORS command.

Change-Id: I1ab418ddda695cbb595a9db2817f00fc7b171f51
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index a7a8e8d..6eb6cd5 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -403,26 +403,19 @@
 }
 
 int TWFunc::Recursive_Mkdir(string Path) {
-	string pathCpy = Path;
-	string wholePath;
-	size_t pos = pathCpy.find("/", 2);
-
-	while (pos != string::npos)
-	{
-		wholePath = pathCpy.substr(0, pos);
-		if (!TWFunc::Path_Exists(wholePath)) {
-			if (mkdir(wholePath.c_str(), 0777)) {
-				gui_msg(Msg(msg::kError, "create_folder_strerr=Can not create '{1}' folder ({2})")(wholePath)(strerror(errno)));
+	std::vector<std::string> parts = Split_String(Path, "/", true);
+	std::string cur_path;
+	for (size_t i = 0; i < parts.size(); ++i) {
+		cur_path += "/" + parts[i];
+		if (!TWFunc::Path_Exists(cur_path)) {
+			if (mkdir(cur_path.c_str(), 0777)) {
+				gui_msg(Msg(msg::kError, "create_folder_strerr=Can not create '{1}' folder ({2})")(cur_path)(strerror(errno)));
 				return false;
 			} else {
-				tw_set_default_metadata(wholePath.c_str());
+				tw_set_default_metadata(cur_path.c_str());
 			}
 		}
-
-		pos = pathCpy.find("/", pos + 1);
 	}
-	if (mkdir(wholePath.c_str(), 0777) && errno != EEXIST)
-		return false;
 	return true;
 }