ksherlock / mpw

Macintosh Programmer's Workshop (mpw) compatibility layer
238 stars 21 forks source link

MPW Rez errors with OS error -1421 during CreateResFile() #18

Closed steventroughtonsmith closed 9 years ago

steventroughtonsmith commented 9 years ago

Using MPW's version of Rez fails for many of the examples included with MPW.

You can use Xcode's copy of Rez as a workaround, if you pass it the right includes directory.

Sample project attached; "make -i" to build both MPW-Rez and Xcode-Rez targets

mpw Rez -rd -o Sample Sample.r -append
### Rez - OS error -1421 (Error message text not available) during CreateResFile().
### Rez - Fatal Error, can't recover.
### Rez - Since errors occured, Sample's resource fork was not completely updated.

https://gist.github.com/steventroughtonsmith/0b4ba30fedbc59ed6661

steventroughtonsmith commented 9 years ago

Looks like FSCreateResourceFork is erroring with errFSForkExists; seems the compiler creates a fork and Rez dies because of it.

If you manually remove the fork, Rez continues fine until it hits

Unsupported tool trap: a9aa (_ChangedResource)
ksherlock commented 9 years ago

If I fix CreateResource and ChangedResource, it works... except it turns out that the x86 carbon resource manager "helpfully" tries to convert some resources from little endian to big endian before saving. Which is, of course, counterproductive if the data is already big endian.

So this might not get fixed until the resource manager is re-written (which has to happen to work on other platforms... and on OS X someday when Carbon is killed off).

CoreEndianFlipData: error -4940 returned for rsrc type DITL (id 128, length 200, native = yes)
File "Sample.r"; Line 205; ### Rez - OS error -4940 (Error message text not available) during WriteResource().
File "Sample.r"; Line 205; ### Rez - Fatal Error, can't recover.
File "Sample.r"; ### Rez - Since errors occured, Sample's resource fork was not completely updated.
CoreEndianFlipData: error -4940 returned for rsrc type MBAR (id 128, length 10, native = yes)

/* CoreEndian error codes.  These can be returned by Flippers. */
enum {
  errCoreEndianDataTooShortForFormat = -4940,
  errCoreEndianDataTooLongForFormat = -4941,
  errCoreEndianDataDoesNotMatchFormat = -4942
};

http://www.cocoabuilder.com/archive/xcode/252893-core-endian-errors-with-resources.html

http://www.cocoabuilder.com/archive/xcode/256295-architecture-dependant-problems-with-resmerger.html

steventroughtonsmith commented 9 years ago

As Xcode's version of Rez continues to work fine I wouldn't worry too much about it in the short term!

ksherlock commented 9 years ago

I was able to disable the resource byte swapping (f0e585aada886ff41ffbc8b65e38e5f2c5e3c244) so Rez now seems to work.