-
-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can amiberry test for whdload.lha archives, before trying to load any.lha archive? (automate filetype associations) #1461
Comments
I think that goes a bit out of scope. |
For sure, it'd be a good idea to remove application/x-lha from the MIMETYPE then to avoid the inevitable. It does leave the user free to RMB-> Open with amiberry ....beyond that point it begets a semantic debate, as often the choice of 'Always open the same type of files..' can make the decision tricky..... because the reality is a whdload.lha gamepack, is a uniquely different type of file to that of some archive.lha that isn't a whdload gamepack ....sigh 8) ...there's also two layers here... what a browser app does opening this filetype, and what the WM in use does handling the same thing...ie; without the mimetype, no double-click... I agree however, as mentioned ~ if links2 can detect the pattern and return that flag, other browser apps (and WMs) should be doing something similar. Thanks ;) |
After some investigation and reading, it would appear this is 'our problem' so to speak -- the position wrt the handling of .lha files, is a good example as it turns out.. citing: https://specifications.freedesktop.org/shared-mime-info-spec/latest/ar01s02.html#id-1.3.19 "The type determined in this way is only a guess, and an application MUST NOT trust a file based simply on its MIME type. For example, a downloader should not pass a file directly to a launcher application without confirmation simply because the type looks `harmless' (eg, text/plain)." So at best currently, we can only use mime-type detection as being 'hints'... the rest is up to us ;) The progression above (although it does specify downloader, also consider doubleclick on desktop icon)... *the System mode of shared-mime-info correctly identifies the It could be said, firefox isn't following the 'standards' here ; links2 is ;) However, by the same token, herein lies the lesson example, of why we can't trust System mode and blindly accept files, just because shared-mime-info says so... In a so called 'perfect world', amiberry should have a 'file-loader' to check the veracity of the file.ext it's being asked to handle, and if the ...the next level down, is by leveraging the share-mime-info system itself, as fs-uae does by including the The things that I noted could be added here, are detection of .ipf & .dms images (these are currently undefined), and being able to detect .lha I can puddle about with this mime stuff if you like? |
Brief: The .ipf & .dms floppy image filetypes are untested by shared-mime-info, and of type 'unknown' -- on my advice, we added application/octet-stream to the Amiberry.desktop file, which in turn promotes amiberry to be a 'Recommended' application for this filetype, but it is only deduced by file extension. This is fraught with danger, in that any file with the .ipf or .dms extension will be loaded (by amiberry) unchecked. Also, the user ..if desired ... has to manually set the default app for these extensions.... ...application/x-lha is a problem child, in that normal archive.lha files are also aliased to application/x-lzh-compressed, and the shared-mime-info system only tests for the lha compression. The whdload.lha files from ie; Retroplay repo, differ in significant ways, as illustrated by the use of the file RodLand_v1.4_1509.lha file Picasso96.lha I believe the alias to application/x-lzh-compressed is in somehow related to the glob value "*.lzh" for file extension that will be considered as application/x-lha as well as "*.lha". In any event, applications should NOT trust mime-type detection at a System mode level anyway, however application specific mime-types are allowed, so that one can add to/extend the base shared-mime-info structure, to suit the application needs...(this is the 'free' part of freedesktop standards ;) This is considered 'safe' practice, and a multitude of (linux) applications, employ this system in exactly the same way as described below (following their examples =). Proposed: The following changes, achieves .... *creates the mime-type *creates the mime-type *creates the mime-type ..for /usr/share/mime/packages/amiberry.xml
...for /usr/share/applications/Amiberry.desktop
Notes: I've left The icon choices for the floppy disk image files should work on any linux distro...I think ... needs to be checked -- OS will default to something else if icon file not found, nothing goes boom. To test -- as root, copy the attached files into Seems good here, let me know if any problems exist (works here in Bookworm & Puppy 10) |
As discussed, associating amiberry with the .lha mime-type, results in any archive.lha file being actioned with "Open with amiberry".... regardless of whether the .lha is a whdload gamepak or not. As mentioned, the links2 console based web-browser, was able to differentiate that a whdload.lha was mime-type x-lzh-compressed and all other archive.lha files as x-lha-archive.
Digging deeper, the third through seventh bytes of the compressed file, identify the archive compression method as type -lha5-
The eighth byte I am unsure of...
However, for the ninth through twelfth bytes of the compressed archive, are unique to whdload.lha files --
01 00 00 84
Is there any way amiberry can test for this signature, before attempting to load (or being fed) any *.lha file?
TIA
The text was updated successfully, but these errors were encountered: