(svn r10152) [0.5] -Fix: MorphOS interprets // as /../, so do not add any duplicate slashes (tokai). 0.5
authorrubidium
Wed, 13 Jun 2007 20:48:11 +0000
branch0.5
changeset 5508 f84e84891954
parent 5507 65cf99137628
child 5509 0b111f4e6dc9
(svn r10152) [0.5] -Fix: MorphOS interprets // as /../, so do not add any duplicate slashes (tokai).
unix.c
--- a/unix.c	Wed Jun 13 20:30:48 2007 +0000
+++ b/unix.c	Wed Jun 13 20:48:11 2007 +0000
@@ -88,6 +88,12 @@
 	/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
 	if (FiosIsRoot(path)) {
 		snprintf(filename, lengthof(filename), "%s:%s", path, ent->d_name);
+	} else if (path[strlen(path) - 1] == PATHSEPCHAR) { // PATHSEP is only one byte
+		/* Paths with double PATHSEP like "directory//foobar.ext" won't work under MorphOS/AmigaOS
+		 * (the extra slash is interpreted like ".." under UNIXes). UNIXes simply interpret double
+		 * slash as single slash, so the adding of the PATHSEP further below could actually be
+		 * removed. */
+		snprintf(filename, lengthof(filename), "%s%s", path, ent->d_name);
 	} else // XXX - only next line!
 #endif
 	snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, ent->d_name);