Game Development Community

Weird name mangling on Mac OSX

by Jason McIntosh · in Torque Game Builder · 08/31/2005 (10:33 pm) · 6 replies

I'm getting this weird thing where the names of my compiled .cs files are having #nnnn appended to them (where nnnn is 4 numbers). This makes them not usable by the engine since it reports that they have an invalid file name. The files affected have long filenames, in excess of 48 chars in some cases. Reasoning behind my weird naming aside, why the heck does Torque do this on Mac??

I guess I'll have to rename all the affected files so they're shorter. But I'm still curious about it.

#1
09/01/2005 (12:51 am)
Here is a thread from 2003 in TGE forums discussing this problem and a code workaround. It should be fixed in the 1.4 codebase, I would hope

http://www.garagegames.com/mg/forums/result.thread.php?qt=13198
#2
09/01/2005 (5:05 am)
Quote:You do not have access to this forum thread.
I really hate that message. :)

Could you pretty please post that code here?
#3
09/01/2005 (9:32 am)
Here you go:

Around line 712 in macCarbFileio.cc in the function _recurseDump() replace:

rInfo.pFileName = StringTable->insert(filename);

with:

char filenameBuf[MAX_MAC_PATH_LONG];             
             FSRef fsRef;
             FSRefParam pb;
             HFSUniStr255 uniNameField;

             dSprintf(filenameBuf, sizeof(filenameBuf), "%s", filename);

             pb.ioVRefNum = platState.volRefNum;
             pb.ioDirID = dirID;
             pb.ioNamePtr = cinfo.hFileInfo.ioNamePtr;
             pb.newRef = &fsRef;
             OSErr res2 = PBMakeFSRefSync(&pb);

             if(res2 == noErr) {
                    res2 = FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, &uniNameField, NULL, NULL);
                    if(res2 == noErr) {
                           CFStringRef str = CFStringCreateWithCharacters( kCFAllocatorDefault, uniNameField.unicode, uniNameField.length );
                           CFStringGetCString(str, filenameBuf, CFStringGetLength(str)+1, kCFStringEncodingMacRoman);
                           CFRelease( str );
                    }
             }
             rInfo.pFileName = StringTable->insert(filenameBuf);
#4
09/01/2005 (5:55 pm)
Luke, you RULE! Thanks oodles. :)
#5
09/01/2005 (8:03 pm)
Actually Alex rules more for posting the loc first :)
#6
09/01/2005 (9:18 pm)
They both rule, because without them both I couldn't have gotten this fix. :)