mkb@ROVER.RI.CMU.EDU (Mike Blackwell) (02/05/88)
I had the very same problem, and it took a lot of head scratching to figure
out what the hell was going on. The problem stems from the definition of
SFReply.fName. It's not a C string, and not really a P string, either - it's
a String(63) (see types.h). Here's a code fragment that does work:
DoLoad()
{
SFReply reply;
Point where;
char filename[100];
SFTypeList texttype;
extern pascal Boolean alignFiles();
FILE *fp;
texttype[0] = 'TEXT';
where.v = 100; where.h = 75;
SFGetFile(&where, "", alignFiles, 1, texttype, nil, &reply);
if (reply.good) {
SetVol(nil, reply.vRefnum);
strncpy(filename, reply.fName.text, reply.fName.length);
filename[reply.fName.length] = '\0';
if ((fp = fopen(filename, "r")) == nil) {
ErrorMessage("Could not open file:", filename);
} else {
... etc ...
}
}
}
Hope this helps...
Mike Blackwell ... mkb@rover.ri.cmu.edu