PierreLorenzi / HyperCardPreview

Little app to see HyperCard stacks in Mac OS X. Programmed in Swift.
MIT License
123 stars 15 forks source link

Cannot open stacks from old versions of Mac OS. #16

Closed solarmist closed 8 months ago

solarmist commented 2 years ago

For example it's refused to try and open Balls! stack from balls.sit at: https://hypercard.org/Pantechnicon/Apps/Games

Screen Shot 2022-02-14 at 2 03 19 PM

I looked at it briefly, but didn't see anything obvious.

splorp commented 2 years ago

I just tested HyperCardPreview 1.4 and was able to open the Balls! stack under macOS 10.13.6 (High Sierra).

This must have something to do with the newer version of macOS you’re running or perhaps the way that you decompressed the StuffIt archive.

Can you provide a few more details?

solarmist commented 2 years ago

Hmm, interesting. I'm on Mac OS Monterey, so I wonder if support for these old files is being dropped bit by bit.

On Feb 14, 2022, at 3:10 PM, Grant Hutchinson @.***> wrote:

 I just tested HyperCardPreview 1.4 and was able to open the Balls! stack under macOS 10.13.6 (High Sierra).

This must have something to do with the newer version of macOS you’re running or perhaps the way that you decompressed the StuffIt archive.

Can you provide a few more details?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.

solarmist commented 2 years ago

As far as decompressing the file I just used the Unarchiver to extract it.

But I do notice that in Monterey things like GetFileInfo are now deprecated. And in hdiutil there's the following notes:

     macOS 10.15:

           •   Introduced lzma compression in the ULMO format, providing smaller images compared to ULFO. These images are not supported in-
               kernel, and will not work on any earlier versions of the OS.

           •   Deprecated OS 9-style dual-fork file support (hdiutil flatten/unflatten).

           •   Removed the deprecated "hdiutil internet-enable" command and the IDME attach flags.

     macOS 11.0:

           •   Removed support for DiskCopy42, DART and NDIF formats.

           •   Removed support for AppleSingle and MacBinary encodings.

           •   Removed the deprecated OS 9-style dual-fork file support (hdiutil flatten/unflatten).

           •   Default file system for new images has changed to APFS (instead of an empty disk image with no partition map). To create an
               empty disk image add "-layout NONE" to the creation flags. This change does not apply to images created with -srcfolder or
               -srcdevice arguments.

     macOS 12.0:

           •   Deprecated UDBZ format (bzip2 compression)

           •   Deprecated segmented UDIF images (hdiutil segment, -segmentSize argument in hdiutil create & convert)

           •   Deprecated hdiutil udifrez/udifderez (embed and extract resources)
PierreLorenzi commented 2 years ago

I'm on Mac OS Monterey too, and it works for me. I tried to open your stack and it was fine. Sorry I don't understand what's happening. And I don't use GetFileInfo, I open the resource fork using getxattr.

Capture d’écran 2022-02-15 à 20 45 52
solarmist commented 2 years ago

Interesting. Ok, well that's good to know that it's something with my setup. I'll update this if I figure anything out.

PierreLorenzi commented 2 years ago

To check if you still have the resource fork, you can execute the command xattr Balls! on a terminal, there must be a line com.apple.ResourceFork.

solarmist commented 2 years ago

It's there.

$: xattr Balls\!
    com.apple.FinderInfo
    com.apple.ResourceFork
    com.apple.quarantine
PierreLorenzi commented 2 years ago

Well your file seems good, I don't understand what's happening

gingerbeardman commented 2 years ago

I'm also unable to open stacks that I know are good (just copied out of an emulator) in Monterey.

Time to dig out an older macOS machine!

gingerbeardman commented 2 years ago

Indeed, everything is working as expected on an old laptop running Mojave (10.14.6).

Exporting is very, very slow but it'll get there I'm sure.

503 cards in the animation I'm looking at.

joevt commented 1 year ago

I used Stuffit Destinations.app to unstuff balls.sit to an HFS+ volume in macOS Monterey 12.6.1. The resource fork is intact and can be accessed. The file size should be ≈376K (107K for data fork and 270K for resource fork). The resource fork contains a custom icon which the Finder displays correctly (since the FinderInfo has the "Use custom icon bit" set).

joevt@Joes-Mac-Pro ~ % uname -a
Darwin Joes-Mac-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Thu Sep 29 20:12:57 PDT 2022; root:xnu-8020.240.7~1/RELEASE_X86_64 x86_64

