Question

I will illustrate a use case of my issue.

I have here two files which happen to be the Finder 7.5.5 and Finder 8.1 from legacy Mac OS versions.

If I use Cmd + I I get the following information:

Version:
7.5.5, © Apple Computer, Inc. 1983-96
System 7.5 Version 7.5.3

and

Version:
8.1, Copyright Apple Computer, Inc. 1983-97
Mac OS 8.1

I want to extract these information programatically. However, I am not even sure where it is being hold.

In a small Objective-C project (Foundation) I did the following for the 7.5 file:

NSString      * finder7     = [[NSString alloc] initWithString:@"/Users/me/Desktop/Finder7"];
NSFileManager * fileManager = [NSFileManager defaultManager];
NSError       * error       = nil;
NSDictionary  * attr        = [fileManager attributesOfItemAtPath:finder7 error:&error];
NSLog(@"%@", attr);

This is the output:

2013-09-25 10:53:30.224 GetAttributes[1164:903] {
    NSFileCreationDate = "1996-01-15 12:00:00 +0000";
    NSFileExtensionHidden = 0;
    NSFileGroupOwnerAccountID = 20;
    NSFileGroupOwnerAccountName = staff;
    NSFileHFSCreatorCode = 1296122707;
    NSFileHFSTypeCode = 1179534418;
    NSFileModificationDate = "1996-01-15 12:00:00 +0000";
    NSFileOwnerAccountID = 501;
    NSFileOwnerAccountName = me;
    NSFilePosixPermissions = 493;
    NSFileReferenceCount = 1;
    NSFileSize = 0;
    NSFileSystemFileNumber = 4384377;
    NSFileSystemNumber = 234881026;
    NSFileType = NSFileTypeRegular;
}

As you can see, there is no reference to version or copyright. I can't open the "app's content" because legacy applications obviously don't have it.

So I figured it could be an extended attribute, so I got the console and did this:

$ ls -l@
-rwxr-xr-x@  1 me    staff          0 15 Jan  1996 Finder7
        com.apple.FinderInfo           32
        com.apple.ResourceFork     503994
-rwxr-xr-x@  1 me    staff    3631000 16 Dec  1997 Finder8
        com.apple.FinderInfo           32
        com.apple.ResourceFork     502012
        com.apple.metadata:kMDItemFinderComment        42

Then I found these entries in each of them:

$ xattr -l com.apple.FinderInfo Finder7
(...)
00077AE0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  |................|
00077AF0  00 00 32 07 55 80 00 00 00 05 37 2E 35 2E 35 25  |..2.U.....7.5.5%|
00077B00  37 2E 35 2E 35 2C 20 A9 20 41 70 70 6C 65 20 43  |7.5.5, . Apple C|
00077B10  6F 6D 70 75 74 65 72 2C 20 49 6E 63 2E 20 31 39  |omputer, Inc. 19|
00077B20  38 33 2D 39 36 00 00 00 2B 00 00 00 00 00 00 00  |83-96...+.......|
(...)

$ xattr -l com.apple.FinderInfo Finder8
(...)
00077330  06 46 69 6E 64 65 72 00 00 00 00 00 00 36 08 10  |.Finder......6..|
00077340  80 00 00 00 03 38 2E 31 2B 38 2E 31 2C 20 43 6F  |.....8.1+8.1, Co|
00077350  70 79 72 69 67 68 74 20 41 70 70 6C 65 20 43 6F  |pyright Apple Co|
00077360  6D 70 75 74 65 72 2C 20 49 6E 63 2E 20 31 39 38  |mputer, Inc. 198|
00077370  33 2D 39 37 00 00 00 26 01 08 10 80 00 06 46 69  |3-97...&......Fi|
00077380  6E 64 65 72 00 00 00 00 00 00 00 00 00 00 00 00  |nder............|
(...)

I never really used extended attributes, specially in a development. So here I need some light. I see the version numbers are in different positions. How can I get this information straight like the OSX Finder does? I spent several minutes to do it manually and still is not clear to me how the version is stored. Is there other place I can find this information or am I going in the right direction?

Are there Objective-C or C solutions that will do this so I don't need to reinvent the wheel?

I appreciate the help!

File information windows

I also tried checking rsrc. Found an easter egg just before the version number.

enter image description here

Was it helpful?

Solution

The information is stored in the extended attribute com.apple.ResourceFork. You can use a tool like DeRez to decompile the information.

If you want to programatically access the resource fork, there is the Resource Manager API, but pretty much everything there is deprecated for 10.8. The resource type for version information is the 'vers' resource.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top