comparison Mac/Python/macimport.c @ 9073:618fb830be65 legacy-trunk

Mods by Just to allow aliases in sys.path entries
author Jack Jansen <jack.jansen@cwi.nl>
date Mon, 07 Sep 1998 11:36:17 +0000
parents ff1a8a38f8c1
children 462ccd0bbe50
comparison
equal deleted inserted replaced
9072:9cea6b617838 9073:618fb830be65
45 #include <Fonts.h> 45 #include <Fonts.h>
46 #include <Menus.h> 46 #include <Menus.h>
47 #include <TextUtils.h> 47 #include <TextUtils.h>
48 #endif 48 #endif
49 #include <CodeFragments.h> 49 #include <CodeFragments.h>
50
51 #ifdef USE_GUSI
52 #include "TFileSpec.h" /* for Path2FSSpec() */
53 #endif
50 54
51 typedef void (*dl_funcptr)(); 55 typedef void (*dl_funcptr)();
52 #define FUNCNAME_PATTERN "init%.200s" 56 #define FUNCNAME_PATTERN "init%.200s"
53 57
54 /* 58 /*
98 */ 102 */
99 oldrh = CurResFile(); 103 oldrh = CurResFile();
100 UseResFile(PyMac_AppRefNum); 104 UseResFile(PyMac_AppRefNum);
101 filerh = -1; 105 filerh = -1;
102 } else { 106 } else {
107 #ifdef USE_GUSI
108 if ( Path2FSSpec(filename, &fss) != noErr ||
109 #else
103 if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr || 110 if ( FSMakeFSSpec(0, 0, Pstring(filename), &fss) != noErr ||
111 #endif
104 FSpGetFInfo(&fss, &finfo) != noErr ) { 112 FSpGetFInfo(&fss, &finfo) != noErr ) {
105 #ifdef INTERN_STRINGS 113 #ifdef INTERN_STRINGS
106 if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj->ob_sinterned ) 114 if ( obj && max_not_a_file < MAXPATHCOMPONENTS && obj->ob_sinterned )
107 not_a_file[max_not_a_file++] = obj; 115 not_a_file[max_not_a_file++] = obj;
108 #endif /* INTERN_STRINGS */ 116 #endif /* INTERN_STRINGS */
294 */ 302 */
295 oldrh = CurResFile(); 303 oldrh = CurResFile();
296 UseResFile(PyMac_AppRefNum); 304 UseResFile(PyMac_AppRefNum);
297 filerh = -1; 305 filerh = -1;
298 } else { 306 } else {
307 #ifdef USE_GUSI
308 if ( (err=Path2FSSpec(filename, &fss)) != noErr ||
309 FSpGetFInfo(&fss, &finfo) != noErr )
310 #else
299 if ( (err=FSMakeFSSpec(0, 0, Pstring(filename), &fss)) != noErr ) 311 if ( (err=FSMakeFSSpec(0, 0, Pstring(filename), &fss)) != noErr )
312 #endif
300 goto error; 313 goto error;
301 if ( (err=FSpGetFInfo(&fss, &finfo)) != noErr ) 314 if ( (err=FSpGetFInfo(&fss, &finfo)) != noErr )
302 goto error; 315 goto error;
303 oldrh = CurResFile(); 316 oldrh = CurResFile();
304 filerh = FSpOpenResFile(&fss, fsRdPerm); 317 filerh = FSpOpenResFile(&fss, fsRdPerm);
399 { 412 {
400 struct filedescr *fdp; 413 struct filedescr *fdp;
401 unsigned char fnbuf[64]; 414 unsigned char fnbuf[64];
402 int modnamelen = strlen(module); 415 int modnamelen = strlen(module);
403 FSSpec fss; 416 FSSpec fss;
417 FInfo finfo;
404 short refnum; 418 short refnum;
405 long dirid; 419 long dirid;
406 420
407 /* 421 /*
408 ** Copy the module name to the buffer (already :-terminated) 422 ** Copy the module name to the buffer (already :-terminated)
417 strcpy(buf+*lenp, module); 431 strcpy(buf+*lenp, module);
418 strcpy(buf+*lenp+modnamelen, _PyImport_Filetab[0].suffix); 432 strcpy(buf+*lenp+modnamelen, _PyImport_Filetab[0].suffix);
419 #else 433 #else
420 strcpy(buf+*lenp, _PyImport_Filetab[0].suffix); 434 strcpy(buf+*lenp, _PyImport_Filetab[0].suffix);
421 #endif 435 #endif
436 #ifdef USE_GUSI
437 if ( Path2FSSpec(buf, &fss) == noErr &&
438 FSpGetFInfo(&fss, &finfo) == noErr)
439 return _PyImport_Filetab;
440 #else
422 if ( FSMakeFSSpec(0, 0, Pstring(buf), &fss) == noErr ) 441 if ( FSMakeFSSpec(0, 0, Pstring(buf), &fss) == noErr )
423 return _PyImport_Filetab; 442 return _PyImport_Filetab;
443 #endif
424 /* 444 /*
425 ** We cannot check for fnfErr (unfortunately), it can mean either that 445 ** We cannot check for fnfErr (unfortunately), it can mean either that
426 ** the file doesn't exist (fine, we try others) or the path leading to it. 446 ** the file doesn't exist (fine, we try others) or the path leading to it.
427 */ 447 */
428 refnum = fss.vRefNum; 448 refnum = fss.vRefNum;