joevt@Joes-Mac-Pro ~ % GetFileInfo /Volumes/Storage/Downloads/Balls\!\ Folder/Balls\! 
file: "/Volumes/Storage/Downloads/Balls! Folder/Balls!"
type: "STAK"
creator: "WILD"
attributes: avbstClinmedz
created: 01/25/1996 02:43:03
modified: 08/19/1999 13:29:38

joevt@Joes-Mac-Pro ~ % ls -l@ /Volumes/Storage/Downloads/Balls\!\ Folder/Balls\! 
-rwxr-xr-x@ 1 joevt  staff  107488 19 Aug  1999 /Volumes/Storage/Downloads/Balls! Folder/Balls!
    com.apple.FinderInfo        32 
    com.apple.ResourceFork  270390 
    com.apple.metadata:kMDItemWhereFroms       153 
    com.apple.quarantine        57 

joevt@Joes-Mac-Pro ~ % xattr -l /Volumes/Storage/Downloads/Balls\!\ Folder/Balls\! 
com.apple.FinderInfo: STAKWILD
com.apple.ResourceFork: 
com.apple.metadata:kMDItemWhereFroms: bplist00?_7https://hypercard.org/Pantechnicon/Apps/Games/balls.sit_.https://hypercard.org/Pantechnicon/Apps/Games/
                                                                                                                                                       E
com.apple.quarantine: 0083;638c7c3e;Safari;3A82B947-3333-4E4B-9FDE-D52E892EA83D

joevt@Joes-Mac-Pro ~ % xattr -lx /Volumes/Storage/Downloads/Balls\!\ Folder/Balls\! 
# output omitted - lots of hex for the resource fork

joevt@Joes-Mac-Pro ~ % derez -p -only xxxx /Volumes/Storage/Downloads/Balls\!\ Folder/Balls\! 2>&1 | sed -E '/.*Skipping /s///'
derez V3.7  
Copyright Apple Computer, Inc. 1986-2018

'ICON' (26635, "Sml Help", purgeable).
'ICON' (19992, "Preferences", purgeable).
'ICON' (27056, "Button Ideas", purgeable).
'XCMD' (9207, "AddColor", purgeable).
'xcmd' (9207, "AddColor", purgeable).
'BITs' (1000, "MyCopyBits", purgeable).
'bits' (1000, "MyCopyBits", purgeable).
'STR#' (8000, "selector names", purgeable).
'STR#' (8001, "Misc errors", purgeable).
'STR#' (8002, "color types", purgeable).
'STR#' (8003, "button types", purgeable).
'STR#' (8004, "field types", purgeable).
'STR#' (8005, "transition names", purgeable).
'STR#' (8006, "Misc strings", purgeable).
'STR#' (9000, "Syntax Strings", purgeable).
'STR#' (9001, "Copyright Strings", purgeable).
'CHEK' (1000, "Time Stamp").
'HCcd' (4076, "4076").
'HCcd' (4366, "4366").
'HCcd' (2817, "2817").
'HCcd' (5471, "5471").
'snd ' (2000, "coin", purgeable).
'snd ' (2001, "Woowoo", purgeable).
'snd ' (2002, "kill", purgeable).
'snd ' (2004, "DOH", purgeable).
'snd ' (2005, "applause", purgeable).
'CURS' (1990, "error1").
'PICT' (29369, "5 Ball.PICT").
'PICT' (27529, "6 Ball.PICT").
'PICT' (12959, "Chartframe").
'PICT' (32690, "PICKS").
'PICT' (12350, "PICK 5").
'PICT' (909, "Bottom Button Bar").
'icl4' (-16455, "Item Icon ").
'icl8' (-16455, "Item Icon ").
'ICN#' (-16455, "Item Icon ").
'icns' (-16455, "Item Icon ").
'HCbg' (3672, "3672").
'HCbg' (2631, "2631").
joevt commented 1 year ago

The Balls! icon is visible in the Open File dialog, so the resource fork must be valid.

Check the Finder Info. If it doesn't have the "STAK" type, then HyperCardPreview.app won't know it's a valid file that it can open.

Do you have any anti virus software installed?

gingerbeardman commented 1 year ago

Curious @joevt! I can reproduce the results of your tests exactly.

But HyperCardPreview still does not see the file to open it. See below for files as shown in the File Open picker/selector.

I do not run any anti-virus software.

image
joevt commented 1 year ago

