Hello,
my name is Marcus Better, and I am working on an HFS driver for OS/2. I have run into a problem with resource forks.
I want my driver to access the resource forks of files and extract resources such as icons. It would then convert the icons to an extended attribute which OS/2 understands. Since there is a description of the layout of resource forks in "Inside Macintosh", it should be straightforward to read the resources of a file.
However, having looked at several resource forks, it seems to me that they don't quite follow the layout in "Inside Macintosh". According to the specification, the header of a resource fork contains an offset to the beginning of a resource map, but in all resource forks I've examined, the resource map start a few bytes beyond that offset. The difference ranges from one byte to perhaps 80 bytes or so, but I still haven't found a single file where the offset was correct. There seems to be no way to predict where the resource map really starts. Although it is easy to find it by hand with some educated guesses, I wouldn't like to write any code based on guesswork.
I think the resource map begins right after the data area (although I'm not entirely sure), but the data area is simply a few bytes longer than the header indicates.
Has anybody had any experience with manipulating resource forks? I would appreciate any clue you might have on this.
By the way, the driver is available at http://www.abc.se/~m9111/HFS. Source code is included. It's an early experimental version but seems to be stable on the whole, although I have fixed a few bugs since it was released.
Regards, Marcus
However, having looked at several resource forks, it seems to me that they don't quite follow the layout in "Inside Macintosh". According to the specification, the header of a resource fork contains an offset to the beginning of a resource map, but in all resource forks I've examined, the resource map start a few bytes beyond that offset. The difference ranges from one byte to perhaps 80 bytes or so, but I still haven't found a single file where the offset was correct. There seems to be no way to predict where the resource map really starts. Although it is easy to find it by hand with some educated guesses, I wouldn't like to write any code based on guesswork.
Offhand, my only suggestion is to be sure you're reading the map offset as an integer in big-endian format. If you're running OS/2 on an Intel box you'll have to do an explicit conversion from little-endian.
That's my only immediate suggestion. If you're doing this already, there is probably something else going on.
Thanks to all who replied to my message about resource forks. I had used a program which translated linefeed characters to CR/LF pairs. Sorry about the trouble.
/Marcus
examined, the resource map start a few bytes beyond that offset. The difference ranges from one byte to perhaps 80 bytes or so, but I still haven't found a single file where the offset was correct. There seems to be no way to predict where the resource map really starts. Although it is easy to find it by hand with some educated guesses, I wouldn't like to write any code based on guesswork.
hmmm - is there any correlation between the filename length and the offset discrepancy?
d