Re: [hatari-devel] Maybe a gemdos bug, I don't know

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On keskiviikko 20 kesäkuu 2012, Laurent Sallafranque wrote:
> It seems to work well :
> 
> GEMDOS path component 'LOADLEVEL.gs' doesn't fit to 8+3 chars!
> GEMDOS path component 'LOADLEVEL.S' doesn't fit to 8+3 chars!
> 
> Maybe displaying also the path 'name' would help to detect easily where
> the error comes from, is it possible ?

Were all your issues only about names where the part before dot
was too long, not the extension?

Were the issues only for directory names or also file names?


It seems that TOS automatically limits extension size to 3 characters:
http://www.atari-forum.com/viewtopic.php?f=51&t=24836&p=228727#p228727

But I haven't found anywhere documentation how TOS actually
deals / is supposed to deal with file names having too many
characers...

Attached patch seems to fix at least MONST v1.x case, but I'm
worried it might regress some other case.


	- Eero
diff -r da6a4fbb78f6 src/gemdos.c
--- a/src/gemdos.c	Tue Mar 26 17:03:44 2013 +0200
+++ b/src/gemdos.c	Wed Mar 27 00:54:45 2013 +0200
@@ -1017,7 +1017,18 @@
 		return false;
 	path[pathlen++] = PATHSEP;
 	path[pathlen] = '\0';
-	
+
+	/* TOS uses max 3 letters from the extension */
+	if (!is_dir)
+	{
+		char *dot = strrchr(name, '.');
+		if (dot && strlen(dot) > 4)
+		{
+			Log_Printf(LOG_WARN, "WARNING: had to ignore/clip %d characters from filename extension!\n", strlen(dot) - 4);
+			dot[4] = '\0';
+		}
+	}
+
 	/* first try exact (case insensitive) match */
 	match = match_host_dir_entry(path, name, false);
 	if (match)
@@ -1148,24 +1159,21 @@
 }
 
 /**
- * Give warning if dir/filename exceeds 8+3 as that wouldn't be
- * valid for TOS.
+ * Give warning if dir/filename before extension exceeds 8 as that
+ * wouldn't be valid for TOS (whereas from extension, TOS takes only
+ * 3 first letters).
  */
 static void check_tos_len(const char *path, const char *fullpath)
 {
-	char *dot;
-
-	dot = strchr(path, '.');
-	if (dot)
+	const char *end;
+
+	end = strchr(path, '.');
+	if (!end)
 	{
-		if (dot-path <= 8 && strlen(dot+1) <= 3)
-			return;
+		end = path + strlen(path);
 	}
-	else
-	{
-		if (strlen(path) <= 8)
-			return;
-	}
+	if (end-path <= 8)
+		return;
 	Log_Printf(LOG_WARN, "GEMDOS path component '%s' doesn't fit to 8+3 chars in\n\t%s !\n", path, fullpath);
 }
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/