Instead of using "Open Stack...", you can try opening the stack from the Finder?

Maybe verify the contents of the stack but this is unlikely to be wrong.

joevt@Joes-Mac-Pro ~ % xattr -px com.apple.ResourceFork /Volumes/Storage/Downloads/Balls\!\ Folder/Balls\! | xxd -p -r | md5
deb89eb587dc5a85198e343b4a28cb33

joevt@Joes-Mac-Pro ~ % md5 /Volumes/Storage/Downloads/Balls\!\ Folder/Balls\!
MD5 (/Volumes/Storage/Downloads/Balls! Folder/Balls!) = 4d1d9c2bca13e18329ab061a0a88c9af

I don't know how to read swift code. Where's the part that does the "Open Stack..." menu command? Maybe it's all handled by macOS using the document type in the info.plist?

Double check the permissions and owner of the file?

joevt@Joes-Mac-Pro HyperCardPreview % ls -l@ /Volumes/Storage/Downloads/Balls\!\ Folder/Balls\!                                         
-rwxr-xr-x@ 1 joevt  staff  107488 19 Aug  1999 /Volumes/Storage/Downloads/Balls! Folder/Balls!
    com.apple.FinderInfo        32 
    com.apple.ResourceFork  270390 
    com.apple.lastuseddate#PS       16 
    com.apple.metadata:kMDItemWhereFroms       153 
    com.apple.quarantine        57 

Maybe remove the com.apple.quarantine attribute? Though it doesn't seem to be causing me problems...

Maybe move the Balls! Folder to a different disk? It works for me from ~/Documents for example.

gingerbeardman commented 1 year ago

Instead of using "Open Stack...", you can try opening the stack from the Finder?

No difference, same error. Double-clicking a HyperCard stack in Finder opens the app (so that association is there) but the app fails to open the file with the same error as earlier.

❯ xattr -px com.apple.ResourceFork /Users/matt/Documents/Share/Balls\!\ Folder/Balls\! | xxd -p -r | md5
deb89eb587dc5a85198e343b4a28cb33

❯ md5 Balls\!
MD5 (Balls!) = 4d1d9c2bca13e18329ab061a0a88c9af

Removing com.apple.macl and com.apple.quarantine attributes makes no difference, same error.

❯  ls -l@ /Users/matt/Documents/Share/Balls\!\ Folder/Balls\!
-rwxr-xr-x@ 1 matt  staff  107488 Aug 19  1999 /Users/matt/Documents/Share/Balls! Folder/Balls!
    com.apple.FinderInfo        32 
    com.apple.ResourceFork  270390 
    com.apple.lastuseddate#PS       16 
    com.apple.metadata:kMDItemWhereFroms       153 

Maybe move the Balls! Folder to a different disk? It works for me from ~/Documents for example.

No difference, same error.

I don't know how to read swift code. Where's the part that does the "Open Stack..." menu command? Maybe it's all handled by macOS using the document type in the info.plist?

https://github.com/PierreLorenzi/HyperCardPreview/blob/059c37f49c71ed92659a8f21e36ce5d2bb604937/HyperCardPreview/Base.lproj/MainMenu.xib#L71

also see:

https://github.com/PierreLorenzi/HyperCardPreview/blob/059c37f49c71ed92659a8f21e36ce5d2bb604937/HyperCardCommon/HyperCardCommon/Command.swift#L152-L159

Hmm

Could there be something different about our installation/setup of APFS?

joevt commented 1 year ago

same error

I don't think you mentioned an error before. Is there an error message?

Could there be something different about our installation/setup of APFS?

I also have HFS+ partitions. You could try creating a writable HFS+ disk image using Disk Uility.app.

What about disabling sip?

joevt@Joes-Mac-Pro Downloads % csrutil status
System Integrity Protection status: unknown (Custom Configuration).

Configuration:
    Apple Internal: disabled
    Kext Signing: disabled
    Filesystem Protections: disabled
    Debugging Restrictions: disabled
    DTrace Restrictions: disabled
    NVRAM Protections: disabled
    BaseSystem Verification: disabled

I also tried the app in Ventura 13.0.1 without problems (though the issue says old versions of Mac OS)

gingerbeardman commented 1 year ago

The document “Balls!” could not be opened. HyperCardPreview cannot open files of this type.

Screen shot 2022-12-06 at 16 47 31

I also have HFS+ partitions. You could try creating a writable HFS+ disk image using Disk Uility.app.

