• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

Stuffit Magic Numbers

equant

Well-known member
In a different thread (over in software), @Dog Cow mentioned that there are magic numbers which can be used to distinguish which version of the stuffit algorithm was used to compress a file.  Does anyone have more information on this?  I would like to build a utility that can sort *.sit files, or perhaps improve the unix 'file' command to report a bit more than just "StuffIt Archive" when it sees "SIT!".  I believe I can compress the same file with different versions and reverse engineer it, but figured I'd ask in case someone had this info somewhere.

Thanks,

Nathan

 

olePigeon

Well-known member
Would it be possible to make an INIT for System 6 and 7 that overrides the System Bundle icons for Stuffit files with one containing a version number?  I could make up a set of icons for it.  Then you could tell right off the bat which version of Stuffit you'd need.

 

Crutch

Well-known member
That’s a fun idea for a project. It’s not immediately obvious to me how to do that, since the Finder (or more likely a DRVR running in the background, launched by the INIT) would need to actually open the StuffIt archive and read far enough into it to get the magic number (if it’s there) each time it needed to decide what icon to draw. Patch _GetResource, and if the Finder is the foreground app and it’s getting an ICN# resource corresponding to an archive document from StuffIt, look up the file whose icon is being drawn (but how do I know which one that is???) in the precomputed hashtable of known archives and return the appropriate icon you designed ... and if the file hasn’t been seen before, stop and open it up to check the type and populate the hashtable entry? ...... or something. If I didn’t have a newborn, I would try it. Unless someone is super expert at how the Finder draws file icons, it would probably require a long Macsbug session.

 

equant

Well-known member
@PowerPup Thanks for those links.  Looks perfect.  I went ahead and did some tests and here's what I came up with.  Looks like it's easy to tell apart pre 1.5.1, 1.5.1, 3.5 and 5.5.

Screenshot_2020-01-17_20-08-13.png

 

equant

Well-known member
@equant Did you end up having any luck with this? :D
A little luck, but not a lot.  You can reliably tell the difference between "5.5 or later" or "pre 5.5".  I found this to be a useful distinction when browsing archives.  I implemented it into the RetroBridgeBBS interface so that I can tell (when browsing online archives) if the file I want to download is compatible with my machines running system 6 or early system 7 software or not.

https://github.com/equant/RetroBridgeBBS

This shows the basic idea of predownloading just the file's header, and then determining if it's old or new Stuffit.

sit_patterns = [
[b"^SIT!", "StuffIt pre 5.5"],
[b"^StuffIt", "StuffIt 5.5 or later"],
]

headers = {"Range": "bytes=0-200", 'User-Agent': USER_AGENT}
header = requests.get(self.url, headers=headers).content
for p in self.sit_patterns:
r = re.compile(p[0])
m = r.match(header)
if m:
print(f"File is archived with: {p[1]}")




Getting a more precise version out of an archive is certainly possible, but it wasn't worth the work to me.

 

LaPorta

Well-known member
Another good idea is for everyone to make StuffIt 1.5.1 archives for everything under System 6, etc...

 
Top