Patch to fix files with double dots when converting with atari-convert-dir.py

A forum about the Hatari ST/STE/Falcon emulator - the current version is v2.2.0

Moderators: simonsunnyboy, thothy, Moderator Team

User avatar
marcello
Atari freak
Atari freak
Posts: 65
Joined: Thu May 03, 2012 9:23 pm

Patch to fix files with double dots when converting with atari-convert-dir.py

Postby marcello » Mon Jan 21, 2019 12:02 pm

Hi
I use atari-convert-dir.py to prepare files in batch for my SD card running on realhardware.
I noticed atari-convert-dir.py leaves files with more than one dot in the filename intact, generating FAT clipped names ( the GEMDOS hd emul will replace the extra dots with a '+' for instance )

I propose the following patch which strips all dots for a file/directory name except the last one.

Note I am not the python guy, just a try here.
You do not have the required permissions to view the files attached to this post.
STMint, try Unix on your 68000 Atari http://subsole.org/st_mint

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1962
Joined: Sun Jul 31, 2011 1:11 pm

Re: Patch to fix files with double dots when converting with atari-convert-dir.py

Postby Eero Tamminen » Mon Jan 21, 2019 10:07 pm

GEMDOS HD does that because most TOS programs wouldn't work with more dots in the file name, and '+' is valid file name character in TOS. It uses something in place of invalid characters so that those modified file names can be better mapped back to the host file names.

However, atari-convert-dir.py has slightly different purpose, it tries to model what Atari TOS does for file names instead of providing two-way atari<->host file name mapping.

Use-case 1: Atari program works with long file names under MiNT, how those file names should be mapped so that this same program works under normal TOS and its 8+3 file system, although it's asking TOS for files with their long names (ScummVM and OpenTTD Atari ports are examples where this is useful)?

Use-case 2: Some Atari disks contain "invalid" TOS filename characters, potentially as some kind of primitive copy protection method. It should still be possible to extract such files from a zip and create a correctly working floppy disk image out of it. I.e. just removing invalid characters isn't necessarily the correct thing to do.

Therefore, before changing anything, I'd like results from an Atari test program that demonstrates what happens:
* If Atari program tries to search (Fsfirst) a pattern with multiple dots in its name. What TOS will actually search from the disk, if anything?
* What if Atari program gives such name for opening (Fopen/Fcreate) a file, what file name TOS actually opens from the disk?

After that, it would be good to check that the modified names can be stored to the disk image with Mtools utilities, or using Hatari to copy them from GEMDOS HD. If there's an issue with Hatari GEMDOS HD emulation, that could be updated.

PS. while using list comprehension to count dots works:

Code: Select all

+    dotpositions = [pos for pos, char in enumerate(name) if char == "."]
+    name = name.replace(".", "", len(dotpositions) - 1)
+    return name


Python has also specific string method for counting chars, which is easier to read:

Code: Select all

+    dots = name.count('.')
+    return name.replace('.', '', dots-1)

User avatar
marcello
Atari freak
Atari freak
Posts: 65
Joined: Thu May 03, 2012 9:23 pm

Re: Patch to fix files with double dots when converting with atari-convert-dir.py

Postby marcello » Wed Jan 23, 2019 6:14 pm

Hi Eero, thanks for feedback and code review.

Use-case 2: Some Atari disks contain "invalid" TOS filename characters, potentially as some kind of primitive copy protection method. It should still be possible to extract such files from a zip and create a correctly working floppy disk image out of it. I.e. just removing invalid characters isn't necessarily the correct thing to do.


Ok my use case was different, I just wanted to create tos compatibles names of files created from Linux. Of course if you want to keep invalid characters, then my fix doesn't make sense.

I'll have to test again how these files with double dots are handled by ST, i did not do a lot of testing here.
STMint, try Unix on your 68000 Atari http://subsole.org/st_mint

User avatar
Eero Tamminen
Atari God
Atari God
Posts: 1962
Joined: Sun Jul 31, 2011 1:11 pm

Re: Patch to fix files with double dots when converting with atari-convert-dir.py

Postby Eero Tamminen » Wed Jan 23, 2019 10:59 pm

For me that's also the most common use-case, but I also want it to support the two (more rare) cases I listed.

That script was very useful for getting programs (ScummVM / OpenTTD) working with TOS. First I ran the program under GEMDOS HD emulation and checked that things worked there, then I changed the script to do exactly same thing as GEMDOS HD emu and tried the results under normal TOS from a disk image. If it didn't work there, I debugged why, mainly with "--trace gemdos", updated the script and checked whether I should update also GEMDOS HD emu (if I remember correctly, I didn't).


Social Media

     

Return to “Hatari”

Who is online

Users browsing this forum: No registered users and 4 guests