I can't open them of HFS volumes either.

I also tried the app in Ventura 13.0.1 without problems (though the issue says old versions of Mac OS)

it means "Cannot open stacks from old versions of Mac OS (on modern macOS using HyperCardPreview)"

SIP will have to wait.

❯ csrutil status
System Integrity Protection status: enabled.
joevt commented 1 year ago

from old

Oh right. I can't read. Its way passed my bedtime.

Rebuild the Desktop database? But this is Mac OS X so nevermind... https://www.techwalla.com/articles/how-to-rebuild-a-desktop-in-mac-os-x

The creator code of the stack is fine - it launches the app when you double click it. But that error message... https://developer.apple.com/forums/thread/128951

There is a LaunchServices database (the lsregister -dump output is ≈100MB = 1.46 million lines): https://stackoverflow.com/questions/62288573/nsdocumentcontroller-opendocument-not-allowing-selection-of-custom-file-type

bundle id:                  HyperCardPreview (0x188fc)
claimed UTIs:               com.apple.hypercard.stack
--------------------------------------------------------------------------------
type id:                    com.apple.hypercard.stack (0x14ce0)
bundle:                     HyperCardPreview (0x188fc)
uti:                        com.apple.hypercard.stack
flags:                      active  rel-icon-path  imported  untrusted (0000000000000009)
iconFiles:                  Contents/Resources/Stack.icns
conforms to:                public.data, public.presentation
tags:                       'STAK'
--------------------------------------------------------------------------------
claim id:                   178672 (0x2b9f0)
rank:                       Default
bundle:                     HyperCardPreview (0x188fc)
flags:                      doc-type  resolves-icloud-conflicts (0000000000000220)
roles:                      Viewer (0000000000000002)
bindings:                   com.apple.hypercard.stack
gingerbeardman commented 11 months ago

Year later I want to do the same Christmas project as I abandoned last year, and banging my head against the same problem here.

I have time to solve it this year, so I'm back at it.

lsregister -dump command not found on macOS 12

gingerbeardman commented 10 months ago

type id: com.apple.hypercard.stack (0x14ce0) bundle: HyperCardPreview (0x188fc) uti: com.apple.hypercard.stack flags: active rel-icon-path imported untrusted (0000000000000009) iconFiles: Contents/Resources/Stack.icns conforms to: public.data, public.presentation tags: 'STAK'

@joevt

Using: /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump

ls.txt.zip

Mine has an interesting difference... "inactive"

type id:                    com.apple.hypercard.stack (0x26d180)
bundle:                     HyperCardPreview (0x106e14)
uti:                        com.apple.hypercard.stack
flags:                      inactive  rel-icon-path  imported  trusted (0000000000000048)
iconFiles:                  Contents/Resources/Stack.icns
conforms to:                public.data, public.presentation
tags:                       'STAK'
gingerbeardman commented 10 months ago

And there we have it! That was the clue we needed to fix this issue.

I saw in my dump of lsregister that Stacksmith was also registered for HyperCard Stacks. I deleted StackSmith and - lo and behold! - HyperCardPreview can now see and open stacks on Monterey. I have no idea why this would happen. They seem to be competing for the com.apple.hypercard.stack uti?

WILD.

@solarmist do you also happen to have Stacksmith on your Mac?

joevt commented 10 months ago

Multiple apps claiming the same UTI - Isn't that why there's an Open With menu in the Get Info dialog for the document file in the Finder? And then use the Change All button to make all files of that type be opened by the selected app?

gingerbeardman commented 10 months ago

(I have of course tried changing that setting on a per-file or per-all basis).

But that's unrelated to the issue at hand. It's not about opening a stack in HyperCardPreview, it's about HyperCardPreview even recognising that it can open the type of file however you try.

I'm confident if you have both apps on your computer you will be able to reproduce the problem.

Here's a video:

https://github.com/PierreLorenzi/HyperCardPreview/assets/49612/e081f6b2-daca-400a-a29b-f7716a8691d1

gingerbeardman commented 8 months ago

Completed? What was the resolution/fix/change? @PierreLorenzi

PierreLorenzi commented 7 months ago

Oh from your post I thought you fixed it yourself

gingerbeardman commented 7 months ago

Not really, just as workaround by deleting a separate app

joevt commented 7 months ago

Here's some notes about launch services: https://eclecticlight.co/2024/04/10/how-macos-opens-a-file-in-the-correct-app/ It might not be of help but is interesting.