[Scummvm-git-logs] scummvm master -> 40f82aacdb4d4999f64f9e6101bbbf583210dfda

sev- sev at scummvm.org
Tue Jul 28 20:22:03 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
40f82aacdb DIRECTOR: Convert '/' in Mac paths to ':'


Commit: 40f82aacdb4d4999f64f9e6101bbbf583210dfda
    https://github.com/scummvm/scummvm/commit/40f82aacdb4d4999f64f9e6101bbbf583210dfda
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-07-28T22:21:02+02:00

Commit Message:
DIRECTOR: Convert '/' in Mac paths to ':'

Changed paths:
    engines/director/util.cpp


diff --git a/engines/director/util.cpp b/engines/director/util.cpp
index b7f097c6d1..16f8fa291f 100644
--- a/engines/director/util.cpp
+++ b/engines/director/util.cpp
@@ -244,7 +244,7 @@ Common::String convertPath(Common::String &path) {
 	if (path.empty())
 		return path;
 
-	if (!path.contains(':')) {
+	if (!path.contains(':') && !path.contains('/') && !path.contains('\\')) {
 		return path;
 	}
 
@@ -252,10 +252,10 @@ Common::String convertPath(Common::String &path) {
 	uint32 idx = 0;
 
 	if (path.hasPrefix("::")) {
-		res = "../";
+		res = "..\\";
 		idx = 2;
 	} else {
-		res = "./";
+		res = ".\\";
 
 		if (path[0] == ':')
 			idx = 1;
@@ -263,14 +263,24 @@ Common::String convertPath(Common::String &path) {
 
 	while (idx != path.size()) {
 		if (path[idx] == ':')
-			res += '/';
+			res += '\\';
+		else if (path[idx] == '/')
+			res += ':';
 		else
 			res += path[idx];
 
 		idx++;
 	}
 
-	return res;
+	// And now convert everything to Unix style paths
+	Common::String res1;
+	for (idx = 0; idx < res.size(); idx++)
+		if (res[idx] == '\\')
+			res1 += '/';
+		else
+			res1 += res[idx];
+
+	return res1;
 }
 
 Common::String getPath(Common::String path, Common::String cwd) {
@@ -285,17 +295,12 @@ Common::String getPath(Common::String path, Common::String cwd) {
 Common::String pathMakeRelative(Common::String path, bool recursive, bool addexts) {
 	Common::String initialPath(path);
 
-	// First, convert Windows-style separators
-	if (g_director->getPlatform() == Common::kPlatformWindows) {
-		if (initialPath.contains('\\'))
-			for (uint i = 0; i < initialPath.size(); i++)
-				if (initialPath[i] == '\\')
-					initialPath.setChar('/', i);
-	}
+	if (recursive) // first level
+		initialPath = convertPath(initialPath);
 
 	debug(2, "pathMakeRelative(): s1 %s -> %s", path.c_str(), initialPath.c_str());
 
-	initialPath = Common::normalizePath(g_director->getCurrentPath() + convertPath(initialPath), '/');
+	initialPath = Common::normalizePath(g_director->getCurrentPath() + initialPath, '/');
 	Common::File f;
 	Common::String convPath = initialPath;
 
@@ -303,7 +308,7 @@ Common::String pathMakeRelative(Common::String path, bool recursive, bool addext
 
 	// Strip the leading whitespace from the path
 	initialPath.trim();
-	
+
 	if (f.open(initialPath))
 		return initialPath;
 




More information about the Scummvm-git-logs mailing list